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}}")
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。