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.
//@version=2 strategy("MovingAvg Cross", overlay=true) length = input(9) confirmBars = input(1) price = close strategy.exit ("trail_points", loss= 1) ma = ema(price, length) bcond = price > ma bcount = bcond ? nz(bcount) + 1 : 0 if (bcount == confirmBars) strategy.entry("MACrossLE", strategy.long, comment="MACrossLE") scond = price < ma scount = scond ? nz(scount) + 1 : 0 if (scount == confirmBars) strategy.entry("MACrossSE", strategy.short, comment="MACrossSE") //plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)
The results of this test speak to this. Whenever you get extremely high PF in a backtest, its a virtual certainty that the reason is due to using future data that couldn't have been known at the time the supposed signal was hypothetically taken.
reference - https://futures.io/ninjatrader-programming/4768-tip-backtesting-renko-charts.html