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}}")
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.