OPEN-SOURCE SCRIPT
Kewme

//version=5
indicator("EMA 9/15 + ATR TP/SL Separate Boxes (No Engulfing)", overlay=true, max_lines_count=500, max_boxes_count=500)
// ===== INPUTS =====
atrLen = input.int(14, "ATR Length")
slMult = input.float(1.0, "SL ATR Multiplier")
rr = input.float(2.0, "Risk Reward")
// ===== EMA =====
ema9 = ta.ema(close, 9)
ema15 = ta.ema(close, 15)
plot(ema9, color=color.green, title="EMA 9")
plot(ema15, color=color.red, title="EMA 15")
// ===== TREND STATE =====
var int trendState = 0
// ===== ATR =====
atr = ta.atr(atrLen)
// ===== Indecision =====
bodySize = math.abs(close - open)
candleRange = high - low
indecision = bodySize <= candleRange * 0.35
// ===== SIGNAL CONDITIONS (NO Engulfing) =====
buySignal =
ema9 > ema15 and
trendState != 1 and
indecision[1] and
close > ema9
sellSignal =
ema9 < ema15 and
trendState != -1 and
indecision[1] and
close < ema9
// ===== UPDATE TREND STATE =====
if buySignal
trendState := 1
if sellSignal
trendState := -1
// ===== SL & TP =====
buySL = close - atr * slMult
buyTP = close + atr * slMult * rr
sellSL = close + atr * slMult
sellTP = close - atr * slMult * rr
// ===== PLOTS =====
plotshape(buySignal, text="BUY", style=shape.labelup, location=location.belowbar, color=color.green, size=size.tiny)
plotshape(sellSignal, text="SELL", style=shape.labeldown, location=location.abovebar, color=color.red, size=size.tiny)
// ===== VARIABLES =====
var line buySLLine = na
var line buyTPLine = na
var line sellSLLine = na
var line sellTPLine = na
var box buySLBox = na
var box buyTPBox = na
var box sellSLBox = na
var box sellTPBox = na
// ===== BUY SIGNAL =====
if buySignal
// Delete previous
if not na(buySLLine)
line.delete(buySLLine)
line.delete(buyTPLine)
box.delete(buySLBox)
box.delete(buyTPBox)
// Draw lines
buySLLine := line.new(bar_index, buySL, bar_index + 15, buySL, color=color.red, width=2)
buyTPLine := line.new(bar_index, buyTP, bar_index + 15, buyTP, color=color.green, width=2)
// Draw separate boxes
buySLBox := box.new(bar_index, buySL - atr*0.1, bar_index + 15, buySL + atr*0.1, border_color=color.red, bgcolor=color.new(color.red,70))
buyTPBox := box.new(bar_index, buyTP - atr*0.1, bar_index + 15, buyTP + atr*0.1, border_color=color.green, bgcolor=color.new(color.green,70))
// ===== SELL SIGNAL =====
if sellSignal
// Delete previous
if not na(sellSLLine)
line.delete(sellSLLine)
line.delete(sellTPLine)
box.delete(sellSLBox)
box.delete(sellTPBox)
// Draw lines
sellSLLine := line.new(bar_index, sellSL, bar_index + 15, sellSL, color=color.red, width=2)
sellTPLine := line.new(bar_index, sellTP, bar_index + 15, sellTP, color=color.green, width=2)
// Draw separate boxes
sellSLBox := box.new(bar_index, sellSL - atr*0.1, bar_index + 15, sellSL + atr*0.1, border_color=color.red, bgcolor=color.new(color.red,70))
sellTPBox := box.new(bar_index, sellTP - atr*0.1, bar_index + 15, sellTP + atr*0.1, border_color=color.green, bgcolor=color.new(color.green,70))
indicator("EMA 9/15 + ATR TP/SL Separate Boxes (No Engulfing)", overlay=true, max_lines_count=500, max_boxes_count=500)
// ===== INPUTS =====
atrLen = input.int(14, "ATR Length")
slMult = input.float(1.0, "SL ATR Multiplier")
rr = input.float(2.0, "Risk Reward")
// ===== EMA =====
ema9 = ta.ema(close, 9)
ema15 = ta.ema(close, 15)
plot(ema9, color=color.green, title="EMA 9")
plot(ema15, color=color.red, title="EMA 15")
// ===== TREND STATE =====
var int trendState = 0
// ===== ATR =====
atr = ta.atr(atrLen)
// ===== Indecision =====
bodySize = math.abs(close - open)
candleRange = high - low
indecision = bodySize <= candleRange * 0.35
// ===== SIGNAL CONDITIONS (NO Engulfing) =====
buySignal =
ema9 > ema15 and
trendState != 1 and
indecision[1] and
close > ema9
sellSignal =
ema9 < ema15 and
trendState != -1 and
indecision[1] and
close < ema9
// ===== UPDATE TREND STATE =====
if buySignal
trendState := 1
if sellSignal
trendState := -1
// ===== SL & TP =====
buySL = close - atr * slMult
buyTP = close + atr * slMult * rr
sellSL = close + atr * slMult
sellTP = close - atr * slMult * rr
// ===== PLOTS =====
plotshape(buySignal, text="BUY", style=shape.labelup, location=location.belowbar, color=color.green, size=size.tiny)
plotshape(sellSignal, text="SELL", style=shape.labeldown, location=location.abovebar, color=color.red, size=size.tiny)
// ===== VARIABLES =====
var line buySLLine = na
var line buyTPLine = na
var line sellSLLine = na
var line sellTPLine = na
var box buySLBox = na
var box buyTPBox = na
var box sellSLBox = na
var box sellTPBox = na
// ===== BUY SIGNAL =====
if buySignal
// Delete previous
if not na(buySLLine)
line.delete(buySLLine)
line.delete(buyTPLine)
box.delete(buySLBox)
box.delete(buyTPBox)
// Draw lines
buySLLine := line.new(bar_index, buySL, bar_index + 15, buySL, color=color.red, width=2)
buyTPLine := line.new(bar_index, buyTP, bar_index + 15, buyTP, color=color.green, width=2)
// Draw separate boxes
buySLBox := box.new(bar_index, buySL - atr*0.1, bar_index + 15, buySL + atr*0.1, border_color=color.red, bgcolor=color.new(color.red,70))
buyTPBox := box.new(bar_index, buyTP - atr*0.1, bar_index + 15, buyTP + atr*0.1, border_color=color.green, bgcolor=color.new(color.green,70))
// ===== SELL SIGNAL =====
if sellSignal
// Delete previous
if not na(sellSLLine)
line.delete(sellSLLine)
line.delete(sellTPLine)
box.delete(sellSLBox)
box.delete(sellTPBox)
// Draw lines
sellSLLine := line.new(bar_index, sellSL, bar_index + 15, sellSL, color=color.red, width=2)
sellTPLine := line.new(bar_index, sellTP, bar_index + 15, sellTP, color=color.green, width=2)
// Draw separate boxes
sellSLBox := box.new(bar_index, sellSL - atr*0.1, bar_index + 15, sellSL + atr*0.1, border_color=color.red, bgcolor=color.new(color.red,70))
sellTPBox := box.new(bar_index, sellTP - atr*0.1, bar_index + 15, sellTP + atr*0.1, border_color=color.green, bgcolor=color.new(color.green,70))
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.