OPEN-SOURCE SCRIPT
MAGIC TRADER RANGE BOX 2.0

//version=6
indicator("MAGIC TRADER RANGE BOX 2.0", overlay=false
// ===== PARAMÈTRES =====
rangeLen = input.int(20, "Longueur Range H1", minval=5)
atrLen = input.int(14, "ATR H1")
atrFactor = input.float(1.0, "Facteur ATR", step=0.1)
maLen = input.int(20, "MA H1")
slopeLimit = input.float(0.05, "Tolérance direction", step=0.01)
// 🎨 STYLE BOÎTE
boxColor = input.color(color.gray, "Couleur de la boîte")
opacity = input.int(85, "Opacité (0-100)", minval=0, maxval=100)
borderColor = input.color(color.gray, "Couleur du contour")
// ===== DONNÉES H1 =====
[h1High, h1Low, h1Close] = request.security(
syminfo.tickerid,
"60",
[high, low, close]
)
h1HH = request.security(syminfo.tickerid, "60", ta.highest(high, rangeLen))
h1LL = request.security(syminfo.tickerid, "60", ta.lowest(low, rangeLen))
h1ATR = request.security(syminfo.tickerid, "60", ta.atr(atrLen))
h1MA = request.security(syminfo.tickerid, "60", ta.sma(close, maLen))
h1Slope = math.abs(h1MA - h1MA[1])
// ===== CONDITIONS RANGE H1 =====
lowVol = (h1HH - h1LL) < h1ATR * atrFactor
noDir = h1Slope < slopeLimit
isH1Range = lowVol and noDir
// ===== BOÎTE =====
var box h1Box = na
if isH1Range and na(h1Box)
h1Box := box.new(
left = bar_index,
right = bar_index,
top = h1HH,
bottom = h1LL,
bgcolor = color.new(boxColor, opacity),
border_color = borderColor
)
if isH1Range and not na(h1Box)
box.set_right(h1Box, bar_index)
box.set_top(h1Box, h1HH)
box.set_bottom(h1Box, h1LL)
if not isH1Range and not na(h1Box)
h1Box := na
// ===== ALERTES =====
alertcondition(isH1Range,
title="Range H1 détecté",
message="📦 RANGE H1 détecté sur {{ticker}}")
alertcondition(close > h1HH,
title="Breakout H1 Haussier",
message="🚀 Breakout HAUSSIER du range H1 sur {{ticker}}")
alertcondition(close < h1LL,
title="Breakout H1 Baissier",
message="🔻 Breakout BAISSIER du range H1 sur {{ticker}}")
indicator("MAGIC TRADER RANGE BOX 2.0", overlay=false
// ===== PARAMÈTRES =====
rangeLen = input.int(20, "Longueur Range H1", minval=5)
atrLen = input.int(14, "ATR H1")
atrFactor = input.float(1.0, "Facteur ATR", step=0.1)
maLen = input.int(20, "MA H1")
slopeLimit = input.float(0.05, "Tolérance direction", step=0.01)
// 🎨 STYLE BOÎTE
boxColor = input.color(color.gray, "Couleur de la boîte")
opacity = input.int(85, "Opacité (0-100)", minval=0, maxval=100)
borderColor = input.color(color.gray, "Couleur du contour")
// ===== DONNÉES H1 =====
[h1High, h1Low, h1Close] = request.security(
syminfo.tickerid,
"60",
[high, low, close]
)
h1HH = request.security(syminfo.tickerid, "60", ta.highest(high, rangeLen))
h1LL = request.security(syminfo.tickerid, "60", ta.lowest(low, rangeLen))
h1ATR = request.security(syminfo.tickerid, "60", ta.atr(atrLen))
h1MA = request.security(syminfo.tickerid, "60", ta.sma(close, maLen))
h1Slope = math.abs(h1MA - h1MA[1])
// ===== CONDITIONS RANGE H1 =====
lowVol = (h1HH - h1LL) < h1ATR * atrFactor
noDir = h1Slope < slopeLimit
isH1Range = lowVol and noDir
// ===== BOÎTE =====
var box h1Box = na
if isH1Range and na(h1Box)
h1Box := box.new(
left = bar_index,
right = bar_index,
top = h1HH,
bottom = h1LL,
bgcolor = color.new(boxColor, opacity),
border_color = borderColor
)
if isH1Range and not na(h1Box)
box.set_right(h1Box, bar_index)
box.set_top(h1Box, h1HH)
box.set_bottom(h1Box, h1LL)
if not isH1Range and not na(h1Box)
h1Box := na
// ===== ALERTES =====
alertcondition(isH1Range,
title="Range H1 détecté",
message="📦 RANGE H1 détecté sur {{ticker}}")
alertcondition(close > h1HH,
title="Breakout H1 Haussier",
message="🚀 Breakout HAUSSIER du range H1 sur {{ticker}}")
alertcondition(close < h1LL,
title="Breakout H1 Baissier",
message="🔻 Breakout BAISSIER du range H1 sur {{ticker}}")
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.