Parabolic SAR Strategy Indicator Pinescript
These strategies are for demonstration purposes only and are not intended for actual trading. Saanmi Capital is not responsible for any profit or loss arising from the use of these sample strategies.
//@version=5
strategy(“Parabolic SAR Strategy”, overlay=true)
// Input parameters
af_start = input.float(0.02, title=”Acceleration Factor Start”)
af_increment = input.float(0.02, title=”Acceleration Factor Increment”)
af_maximum = input.float(0.2, title=”Acceleration Factor Maximum”)
target_points = input.int(100, title=”Target Points”)
stop_loss_points = input.int(50, title=”Stop Loss Points”)
// Calculate Parabolic SAR
sar = ta.sar(af_start, af_increment, af_maximum)
// Strategy logic
long_condition = ta.crossover(close, sar)
short_condition = ta.crossunder(close, sar)
// Plot Parabolic SAR
plot(sar, color=color.blue, title=”Parabolic SAR”, offset=-1)
// Strategy entry and exit
if long_condition
strategy.entry(“Long”, strategy.long)
if short_condition
strategy.entry(“Short”, strategy.short)
// Calculate target and stop loss levels
long_target = strategy.position_avg_price + target_points
long_stop_loss = strategy.position_avg_price – stop_loss_points
short_target = strategy.position_avg_price – target_points
short_stop_loss = strategy.position_avg_price + stop_loss_points
// Strategy exit
strategy.exit(“Long Exit”, “Long”, limit=long_target, stop=long_stop_loss)
strategy.exit(“Short Exit”, “Short”, limit=short_target, stop=short_stop_loss)