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))
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.