"SPY Master" Long/Short Swing Trading Algorithm Beats S&P 500!

"SPY Master" is a simple medium frequency trading algorithm that uses my RSI-EMA oscillator on a 1h chart to trigger buy/cover and sell/short signals. The algorithm only holds 1 position each time and it can go either long or short on SPY ( S&P 500 exchange-traded fund). The average holding period per trade is about 18 hours.

Please note that the backtest uses a fixed size of $10,000 for each trade so there is no reinvestment or compounding.

Commissions aren't factored into the backtest but there are 294 trades (588 orders) total so assuming $1 commission per order, that's $588. That's about how much I pay to make a $10,000 trade with SPY at Interactive Brokers. Dividends are also not factored into the backtest but SPY typically yields about 2% a year in dividends.

The idea behind this strategy follows the premise that most profitable momentum trades usually occur during periods when price is trending up or down. Periods of flat price actions are usually where most unprofitable trades occur. Because we cannot predict exactly when trending periods will occur, the algorithm basically bets money on all trade opportunities during all market conditions. However, the way it's designed also allows it to keep the losers small and let the winners run. The algorithm only wins about 40% of the time but its average winner is 2.6 times the average loser.


Chart interval = 1h
Buy/Cover = EMA2(RSI5) cross> 50
Sell/Short = EMA10(RSI5) cross< 50


- Period = Jan 2013 - Present
- Short-selling enabled
- Dividends disabled
- Trading cost disabled
- Reinvestment disabled
- Initial cash = $10,000
- Fixed trade size = $10,000


SPY (benchmark)
- Net return = +41%
- CAGR = 13%
- Max drawdown = -22%
- CAGR/Max DD = 0.6

Algorithm (long/short):
- Net return = +61%
- CAGR = 18%
- Max drawdown = -10%
- CAGR/Max DD = 1.8
First thank you for sharing your strategy, I know how difficult it is to develop good strategies so you have all my respect.

I had posted a RSI (plus Stochastic) strategy on Tradingview, which has a much higher performance on the 1 hour chart with a profit factor of almost 9, but it suffers from the same issue as your strategy. It only works on the S&P 500 (and recent trades were bad). Here is mine:

I have backtested your strategy script on other indices and just as my strategy it fails on them:


I could have tested much more, but that was enough to find the usual weakness, which I wanted to alert you about.
Hi. Thanks for sharing, that's a cool strategy! My strategy and the settings posted here are not intended as a one size fits all solution. Different asset classes and time frames have different technical characteristics and require different input assumptions as a result. You would need to recalibrate the indicator for different securities and chart intervals.
Btw, what settings did you use for your strategy in that backtest? I'm unable to replicate it.
ChartArt Koi_Capital
The market behaved so badly bullish volatile against my RSI, Stochastic combo that it turned the profit factor in the last 28 days from a factor of 8.97 down to 3.91 and the percent profitable from 70.97% down to 67.14% in this recent span of time.

I noticed I lost four followers this month, around the number which I gained when I had freshly published this script. Bad time for the default setting of this strategy script this month. Shit happens. Never trust backtest data alone.
My strategy seems pretty consistent among certain other asset classes, as long as you re-calibrate the indicator. Here's the strategy for HYG (junk bonds): https://www.tradingview.com/chart/Sf8QfgU5/
Here's TLT (20+ years Treasurys): https://www.tradingview.com/chart/pxULPCP9/
ZH 简体中文
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
SV Svenska
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 繁體中文
AR العربية
HE עברית
首页 股票筛选器 外汇筛选器 加密货币筛选器 财经日历 如何运作 图表功能 网站规则 版主 网站 & 经纪商解决方案 插件 图表库 功能请求 博客 & 新闻 常见问题 帮助 & 维基 Twitter
概述 个人资料设置 账号和账单 我的客服工单 联系支持 已发表观点 粉丝 正在关注 私人消息 聊天 退出