After studying several other scripts, I believe I have found the Holy Grail! (Or perhaps I've just found a bug with Tradingview's Pinescript v4 language) Anyhow, I'm publishing this script in the hope that someone smarter than myself could shed some light on the fact that adding a trailing stop to any strategy seems to make it miraculously...no that's an understatement...incredulously, stupendously, mind-bendingly profitable. I'm talking about INSANE profit factors, higher than 200x, with drawdowns of <10%. Sounds too good to be true? Maybe it is...or you could hook it up to your LIVE broker, and pray it doesn't explode. This is an upgraded version of my original Pin Bar Strategy.
Recommended Chart Settings:
Asset Class: Forex Time Frame: H1
Long Entry Conditions:
a) Exponential Moving Average Fan up trend b) Presence of a Bullish Pin Bar c) Pin Bar pierces the Exponential Moving Average Fan
Short Entry Conditions:
a) Exponential Moving Average down trend b) Presence of a Bearish Pin Bar c) Pin Bar pierces the Exponential Moving Average Fan
Exit Conditions: a) Trailing stop is hit b) Moving Averages cross-back (optional) c) It's the weekend
Default Robot Settings:
Equity Risk (%): 3 //how much account balance to risk per trade Stop Loss (x*ATR, Float): 0.5 //stoploss = x * ATR, you can change x Stop Loss Trail Points (Pips): 1 //the magic sauce, not sure how this works Stop Loss Trail Offset (Pips): 1 //the magic sauce, not sure how this works Slow SMA (Period): 50 //slow moving average period Medium EMA (Period): 18 //medium exponential moving average period Fast EMA (Period): 6 //fast exponential moving average period ATR (Period): 14 // average true range period Cancel Entry After X Bars (Period): 3 //cancel the order after x bars not triggered, you can change x
Backtest Results (2019 to 2020, H1, Default Settings):
As you can clearly see above, this forex robot is projected by the Tradingview backtester to be INSANELY profitable for all common forex pairs. So what was the difference between this strategy and my previous strategies? Check my code and look for "trail_points" and "trail_offset"; you can even look them up in the PineScript v4 documentation. They specify a trailing stop as the exit condition, which automatically closes the trade if price reverses against you.
I however suspect that the backtester is not properly calculating intra-bar price movement, and is using a simplified model. With this simplfied approach, the trailing stop code becomes some sort of "holy grail" generator, making every trade entered profitable.
Risk Warning:
This is a forex trading strategy that involves high risk of equity loss, and backtest performance will not equal future results. You agree to use this script at your own risk.
Hint:
To get more realistic results, and *maybe* overcome the intrabar simulation error, change the settings to: "Stop Loss Trail Points (pips)": 100 I am not sure if this eradicates the bug, but the entries and exits look more proper, and the profit factors are more believable.
No verdadeiro espírito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam compreendê-lo e analisá-lo. Parabéns ao autor! Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.