Free Strategy #01 (ES / SPY)

The strategy was designed to be traded based on daily data on the ES and SPY--the strategy was originally developed on NinjaTrader using approximately 50% out of sample data with a slippage of 1 tick on the ES. This is our first strategy that we converted from NinjaTrader to TradingView, so if you see any issues with our conversion, please let us know as we are still learning TradingView Pine Script.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


Thanks for the feedback, I responded below:

1) When I go back to when the ES backtest starts on my TradingView charts I have a price of about 943.50, so with today's value of 2475, I get a net profit for buy and hold of 123,750 ((2475 - 943.50) * 4 * 12.5), which the strategy outperforms about 38K (we haven't figured out how to add commissions yet to the strategy). When I go back to when the SPY backtest starts on my TradingView charts I have a price of about 44.00, so with today's value of 247.42, I get a net profit for buy and hold of 203.42 (net profit on backtest of 264.69, 0.04% drawdown).
2) This strategy is only meant for a long position and is meant to be built upon later when I release more strategies--the idea being to look at all the different strategies and see which of them create the best "portfolio" of taking the first trade signal from the group.
3) I have to look into that because on our original NinjaTrader backtest with 1 tick slippage on backadjusted ES 09-17 data, there is only a 6.2K drawdown (includes commission), so this could be something with data being between the two platforms that we will have to look into. We normally run from 2000 or 1995ish through the current day with 40-50% out of sample data--I forget exactly what this was ran on since we ran it a while ago (we also set a minimum trade number for in and out of sample data).
wpatte15 TheIndicatorClub
@TheIndicatorClub, It wasn't a big losing period it was just very flat for a significant trading period (re #3) is what I had meant. For buy and hold I was just referring to the Performance Summary that says Net Profit was 161% and Buy and Hold return was 169%. Building a portfolio sounds like a very interesting idea, looking forward to see it come to life (if you're sharing)!
@wpatte15, We appreciate it--we didn't realize the buy and hold was in the performance, which is nice, but I guess it's all part of the TV learning curve. We plan to post a handful of other strategies and then will start exploring the combo strategies (all open source for people to use).
+1 Reply
himeshforex TheIndicatorClub
@TheIndicatorClub, mate you also got to add some margin for tick slippage and commission. it all adds up with the no of trades
TheIndicatorClub himeshforex
@himeshforex, we just saw how to do that today on TV--we normally back test with 1 tick slippage and three sixty four in round trip on the ES, which would bring the new back test net profit down about 7K
This looks good code wise however my concerns are

1) It underperforms Buy and Hold
2) It's long only and the index has obviously performed very well during the time, I'd be interested in how a short side would go.
3) That 50-60 trade drawdown period seems excessively long, was this your out of sample data? If so I believe you may have over optimized.

Thanks for sharing and good luck building this strategy!