This strategy utilizes Parabolic SAR (Stop and Reverse) indicator combined with EMA filtering to improve signal accuracy. It is suitable for traders who trade with the trend.
A long signal is triggered when SAR is below price and price is above slow EMA plus offset. A short signal is triggered when SAR is above price and price is below slow EMA minus offset. Crossover between fast EMA and slow EMA provides additional filtering. This avoids false signals when using SAR alone.
Specifically, long entry conditions are:
Short entry conditions are:
Combining SAR and EMA filtering, this strategy can identify trend direction well and reduce false signals.
Advantages are:
There are some risks to this strategy:
This strategy can be optimized from the following aspects:
This strategy combines the strengths of SAR and EMA to design a flexible trend following system. Overall it has good trend detection capability and works well in tracking trends. Further enhancements in parameter optimization and risk management can improve stability and profitability. It suits investors with good risk management awareness and optimization skills.
/*backtest start: 2023-01-11 00:00:00 end: 2024-01-17 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=3 strategy("SAR Trend Trader Strategy By: jhanson107", shorttitle="SAR Trend Trader Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100) SlowEMALength = input(100, "Slow EMA Length") FastEMALength = input(10, "Fast EMA Length") emaoffset = input(1.00, "EMA Offset %") start = input(0.01) increment = input(0.005) maximum = input(0.08) //////////////////////////////////////////////////////////////////////////////// // BACKTESTING RANGE // From Date Inputs fromDay = input(defval = 1, title = "From Day", minval = 1, maxval = 31) fromMonth = input(defval = 1, title = "From Month", minval = 1, maxval = 12) fromYear = input(defval = 2019, title = "From Year", minval = 1970) // To Date Inputs toDay = input(defval = 1, title = "To Day", minval = 1, maxval = 31) toMonth = input(defval = 1, title = "To Month", minval = 1, maxval = 12) toYear = input(defval = 2020, title = "To Year", minval = 1970) // Calculate start/end date and time condition startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00) finishDate = timestamp(toYear, toMonth, toDay, 00, 00) time_cond = true //////////////////////////////////////////////////////////////////////////////// psar = sar(start, increment, maximum) ema = ema(close, SlowEMALength) fastema = ema(close, FastEMALength) offset = (emaoffset / 100) * ema // Signals long = high[1] < psar[2] and high >= psar[1] and close > ema + offset or crossunder(ema, fastema) and close > psar and close > ema + offset short = low[1] > psar[2] and low <= psar[1] and close < ema - offset or crossover(ema, fastema) and close < psar and close < ema - offset // Plot PSAR plot(psar, title="PSAR", color = low < psar and not long ? green : red, trackprice=true) //Barcolor barcolor(close > psar and close > ema + offset and fastema > ema ? green : na) barcolor(close > psar and close < ema + offset or close > psar and fastema < ema ? white : na) barcolor(close < psar and close < ema - offset and fastema < ema and close? red : na) barcolor(close < psar and close > ema - offset or close < psar and fastema > ema ? white : na) //Plot EMA plot(ema, color=blue, linewidth=1, transp=0, title="Slow EMA") plot(fastema, color=purple, linewidth=1, transp=0, title="Fast EMA") if(high > psar) strategy.close("Short") if(low < psar) strategy.close("Long") if(long and time_cond) strategy.entry("Long", strategy.long, comment="Long") if(short and time_cond) strategy.entry("Short", strategy.short, comment="Short") if (not time_cond) strategy.close_all()