INVITE-ONLY SCRIPT
Leg-In | Boring (Small/Medium) | Leg-Out Strategy jayendra

//version=5
indicator("Leg-In | Boring (Small/Medium) | Leg-Out Strategy", overlay=true)
// ================= INPUTS =================
emaLen = input.int(50, "EMA Length")
atrLen = input.int(14, "ATR Length")
slMult = input.float(1.0, "Stop-Loss ATR x", step=0.1)
tpMult = input.float(2.0, "Take-Profit ATR x", step=0.1)
// ================= COLORS =================
legInColor = color.black
boringColor = color.blue
legOutColor = color.purple
// ================= CALCULATIONS =================
emaVal = ta.ema(close, emaLen)
atrVal = ta.atr(atrLen)
// Candle body sizes
legInSize = math.abs(close[2] - open[2])
boringSize = math.abs(close[1] - open[1])
legOutSize = math.abs(close - open)
// ================= RULES =================
// Leg-In: strong directional candle
legInValid = legInSize >= boringSize * 2
// Boring: small or medium size (flexible)
boringValid = (boringSize > atrVal * 0.3) and (boringSize <= legInSize)
// Leg-Out: breakout candle
legOutValid = legOutSize >= boringSize * 4
breakUp = high > high[1]
breakDown = low < low[1]
// Pattern valid
patternValid = legInValid and boringValid and legOutValid
// ================= DIRECTION =================
buySignal = patternValid and close > open and breakUp and close > emaVal
sellSignal = patternValid and close < open and breakDown and close < emaVal
setupFound = buySignal or sellSignal
// ================= CANDLE COLORING =================
barcolor(setupFound ? legOutColor : na)
barcolor(setupFound ? boringColor : na, offset=-1)
barcolor(setupFound ? legInColor : na, offset=-2)
// ================= PLOTS =================
plot(emaVal, color=color.orange, linewidth=2, title="EMA")
plotshape(buySignal, title="BUY", text="BUY",
style=shape.labelup, location=location.belowbar,
color=color.green, textcolor=color.white)
plotshape(sellSignal, title="SELL", text="SELL",
style=shape.labeldown, location=location.abovebar,
color=color.red, textcolor=color.white)
// ================= ALERTS =================
alertcondition(buySignal, title="BUY Alert", message="BUY: Leg-In (Black) → Boring (Blue, small/medium) → Leg-Out (Purple)")
alertcondition(sellSignal, title="SELL Alert", message="SELL: Leg-In (Black) → Boring (Blue, small/medium) → Leg-Out (Purple)")
// ================= STOP LOSS / TAKE PROFIT =================
var float buySL = na
var float buyTP = na
var float sellSL = na
var float sellTP = na
if buySignal
buySL := close - atrVal * slMult
buyTP := close + atrVal * tpMult
if sellSignal
sellSL := close + atrVal * slMult
sellTP := close - atrVal * tpMult
plot(buySL, color=color.red, style=plot.style_linebr, title="Buy SL")
plot(buyTP, color=color.green, style=plot.style_linebr, title="Buy TP")
plot(sellSL, color=color.red, style=plot.style_linebr, title="Sell SL")
plot(sellTP, color=color.green, style=plot.style_linebr, title="Sell TP")
indicator("Leg-In | Boring (Small/Medium) | Leg-Out Strategy", overlay=true)
// ================= INPUTS =================
emaLen = input.int(50, "EMA Length")
atrLen = input.int(14, "ATR Length")
slMult = input.float(1.0, "Stop-Loss ATR x", step=0.1)
tpMult = input.float(2.0, "Take-Profit ATR x", step=0.1)
// ================= COLORS =================
legInColor = color.black
boringColor = color.blue
legOutColor = color.purple
// ================= CALCULATIONS =================
emaVal = ta.ema(close, emaLen)
atrVal = ta.atr(atrLen)
// Candle body sizes
legInSize = math.abs(close[2] - open[2])
boringSize = math.abs(close[1] - open[1])
legOutSize = math.abs(close - open)
// ================= RULES =================
// Leg-In: strong directional candle
legInValid = legInSize >= boringSize * 2
// Boring: small or medium size (flexible)
boringValid = (boringSize > atrVal * 0.3) and (boringSize <= legInSize)
// Leg-Out: breakout candle
legOutValid = legOutSize >= boringSize * 4
breakUp = high > high[1]
breakDown = low < low[1]
// Pattern valid
patternValid = legInValid and boringValid and legOutValid
// ================= DIRECTION =================
buySignal = patternValid and close > open and breakUp and close > emaVal
sellSignal = patternValid and close < open and breakDown and close < emaVal
setupFound = buySignal or sellSignal
// ================= CANDLE COLORING =================
barcolor(setupFound ? legOutColor : na)
barcolor(setupFound ? boringColor : na, offset=-1)
barcolor(setupFound ? legInColor : na, offset=-2)
// ================= PLOTS =================
plot(emaVal, color=color.orange, linewidth=2, title="EMA")
plotshape(buySignal, title="BUY", text="BUY",
style=shape.labelup, location=location.belowbar,
color=color.green, textcolor=color.white)
plotshape(sellSignal, title="SELL", text="SELL",
style=shape.labeldown, location=location.abovebar,
color=color.red, textcolor=color.white)
// ================= ALERTS =================
alertcondition(buySignal, title="BUY Alert", message="BUY: Leg-In (Black) → Boring (Blue, small/medium) → Leg-Out (Purple)")
alertcondition(sellSignal, title="SELL Alert", message="SELL: Leg-In (Black) → Boring (Blue, small/medium) → Leg-Out (Purple)")
// ================= STOP LOSS / TAKE PROFIT =================
var float buySL = na
var float buyTP = na
var float sellSL = na
var float sellTP = na
if buySignal
buySL := close - atrVal * slMult
buyTP := close + atrVal * tpMult
if sellSignal
sellSL := close + atrVal * slMult
sellTP := close - atrVal * tpMult
plot(buySL, color=color.red, style=plot.style_linebr, title="Buy SL")
plot(buyTP, color=color.green, style=plot.style_linebr, title="Buy TP")
plot(sellSL, color=color.red, style=plot.style_linebr, title="Sell SL")
plot(sellTP, color=color.green, style=plot.style_linebr, title="Sell TP")
초대 전용 스크립트
이 스크립트는 작성자가 승인한 사용자만 접근할 수 있습니다. 사용하려면 요청 후 승인을 받아야 하며, 일반적으로 결제 후에 허가가 부여됩니다. 자세한 내용은 아래 작성자의 안내를 따르거나 jayendrabhoi2711에게 직접 문의하세요.
트레이딩뷰는 스크립트의 작동 방식을 충분히 이해하고 작성자를 완전히 신뢰하지 않는 이상, 해당 스크립트에 비용을 지불하거나 사용하는 것을 권장하지 않습니다. 커뮤니티 스크립트에서 무료 오픈소스 대안을 찾아보실 수도 있습니다.
작성자 지시 사항
pls do contact on
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
초대 전용 스크립트
이 스크립트는 작성자가 승인한 사용자만 접근할 수 있습니다. 사용하려면 요청 후 승인을 받아야 하며, 일반적으로 결제 후에 허가가 부여됩니다. 자세한 내용은 아래 작성자의 안내를 따르거나 jayendrabhoi2711에게 직접 문의하세요.
트레이딩뷰는 스크립트의 작동 방식을 충분히 이해하고 작성자를 완전히 신뢰하지 않는 이상, 해당 스크립트에 비용을 지불하거나 사용하는 것을 권장하지 않습니다. 커뮤니티 스크립트에서 무료 오픈소스 대안을 찾아보실 수도 있습니다.
작성자 지시 사항
pls do contact on
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.