🔓 Get All Tools for FREE!
- ✅ Click here to open a trading account using our referral link and start trading.
- 📅 After 7 days of active trading under our referral link, you can get access to all tools in your account.
- ⚠️ Keep trading to keep access free — if you're inactive for 7 days, your access will be removed.
- 👉 Already have an account? You can change the IB (introducing broker) to our referral link ( https://one.exnesstrack.org/a/w7syl3vnjb ) and still qualify!
Parabolic SAR with Moving Average Filter Strategy [algo_aakash] | Full Code Inside
This article introduces a powerful trading strategy that combines the trend-following capabilities of the Parabolic SAR with the smoothing filter of a moving average. By integrating these two classic technical indicators, traders can generate more reliable signals and avoid false breakouts. The following sections will break down the strategy’s logic and present a complete, ready-to-use Pine Script implementation.
Core Components and Signal Generation
🔓 Get All Tools for FREE!
- ✅ Click here to open a trading account using our referral link and start trading.
- 📅 After 7 days of active trading under our referral link, you can get access to all tools in your account.
- ⚠️ Keep trading to keep access free — if you're inactive for 7 days, your access will be removed.
- 👉 Already have an account? You can change the IB (introducing broker) to our referral link ( https://one.exnesstrack.org/a/w7syl3vnjb ) and still qualify!
The strategy hinges on the synergy between two components. The Parabolic SAR (Stop and Reverse) is plotted directly on the chart, providing dynamic support and resistance points that flip when a trend reverses. Its sensitivity, however, can lead to whipsaws in ranging markets. This is where the moving average filter comes into play. A simple moving average (SMA) is applied to the price to determine the overall market bias. A long signal is only generated when the Parabolic SAR dot moves below the price bar and the closing price is above the SMA. Conversely, a short signal requires the SAR dot above the price and the close below the SMA.
Risk Management and Strategy Execution
No strategy is complete without robust risk management. This system incorporates practical exit rules. The Parabolic SAR itself acts as a trailing stop loss, continuously adjusting to lock in profits as a trend progresses. For additional protection, a fixed percentage-based stop loss is also implemented to cap potential losses on any single trade. Furthermore, a take profit level can be set as a multiple of the initial risk, defining a clear reward-to-risk ratio for every position entered by the strategy’s logic.
In conclusion, the Parabolic SAR with Moving Average filter strategy offers a systematic approach to trend trading by filtering out market noise. It provides clear entry and exit points alongside essential risk controls. The complete code below allows for immediate backtesting and customization to fit various trading instruments and timeframes.
//@version=5
strategy("Parabolic SAR with Moving Average Filter Strategy [algo_aakash] | Full Code Inside", overlay=true, margin_long=100, margin_short=100)
// Author: algo_aakash
// Inputs for Parabolic SAR
sarStart = input.float(0.02, "SAR Start", step=0.01)
sarIncrement = input.float(0.02, "SAR Increment", step=0.01)
sarMaximum = input.float(0.2, "SAR Maximum", step=0.01)
// Input for Moving Average
maLength = input.int(50, "Moving Average Length")
// Inputs for Risk Management
stopLossPerc = input.float(1.0, "Stop Loss %", step=0.1) / 100
takeProfitPerc = input.float(2.0, "Take Profit %", step=0.1) / 100
// Calculate Indicators
sar = ta.sar(sarStart, sarIncrement, sarMaximum)
sma = ta.sma(close, maLength)
// Define Trend Conditions based on MA Filter
bullishTrend = close > sma
bearishTrend = close < sma
// Define Trading Signals
longSignal = ta.sar < low and bullishTrend
shortSignal = ta.sar > high and bearishTrend
// Calculate Exit Prices for Fixed SL/TP
longStopPrice = strategy.position_avg_price * (1 - stopLossPerc)
longTakeProfitPrice = strategy.position_avg_price * (1 + takeProfitPerc)
shortStopPrice = strategy.position_avg_price * (1 + stopLossPerc)
shortTakeProfitPrice = strategy.position_avg_price * (1 - takeProfitPerc)
// Strategy Entry and Exit Rules
if (longSignal)
strategy.entry("Long", strategy.long)
strategy.exit("Long Exit", "Long", stop=longStopPrice, limit=longTakeProfitPrice)
if (shortSignal)
strategy.entry("Short", strategy.short)
strategy.exit("Short Exit", "Short", stop=shortStopPrice, limit=shortTakeProfitPrice)
// Plot Indicators and Signals
plot(sar, "Parabolic SAR", color=color.orange, style=plot.style_cross)
plot(sma, "SMA", color=color.blue)
plotshape(longSignal, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, title="Buy Signal")
plotshape(shortSignal, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, title="Sell Signal")
0 Comments