A momentum-based trend-following indicator that identifies potential reversal points using the Parabolic SAR (Stop and Reverse) algorithm.
Dynamic Stop and Reverse System
The Parabolic SAR provides dynamic support/resistance levels that track price movement. When price crosses the SAR dots, it signals a potential trend reversal. Combined with a 200 EMA trend filter, this strategy identifies high-probability reversal points while avoiding whipsaws in sideways markets.
Trend ReversalType
4h ChartTimeframe
BeginnerComplexity
TrendingBest Market
Signal Logic
Long (Buy)
Price crosses above Parabolic SAR dots while above the 200 EMA trend filter, indicating bullish reversal.
Short (Sell)
Price crosses below Parabolic SAR dots while below the 200 EMA trend filter, indicating bearish reversal.
Implementation
//@version=6strategy("Parabolic SAR Strategy", overlay=true, initial_capital=1000000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// ==========================================// 🔹 INPUTS// ==========================================// Group: Parabolic SAR Settings
grp_sar = "Parabolic SAR Settings"
start = input.float(0.02, "Start (AF)", step=0.01, group=grp_sar)
increment = input.float(0.02, "Increment (AF)", step=0.01, group=grp_sar)
maximum = input.float(0.2, "Maximum (AF)", step=0.01, group=grp_sar)
// Group: Trend Filter
grp_trend = "Trend Filter"
use_trend = input.bool(true, "Use Trend Filter (EMA 200)", group=grp_trend)
ema_len = input.int(200, "Trend EMA Length", minval=1, group=grp_trend)
// Group: Risk Management
grp_risk = "Risk Management"
tp_ratio = input.float(2.0, "Risk:Reward Ratio", step=0.1, group=grp_risk)
// ==========================================// 🔹 CALCULATIONS// ==========================================// Parabolic SAR calculation
sar_val = ta.sar(start, increment, maximum)
// Trend EMA
ema_val = ta.ema(close, ema_len)
// Determine trend direction using SAR
is_uptrend = close > sar_val
is_downtrend = close < sar_val
// Trend filter
use_ema_uptrend = use_trend ? close > ema_val : true
use_ema_downtrend = use_trend ? close < ema_val : true// ==========================================// 🔹 STRATEGY LOGIC// ==========================================// Long Entry: Price crosses above SAR (trend changes from down to up)
long_signal = is_uptrend and is_downtrend[1] and use_ema_uptrend
// Short Entry: Price crosses below SAR (trend changes from up to down)
short_signal = is_downtrend and is_uptrend[1] and use_ema_downtrend
// ==========================================// 🔹 EXECUTION & RISK MANAGEMENT// ==========================================if long_signal
strategy.entry("Long", strategy.long, comment="L | PSAR")
if short_signal
strategy.entry("Short", strategy.short, comment="S | PSAR")
// Risk management - use SAR as dynamic stopif strategy.position_size > 0// Long position - SAR as trailing stop
stop_level = sar_val
profit_level = strategy.position_avg_price + (strategy.position_avg_price - stop_level) * tp_ratio
strategy.exit("Exit Long", "Long", stop=stop_level, limit=profit_level, comment_loss="SL", comment_profit="TP")
if strategy.position_size < 0// Short position - SAR as trailing stop
stop_level = sar_val
profit_level = strategy.position_avg_price - (stop_level - strategy.position_avg_price) * tp_ratio
strategy.exit("Exit Short", "Short", stop=stop_level, limit=profit_level, comment_loss="SL", comment_profit="TP")
// ==========================================// 🔹 VISUALS// ==========================================// Plot EMAplot(use_trend ? ema_val : na, "Trend EMA", color=color.new(color.orange, 0), linewidth=2)
// Plot Parabolic SARplot(sar_val, "Parabolic SAR", color=color.new(color.blue, 0), style=plot.style_circles, linewidth=2)
// Plot Signalsplotshape(long_signal, title="Long Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY", textcolor=color.white)
plotshape(short_signal, title="Short Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL", textcolor=color.white)
// Background color for trendbgcolor(is_uptrend ? color.new(color.green, 95) : color.new(color.red, 95))