What the Original Strategy Does:
Inputs & Parameters: The original strategy provides several user-adjustable parameters, such as stop loss percentage, trailing stop percentage, lookback period, lengths for two different EMAs (Exponential Moving Averages), minimum holding period, and a start date for the strategy.
Heikin Ashi Candles: The strategy initially used Heikin Ashi candles for smoother price data. These candles are calculated using a combination of the open, high, low, and close prices from the current and previous bars.
Moving Averages: Two EMAs were calculated based on the Heikin Ashi candle's closing prices. These EMAs were colored yellow and purple.
Percentile Calculation: It calculates the 25th and 75th percentiles of the Heikin Ashi closing prices over a given lookback period.
Trade Signals:
A long entry signal (longSignal) is generated when the Heikin Ashi closing price crosses over the 75th percentile and is greater than the yellow EMA.
A long exit signal (sellSignal) is generated when the Heikin Ashi closing price crosses under the yellow EMA.
Additionally, the strategy has a similar set of conditions for short entries and exits (longSignal1 and sellSignal1) but uses the purple EMA.
Why the Updates Were Necessary:
Repainting: Your original script had the potential for repainting, particularly due to the setting calc_on_every_tick = true. Repainting can distort backtesting results, making the strategy look more effective than it actually is.
Look-Ahead Bias: Your script used calc_on_order_fills = true, which could introduce look-ahead bias by giving the strategy access to intra-bar high and low values. This is unrealistic in live trading.
Heikin Ashi Candles: While Heikin Ashi candles are useful for identifying trends, they are derived from actual price data and can sometimes lag behind. They can also cause issues with backtesting, as TradingView may handle these candles differently.
What the Updated Strategy Does:
Standard Candles: The updated strategy uses standard OHLC candles instead of Heikin Ashi. This makes the strategy more straightforward and potentially more reliable in backtesting and live trading.
Removed Potential for Repainting and Look-Ahead Bias: The updated strategy sets calc_on_order_fills = false and calc_on_every_tick = false to avoid repainting and look-ahead bias, making backtesting results more reliable.