// PARABOLIC SAR start = input(defval=0.02, group="Parabolic SAR Settings") increment = input(defval=0.02, group="Parabolic SAR Settings") maximum = input(defval=0.2, title="Max Value", group="Parabolic SAR Settings")
colUp = close >= sarDown ? color.lime : na colDown = close <= sarUp ? color.red : na
plot(susLS and sarUp ? sarUp : na, title="Linear SAR - Up Trending SAR", style=plot.style_circles, linewidth=2,color=colUp) plot(sdsLS and sarDown ? sarDown : na, title="Linear SAR - Down Trending SAR", style=plot.style_circles, linewidth=2,color=colDown)
// LUCID SAR AF_initial = input(defval=0.02, group="LUCID SAR SETTINGS") AF_increment = input(defval=0.02, group="LUCID SAR SETTINGS") AF_maximum = input(defval=0.2, group="LUCID SAR SETTINGS")
LUCID_SAR(initial, increment, maximum) =>
// start with uptrend uptrend = true new_trend = false EP = high SAR = low AF = AF_initial
// before a reversal, the reversal_state is 0; // after a reversal, within the same candle as the reversal, // the reversal_state can be 1 (uptrend) or 2 (downtrend) reversal_state = 0
if not na(uptrend[1]) and not na(new_trend[1]) if reversal_state == 0 if uptrend[1] EP := math.max(high, EP[1]) else EP := math.min(low, EP[1]) if new_trend[1] AF := AF_initial else if EP != EP[1] AF := math.min(AF_maximum, AF[1] + AF_increment) else AF := AF[1] SAR := SAR[1] + AF * (EP - SAR[1]) if uptrend[1] SAR := math.min(SAR, low[1]) if not na(low[2]) SAR := math.min(SAR, low[2]) if SAR > low uptrend := false new_trend := true SAR := math.max(high, EP[1]) EP := math.min(low, low[1]) reversal_state := 2 else uptrend := true new_trend := false else SAR := math.max(SAR, high[1]) if not na(high[2]) SAR := math.max(SAR, high[2]) if SAR < high uptrend := true new_trend := true SAR := math.min(low, EP[1]) EP := math.max(high, high[1]) reversal_state := 1 else uptrend := false new_trend := false else if reversal_state == 1 EP := high if low < SAR SAR := EP EP := low reversal_state == 2 uptrend := false else EP := low if high > SAR SAR := EP EP := high reversal_state == 1 uptrend := true SAR
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.