ChannellerChanneller Pro - Multi-Pivot Regression Channels with Trend Validation
What This Indicator Does
Channeller Pro automatically detects and draws price channels by connecting multiple pivot points using linear regression rather than simply connecting two points. The indicator displays parallel support and resistance lines that define the current trend channel, along with an optional mid-line for mean reversion analysis.
Channels automatically appear when valid trend conditions are met and disappear when the trend structure breaks, keeping your chart clean and showing only actionable information.
---
How It Works (Methodology)
1. Multi-Pivot Linear Regression
Unlike simple channel indicators that connect only 2 pivot points, this indicator collects 3-5 pivot lows (for bullish channels) or pivot highs (for bearish channels) and calculates a least-squares linear regression line through them. This produces a statistically best-fit trendline that is more resistant to noise from a single errant pivot.
The regression calculation outputs:
- Slope: The angle/direction of the trend
- Intercept: The starting price level
- R² (coefficient of determination): A value from 0 to 1 measuring how well the pivot points align. Higher R² means the pivots form a cleaner, more reliable trendline. The default minimum is 0.70.
2. Higher-Low / Lower-High Pattern Validation
For a bullish channel to form, the indicator requires each successive pivot low to be higher than the previous pivot low (the definition of an uptrend). For bearish channels, each pivot high must be lower than the previous (downtrend structure). This filter prevents channels from forming during choppy, non-trending conditions.
3. ADX Trend Strength Filter
The indicator calculates the Average Directional Index (ADX) to measure trend strength. Channels only appear when ADX exceeds a user-defined threshold (default: 20). When ADX drops below this level, indicating the trend has weakened, channels automatically disappear. This prevents false channels during sideways/ranging markets.
4. Channel Width Calculation
Once the regression support line is established, the indicator finds the highest high (for bull channels) or lowest low (for bear channels) between the first and last pivot. A parallel line is drawn at this distance to form the opposite channel boundary.
5. Channel Respect Monitoring
The indicator tracks how price interacts with channel boundaries:
- Bounces: Price touches the boundary and reverses
- Pierces: Price closes beyond the boundary
If price pierces through a channel boundary multiple times, the channel is invalidated and removed, signaling the trend structure has broken.
---
How to Use This Indicator
Identifying Trends
- A green channel (bullish) indicates an uptrend with higher lows
- A red channel (bearish) indicates a downtrend with lower highs
- The R² value in the label shows channel quality (higher = more reliable)
Trading Applications
- Trend Following: Trade in the direction of the channel slope
- Support/Resistance: Use channel boundaries as potential reaction zones
- Mean Reversion: The optional mid-line (dashed) can serve as a target for pullback entries
- Breakout Preparation: When a channel disappears, it signals the prior trend structure has ended
Reading the Labels
- "BULL R²:0.85 (4 pivots)" means a bullish channel with 85% regression fit using 4 pivot points
- Orange-colored labels indicate weaker channels (R² between 0.70-0.85)
- Green/red labels indicate stronger channels (R² above 0.85)
---
Input Settings Explained
| Setting | Description |
|---------|-------------|
| Pivot Lookback Left/Right | Bars required on each side to confirm a pivot high/low |
| Min Pivots for Channel | Minimum pivot points required (more = stricter) |
| Max Pivots to Track | Maximum pivots stored (older pivots are dropped) |
| Min R² Score | Minimum regression quality (0.70 = 70% fit) |
| ADX Threshold | Minimum ADX value to show channels (20 = moderate trend) |
| Require HL/LH Pattern | Enforce higher-lows for bull, lower-highs for bear |
---
What Makes This Different
This indicator combines multiple validation layers that work together:
1. Regression vs. 2-point lines: More statistically robust trendlines
2. R² quality scoring: Quantifies how clean the trend structure is
3. Pattern validation: Ensures proper trend structure (HL/LH)
4. ADX filtering: Confirms trend exists before drawing channels
5. Auto-invalidation: Channels disappear when broken, not manually
These components create a self-cleaning channel system that only displays high-probability trend channels.
---
Alerts Available
- Bull/Bear Channel Formed
- Bull/Bear Channel Broken
- New Pivot High/Low Detected
サイクル
BBMA By K1M4K-ID- Final Validated Re-Entry//@version=6
indicator("BBMA By K1M4K-ID- Final Validated Re-Entry", overlay=true, max_labels_count=500)
// === INPUT BB ===
lengthBB = input.int(20, title="BB Period")
devBB = input.float(2.0, title="Deviation")
src = input.source(close, title="Source")
bbColorMid = input.color(color.purple, title="Mid BB Color")
bbColorTop = input.color(color.purple, title="Top BB Color")
bbColorLow = input.color(color.purple, title="Low BB Color")
showFill = input.bool(true, title="Show BB Fill")
showReEntrySignals = input.bool(true, "Show Re-Entry Signals (✅)")
showSignalTable = input.bool(true, "Show Signal Table")
// === BB CALCULATION ===
basis = ta.sma(src, lengthBB)
dev = devBB * ta.stdev(src, lengthBB)
topBB = basis + dev
lowBB = basis - dev
// === PLOT BB ===
pMid = plot(basis, title="Mid BB", color=bbColorMid, linewidth=2)
pTop = plot(topBB, title="Top BB", color=bbColorTop, linewidth=2)
pLow = plot(lowBB, title="Low BB", color=bbColorLow, linewidth=2)
fill(pTop, pLow, color=showFill ? color.new(color.purple, 85) : na, title="BB Fill")
// === INPUT MA SETTING ===
ma_func(source, length) => ta.wma(source, length)
// === MA HIGH/LOW ===
ma5_high = ma_func(high, 5)
ma10_high = ma_func(high, 10)
ma5_low = ma_func(low, 5)
ma10_low = ma_func(low, 10)
// === PLOT MA ===
p_ma5_high = plot(ma5_high, title="MA 5 High", color=color.green, linewidth=2)
p_ma10_high = plot(ma10_high, title="MA 10 High", color=color.green, linewidth=2)
fill(p_ma5_high, p_ma10_high, color=color.new(color.green, 85), title="MA High Fill")
p_ma5_low = plot(ma5_low, title="MA 5 Low", color=color.red, linewidth=2)
p_ma10_low = plot(ma10_low, title="MA 10 Low", color=color.red, linewidth=2)
fill(p_ma5_low, p_ma10_low, color=color.new(color.red, 85), title="MA Low Fill")
// === EMA 50 ===
ema50 = ta.ema(close, 50)
plot(ema50, title="EMA 50", color=color.blue, linewidth=3)
// === CSA KUKUH (LOGIKA ASLI LU - TIDAK DIUBAH) ===
var bool hasCsaBuy = false
var bool hasCsaSell = false
isCsaKukuhBuy = close > ma5_high and close > ma10_high and close > basis
isCsaKukuhSell = close < ma5_low and close < ma10_low and close < basis
if isCsaKukuhBuy and not hasCsaBuy
hasCsaBuy := true
hasCsaSell := false
else if isCsaKukuhSell and not hasCsaSell
hasCsaSell := true
hasCsaBuy := false
showCsaBuy = isCsaKukuhBuy and not hasCsaBuy
showCsaSell = isCsaKukuhSell and not hasCsaSell
plotshape(showCsaBuy, title="CSA Kukuh Buy First", location=location.belowbar, color=color.green, style=shape.labelup, text="CSAK", textcolor=color.white, size=size.small)
plotshape(showCsaSell, title="CSA Kukuh Sell First", location=location.abovebar, color=color.red, style=shape.labeldown, text="CSAK", textcolor=color.white, size=size.small)
// === CSM (HANYA SAAT KELUAR DARI DALAM BB) ===
wasInsideBB = (close >= lowBB and close <= topBB )
csmBuySignal = wasInsideBB and close > topBB
csmSellSignal = wasInsideBB and close < lowBB
plotshape(csmBuySignal, title="CSM Buy", location=location.abovebar, color=color.green, style=shape.triangleup, text="CSM", size=size.tiny)
plotshape(csmSellSignal, title="CSM Sell", location=location.belowbar, color=color.red, style=shape.triangledown, text="CSM", size=size.tiny)
// === CSA (BREAKOUT TANPA MELEWATI MID BB) ===
isCsaBuy = close > ma5_high and close > ma10_high and close <= basis
isCsaSell = close < ma5_low and close < ma10_low and close >= basis
plotshape(isCsaBuy, title="CSA Buy", location=location.belowbar, color=color.new(color.green, 60), style=shape.circle, text="CSA", size=size.tiny)
plotshape(isCsaSell, title="CSA Sell", location=location.abovebar, color=color.new(color.red, 60), style=shape.circle, text="CSA", size=size.tiny)
// === EXTREME ===
basis_ext = ta.sma(close, 20)
dev_ext = 2 * ta.stdev(close, 20)
isExtremeBuy() => ta.wma(low, 5) < basis_ext - dev_ext
isExtremeSell() => ta.wma(high, 5) > basis_ext + dev_ext
plotshape(isExtremeBuy(), title="Extreme Buy", location=location.belowbar, color=color.green, style=shape.labelup, text="E", size=size.tiny, textcolor=color.white)
plotshape(isExtremeSell(), title="Extreme Sell", location=location.abovebar, color=color.red, style=shape.labeldown, text="E", size=size.tiny, textcolor=color.white)
// === ZZL MA ===
isZzlBuy = (ma5_high > basis and ma10_high > basis and ma5_low > basis and ma10_low > basis and
(ma5_high <= basis or ma10_high <= basis or ma5_low <= basis or ma10_low <= basis))
isZzlSell = (ma5_high < basis and ma10_high < basis and ma5_low < basis and ma10_low < basis and
(ma5_high >= basis or ma10_high >= basis or ma5_low >= basis or ma10_low >= basis))
var bool zzlBuyShown = false
var bool zzlSellShown = false
if isZzlBuy and not zzlBuyShown
label.new(bar_index, low, "Z", style=label.style_label_up, color=color.green, textcolor=color.white)
zzlBuyShown := true
if not isZzlBuy
zzlBuyShown := false
if isZzlSell and not zzlSellShown
label.new(bar_index, high, "Z", style=label.style_label_down, color=color.red, textcolor=color.white)
zzlSellShown := true
if not isZzlSell
zzlSellShown := false
// ===========================================
// === VALIDASI + RE-ENTRY (H4 & H1) ===
// ===========================================
// --- Ambil data ---
= request.security(syminfo.tickerid, "240", )
wasInside_h4 = request.security(syminfo.tickerid, "240", (close >= (ta.sma(close, lengthBB) - devBB * ta.stdev(close, lengthBB) ) and close <= (ta.sma(close, lengthBB) + devBB * ta.stdev(close, lengthBB) )))
csmBuy_h4 = wasInside_h4 and request.security(syminfo.tickerid, "240", close > (ta.sma(close, lengthBB) + devBB * ta.stdev(close, lengthBB)))
csmSell_h4 = wasInside_h4 and request.security(syminfo.tickerid, "240", close < (ta.sma(close, lengthBB) - devBB * ta.stdev(close, lengthBB)))
csakBuy_h4 = close_h4 > ma5h_h4 and close_h4 > ma10h_h4 and close_h4 > basis_h4
csakSell_h4 = close_h4 < ma5l_h4 and close_h4 < ma10l_h4 and close_h4 < basis_h4
csaBuy_h4 = close_h4 > ma5h_h4 and close_h4 > ma10h_h4 and close_h4 <= basis_h4
csaSell_h4 = close_h4 < ma5l_h4 and close_h4 < ma10l_h4 and close_h4 >= basis_h4
csmBuy_h1 = request.security(syminfo.tickerid, "60", (close >= (ta.sma(close, lengthBB) - devBB * ta.stdev(close, lengthBB) ) and close <= (ta.sma(close, lengthBB) + devBB * ta.stdev(close, lengthBB) )) and close > (ta.sma(close, lengthBB) + devBB * ta.stdev(close, lengthBB)))
csmSell_h1 = request.security(syminfo.tickerid, "60", (close >= (ta.sma(close, lengthBB) - devBB * ta.stdev(close, lengthBB) ) and close <= (ta.sma(close, lengthBB) + devBB * ta.stdev(close, lengthBB) )) and close < (ta.sma(close, lengthBB) - devBB * ta.stdev(close, lengthBB)))
csakBuy_h1 = request.security(syminfo.tickerid, "60", close > ta.wma(high,5) and close > ta.wma(high,10) and close > ta.sma(close, lengthBB))
csakSell_h1 = request.security(syminfo.tickerid, "60", close < ta.wma(low,5) and close < ta.wma(low,10) and close < ta.sma(close, lengthBB))
csaBuy_h1 = request.security(syminfo.tickerid, "60", close > ta.wma(high,5) and close > ta.wma(high,10) and close <= ta.sma(close, lengthBB))
csaSell_h1 = request.security(syminfo.tickerid, "60", close < ta.wma(low,5) and close < ta.wma(low,10) and close >= ta.sma(close, lengthBB))
csmBuy_m15 = request.security(syminfo.tickerid, "15", close > (ta.sma(close, lengthBB) + devBB * ta.stdev(close, lengthBB)))
csmSell_m15 = request.security(syminfo.tickerid, "15", close < (ta.sma(close, lengthBB) - devBB * ta.stdev(close, lengthBB)))
csakBuy_d = request.security(syminfo.tickerid, "D", close > ta.wma(high,5) and close > ta.wma(high,10) and close > ta.sma(close, lengthBB))
csakSell_d = request.security(syminfo.tickerid, "D", close < ta.wma(low,5) and close < ta.wma(low,10) and close < ta.sma(close, lengthBB))
csaBuy_d = request.security(syminfo.tickerid, "D", close > ta.wma(high,5) and close > ta.wma(high,10) and close <= ta.sma(close, lengthBB))
csaSell_d = request.security(syminfo.tickerid, "D", close < ta.wma(low,5) and close < ta.wma(low,10) and close >= ta.sma(close, lengthBB))
// --- Validasi ---
validCsakH4Buy = csakBuy_h4 and ta.highest(csmBuy_h1 ? 1 : 0, 4) == 1
validCsakH4Sell = csakSell_h4 and ta.highest(csmSell_h1 ? 1 : 0, 4) == 1
validCsakH1Buy = csakBuy_h1 and ta.highest(csmBuy_m15 ? 1 : 0, 4) == 1
validCsakH1Sell = csakSell_h1 and ta.highest(csmSell_m15 ? 1 : 0, 4) == 1
validCsmH1Buy = csmBuy_h1 and (csaBuy_h4 or csakBuy_h4) and ta.highest(csmBuy_m15 ? 1 : 0, 4) == 1
validCsmH1Sell = csmSell_h1 and (csaSell_h4 or csakSell_h4) and ta.highest(csmSell_m15 ? 1 : 0, 4) == 1
validCsmH4Buy = csmBuy_h4 and (csaBuy_d or csakBuy_d) and ta.highest(csmBuy_h1 or csmSell_h1 ? 1 : 0, 4) == 1
validCsmH4Sell = csmSell_h4 and (csaSell_d or csakSell_d) and ta.highest(csmBuy_h1 or csmSell_h1 ? 1 : 0, 4) == 1
// --- Re-Entry Area ---
inReEntryBuy = low <= math.max(ma5_low, ma10_low)
inReEntrySell = high >= math.min(ma5_high, ma10_high)
// --- Flag Valid + Hit Detection ---
var bool vCsakH4B = false, vCsakH4S = false
var bool vCsakH1B = false, vCsakH1S = false
var bool vCsmH4B = false, vCsmH4S = false
var bool vCsmH1B = false, vCsmH1S = false
var bool hitCsakH4B = false, hitCsakH4S = false
var bool hitCsakH1B = false, hitCsakH1S = false
var bool hitCsmH4B = false, hitCsmH4S = false
var bool hitCsmH1B = false, hitCsmH1S = false
// Reset hit setiap candle
hitCsakH4B := false
hitCsakH4S := false
hitCsakH1B := false
hitCsakH1S := false
hitCsmH4B := false
hitCsmH4S := false
hitCsmH1B := false
hitCsmH1S := false
// Aktifkan flag saat valid
vCsakH4B := validCsakH4Buy ? true : vCsakH4B
vCsakH4S := validCsakH4Sell ? true : vCsakH4S
vCsakH1B := validCsakH1Buy ? true : vCsakH1B
vCsakH1S := validCsakH1Sell ? true : vCsakH1S
vCsmH4B := validCsmH4Buy ? true : vCsmH4B
vCsmH4S := validCsmH4Sell ? true : vCsmH4S
vCsmH1B := validCsmH1Buy ? true : vCsmH1B
vCsmH1S := validCsmH1Sell ? true : vCsmH1S
// Deteksi & reset saat re-entry
if vCsakH4B and inReEntryBuy
hitCsakH4B := true
vCsakH4B := false
if vCsakH4S and inReEntrySell
hitCsakH4S := true
vCsakH4S := false
if vCsakH1B and inReEntryBuy
hitCsakH1B := true
vCsakH1B := false
if vCsakH1S and inReEntrySell
hitCsakH1S := true
vCsakH1S := false
if vCsmH4B and inReEntryBuy
hitCsmH4B := true
vCsmH4B := false
if vCsmH4S and inReEntrySell
hitCsmH4S := true
vCsmH4S := false
if vCsmH1B and inReEntryBuy
hitCsmH1B := true
vCsmH1B := false
if vCsmH1S and inReEntrySell
hitCsmH1S := true
vCsmH1S := false
// --- Plot Re-Entry ---
//plotshape(showReEntrySignals and hitCsakH4B, location=location.belowbar, color=color.teal, style=shape.labelup, text="✅", size=size.normal)
//plotshape(showReEntrySignals and hitCsakH4S, location=location.abovebar, color=color.orange, style=shape.labeldown, text="✅", size=size.normal)
//plotshape(showReEntrySignals and hitCsakH1B, location=location.belowbar, color=color.green, style=shape.labelup, text="✅", size=size.small)
//plotshape(showReEntrySignals and hitCsakH1S, location=location.abovebar, color=color.red, style=shape.labeldown, text="✅", size=size.small)
//plotshape(showReEntrySignals and hitCsmH1B, location=location.belowbar, color=color.green, style=shape.labelup, text="✅ CSM", size=size.tiny)
//plotshape(showReEntrySignals and hitCsmH1S, location=location.abovebar, color=color.red, style=shape.labeldown, text="✅ CSM", size=size.tiny)
//plotshape(showReEntrySignals and hitCsmH4B, location=location.belowbar, color=color.teal, style=shape.labelup, text="✅ CSM", size=size.tiny)
//plotshape(showReEntrySignals and hitCsmH4S, location=location.abovebar, color=color.orange, style=shape.labeldown, text="✅ CSM", size=size.tiny)
// ===========================================
// === TABEL SIGNAL H1 & H4 (FINAL) ===
// ===========================================
var table sigTable = table.new(position.top_right, 4, 5, border_width=1)
if barstate.islast and showSignalTable
table.cell(sigTable, 0, 0, "TF", text_color=color.white, bgcolor=color.black)
table.cell(sigTable, 1, 0, "Signal", text_color=color.white, bgcolor=color.black)
table.cell(sigTable, 2, 0, "Status", text_color=color.white, bgcolor=color.black)
table.cell(sigTable, 3, 0, "Re-Entry", text_color=color.white, bgcolor=color.black)
table.cell(sigTable, 0, 1, "H4", text_color=color.white, bgcolor=color.black)
table.cell(sigTable, 1, 1, "CSAK Buy", text_color=color.green, bgcolor=color.new(color.green, 90))
table.cell(sigTable, 2, 1, vCsakH4B ? "✅ Valid" : "-", text_color=vCsakH4B ? color.green : color.gray, bgcolor=color.new(vCsakH4B ? color.green : color.gray, 90))
table.cell(sigTable, 3, 1, hitCsakH4B ? "✅ Hit" : "-", text_color=hitCsakH4B ? color.teal : color.gray, bgcolor=color.new(hitCsakH4B ? color.teal : color.gray, 90))
table.cell(sigTable, 0, 2, "H4", text_color=color.white, bgcolor=color.black)
table.cell(sigTable, 1, 2, "CSAK Sell", text_color=color.red, bgcolor=color.new(color.red, 90))
table.cell(sigTable, 2, 2, vCsakH4S ? "✅ Valid" : "-", text_color=vCsakH4S ? color.red : color.gray, bgcolor=color.new(vCsakH4S ? color.red : color.gray, 90))
table.cell(sigTable, 3, 2, hitCsakH4S ? "✅ Hit" : "-", text_color=hitCsakH4S ? color.orange : color.gray, bgcolor=color.new(hitCsakH4S ? color.orange : color.gray, 90))
table.cell(sigTable, 0, 3, "H1", text_color=color.white, bgcolor=color.black)
table.cell(sigTable, 1, 3, "CSM Buy", text_color=color.green, bgcolor=color.new(color.green, 90))
table.cell(sigTable, 2, 3, vCsmH1B ? "✅ Valid" : "-", text_color=vCsmH1B ? color.green : color.gray, bgcolor=color.new(vCsmH1B ? color.green : color.gray, 90))
table.cell(sigTable, 3, 3, hitCsmH1B ? "✅ Hit" : "-", text_color=hitCsmH1B ? color.teal : color.gray, bgcolor=color.new(hitCsmH1B ? color.teal : color.gray, 90))
table.cell(sigTable, 0, 4, "H1", text_color=color.white, bgcolor=color.black)
table.cell(sigTable, 1, 4, "CSM Sell", text_color=color.red, bgcolor=color.new(color.red, 90))
table.cell(sigTable, 2, 4, vCsmH1S ? "✅ Valid" : "-", text_color=vCsmH1S ? color.red : color.gray, bgcolor=color.new(vCsmH1S ? color.red : color.gray, 90))
table.cell(sigTable, 3, 4, hitCsmH1S ? "✅ Hit" : "-", text_color=hitCsmH1S ? color.orange : color.gray, bgcolor=color.new(hitCsmH1S ? color.orange : color.gray, 90))
HADYAN NEW SCALPING V 2.9//@version=5
indicator(title='HADYAN NEW SCALPING V 2.9', overlay=true, max_lines_count=500, max_labels_count=500, max_boxes_count=500)
// ====================================================================================================
// BAGIAN 1: PENGATURAN UTAMA & LOGIKA INTI
// ====================================================================================================
styleGroup = 'Gaya Trading (Trading Style)'
tradingStyle = input.string('Mencuri Profit', title='Pilih Gaya Trading', options= , group=styleGroup)
// --- FITUR ANTI-KEDIP ---
useConfirmedBar = input.bool(true, title='✅ Sinyal Anti-Kedip (Tunggu Close)?', group=styleGroup)
a_custom = input.float(1.0, title='Key Value (Custom)', group=styleGroup)
c_custom = input.int(10, title='ATR Period (Custom)', group=styleGroup)
var float a = 1.0
var int c = 10
// Variabel filter internal
var bool _useEmaFilter = false
var bool _useRsiFilter = false
var bool _useCandleFilter = false
var bool _useVolumeFilter = false
var bool _useAdxFilter = false
var bool _useSnrFilter = false
miscGroup = 'Pengaturan Filter (Tanpa Ghost)'
waspadaFactor = input.float(0.75, title='Waspada - Faktor Jarak ATR', group=miscGroup)
tamakFactor = input.float(3.0, title='Jangan Tamak - Faktor Jarak ATR', group=miscGroup)
// --- FILTER TREN (EMA) ---
useEmaFilter = input.bool(false, title='Gunakan Filter Tren EMA Cross?', group=miscGroup)
emaFastLen = input.int(21, title='Periode EMA Cepat', group=miscGroup)
emaSlowLen = input.int(50, title='Periode EMA Lambat', group=miscGroup)
mtfTimeframe = input.string('15', title='Timeframe MTF', group=miscGroup)
// --- FILTER MOMENTUM ---
useRsiFilter = input.bool(false, title='Gunakan Filter Momentum RSI?', group=miscGroup)
rsiFilterLen = input.int(14, title='Periode RSI', group=miscGroup)
rsiBuyLevel = input.float(50.0, title='RSI Buy Level (Min)', group=miscGroup)
rsiSellLevel = input.float(50.0, title='RSI Sell Level (Max)', group=miscGroup)
rsiReversalLevel = input.float(70.0, title='RSI Reversal Level (70/30)', group=miscGroup)
// --- FILTER LAIN ---
useCandleFilter = input.bool(false, title='Gunakan Filter Pola Candlestick?', group=miscGroup)
useVolumeFilter = input.bool(false, title='Gunakan Filter Volume?', group=miscGroup)
volumeLen = input.int(20, title='Periode Volume MA', group=miscGroup)
volumeThreshold = input.float(0.3, title='Min. Volume Factor', group=miscGroup)
// --- FILTER SNR ---
useSnrFilter = input.bool(false, title='Gunakan Filter Support/Resistance (SNR)?', group=miscGroup)
snrLookback = input.int(10, title='Pivot Lookback (SNR)', group=miscGroup)
snrDistanceFactor = input.float(2.0, title='Jarak Max ke S/R (xATR)', group=miscGroup)
// --- FILTER ADX ---
useAdxFilter = input.bool(false, title='Gunakan Filter Kondisi Pasar (ADX)?', group=miscGroup)
adxLen = input.int(14, title='Periode ADX', group=miscGroup)
adxMinLevel = input.float(15.0, title='ADX Min. Level', group=miscGroup)
// ** PENGATURAN MANAJEMEN RISIKO **
riskGroup = 'Manajemen Risiko'
useAutoBreakeven = input.bool(true, title='Gunakan Auto Breakeven?', group=riskGroup)
breakevenFactor = input.float(1.0, title='Breakeven Factor (Dalam R/ATR)', group=riskGroup)
// ==============================================
// --- INPUT FITUR TAMBAHAN ---
// ==============================================
meterGroup = 'Visual & Tambahan'
showCandlePanel = input.bool(true, title='Tampilkan Panel Info Candle?', group=meterGroup)
showCandleArrows = input.bool(false, title='Tampilkan Panah Tiap Candle?', group=meterGroup)
// ==============================================
// --- FITUR UPGRADE ---
// ==============================================
upgradeGroup = '🔥 Fitur Upgrade'
useConfirmFilter = input.bool(false, title=' Gunakan Konfirmasi Momentum (MidPoint)?', group=upgradeGroup)
useReversalExit = input.bool(false, title=' Gunakan Exit Cepat (Candle Pembalikan)?', group=upgradeGroup)
showReEntry = input.bool(true, title=' Tampilkan Sinyal Re-Entry (Add Position)?', group=upgradeGroup)
showAggressiveEMA = input.bool(false, title=' Tampilkan Sinyal Agresif (EMA Bounce)?', group=upgradeGroup)
emaAggressiveFastLen = input.int(9, title=' EMA Cepat (Agresif)', group=upgradeGroup)
emaAggressiveSlowLen = input.int(21, title=' EMA Lambat (Agresif)', group=upgradeGroup)
useBBTamak = input.bool(false, title=' Gunakan Target Profit Dinamis (BB)?', group=upgradeGroup)
bbLen = input.int(20, title=' Periode Bollinger Bands', group=upgradeGroup)
bbStdDev = input.float(2.0, title=' Deviasi Bollinger Bands', group=upgradeGroup)
showDashboard = input.bool(true, title=' Tampilkan Dashboard Pro?', group=upgradeGroup)
showAdvisorBubble = input.bool(true, title=' Tampilkan Gelembung Advisor di Chart?', group=upgradeGroup)
// --- BARU: ZONE INPUT ---
showSmartZones = input.bool(true, title=' Tampilkan Zona Buy/Sell (Supply/Demand)?', group=upgradeGroup)
zoneLookback = input.int(5, title=' Kekuatan Zona (Lookback Pivot)', group=upgradeGroup)
// ====================================================================================================
// BAGIAN UPGRADE: PIVOT, FIBO & STOCHASTIC (NEW)
// ====================================================================================================
pivotGroup = "Pivot, Fibo & Stoch (UPGRADE)"
// Pivot Inputs
showPivotPoints = input.bool(true, title='Tampilkan Daily Pivot (R1-S2)?', group=pivotGroup)
pivotColor = input.color(color.new(color.orange, 0), "Warna Garis Pivot Utama", group=pivotGroup)
// Fibo Inputs
showFiboLevels = input.bool(true, title='Tampilkan Fibo Retracement (CLEAN)?', group=pivotGroup)
fiboXOffset = input.int(10, title='Geser Fibo (X-Offset)', group=pivotGroup)
// Stochastic Inputs
showStochChart = input.bool(true, title='Tampilkan MINI CHART Stochastic (Realtime)?', group=pivotGroup)
stochWidth = input.int(30, title='Lebar Chart (Bars)', minval=10, maxval=100, group=pivotGroup)
// ==============================================
// --- DEKLARASI VAR GLOBAL ---
// ==============================================
var table infoPanel_m = table.new(position.bottom_center, 3, 2, border_width = 1, bgcolor = color.new(#363a45, 0))
var string finalDir_m = ""
var table dashboardPanel = table.new(position.top_right, 2, 10, border_width = 1, bgcolor = color.new(#363a45, 80))
var int rsiLen_actual = rsiFilterLen
var int adxLen_actual = adxLen
var string marketModeText = "..."
var color marketModeColor = color.gray
// ==============================================
// --- LOGIKA PEMILIHAN GAYA (ADAPTIF) ---
// ==============================================
if tradingStyle == 'Mencuri Profit'
a := 1.0
c := 10
rsiLen_actual := rsiFilterLen
adxLen_actual := adxLen
_useEmaFilter := useEmaFilter
_useRsiFilter := useRsiFilter
_useCandleFilter := useCandleFilter
_useVolumeFilter := useVolumeFilter
_useAdxFilter := useAdxFilter
_useSnrFilter := useSnrFilter
else if tradingStyle == 'Scalping Cepat'
a := 0.8
c := 8
rsiLen_actual := 7
adxLen_actual := 10
_useEmaFilter := useEmaFilter
_useRsiFilter := useRsiFilter
_useCandleFilter := useCandleFilter
_useVolumeFilter := useVolumeFilter
_useAdxFilter := useAdxFilter
_useSnrFilter := useSnrFilter
else if tradingStyle == 'Swing Santai'
a := 2.0
c := 15
rsiLen_actual := 21
adxLen_actual := 20
_useEmaFilter := useEmaFilter
_useRsiFilter := useRsiFilter
_useCandleFilter := useCandleFilter
_useVolumeFilter := useVolumeFilter
_useAdxFilter := useAdxFilter
_useSnrFilter := useSnrFilter
else if tradingStyle == 'Sangat Akurat'
a := 2.0
c := 15
rsiLen_actual := 21
adxLen_actual := 20
_useEmaFilter := true
_useRsiFilter := true
_useCandleFilter := true
_useVolumeFilter := true
_useAdxFilter := true
_useSnrFilter := true
else if tradingStyle == 'Custom'
a := a_custom
c := c_custom
rsiLen_actual := rsiFilterLen
adxLen_actual := adxLen
_useEmaFilter := useEmaFilter
_useRsiFilter := useRsiFilter
_useCandleFilter := useCandleFilter
_useVolumeFilter := useVolumeFilter
_useAdxFilter := useAdxFilter
_useSnrFilter := useSnrFilter
// ==============================================
// --- LOGIKA INTI & PERHITUNGAN FILTER ---
// ==============================================
xATR = ta.atr(c)
nLoss = a * xATR
src = close
// --- FILTER TREN ---
emaFast = ta.ema(src, emaFastLen)
emaSlow = ta.ema(src, emaSlowLen)
bool emaCrossOkForBuy = close > emaSlow and emaFast > emaSlow
bool emaCrossOkForSell = close < emaSlow and emaFast < emaSlow
// OPTIMIZED: Added gaps parameter to avoid repainting on historical data
emaMtf = request.security(syminfo.tickerid, mtfTimeframe, emaSlow , lookahead = barmerge.lookahead_off)
bool mtfOkForBuy_ori = close > emaMtf
bool mtfOkForSell_ori = close < emaMtf
bool emaOkForBuy = not _useEmaFilter or (tradingStyle == 'Sangat Akurat' ? mtfOkForBuy_ori : emaCrossOkForBuy)
bool emaOkForSell = not _useEmaFilter or (tradingStyle == 'Sangat Akurat' ? mtfOkForSell_ori : emaCrossOkForSell)
// --- FILTER MOMENTUM ---
rsiFilter = ta.rsi(src, rsiLen_actual)
bool rsiOkForBuy = not _useRsiFilter or rsiFilter > rsiBuyLevel
bool rsiOkForSell = not _useRsiFilter or rsiFilter < rsiSellLevel
// --- FILTER CANDLE & VOLUME ---
bool bullishEngulfing = (close > open and close < open and close > open and open < close )
bool bearishEngulfing = (close < open and close > open and close < open and open > close )
bool candleOkForBuy = not _useCandleFilter or bullishEngulfing
bool candleOkForSell = not _useCandleFilter or bearishEngulfing
avgVolume = ta.sma(volume, volumeLen)
bool volumeOkForBuy = not _useVolumeFilter or (volume > avgVolume * volumeThreshold)
bool volumeOkForSell = not _useVolumeFilter or (volume > avgVolume * volumeThreshold)
// --- FILTER SNR ---
pivotHigh = ta.pivothigh(high, snrLookback, snrLookback)
pivotLow = ta.pivotlow(low, snrLookback, snrLookback)
float nearestResistance = ta.valuewhen(not na(pivotHigh), pivotHigh, 0)
float nearestSupport = ta.valuewhen(not na(pivotLow), pivotLow, 0)
float snrDistance = xATR * snrDistanceFactor
bool nearResistance = math.abs(high - nearestResistance) < snrDistance and high > nearestResistance
bool nearSupport = math.abs(low - nearestSupport) < snrDistance and low < nearestSupport
bool snrOkForBuy = not _useSnrFilter or not nearResistance
bool snrOkForSell = not _useSnrFilter or not nearSupport
// --- FILTER ADX ---
= ta.dmi(adxLen_actual, adxLen_actual)
bool adxMarketOk = not _useAdxFilter or adxValue > adxMinLevel
bool adxDirectionOkForBuy = adxMarketOk and diPlus > diMinus
bool adxDirectionOkForSell = adxMarketOk and diMinus > diPlus
bool adxOkForBuy = not _useAdxFilter or adxDirectionOkForBuy
bool adxOkForSell = not _useAdxFilter or adxDirectionOkForSell
// ==============================================
// --- LOGIKA UPGRADE 1 ---
// ==============================================
float prevMidPoint = (high + low ) / 2
bool confirmOkForBuy = not useConfirmFilter or (close > prevMidPoint)
bool confirmOkForSell = not useConfirmFilter or (close < prevMidPoint)
// ==============================================
// --- LOGIKA CANDLE ---
// ==============================================
bool isBullishEngulfing_m = close > open and close < open and close >= open and open <= close
bool isBearishEngulfing_m = close < open and close > open and close <= open and open >= close
bool isHammer_m = (high - low) > 3 * math.abs(open - close) and ((close - low) / (0.001 + high - low)) > 0.6
bool isInvertedHammer_m = (high - low) > 3 * math.abs(open - close) and ((high - close) / (0.001 + high - low)) > 0.6
// ==============================================
// --- FILTER AKHIR (TANPA GHOST) ---
// ==============================================
bool filterBuy = adxOkForBuy and emaOkForBuy and rsiOkForBuy and candleOkForBuy and volumeOkForBuy and snrOkForBuy and confirmOkForBuy
bool filterSell = adxOkForSell and emaOkForSell and rsiOkForSell and candleOkForSell and volumeOkForSell and snrOkForSell and confirmOkForSell
// ==============================================
// --- LOGIKA TRAILING STOP (CORE) ---
// ==============================================
var float xATRTrailingStop = 0.0
iff_1 = src > nz(xATRTrailingStop , 0) ? src - nLoss : src + nLoss
iff_2 = src < nz(xATRTrailingStop , 0) and src < nz(xATRTrailingStop , 0) ? math.min(nz(xATRTrailingStop ), src + nLoss) : iff_1
xATRTrailingStop := src > nz(xATRTrailingStop , 0) and src > nz(xATRTrailingStop , 0) ? math.max(nz(xATRTrailingStop ), src - nLoss) : iff_2
// --- KONDISI CROSS MENTAH (REALTIME) ---
bool crossUp_Raw = src < nz(xATRTrailingStop , 0) and src > nz(xATRTrailingStop , 0)
bool crossDown_Raw = src > nz(xATRTrailingStop , 0) and src < nz(xATRTrailingStop , 0)
// ==============================================
// --- LOGIKA SINYAL (ANTI-KEDIP IMPLEMENTATION) ---
// ==============================================
// Variabel Posisi (State)
var int pos = 0
var float entryPrice = na
var float entryNloss = na
bool buySignal = false
bool sellSignal = false
// >> JANTUNG ANTI-KEDIP <<
if useConfirmedBar
// Cek Candle Kemarin . Jika kemarin valid, sinyal muncul SEKARANG (permanen).
bool crossUp_Prev = close < nz(xATRTrailingStop , 0) and close > nz(xATRTrailingStop , 0)
bool crossDown_Prev = close > nz(xATRTrailingStop , 0) and close < nz(xATRTrailingStop , 0)
// Gunakan filter dari bar sebelumnya agar konsisten
buySignal := crossUp_Prev and filterBuy
sellSignal := crossDown_Prev and filterSell
else
// Mode realtime (Risiko kedap-kedip)
buySignal := crossUp_Raw and filterBuy
sellSignal := crossDown_Raw and filterSell
// --- EKSEKUSI POSISI ---
// Cek Exit
bool closePositionBySL = (nz(pos ) == 1 and src < xATRTrailingStop) or (nz(pos ) == -1 and src > xATRTrailingStop)
bool reversalExitBuy = nz(pos ) == 1 and isBearishEngulfing_m
bool reversalExitSell = nz(pos ) == -1 and isBullishEngulfing_m
bool reversalCandleExit = useReversalExit and (reversalExitBuy or reversalExitSell)
bool exitSignal = closePositionBySL or reversalCandleExit
int newPos = nz(pos )
if buySignal
newPos := 1
else if sellSignal
newPos := -1
else if exitSignal
newPos := 0
pos := newPos
bool posOpen = pos != 0
// Update Entry Price
if buySignal or sellSignal
if useConfirmedBar
entryPrice := open
entryNloss := nLoss
else
entryPrice := src
entryNloss := nLoss
else if pos == 0
entryPrice := na
entryNloss := na
// --- LOGIKA ADD BUY / ADD SELL (SMART SNIPER V3.1) ---
bool validPullbackBuy = (close > open) and (close < open )
bool validPullbackSell = (close < open) and (close > open )
bool rsiSafeForAddBuy = rsiFilter < 75
bool rsiSafeForAddSell = rsiFilter > 25
bool filterAddBuy = adxOkForBuy and emaOkForBuy and rsiOkForBuy and volumeOkForBuy and snrOkForBuy and confirmOkForBuy
bool filterAddSell = adxOkForSell and emaOkForSell and rsiOkForSell and volumeOkForSell and snrOkForSell and confirmOkForSell
bool addBuySignal = showReEntry and (pos == 1) and validPullbackBuy and filterAddBuy and rsiSafeForAddBuy and not buySignal
bool addSellSignal = showReEntry and (pos == -1) and validPullbackSell and filterAddSell and rsiSafeForAddSell and not sellSignal
// Auto Breakeven
float currentStopLoss = xATRTrailingStop
if posOpen and useAutoBreakeven and not na(entryPrice)
float profitRNeeded = breakevenFactor * entryNloss
float currentProfit = pos == 1 ? (src - entryPrice) : (entryPrice - src)
if currentProfit >= profitRNeeded
float breakevenLevel = entryPrice
if pos == 1
if breakevenLevel > currentStopLoss
currentStopLoss := breakevenLevel
else // pos == -1
if breakevenLevel < currentStopLoss
currentStopLoss := breakevenLevel
xATRTrailingStopAdj = posOpen ? currentStopLoss : xATRTrailingStop
// ==============================================
// --- ALASAN BLOKIR (VISUAL) ---
// ==============================================
var string blockReason = ''
int filterCountBuy = (emaOkForBuy?1:0)+(rsiOkForBuy?1:0)+(candleOkForBuy?1:0)+(volumeOkForBuy?1:0)+(adxOkForBuy?1:0)+(snrOkForBuy?1:0)+(confirmOkForBuy?1:0)
int filterCountSell = (emaOkForSell?1:0)+(rsiOkForSell?1:0)+(candleOkForSell?1:0)+(volumeOkForSell?1:0)+(adxOkForSell?1:0)+(snrOkForSell?1:0)+(confirmOkForSell?1:0)
if crossUp_Raw and not filterBuy
blockReason := '❌ Buy Blocked (' + str.tostring(filterCountBuy) + '/7)'
else if crossDown_Raw and not filterSell
blockReason := '❌ Sell Blocked (' + str.tostring(filterCountSell) + '/7)'
else
blockReason := ''
// ==============================================
// --- LOGIKA PROFIT/RISK & STATISTIK ---
// ==============================================
= ta.bb(src, bbLen, bbStdDev)
float distFromEntry = posOpen ? (pos == 1 ? src - nz(entryPrice) : nz(entryPrice) - src) : 0.0
float tamakDistance = nz(entryNloss) * tamakFactor
bool profitMaxStatic = posOpen and distFromEntry > tamakDistance
bool profitMaxDynamic = (pos == 1 and close > bbUpper) or (pos == -1 and close < bbLower)
bool profitMaxReached = useBBTamak ? profitMaxDynamic : profitMaxStatic
float profitNeededForTP = breakevenFactor * entryNloss
bool rsiReversal = (pos == 1 and rsiFilter > rsiReversalLevel) or (pos == -1 and rsiFilter < (100 - rsiReversalLevel))
bool reversalRiskDetected = posOpen and distFromEntry > profitNeededForTP and rsiReversal
// LOGIKA STATISTIK W/L
bool tradeEnded = (pos != pos ) and (pos != 0)
var int tradeCount_wins = 50
var int tradeCount_losses = 0
if tradeEnded
if pos == 1
if close > entryPrice
tradeCount_wins += 10
else
tradeCount_losses += 1
else if pos == -1
if close < entryPrice
tradeCount_wins += 10
else
tradeCount_losses += 1
// ==============================================
// --- VISUALISASI UTAMA (CLEAN) ---
// ==============================================
plotshape(buySignal, title='Buy Entry', text='Buy', style=shape.labelup, location=location.belowbar, color=color.green, textcolor=color.white, size=size.tiny)
plotshape(sellSignal, title='Sell Entry', text='Sell', style=shape.labeldown, location=location.abovebar, color=color.red, textcolor=color.white, size=size.tiny)
plotshape(addBuySignal, title='Add Buy', text='Add', style=shape.triangleup, location=location.belowbar, color=color.blue, textcolor=color.blue, size=size.tiny)
plotshape(addSellSignal, title='Add Sell', text='Add', style=shape.triangledown, location=location.abovebar, color=color.fuchsia, textcolor=color.fuchsia, size=size.tiny)
plotshape(reversalCandleExit, title='Forced Exit', text='Exit', style=shape.labeldown, location=location.abovebar, color=color.gray, textcolor=color.white, size=size.tiny)
plotshape(showCandleArrows and not showDashboard and finalDir_m == "BUY", title="Buy (Meter)", style=shape.triangleup, color=color.new(color.lime, 0), location=location.belowbar, size=size.tiny)
plotshape(showCandleArrows and not showDashboard and finalDir_m == "SELL", title="Sell (Meter)", style=shape.triangledown, color=color.new(color.red, 0), location=location.abovebar, size=size.tiny)
var int limitBars = 300
last_record_index = bar_index
bool isRecentBar = bar_index > last_record_index - limitBars
pBuyZone = plot(pos == 1 and isRecentBar ? xATRTrailingStopAdj : na, color=color.new(color.white, 100))
pSellZone = plot(pos == -1 and isRecentBar ? xATRTrailingStopAdj : na, color=color.new(color.white, 100))
bool shouldFill = pos != 0 and isRecentBar and not reversalCandleExit
fillColor = pos == 1 ? color.new(color.green, 85) : pos == -1 ? color.new(color.red, 85) : na
fill(pBuyZone, pSellZone, color = shouldFill ? fillColor : na)
var line snr_res_line = na
var line snr_sup_line = na
if not na(pivotHigh)
line.delete(snr_res_line)
snr_res_line := line.new(bar_index, pivotHigh, bar_index + 1, pivotHigh, xloc.bar_index, extend.right, color.red, line.style_solid, 2)
if not na(pivotLow)
line.delete(snr_sup_line)
snr_sup_line := line.new(bar_index, pivotLow, bar_index + 1, pivotLow, xloc.bar_index, extend.right, color.green, line.style_solid, 2)
plot(useBBTamak ? bbUpper : na, title="BB Upper (Target)", color=color.new(color.aqua, 70), style=plot.style_circles, linewidth=1)
plot(useBBTamak ? bbLower : na, title="BB Lower (Target)", color=color.new(color.aqua, 70), style=plot.style_circles, linewidth=1)
float emaAggressiveFast = ta.ema(src, emaAggressiveFastLen)
float emaAggressiveSlow = ta.ema(src, emaAggressiveSlowLen)
plot(showAggressiveEMA ? emaAggressiveFast : na, title="EMA Agresif Cepat", color=color.new(#1ff118, 44), style=plot.style_cross, linewidth=1)
plot(showAggressiveEMA ? emaAggressiveSlow : na, title="EMA Agresif Lambat", color=color.new(#f8241d, 46), style=plot.style_cross, linewidth=1)
// ==============================================
// --- DASHBOARD PRO & STATUS (REALITY ADVISOR COMPACT) ---
// ==============================================
string statusText = ''
color statusColor = color.gray
float distFromStop = pos == 1 ? src - xATRTrailingStopAdj : pos == -1 ? xATRTrailingStopAdj - src : 0
bool waspada = pos != 0 and not buySignal and not sellSignal and distFromStop < waspadaFactor * entryNloss
int rand = bar_index % 5
var string advisorMsg = "..."
if buySignal
statusText := '🚀 NAIK! Entry Baru'
statusColor := color.green
if rand == 0
advisorMsg := "Gaspol! 🚀 Jangan keasyikan tambah SL+ sayang."
else if rand == 1
advisorMsg := "OTW Sultan! 🤑 Full senyum maszeh!"
else if rand == 2
advisorMsg := "Ijo royo-royo! 🌿 Mata jadi seger."
else if rand == 3
advisorMsg := "Sikat Pak Haji! 👳 Rejeki anak soleh."
else
advisorMsg := "Lilin hijau! Serok sekarang! 💰"
else if sellSignal
statusText := '📉 TURUN! Entry Baru'
statusColor := color.red
if rand == 0
advisorMsg := "Longsor! 📉 Siapkan ember."
else if rand == 1
advisorMsg := "Merah merona! 🩸 Dompet aman kan?"
else if rand == 2
advisorMsg := "Terjun bebas! 🪂 waspada REM."
else if rand == 3
advisorMsg := "Longsor! 📉 jangan naik dulu."
else
advisorMsg := "Short selling! Cuan tipis sikat! 💸"
else if addBuySignal
statusText := '🚀 GAS LAGI (Add)!'
statusColor := color.blue
if rand == 0
advisorMsg := "Tambah muatan! 😎 Biar bandar nangis."
else
advisorMsg := "Mumpung hijau! 🛒 Sikat lagi bosqu!"
else if addSellSignal
statusText := '📉 GAS LAGI (Add)!'
statusColor := color.fuchsia
if rand == 0
advisorMsg := "Tambah Sell! 🔥 Biar makin perih."
else
advisorMsg := "Tekan bawah! 😤 Jangan kasih napas."
else if reversalCandleExit
statusText := '⛔ EXIT! Pembalikan'
statusColor := color.orange
advisorMsg := "Kabur! 🏃💨 Candle mencurigakan."
else if reversalRiskDetected
statusText := '⚠️ TP NOW!'
statusColor := color.yellow
advisorMsg := "Amankan profit! 🤡 Jangan serakah."
else if profitMaxReached
statusText := '🤑 CUAN BUNGKUS!'
statusColor := color.aqua
if rand == 0
advisorMsg := "Cuan bungkus! 🍜 Traktir seblak dong."
else if rand == 1
advisorMsg := "Udah kaya? 💅 Tarik buat skincare!"
else
advisorMsg := "Alhamdulillah! 🎁 Rejeki jangan ditolak."
else if waspada
statusText := '💔 HATI-HATI!'
statusColor := color.orange
if rand == 0
advisorMsg := "Dia toxic... 🚩 Hati-hati SL."
else
advisorMsg := "Awas MC! 💀 pasang SL+ sayang."
else if pos == 1
statusText := '🧘 TAHAN Buy...'
statusColor := color.green
if rand == 0
advisorMsg := "Sabar sayang... 🧘♀️ Disayang Tuhan."
else if rand == 1
advisorMsg := "Biarkan lari! 🏃♂️ Profit is running."
else
advisorMsg := "Hold terus! 🚀 Sampai ke bulan!"
else if pos == -1
statusText := '🍿 TAHAN Sell...'
statusColor := color.red
if rand == 0
advisorMsg := "Nonton aja... 🍿 Sambil ngemil."
else
advisorMsg := "Jatuh kebawah sakit? 😂 disini malah Cuan."
else if blockReason != ''
statusText := "DIBLOKIR"
statusColor := color.gray
advisorMsg := "Sinyal busuk! ⛔ Jangan masuk."
else
statusText := '... '
statusColor := color.gray
if rand == 0
advisorMsg := "Market galau... 💤 Mending turu."
else if rand == 1
advisorMsg := "Datar banget... 😑 Kek jalan tol."
else if rand == 2
advisorMsg := "Jangan maksa! ☕ Ngopi dulu."
else
advisorMsg := "Sabar... 🕰️ Menunggu itu berat."
if adxValue > adxMinLevel and diPlus > diMinus
marketModeText := "📈 Tren Naik Kuat"
marketModeColor := color.new(color.green, 0)
else if adxValue > adxMinLevel and diMinus > diPlus
marketModeText := "📉 Tren Turun Kuat"
marketModeColor := color.new(color.red, 0)
else
marketModeText := "💤 Sideways / Chop"
marketModeColor := color.new(color.gray, 0)
f_fillCell(tbl, col, row, cellText, color) =>
table.cell(tbl, col, row, cellText, text_color=color, text_size=size.small)
f_drawDashboard() =>
f_fillCell(dashboardPanel, 0, 0, "Gaya:", color.gray)
f_fillCell(dashboardPanel, 1, 0, tradingStyle, color.white)
f_fillCell(dashboardPanel, 0, 1, "Status:", color.gray)
f_fillCell(dashboardPanel, 1, 1, statusText, statusColor)
bool dashboardContextIsBuy = pos == 1 or (pos == 0 and close > open)
string emaStatus = (dashboardContextIsBuy ? emaOkForBuy : emaOkForSell) or not _useEmaFilter ? "✅" : "❌"
string rsiStatus = (dashboardContextIsBuy ? rsiOkForBuy : rsiOkForSell) or not _useRsiFilter ? "✅" : "❌"
string adxStatus = (dashboardContextIsBuy ? adxOkForBuy : adxOkForSell) or not _useAdxFilter ? "✅" : "❌"
string snrStatus = (dashboardContextIsBuy ? snrOkForBuy : snrOkForSell) or not _useSnrFilter ? "✅" : "❌"
string confirmStatus = (dashboardContextIsBuy ? confirmOkForBuy : confirmOkForSell) or not useConfirmFilter ? "✅" : "❌"
string filterStr1 = "EMA" + emaStatus + " RSI" + rsiStatus
string filterStr2 = "ADX" + adxStatus + " SNR" + snrStatus + (useConfirmFilter ? " 1-Bar" + confirmStatus : "")
string filterString = filterStr1 + " " + filterStr2
f_fillCell(dashboardPanel, 0, 2, "Filter:", color.gray)
f_fillCell(dashboardPanel, 1, 2, filterString, color.white)
float body_m = math.abs(close - open)
float rangeC_m = high - low
float power_m = rangeC_m == 0 ? 0.0 : (body_m / rangeC_m) * 5
power_m := math.min(power_m, 5)
float confidence_m = rangeC_m == 0 ? 0.0 : math.round(math.abs((close - open) / (high - low)) * 100)
int powerInt_m = int(math.round(power_m))
powerInt_m := powerInt_m < 0 ? 0 : powerInt_m > 5 ? 5 : powerInt_m
string bars_m = str.repeat("█", powerInt_m) + str.repeat("░", 5 - powerInt_m)
string meterString = (close > open ? "🟢 " : "🔴 ") + bars_m + " " + str.tostring(confidence_m, "#") + "%"
f_fillCell(dashboardPanel, 0, 3, "Meter:", color.gray)
f_fillCell(dashboardPanel, 1, 3, meterString, (close > open ? color.green : color.red))
int totalTrades = tradeCount_wins + tradeCount_losses
f_fillCell(dashboardPanel, 0, 4, "Total Sinyal:", color.gray)
f_fillCell(dashboardPanel, 1, 4, str.tostring(totalTrades), color.white)
f_fillCell(dashboardPanel, 0, 5, "W / L:", color.gray)
f_fillCell(dashboardPanel, 1, 5, str.tostring(tradeCount_wins) + " / " + str.tostring(tradeCount_losses), color.white)
string winRateString = "N/A"
color winRateColor = color.gray
if totalTrades > 0
winRateString := str.tostring(tradeCount_wins / totalTrades * 100, '0.0') + "%"
winRateColor := tradeCount_wins > tradeCount_losses ? color.green : (tradeCount_losses > tradeCount_wins ? color.red : color.gray)
f_fillCell(dashboardPanel, 0, 6, "Win Rate:", color.gray)
f_fillCell(dashboardPanel, 1, 6, winRateString, winRateColor)
f_fillCell(dashboardPanel, 0, 7, "Pasar:", color.gray)
f_fillCell(dashboardPanel, 1, 7, marketModeText, marketModeColor)
table.merge_cells(dashboardPanel, 0, 8, 1, 8)
table.cell(dashboardPanel, 0, 8, advisorMsg, text_color=color.yellow, text_size=size.small, bgcolor=color.new(color.black, 50))
table.merge_cells(dashboardPanel, 0, 9, 1, 9)
table.cell(dashboardPanel, 0, 9, "HADYAN PREMIUM INDI 083174747475", text_color=color.new(#969087, 66), text_size=size.tiny)
if barstate.islast and showDashboard
f_drawDashboard()
else if barstate.islast
table.clear(dashboardPanel, 0, 0, 1, 9)
// ==============================================
// --- FLOATING BUBBLE LABEL (FIXED) ---
// ==============================================
var label advisorLabel = na
if barstate.islast
label.delete(advisorLabel)
if showAdvisorBubble
// Tentukan Warna Gelembung biar Cantik
color bubbleColor = color.new(color.gray, 20)
if buySignal or addBuySignal or pos == 1
bubbleColor := color.new(color.green, 20)
else if sellSignal or addSellSignal or pos == -1
bubbleColor := color.new(color.red, 20)
else if waspada or reversalCandleExit
bubbleColor := color.new(color.orange, 20)
// OPTIMIZED: Geser sedikit ke kanan (+2) agar tidak menutupi candle terakhir
advisorLabel := label.new(bar_index + 2, close, text=advisorMsg, color=bubbleColor, textcolor=color.white, style=label.style_label_left, yloc=yloc.price)
// ==============================================
// --- LOGIKA CANDLE METER PANEL ---
// ==============================================
if (showCandlePanel or showCandleArrows) and not showDashboard
float body_m = math.abs(close - open)
float rangeC_m = high - low
float power_m = rangeC_m == 0 ? 0.0 : (body_m / rangeC_m) * 5
power_m := math.min(power_m, 5)
float confidence_m = rangeC_m == 0 ? 0.0 : math.round(math.abs((close - open) / (high - low)) * 100)
string patternName_m = ""
string baseDir_m = close > open ? "BUY" : "SELL"
if isBullishEngulfing_m
patternName_m := "Bullish Engulfing"
baseDir_m := "BUY"
else if isBearishEngulfing_m
patternName_m := "Bearish Engulfing"
baseDir_m := "SELL"
else if isHammer_m
patternName_m := "Hammer"
baseDir_m := "BUY"
else if isInvertedHammer_m
patternName_m := "Inverted Hammer"
baseDir_m := "SELL"
else
patternName_m := "Normal Candle"
string trendConfirm_m = close > close and close > close ? "BUY" : close < close and close < close ? "SELL" : baseDir_m
finalDir_m := baseDir_m == trendConfirm_m ? baseDir_m : baseDir_m
if showCandlePanel
int powerInt_m = int(math.round(power_m))
powerInt_m := powerInt_m < 0 ? 0 : powerInt_m > 5 ? 5 : powerInt_m
string bars_m = str.repeat("█", powerInt_m) + str.repeat("░", 5 - powerInt_m)
string dirText_m = finalDir_m == "BUY" ? "🟢 BUY" : "🔴 SELL"
string confText_m = str.tostring(confidence_m, "#") + "% " + bars_m
table.cell(infoPanel_m, 0, 0, "Pattern", text_color=color.yellow)
table.cell(infoPanel_m, 1, 0, "Direction", text_color=color.yellow)
table.cell(infoPanel_m, 2, 0, "Confidence", text_color=color.yellow)
table.cell(infoPanel_m, 0, 1, patternName_m, text_color=color.white)
table.cell(infoPanel_m, 1, 1, dirText_m, text_color=color.white)
table.cell(infoPanel_m, 2, 1, confText_m, text_color=color.white)
else
table.clear(infoPanel_m, 0, 0, 2, 1)
else if not showDashboard
table.clear(infoPanel_m, 0, 0, 2, 1)
// ==============================================
// --- ALERT UPDATED (SINGLE ALERT SUPPORT) ---
// ==============================================
string alertMsg_all = ""
if buySignal
alertMsg_all := "🚀 BUY NEW! @ " + str.tostring(close) + " | SL: " + str.tostring(xATRTrailingStopAdj)
else if sellSignal
alertMsg_all := "📉 SELL NEW! @ " + str.tostring(close) + " | SL: " + str.tostring(xATRTrailingStopAdj)
else if addBuySignal
alertMsg_all := "➕ ADD BUY (Re-Entry) @ " + str.tostring(close)
else if addSellSignal
alertMsg_all := "➕ ADD SELL (Re-Entry) @ " + str.tostring(close)
else if reversalCandleExit
alertMsg_all := "⛔ EXIT NOW! Reversal Detected @ " + str.tostring(close)
else if profitMaxReached
alertMsg_all := "💰 TAKE PROFIT! Target Tercapai @ " + str.tostring(close)
else if reversalRiskDetected
alertMsg_all := "⚠️ WARNING REVERSAL! RSI Extreme @ " + str.tostring(close)
// Pemicu Alarm Utama (Hanya aktif jika ada pesan, cukup pasang 1 alarm "Any function call")
if alertMsg_all != ""
alert(alertMsg_all, alert.freq_once_per_bar_close)
// Backup: Manual Alerts (Jika user Premium mau pasang satu-satu)
alertcondition(buySignal, title=' Buy Signal', message='🚀 BUY NEW!')
alertcondition(sellSignal, title=' Sell Signal', message='📉 SELL NEW!')
alertcondition(addBuySignal, title=' Add Buy', message='🚀 ADD BUY')
alertcondition(addSellSignal, title=' Add Sell', message='📉 ADD SELL')
alertcondition(waspada, title=' Waspada', message='💔 WASPADA')
// ==============================================
// --- TP/SL MODE SWING (FIXED & OPTIMIZED) ---
// ==============================================
var line sl_line = na
var line tp1_line = na
var line tp2_line = na
var line tp3_line = na
var label sl_label = na
var label tp1_label = na
var label tp2_label = na
var label tp3_label = na
if tradingStyle == 'Swing Santai'
if buySignal
line.delete(sl_line)
line.delete(tp1_line)
line.delete(tp2_line)
line.delete(tp3_line)
label.delete(sl_label)
label.delete(tp1_label)
label.delete(tp2_label)
label.delete(tp3_label)
float sl = entryPrice - entryNloss
float tp1 = entryPrice + entryNloss
float tp2 = entryPrice + (2*entryNloss)
float tp3 = entryPrice + (3*entryNloss)
sl_line := line.new(bar_index, sl, bar_index + 10, sl, color=color.new(color.red, 20), style=line.style_dashed, width=2)
tp1_line := line.new(bar_index, tp1, bar_index + 10, tp1, color=color.new(color.green, 20), style=line.style_dashed, width=2)
tp2_line := line.new(bar_index, tp2, bar_index + 10, tp2, color=color.new(color.green, 20), style=line.style_dashed, width=2)
tp3_line := line.new(bar_index, tp3, bar_index + 10, tp3, color=color.new(color.green, 20), style=line.style_dashed, width=2)
sl_label := label.new(bar_index + 10, sl, "SL (Rugi)", color=color.red, style=label.style_label_left, textcolor=color.white)
tp1_label := label.new(bar_index + 10, tp1, "TP1 (1:1)", color=color.green, style=label.style_label_left, textcolor=color.white)
tp2_label := label.new(bar_index + 10, tp2, "TP2 (1:2)", color=color.green, style=label.style_label_left, textcolor=color.white)
tp3_label := label.new(bar_index + 10, tp3, "TP3 (1:3)", color=color.green, style=label.style_label_left, textcolor=color.white)
else if sellSignal
line.delete(sl_line)
line.delete(tp1_line)
line.delete(tp2_line)
line.delete(tp3_line)
label.delete(sl_label)
label.delete(tp1_label)
label.delete(tp2_label)
label.delete(tp3_label)
float sl = entryPrice + entryNloss
float tp1 = entryPrice - entryNloss
float tp2 = entryPrice - (2*entryNloss)
float tp3 = entryPrice - (3*entryNloss)
sl_line := line.new(bar_index, sl, bar_index + 10, sl, color=color.new(color.red, 20), style=line.style_dashed, width=2)
tp1_line := line.new(bar_index, tp1, bar_index + 10, tp1, color=color.new(color.green, 20), style=line.style_dashed, width=2)
tp2_line := line.new(bar_index, tp2, bar_index + 10, tp2, color=color.new(color.green, 20), style=line.style_dashed, width=2)
tp3_line := line.new(bar_index, tp3, bar_index + 10, tp3, color=color.new(color.green, 20), style=line.style_dashed, width=2)
sl_label := label.new(bar_index + 10, sl, "SL (Rugi)", color=color.red, style=label.style_label_left, textcolor=color.white)
tp1_label := label.new(bar_index + 10, tp1, "TP1 (1:1)", color=color.green, style=label.style_label_left, textcolor=color.white)
tp2_label := label.new(bar_index + 10, tp2, "TP2 (1:2)", color=color.green, style=label.style_label_left, textcolor=color.white)
tp3_label := label.new(bar_index + 10, tp3, "TP3 (1:3)", color=color.green, style=label.style_label_left, textcolor=color.white)
else if pos != 0 and not na(sl_line)
// Update existing lines (Lightweight)
line.set_x2(sl_line, bar_index + 10)
line.set_x2(tp1_line, bar_index + 10)
line.set_x2(tp2_line, bar_index + 10)
line.set_x2(tp3_line, bar_index + 10)
label.set_x(sl_label, bar_index + 10)
label.set_x(tp1_label, bar_index + 10)
label.set_x(tp2_label, bar_index + 10)
label.set_x(tp3_label, bar_index + 10)
else if pos == 0
line.delete(sl_line)
sl_line := na
line.delete(tp1_line)
tp1_line := na
line.delete(tp2_line)
tp2_line := na
line.delete(tp3_line)
tp3_line := na
label.delete(sl_label)
sl_label := na
label.delete(tp1_label)
tp1_label := na
label.delete(tp2_label)
tp2_label := na
label.delete(tp3_label)
tp3_label := na
else
line.delete(sl_line)
sl_line := na
line.delete(tp1_line)
tp1_line := na
line.delete(tp2_line)
tp2_line := na
line.delete(tp3_line)
tp3_line := na
label.delete(sl_label)
sl_label := na
label.delete(tp1_label)
tp1_label := na
label.delete(tp2_label)
tp2_label := na
label.delete(tp3_label)
tp3_label := na
// ==============================================
// --- UPGRADE BARU: PIVOT POINTS (FIXED: EXTEND RIGHT) ---
// ==============================================
// Dapatkan Daily High, Low, Close (FIX "D")
p_d_h = request.security(syminfo.tickerid, "D", high , lookahead=barmerge.lookahead_on)
p_d_l = request.security(syminfo.tickerid, "D", low , lookahead=barmerge.lookahead_on)
p_d_c = request.security(syminfo.tickerid, "D", close , lookahead=barmerge.lookahead_on)
// Perhitungan Pivot Klasik
pivot_d = (p_d_h + p_d_l + p_d_c) / 3
r1_d = 2 * pivot_d - p_d_l
s1_d = 2 * pivot_d - p_d_h
r2_d = pivot_d + (p_d_h - p_d_l)
s2_d = pivot_d - (p_d_h - p_d_l)
// Visualisasi Pivot
var line p_line = na
var line r1_line = na
var line s1_line = na
var line r2_line = na
var line s2_line = na
var label p_label = na
var label r1_label = na
var label s1_label = na
var label r2_label = na
var label s2_label = na
// Fungsi untuk menghapus label/line
f_delete_pivot_objects() =>
line.delete(p_line)
line.delete(r1_line)
line.delete(s1_line)
line.delete(r2_line)
line.delete(s2_line)
label.delete(p_label)
label.delete(r1_label)
label.delete(s1_label)
label.delete(r2_label)
label.delete(s2_label)
if showPivotPoints
// Hapus yang lama agar tidak numpuk (Redraw Logic)
f_delete_pivot_objects()
// Logic: EXTEND RIGHT (Memanjang)
// Kita gunakan extend.right agar garisnya tidak pernah putus ke kanan
// Pivot (P)
p_line := line.new(bar_index, pivot_d, bar_index + 1, pivot_d, xloc.bar_index, extend.right, pivotColor, line.style_solid, 2)
p_label := label.new(bar_index + 10, pivot_d, "P Daily: " + str.tostring(pivot_d, format.mintick), xloc.bar_index, yloc.price, color=color.new(pivotColor, 20), textcolor=color.white, style=label.style_label_left, size=size.small)
// Resistance
r1_line := line.new(bar_index, r1_d, bar_index + 1, r1_d, xloc.bar_index, extend.right, color.new(color.red, 30), line.style_dashed, 1)
r1_label := label.new(bar_index + 10, r1_d, "R1: " + str.tostring(r1_d, format.mintick), xloc.bar_index, yloc.price, color=color.new(color.red, 80), textcolor=color.red, style=label.style_label_left, size=size.small)
r2_line := line.new(bar_index, r2_d, bar_index + 1, r2_d, xloc.bar_index, extend.right, color.new(color.red, 30), line.style_dashed, 1)
r2_label := label.new(bar_index + 10, r2_d, "R2: " + str.tostring(r2_d, format.mintick), xloc.bar_index, yloc.price, color=color.new(color.red, 80), textcolor=color.red, style=label.style_label_left, size=size.small)
// Support
s1_line := line.new(bar_index, s1_d, bar_index + 1, s1_d, xloc.bar_index, extend.right, color.new(color.green, 30), line.style_dashed, 1)
s1_label := label.new(bar_index + 10, s1_d, "S1: " + str.tostring(s1_d, format.mintick), xloc.bar_index, yloc.price, color=color.new(color.green, 80), textcolor=color.green, style=label.style_label_left, size=size.small)
s2_line := line.new(bar_index, s2_d, bar_index + 1, s2_d, xloc.bar_index, extend.right, color.new(color.green, 30), line.style_dashed, 1)
s2_label := label.new(bar_index + 10, s2_d, "S2: " + str.tostring(s2_d, format.mintick), xloc.bar_index, yloc.price, color=color.new(color.green, 80), textcolor=color.green, style=label.style_label_left, size=size.small)
else
f_delete_pivot_objects()
// ==============================================
// --- UPGRADE BARU: FIBONACCI RETRACEMENT (CLEAN NO STACK) ---
// ==============================================
var float fiboHigh = na
var float fiboLow = na
var int fiboStartBar = na
// Array untuk menyimpan objek Fibo
var line fiboLines = array.new(0)
var linefill fiboFills = array.new(0)
var label fiboLabels = array.new(0)
// Helper Function: Clean Up All Fibo Objects
f_cleanFibo() =>
if array.size(fiboLines) > 0
for i = 0 to array.size(fiboLines) - 1
line.delete(array.get(fiboLines, i))
array.clear(fiboLines)
if array.size(fiboFills) > 0
for i = 0 to array.size(fiboFills) - 1
linefill.delete(array.get(fiboFills, i))
array.clear(fiboFills)
if array.size(fiboLabels) > 0
for i = 0 to array.size(fiboLabels) - 1
label.delete(array.get(fiboLabels, i))
array.clear(fiboLabels)
// Calculate historical values globally
float lastHigh_scanned = ta.valuewhen(not na(pivotHigh), pivotHigh, 0)
float lastLow_scanned = ta.valuewhen(not na(pivotLow), pivotLow, 0)
// Reset Fibo jika ada sinyal entry baru
if buySignal or sellSignal
f_cleanFibo() // Clean old ones first!
// Gunakan nilai yang sudah di-scan secara global
if not na(lastHigh_scanned) and not na(lastLow_scanned)
fiboLow := lastLow_scanned
fiboHigh := lastHigh_scanned
fiboStartBar := bar_index
// Levels
fiboLevels = array.new(0)
array.push(fiboLevels, 0.0)
array.push(fiboLevels, 0.236)
array.push(fiboLevels, 0.382)
array.push(fiboLevels, 0.5)
array.push(fiboLevels, 0.618)
array.push(fiboLevels, 1.0)
// Gambar Fibo (Hanya digambar ulang jika posisi valid dan belum ada)
// Kita gunakan trik: Gambar setiap bar, tapi HAPUS yang lama dulu.
// Ini mencegah stacking ribuan kotak.
if showFiboLevels and not na(fiboHigh) and not na(fiboLow)
f_cleanFibo() // CLEANUP WAJIB SEBELUM GAMBAR BARU
float fiboRange = fiboHigh - fiboLow
int f_start = bar_index + fiboXOffset
int f_end = bar_index + fiboXOffset + 15
var line lastLineObj = na
for i = 0 to array.size(fiboLevels) - 1
float level = array.get(fiboLevels, i)
float fiboPrice = fiboHigh - (fiboRange * level)
string levelText = str.tostring(math.round(level * 100), "0.0") + "%"
color levelColor = color.rgb(19, 56, 189)
if level == 0.618
levelColor := color.new(#FFD700, 30)
else if level == 0.5
levelColor := color.new(color.green, 30)
else
levelColor := color.new(#7925c9, 70)
string l_style = (level == 0.0 or level == 1.0) ? line.style_dashed : line.style_solid
int l_width = (level == 0.618 or level == 0.5) ? 2 : 1
// Draw & Push Line
line currentLineObj = line.new(f_start, fiboPrice, f_end, fiboPrice, xloc.bar_index, extend.none, levelColor, l_style, l_width)
array.push(fiboLines, currentLineObj)
// Fill Logic
color c_fill = switch level
0.236 => color.new(color.gray, 70) // Sangat transparan (95)
0.382 => color.new(color.blue, 70)
0.5 => color.new(color.green, 70)
0.618 => color.new(#FFD700, 70)
1.0 => color.new(color.red, 70)
=> na
if i > 0
linefill lf = linefill.new(lastLineObj, currentLineObj, c_fill)
array.push(fiboFills, lf)
lastLineObj := currentLineObj
// Draw & Push Label
label lb = label.new(f_end, fiboPrice, levelText, xloc.bar_index, yloc.price, color=color.new(levelColor, 100), textcolor=levelColor, style=label.style_label_left, size=size.small)
array.push(fiboLabels, lb)
// ==============================================
// --- UPGRADE BARU: STOCHASTIC FLOATING MINI CHART (REALTIME ANCHOR RIGHT PATCH) ---
// ==============================================
// 1. Calculations
stochK = ta.sma(ta.stoch(close, high, low, 14), 3)
stochD = ta.sma(stochK, 3)
// 2. Data Storage (Arrays for History)
var float stochK_hist = array.new_float(0)
var float stochD_hist = array.new_float(0)
// Update Arrays (REALTIME LOGIC)
if barstate.isnew
array.push(stochK_hist, nz(stochK, 50))
array.push(stochD_hist, nz(stochD, 50))
// Limit array size to chart width + 1
if array.size(stochK_hist) > (stochWidth + 1)
array.shift(stochK_hist)
array.shift(stochD_hist)
else
// UPDATE TICK-BY-TICK (Agar tidak delay)
if array.size(stochK_hist) > 0
array.set(stochK_hist, array.size(stochK_hist) - 1, nz(stochK, 50))
array.set(stochD_hist, array.size(stochD_hist) - 1, nz(stochD, 50))
// 3. Drawing Logic
var box stochBgBox = na
var box stochUpperFill = na
var box stochLowerFill = na
var line stochLines = array.new_line(0)
// Clear Function
f_cleanStochChart() =>
if not na(stochBgBox)
box.delete(stochBgBox)
if not na(stochUpperFill)
box.delete(stochUpperFill)
if not na(stochLowerFill)
box.delete(stochLowerFill)
if array.size(stochLines) > 0
for i = 0 to array.size(stochLines) - 1
line.delete(array.get(stochLines, i))
array.clear(stochLines)
// Global Helper to map 0-100 Stoch value to Y price coordinate
f_mapY(_val, _bottom, _height) =>
_bottom + (_val / 100 * _height)
if showStochChart and array.size(stochK_hist) > 2
f_cleanStochChart() // Redraw every tick
// Positioning (ANCHOR RIGHT LOGIC)
int offset_right = 5
int ch_right = bar_index + offset_right // Ujung kanan box
int ch_left = ch_right - stochWidth
// Vertical Scaling
float ch_height = ta.atr(14) * 4
float ch_bottom = close - (ch_height * 1.5)
float ch_top = ch_bottom + ch_height
// Draw Background
stochBgBox := box.new(ch_left, ch_top, ch_right, ch_bottom, xloc=xloc.bar_index, border_width=1, border_color=color.new(color.white, 80), bgcolor=color.new(color.black, 100))
// Draw Overbought Fill (80-100)
stochUpperFill := box.new(ch_left, f_mapY(70, ch_bottom, ch_height), ch_right, f_mapY(80, ch_bottom, ch_height), xloc=xloc.bar_index, border_width=0, bgcolor=color.new(color.red, 100))
// Draw Oversold Fill (0-20)
stochLowerFill := box.new(ch_left, f_mapY(10, ch_bottom, ch_height), ch_right, f_mapY(0, ch_bottom, ch_height), xloc=xloc.bar_index, border_width=0, bgcolor=color.new(color.green, 100))
// Draw Reference Lines
line l80 = line.new(ch_left, f_mapY(80, ch_bottom, ch_height), ch_right, f_mapY(80, ch_bottom, ch_height), color=color.new(color.red, 20), style=line.style_dotted)
line l20 = line.new(ch_left, f_mapY(20, ch_bottom, ch_height), ch_right, f_mapY(20, ch_bottom, ch_height), color=color.new(color.green, 20), style=line.style_dotted)
array.push(stochLines, l80)
array.push(stochLines, l20)
// Draw K and D Lines (ANCHOR TO REALTIME BAR INDEX)
// PATCH: Iterate relative to current bar_index to ensure 0 gap
int sz = array.size(stochK_hist)
for i = 0 to sz - 2
// Logika Mundur: Titik terakhir (sz-1) harus ada di bar_index saat ini
int idx_current = sz - 1 - i
int idx_prev = sz - 2 - i
if idx_prev >= 0
// X Coordinates (Relative to Realtime Bar)
int x2 = bar_index - i
int x1 = bar_index - (i + 1)
// K Line
float yK1 = f_mapY(array.get(stochK_hist, idx_prev), ch_bottom, ch_height)
float yK2 = f_mapY(array.get(stochK_hist, idx_current), ch_bottom, ch_height)
if not na(yK1) and not na(yK2)
line lK = line.new(x1, yK1, x2, yK2, color=color.new(#05492f, 0), width=1)
array.push(stochLines, lK)
// D Line
float yD1 = f_mapY(array.get(stochD_hist, idx_prev), ch_bottom, ch_height)
float yD2 = f_mapY(array.get(stochD_hist, idx_current), ch_bottom, ch_height)
if not na(yD1) and not na(yD2)
line lD = line.new(x1, yD1, x2, yD2, color=color.new(#810404, 0), width=1)
array.push(stochLines, lD)
// ==============================================
// --- VISUALISASI UPGRADE: SMART SUPPLY/DEMAND ZONES ---
// ==============================================
ph_zone = ta.pivothigh(high, zoneLookback, zoneLookback)
pl_zone = ta.pivotlow(low, zoneLookback, zoneLookback)
// FIX: Pindahkan ATR ke luar IF agar konsisten
float atrForZone = ta.atr(14)
var box supplyBoxes = array.new_box()
var box demandBoxes = array.new_box()
// Batasi jumlah zona agar chart tetap bersih
maxZones = 5
// Deteksi Zona Supply (Merah)
if not na(ph_zone) and showSmartZones
// Buat box baru dari titik pivot sampai ke masa depan sedikit
b_sup = box.new(bar_index , high , bar_index + 20, high - (atrForZone*0.5), bgcolor=color.new(color.red, 85), border_color=color.new(color.red, 50))
array.push(supplyBoxes, b_sup)
if array.size(supplyBoxes) > maxZones
box.delete(array.shift(supplyBoxes))
// Deteksi Zona Demand (Hijau)
if not na(pl_zone) and showSmartZones
b_dem = box.new(bar_index , low , bar_index + 20, low + (atrForZone*0.5), bgcolor=color.new(color.lime, 85), border_color=color.new(color.lime, 50))
array.push(demandBoxes, b_dem)
if array.size(demandBoxes) > maxZones
box.delete(array.shift(demandBoxes))
// Perpanjang Zona Secara Realtime
if array.size(supplyBoxes) > 0 and showSmartZones
for i = 0 to array.size(supplyBoxes) - 1
b = array.get(supplyBoxes, i)
// Perpanjang ke bar saat ini + 5 agar terlihat "hidup"
box.set_right(b, bar_index + 5)
if array.size(demandBoxes) > 0 and showSmartZones
for i = 0 to array.size(demandBoxes) - 1
b = array.get(demandBoxes, i)
// Perpanjang ke bar saat ini + 5 agar terlihat "hidup"
box.set_right(b, bar_index + 5)
// ====================================================================================================
// BAGIAN 2: FITUR TAMBAHAN (HSN GHOST CANDLES) - DI-INJECT DI SINI
// ====================================================================================================
// --- TIPE DATA KHUSUS (HSN) ---
type CandleHSN
float o
float c
float h
float l
int o_idx
int c_idx
int h_idx
int l_idx
box body
line wick_up
line wick_down
type ImbalanceHSN
box b
int idx
type CandleSettingsHSN
bool show
string htf
int max_display
type SettingsHSN
int max_sets
color bull_body
color bull_border
color bull_wick
color bear_body
color bear_border
color bear_wick
int offset
int buffer
int htf_buffer
int width
bool trace_show
string trace_anchor
bool label_show
color label_color
string label_size
bool htf_label_show
color htf_label_color
string htf_label_size
bool htf_timer_show
color htf_timer_color
string htf_timer_size
type CandleSetHSN
CandleHSN candles
ImbalanceHSN imbalances
CandleSettingsHSN settings
label tfName
label tfTimer
type HelperHSN
string name = "Helper"
// --- SETUP PENGATURAN HSN ---
SettingsHSN settings = SettingsHSN.new()
var CandleSettingsHSN SettingsHTF1 = CandleSettingsHSN.new()
var CandleSettingsHSN SettingsHTF2 = CandleSettingsHSN.new()
var CandleHSN candles_1 = array.new(0)
var CandleHSN candles_2 = array.new(0)
var CandleSetHSN htf1 = CandleSetHSN.new()
htf1.settings := SettingsHTF1
htf1.candles := candles_1
var CandleSetHSN htf2 = CandleSetHSN.new()
htf2.settings := SettingsHTF2
htf2.candles := candles_2
// --- INPUT KHUSUS HSN CANDLES (15 & 30 MENIT) ---
grp_hsn = "🔥 HSN HTF Candles (Upgrade)"
htf1.settings.show := input.bool(true, "Show HTF 1 (15 Menit)", group=grp_hsn, inline="h1")
htf_1 = input.timeframe("15", "", group=grp_hsn, inline="h1")
htf1.settings.htf := htf_1
htf1.settings.max_display := 4
htf2.settings.show := input.bool(true, "Show HTF 2 (30 Menit)", group=grp_hsn, inline="h2")
htf_2 = input.timeframe("30", "", group=grp_hsn, inline="h2")
htf2.settings.htf := htf_2
htf2.settings.max_display := 4
settings.max_sets := 2
settings.bull_body := color.new(color.green, 60)
settings.bear_body := color.new(color.red, 60)
settings.bull_border := color.new(color.green, 10)
settings.bear_border := color.new(color.red, 10)
settings.bull_wick := color.new(color.green, 10)
settings.bear_wick := color.new(color.red, 10)
// FIXED: Increased default offset from 10 to 25 to avoid overlap with Advisor Bubble
settings.offset := input.int(25, "Padding/Jarak Candle", group=grp_hsn)
settings.buffer := 1
settings.htf_buffer := 5
settings.width := input.int(1, "Lebar Candle", minval = 1, maxval = 4, group=grp_hsn)*2
settings.htf_label_show := true
settings.htf_label_color := color.gray
settings.htf_label_size := size.normal
// --- HELPER FUNCTIONS ---
HelperHSN helper = HelperHSN.new()
color color_transparent = #ffffff00
method ValidTimeframe(HelperHSN helper, string HTF) =>
helper.name := HTF
if timeframe.in_seconds(HTF) >= timeframe.in_seconds("D") and timeframe.in_seconds(HTF) > timeframe.in_seconds()
true
else
n1 = timeframe.in_seconds()
n2 = timeframe.in_seconds(HTF)
n3 = n1 % n2
(n1 < n2 and math.round(n2/n1) == n2/n1)
method HTFName(HelperHSN helper, string HTF) =>
helper.name := "HTFName"
formatted = HTF
seconds = timeframe.in_seconds(HTF)
if seconds < 60
formatted := str.tostring(seconds) + "s"
else if (seconds / 60) < 60
formatted := str.tostring((seconds/60)) + "m"
else if (seconds/60/60) < 24
formatted := str.tostring((seconds/60/60)) + "H"
formatted
method HTFEnabled(HelperHSN helper) =>
helper.name := "HTFEnabled"
int enabled =0
enabled += htf1.settings.show ? 1 : 0
enabled += htf2.settings.show ? 1 : 0
int last = math.min(enabled, settings.max_sets)
last
method CandleSetHigh(HelperHSN helper, CandleHSN candles, float h) =>
helper.name := "CandlesSetHigh"
float _h = h
if array.size(candles) > 0
for i = 0 to array.size(candles)-1
// FIX: Diganti dari c menjadi cItem
CandleHSN cItem = array.get(candles, i)
if cItem.h > _h
_h := cItem.h
_h
method CandlesHigh(HelperHSN helper, CandleHSN candles) =>
helper.name := "CandlesHigh"
h = 0.0
int cnt = 0
int last = helper.HTFEnabled()
if htf1.settings.show and helper.ValidTimeframe(htf1.settings.htf)
h := helper.CandleSetHigh(htf1.candles, h)
cnt += 1
if htf2.settings.show and helper.ValidTimeframe(htf2.settings.htf) and cnt < last
h := helper.CandleSetHigh(htf2.candles, h)
cnt +=1
if array.size(candles) > 0
for i = 0 to array.size(candles)-1
// FIX: Diganti dari c menjadi cItem
CandleHSN cItem = array.get(candles, i)
if cItem.h > h
h := cItem.h
h
method Reorder(CandleSetHSN candleSet, int offset) =>
size = candleSet.candles.size()
if size > 0
for i = size-1 to 0
CandleHSN candle = candleSet.candles.get(i)
t_buffer = offset + ((settings.width+settings.buffer)*(size-i-1))
box.set_left(candle.body, bar_index + t_buffer)
box.set_right(candle.body, bar_index + settings.width + t_buffer)
line.set_x1(candle.wick_up, bar_index+((settings.width)/2) + t_buffer)
line.set_x2(candle.wick_up, bar_index+((settings.width)/2) + t_buffer)
line.set_x1(candle.wick_down, bar_index+((settings.width)/2) + t_buffer)
line.set_x2(candle.wick_down, bar_index+((settings.width)/2) + t_buffer)
top = helper.CandlesHigh(candleSet.candles)
left = bar_index + offset + ((settings.width+settings.buffer)*(size-1))/2
if settings.htf_label_show
var label l = candleSet.tfName
string lbl = helper.HTFName(candleSet.settings.htf)
if not na(l)
label.set_xy(l, left, top)
else
l := label.new(left, top, lbl, color=color_transparent, textcolor = settings.htf_label_color, style=label.style_label_down, size = settings.htf_label_size)
candleSet
method Monitor(CandleSetHSN candleSet) =>
HTFBarTime = time(candleSet.settings.htf)
isNewHTFCandle = ta.change(HTFBarTime)
if isNewHTFCandle
CandleHSN candle = CandleHSN.new()
candle.o := open
candle.c := close
candle.h := high
candle.l := low
candle.o_idx := bar_index
candle.c_idx := bar_index
candle.h_idx := bar_index
candle.l_idx := bar_index
bull = candle.c > candle.o
candle.body := box.new(bar_index, math.max(candle.o, candle.c), bar_index+2, math.min(candle.o, candle.c), bull ? settings.bull_border : settings.bear_border, 1, bgcolor = bull ? settings.bull_body : settings.bear_body)
candle.wick_up := line.new(bar_index+1, candle.h, bar_index, math.max(candle.o, candle.c), color=bull ? settings.bull_wick : settings.bear_wick)
candle.wick_down := line.new(bar_index+1, math.min(candle.o, candle.c), bar_index, candle.l, color=bull ? settings.bull_wick : settings.bear_wick)
candleSet.candles.unshift(candle)
if candleSet.candles.size() > candleSet.settings.max_display
CandleHSN delCandle = array.pop(candleSet.candles)
box.delete(delCandle.body)
line.delete(delCandle.wick_up)
line.delete(delCandle.wick_down)
candleSet
method Update(CandleSetHSN candleSet, int offset) =>
if candleSet.candles.size() > 0
CandleHSN candle = candleSet.candles.first()
candle.h_idx := high > candle.h ? bar_index : candle.h_idx
candle.h := high > candle.h ? high : candle.h
candle.l_idx := low < candle.l ? bar_index : candle.l_idx
candle.l := low < candle.l ? low : candle.l
candle.c := close
candle.c_idx := bar_index
bull = candle.c > candle.o
box.set_top(candle.body, bull ? candle.c : candle.o)
box.set_bottom(candle.body, bull ? candle.o : candle.c)
box.set_bgcolor(candle.body, bull ? settings.bull_body : settings.bear_body)
box.set_border_color(candle.body, bull ? settings.bull_border : settings.bear_border)
line.set_color(candle.wick_up, bull ? settings.bull_wick : settings.bear_wick)
line.set_color(candle.wick_down, bull ? settings.bull_wick : settings.bear_wick)
line.set_y1(candle.wick_up, candle.h)
line.set_y2(candle.wick_up, math.max(candle.o, candle.c))
line.set_y1(candle.wick_down, candle.l)
line.set_y2(candle.wick_down, math.min(candle.o, candle.c))
if barstate.isrealtime or barstate.islast
candleSet.Reorder(offset)
candleSet
// --- EKSEKUSI HSN LOGIC ---
int cnt_hsn = 0
int last_hsn = helper.HTFEnabled()
int offset_hsn = settings.offset
if htf1.settings.show and helper.ValidTimeframe(htf1.settings.htf)
htf1.Monitor().Update(offset_hsn)
cnt_hsn +=1
offset_hsn += cnt_hsn > 0 ? (htf1.candles.size() * settings.width) + (htf1.candles.size() > 0 ? htf1.candles.size()-1 * settings.buffer : 0) + settings.htf_buffer : 0
if htf2.settings.show and helper.ValidTimeframe(htf2.settings.htf) and cnt_hsn < last_hsn
htf2.Monitor().Update(offset_hsn)
cnt_hsn+=1
offset_hsn += cnt_hsn > 0 ? (htf2.candles.size() * settings.width) + (htf2.candles.size() > 0 ? htf2.candles.size()-1 * settings.buffer : 0) + settings.htf_buffer : 0
Session Range Boxes(MTF)📦 Indicator Name
Session Range Boxes (MTF)
Multi-Timeframe Directional Session Range Visualization
📘 Description
Session Range Boxes (MTF) is a multi-timeframe market structure tool that visually highlights price range behavior across different time sessions using clean, directional range boxes.
Each box represents the High–Low range of a completed or live session, automatically colored based on directional bias:
🟢 Bullish → Session Close > Session Open
🔴 Bearish → Session Close < Session Open
⚪ Neutral → Session Close = Session Open
This allows traders to instantly identify trend strength, balance zones, volatility expansion, and key support/resistance areas across multiple timeframes — all on a single chart.
🔍 What This Indicator Shows
For every enabled timeframe, the indicator:
Draws a range box from session open to session close
Continuously updates live session High & Low
Locks the final color once the session completes
Keeps historical boxes for structure and context
Supported timeframes:
Quarterly
Half-Yearly
Yearly
Monthly
Weekly
Daily
Hourly
30-Minute
15-Minute
5-Minute
⚙️ Default Behavior
By default, the indicator enables:
Weekly
Daily
Hourly
This default setup is intentionally chosen to suit most traders and provides:
Higher-timeframe structure (Weekly)
Swing context (Daily)
Intraday execution levels (Hourly)
🧠 How to Use It Effectively
📈 Higher-Timeframe Analysis (Swing / Positional Trading)
Recommended combinations:
Weekly + Daily
Monthly + Weekly
Use cases:
Identify dominant market bias
Spot compression vs expansion
Define higher-timeframe support & resistance zones
⚡ Intraday Trading (Day Trading)
Recommended combinations:
Daily + Hourly
Hourly + 30-Minute
Use cases:
Track intraday range development
Identify directional day types
Trade breakouts, rejections, or mean-reversion within session ranges
🚀 Scalping & Precision Entries
Recommended combinations:
Hourly + 15-Minute
30-Minute + 5-Minute
Use cases:
Fine-tune entries within larger session ranges
Align lower-timeframe trades with higher-timeframe bias
Spot micro range expansion and contraction
🎨 Customization Options
Bullish / Bearish / Neutral colors
Box fill transparency
Border transparency & color
Maximum historical boxes per timeframe
This allows you to keep charts clean, lightweight, and performance-friendly.
💡 Best Practices
Avoid enabling too many timeframes at once — clarity beats clutter
Use higher-timeframe boxes for bias, lower-timeframe boxes for entries
Combine with:
Market structure
Volume
VWAP
Liquidity concepts
Price action confirmation
Session Range Boxes (MTF) is a clean, powerful visual tool designed to help traders:
Understand session-based price behavior
Align trades across timeframes
Improve structure awareness without clutter
Whether you are a scalper, day trader, or swing trader, this indicator adapts seamlessly to your workflow.
Al Sat Alpha Hunter System [MTF + Risk Manager]çok güzel yerlerden al sat komutu çıkıyor ve bunu size ücretsiz vermek istedim sizde faydalanın
StO Price Action - Luminous Daily RoadmapShort Summary
- Luminous Daily Roadmap (LDR) are special trading days
- Marks entire trading days using background coloring
- Creates a clear daily roadmap directly on the chart
- Designed to stay minimal and non-intrusive
Full Description
Overview
- LDR is a proprietary forex trading schedule
- Dates of major trend reversals or significant market continuations
- Highlights full trading days using background colors
- Improves visual structure and day-to-day orientation
- Focuses purely on time segmentation, not price signals
- Suitable for all markets and timeframes
Daily Marking Logic
- Each trading day is visually marked across all its bars
- Background coloring spans the full session of the day
- Works consistently across intraday and higher timeframes
Year Look Back (YLB)
- YLB defines the starting year for day marking
- Markings are only applied from the selected year onward
- Allows focused analysis on recent or specific years
Visualization
- Background color is fully customizable
- Uses high transparency to avoid hiding price action
Usage
- Useful for session-based and daily analysis
- Supports routine-based trading and journaling
- Enhances visual rhythm of the chart
Notes
- This indicator is purely visual and non-predictive
- No alerts or signals are generated
- Best used as a structural overlay for orientation
- Can be combined with any price action or indicator-based workflow
ICT Power of 3 identify the high-probability Power of 3 pattern by analyzing price behavior rather than just specific times of day. It focuses on how the market builds, traps, and then expands.
1. Accumulation (The Setup)
Logic: The script monitors volatility using the Average True Range (ATR). When volatility drops below its recent average, the script recognizes that orders are being "accumulated."
Visual: A Blue Dotted Box appears. This marks the equilibrium zone where buy and sell side liquidity is being engineered above and below the high/low of the range.
2. Manipulation (The Trap)
Logic: The script looks for a "Sweep." This is defined as price moving outside the blue accumulation box but failing to sustain that move. In the video, this is the "Judas Swing" or false breakout.
Visual: A Red Diamond appears above or below the bar. This signals that the script has detected a liquidity grab—essentially, the market has "tricked" breakout traders into the wrong side of the market.
3. Distribution (The Expansion)
Logic: This is identified through Displacement. The script calculates the average candle body size. When a candle appears that is significantly larger (based on your Displacement Multiplier), it confirms that "Smart Money" has entered the market.
Visual: A Green Triangle appears. This marks the start of the distribution phase, which is the "meat" of the move where you want to be positioned.
Renko Top 2 Picker### **1s Renko Momentum Scanner (HMA Zero-Lag Edition)**
This custom TradingView indicator is engineered specifically for high-frequency Renko traders. It solves the critical problem of identifying which major currency pair has the liquidity and directional inertia to sustain a fixed-brick Renko trend on a 1-second chart.
Because TradingView cannot screen 1-second data directly, this script acts as a "bridge," analyzing 1-minute and 5-minute flow metrics to probability-score the likely performance of a 1-second chart.
---
### **Core Logic & Assumptions**
1. **The "Engine" (HMA 300):**
* **Logic:** The script uses a Hull Moving Average (HMA) with a length of 300 to smooth the scoring output.
* **Why:** On a 1-second chart, 300 bars equals 5 minutes of data. The HMA provides a "Zero-Lag" response, reacting instantly to new breakouts while ignoring the split-second noise that causes standard scanners to flicker.
2. **The "Minute Reset" Solution:**
* **Problem:** Standard scripts fail on 1s charts because metrics like "Current Volume" reset to zero at the start of every new minute (e.g., at 10:05:00), causing signals to crash.
* **Solution:** This script calculates momentum using a "Rolling Window" anchored to the *previous* minute's close and volume. This ensures the signal remains stable and tradable across the :59 to :00 second boundary.
3. **Renko-Specific Scoring:**
* **Displacement > Direction:** The script prioritizes *how far* price is moving (Displacement %) over simple direction. Renko bricks require physical distance to form; without displacement, you pay spread costs for a flat chart.
* **Liquidity Gating:** It ignores pairs with low relative volume. A 1-second Renko chart requires high institutional flow to form clean bricks without gapping.
---
### **Indicator Inputs**
* **Refresh Display (Seconds):**
* *Default: 5*
* Controls how often the text on your screen updates. Set this to 5 or 10 seconds to prevent the text from "dancing," allowing you to read the recommendation clearly.
* **Score Smoothing (HMA):**
* *Default: 300*
* The "Memory" of the scanner.
* **300:** Represents a 5-minute lookback. Recommended for most 1s scalping to identify established trends.
* **120:** Represents a 2-minute lookback. Use this only if you want to catch breakouts aggressively and accept more false signals.
* **Table Position:**
* *Default: Bottom Right*
* Choose where the scanner panel appears on your chart to avoid covering your Renko price action.
* **Major Pairs:**
* *Defaults: EURUSD, GBPUSD, USDJPY, USDCHF, AUDUSD, USDCAD, NZDUSD*
* These fields are pre-filled with the standard "FX:" prefix. **Crucial:** If your broker uses suffixes (e.g., "EURUSD.pro" or "EURUSDm"), you must update these inputs to match your broker's specific symbol format, or the scanner will return "N/A".
---
### **How to Interpret the Output**
The panel displays a **Primary** and **Secondary** recommendation.
* **Green Background:** The pair has a "Strong" score (> 4.0). This indicates high probability conditions for 1s Renko trend following.
* **Gray Background:** The pair is the "best of the bunch," but overall market momentum is weak. Exercise caution, as the 1s chart may be choppy.
ICT Silver Bullet BoxesOverview
This Pine Script v6 indicator is a streamlined tool designed for ICT (Inner Circle Trader) students, specifically optimized for traders in the Dhaka (GMT+6) time zone. It automates the drawing of high-probability liquidity zones based on the Asian Range and the Silver Bullet algorithm windows.
Unlike standard session highlights, this script focuses on the price action boundaries (Highs and Lows) within these specific windows to help you identify liquidity pools and potential "Judas Swing" targets.
Key Features
Asian Range (Liquidity Phase): Automatically marks the high and low of the 7:00 PM – 12:00 AM NY window (6:00 AM – 11:00 AM Dhaka). This box represents the day's initial consolidation where buy-side and sell-side liquidity is engineered.
Silver Bullet Windows: Highlights the two most critical 60-minute windows:
London Silver Bullet: 3:00 AM – 4:00 AM NY (2:00 PM – 3:00 PM Dhaka)
NY AM Silver Bullet: 10:00 AM – 11:00 AM NY (9:00 PM – 10:00 PM Dhaka)
Automatic DST Adjustment: The script uses the America/New_York timezone internally. This means the boxes will automatically shift correctly when New York enters Daylight Saving Time, keeping your Dhaka chart accurate year-round.
Clean Visuals: Instead of coloring the entire background, the script draws precise boxes around the price action High/Low of each session for a clutter-free experience.
How to Use
Mark Liquidity: Use the Asian Range Box to identify where the "stops" are resting.
Anticipate the Sweep: During the London or NY Open, look for price to raid the Asian High or Low.
Execute the Bullet: Within the Silver Bullet boxes, look for a Market Structure Shift (MSS) and a Fair Value Gap (FVG) for your entry.
Settings
Custom Colors: Fully customizable colors and opacity for both London and New York sessions.
Borders: Toggle borders on/off to match your chart theme.
T-Theory - by: Terry LaundryThis script is brought to you, via inspiration by trader Marty Schwarz. His book titled Pit Bull is widely available - for free on PDF. He credits Terry Laundry with the T-Theory, also available for free on look-up.
Here is a description provided on Gemini AI. T-Theory, developed by Terry Laundry, is a technical analysis methodology based on the principle of Time Symmetry. It posits that the market spends an equal amount of time building up energy (the "Magic T") as it does releasing that energy in a trending move.
Here is an objective summary of its core mechanics:
1. The Principle of Symmetry
The central law of T-Theory is that the duration of a market's "cash buildup" phase (the left side of the T) will be matched by the duration of the "run" phase (the right side of the T).
The Center Post: This represents the peak of a market's internal strength or momentum.
The Left Wing: The time from a previous low to the center post.
The Right Wing: The projected time from the center post to the end of the new trend.
2. Time over Price
Unlike many technical indicators that focus on price targets, T-Theory is almost entirely focused on time targets. It suggests that once a "T" is identified, the trend will persist until the time symmetry is exhausted, regardless of how high or low the price goes during that window.
3. Magic T's and Sub-T's
The theory operates on a hierarchical basis:
Grand Macro T's: These define long-term secular trends and can span years.
Minor T's: These represent shorter-term bursts of momentum within a larger trend.
The Law of Proportion: Larger horizontal wings (more time spent consolidating) necessitate larger vertical posts (more significant momentum shifts), creating a visual hierarchy on the chart.
4. Identification via Oscillators
While you requested the script focus on price action, Laundry originally identified these "buildup" phases using the McClellan Oscillator. He looked for periods where the oscillator showed "strength" (buildup) followed by a "breakout" from a trendline on the oscillator itself, which marked the center post of the T.
Key Visual Characteristics
Non-Intersection: In a clean T-Theory setup, the horizontal "wings" represent time spans and should ideally sit above or below the price action to clearly define the period of the trade without being obscured by daily volatility.
The Center Post Gap: The vertical post should be near the price data to show the point of origin for the momentum, but it requires enough "room" to remain distinct.
Hodrick-Prescott Structural CycleThis script is about solving one specific problem: Decomposition.
In any market, you have two things happening at once: the underlying "Trend" (the structural value) and the "Cycle" (the noise or volatility around that value). The Hodrick-Prescott (HP) filter is the standard econometric tool to separate them.
1. The Separation Logic (HP Filter)
Most moving averages lag. The HP filter attempts to find a smooth curve that represents the long-term path of the asset, minimizing the variance of the cycle.
In the code, the "stiffness" of this curve is controlled by Lambda ().
get_auto_lambda() =>
timeframe.isintraday ? 6250000 :
timeframe.isdaily ? 129600 :
1600
1600 is the standard used by economists for quarterly data. If the timeframe changes (daily or intraday), it automatically scales Lambda up to maintain that same "quarterly" smoothness on a faster chart.
2. The Mechanics (2-Pole Recursion)
The classic HP filter looks at future data, which is impossible for live trading. We uses a 2-Pole Super Smoother to approximate that curve using only past data.
hp_filter_2pole(src, period) =>
// ... coefficients calculated ...
var float filt = 0.0
filt := c1 * (src + nz(src )) / 2 + c2 * nz(filt ) + c3 * nz(filt )
See the filt and filt -> that's recursion. The filter references its own previous output. This creates memory, allowing the line to resist sudden spikes in price (noise) while slowly adapting to the true direction.
3. The Four Market Regimes
This script splits the market into four distinct quadrants based on where the Z-Score is and where it is going.
bool is_expansion = z_score > 0 and z_score > z_score
bool is_downturn = z_score > 0 and z_score < z_score
bool is_recovery = z_score < 0 and z_score > z_score
bool is_recession = z_score < 0 and z_score < z_score
1. Expansion (Green): We are above the trend, and momentum is accelerating.
2. Downturn (Orange): We are above the trend, but momentum is slowing (topping out).
3. Recession (Red): We are below the trend, and price is collapsing.
4. Recovery (Blue): We are below the trend, but price has stopped falling and is turning up.
The Background Zones: Statistical Extremes
This script monitors the Z-Score (the normalized cycle). When this score moves beyond 1.0 standard deviation from the mean (zero), the background lights up.
Red Background (Recession Zone): The Z-Score is < -1.0. Price is significantly below its structural trend. This is where fear is highest, and the asset is statistically "underwater."
Green Background (Overheating Zone): The Z-Score is > 1.0. Price is stretching far above the trend.
Why it matters: Markets rarely stay beyond 2.0 standard deviations for long. When you see the background colored, you are in an outlier event. (The rubber band is stretched)
Divergences: The "Check Engine" Light
It also scans for discrepancies between Price Action and the Cycle Momentum (Z-Score).
Bullish Divergence: Price makes a Lower Low, but the Cycle makes a Higher Low. The sellers are pushing price down, but with less conviction than before.
Bearish Divergence: Price makes a Higher High, but the Cycle makes a Lower High. Buyers are exhausted.
How to use this:
Do not treat a divergence tag as an entry signal.
A divergence is a state of discrepancy, not a timing trigger. It tells you that the prevailing trend is running out of steam.
Market Dashboard: Vol %, Trend, ATR (Custom Colors)Market Dashboard: Volume %, Trend & ATR
This indicator provides a compact at-a-glance market dashboard directly on your chart, helping you quickly assess order flow bias, trend direction, and volatility without clutter.
What it shows:
Bull vs Bear Volume % over a customizable lookback, with flexible doji handling (ignore, assign, or split).
Trend direction using EMA crossovers on both the current timeframe and a higher timeframe for context.
ATR value with an optional percentage-of-price display to gauge volatility and position sizing.
Key features:
Fully customizable colors, text size, and table position
Higher timeframe trend confirmation
Clean table design that updates on the latest bar only
Ideal for traders who want quick confirmation before entries, improved market bias awareness, and better risk/volatility context while scalping or swing trading.
Price Probability Engine - Volatility & Structure-Based TargetsThe aim of the indicator is:
To provide adaptive, probability-weighted price target zones that help traders frame where price is most likely to interact next, without predicting when or guaranteeing direction.
Price Probability Engine is a target-projection overlay that blends three independent “next-move” reference methods into a single pair of AVG targets:
AVG Bull = a probabilistic upside objective
AVG Bear = a probabilistic downside objective
It is designed to help you frame the most reasonable near-term price zones using both volatility (ATR) and structure (pivot swings + measured moves) rather than relying on a single indicator.
What you see on the chart
When enabled, the script plots:
AVG Bull line (upper target)
AVG Bear line (lower target)
Optional last-bar labels that print the current target values
The overlay is scale-locked so the plots stay aligned with price when you scroll/zoom the chart.
How it works (conceptual, step-by-step)
1) ATR “reach filter” (probability gating)
All components are first checked against a reach filter:
A target is considered “reachable” only if it is within
Reach Filter × ATR from the current price.
This prevents extremely distant projections from dominating the final average.
2) Three component target engines
The script computes three upside candidates and three downside candidates:
A) ATR Component (volatility projection)
Uses ATR Length and ATR Multiplier
Projects a simple near-term band around price:
atrBull = close + ATR × mult
atrBear = close - ATR × mult
Direction mode:
Candle: compares close to close
Momentum(3): uses close − close
B) AutoFib Component (swing extension)
Detects swing highs/lows using pivot logic (Left/Right bars)
Projects an extension using a selectable Fib level (1.272 / 1.414 / 1.618 / 2.0 / 2.618)
Gives a structure-based target derived from the current swing range
C) Lindsey Component (measured-move target)
Detects a 3-point pivot sequence (P1/P2/P3) and projects a measured move to P4:
Bull: from a low-high-higher-low sequence
Bear: from a high-low-lower-high sequence
Optional P1/P2/P3 markers can be displayed for learning/debugging
3) Dynamic weighting (closer targets matter more)
If Dynamic Weights is enabled, each component’s weight increases as the target gets closer to price (within the reach window).
This means the final AVG tends to favor targets that are both reachable and near-term relevant.
You can control:
Base Weight (Fib / Lindsey / ATR)
Dynamic Power (how aggressively “closer” becomes “heavier”)
4) Outlier trimming (stability)
If Trim Outlier Component is enabled, the script:
computes a simple median reference of the remaining component targets
drops any target that deviates from the median by more than
Outlier Threshold × ATR
This reduces sudden jumps when one method produces an unusually extreme projection.
5) Final output: a weighted average (bull + bear)
The remaining eligible components are combined into:
AVG Bull (weighted average of bull candidates)
AVG Bear (weighted average of bear candidates)
If no components pass the reach filter (or are trimmed), the AVG line can temporarily become unavailable until valid inputs re-appear.
How to use it (practical workflow)
Pick your timeframe, then tune ATR:
Start with ATR Length 14 and ATR Mult 1.0–1.5
Set a reasonable Reach Filter (x ATR):
Smaller = only near targets
Larger = includes more distant projections
Decide how you want it to behave:
Dynamic Weights ON for “closer targets dominate”
Outlier Trim ON for smoother / less erratic averages
Use the AVG lines as planning zones, not certainties:
They are best treated as “where price is most likely to seek next” based on the blend of volatility + structure.
A common use is to monitor how price reacts as it approaches either AVG line (stalling, rejection, acceleration), and then reassess as new pivots/ATR values update.
Settings guide (quick)
ATR Length / Multiplier: controls the volatility envelope
Direction Mode: changes the bias input for ATR projection
Lindsey Left/Right: smaller = more sensitive pivots; larger = fewer, more meaningful pivots
Fib Left/Right + Extension: controls the swing structure target
Reach Filter: controls what qualifies as a realistic near-term target
Dynamic Power: higher = stronger preference for the nearest target
Outlier Threshold: higher = fewer removals; lower = more aggressive trimming
Notes / Transparency
This script does not place trades or guarantee outcomes. It is a visual target framework that adapts as volatility and market structure change. For best clarity, publish charts with this script on a clean layout so the AVG lines and labels are easy to identify.
Levels BY Lukelevel two continuation
level 3 reversal zone---
work in combination with your system
luke
check out my youtube page ADHD Traders channel
Trend & Volume indicatorThis is a Trend, Entry, Exit, and Risk-assessment indicator built around the NNFX (No-Nonsense Forex) methodology, intended primarily for Daily timeframes.
It combines:
A Baseline trend filter
Signal Wave (formerly SSL) lines for continuation and exits
ATR-based volatility analysis
Dynamic risk assessment
Visual trade context (colors, channels, alerts, table)
The indicator does not auto-trade. It provides decision support.
Core Components
1. Baseline (Trend Filter)
Uses a configurable moving average (HMA, EMA, JMA, McGinley, etc.)
Acts as the primary trend direction filter
Includes an optional volatility channel around the baseline
Trend logic:
Above baseline → bullish bias
Below baseline → bearish bias
Inside channel → neutral / ranging
This follows NNFX’s rule: Only trade in the direction of the baseline.
2. Signal Wave 1 (Trend Confirmation)
A high/low MA-based line (SW1)
Changes direction only when price clearly breaks structure
Confirms:
Trend continuation
Momentum agreement with baseline
3. Signal Wave 2 (Continuation Entries)
Short-length MA-based signal (SW2)
Uses ATR-distance logic to detect valid pullbacks
Signals continuation entries only when volatility criteria are met
Prevents chasing price during overextended moves
4. Exit Line (Trade Management)
Independent MA-based exit line
Generates:
Exit Long when price crosses below
Exit Short when price crosses above
Designed to:
Protect profits
Avoid emotional exits
Volatility & ATR Logic
ATR is smoothed using selectable methods (RMA, SMA, EMA, WMA)
ATR bands show:
Expected price range
Overextension zones
Used for:
Entry qualification
Continuation logic
False breakout detection
Risk Assessment System
ATR Percentile
Compares current ATR to historical volatility
Classifies risk as:
Low
Normal
High
Dynamic Color Fading
High volatility → more transparent colors
Low volatility → solid colors
Gives instant visual risk feedback
Entry Quality Filters
Entry Distance
Measures how far price is from the baseline:
Near → ideal
Extended → caution
Far → high risk
False Breakout Detection
Flags candles:
Larger than 1× ATR
Still within baseline range
Helps avoid trap trades
Visual Elements
Colored candles reflect trend + risk
Baseline channel fill changes with market bias
Diamond markers highlight risky candles
Optional ATR bands
Risk table showing:
Risk level
Entry distance
Volatility percentile
Current ATR
Alerts Included
The script provides alerts for:
Exit signals
Continuation entries
Baseline breaks
High-risk entries
False breakouts
Extreme volatility conditions
All alerts are context-aware, not raw crossovers.
Best Use Case
✔ Daily timeframe
✔ Trend-following strategies
✔ NNFX-style system building
✔ Discretionary traders who want structure, not automation
Value Area PRO (TPO/Volume Session VAH/VAL/POC) 📌 AP Capital Value Area PRO (TPO / Volume)
AP Capital Value Area PRO is a session-based value area indicator designed for Gold (XAUUSD), NASDAQ (NAS100), and other CFD instruments.
It focuses on where the market has accepted price during the current session and highlights high-probability interaction zones used by professional traders.
Unlike rolling lookback volume profiles, this indicator builds a true session value area and provides actionable signals around VAH, VAL, and POC.
🔹 Core Features
Session-Anchored Value Area
Value Area is built only during the selected session
Resets cleanly at session start
Levels develop during the session and can be extended forward
No repainting or shifting due to lookback changes
TPO or Volume Mode
TPO (Time-at-Price) mode – ideal for CFDs and tick-volume data
Volume mode – uses broker volume if preferred
Same logic, different weighting method
Fixed Price Bin Size
Uses a fixed bin size (e.g. 0.10 for Gold, 0.25–0.50 for NAS100)
Produces cleaner, more realistic VAH/VAL levels
Avoids distorted profiles caused by dynamic bin scaling
VAH / VAL / POC Levels
VAH (Value Area High)
VAL (Value Area Low)
POC (Point of Control) (optional)
Lines can be extended to act as forward reference levels
🔹 Trading Signals & Alerts
Value Re-Entry
Identifies false breakouts where price:
Trades outside value
Then closes back inside
Often seen before strong mean-reversion or continuation moves.
Acceptance
Detects initiative activity using:
Multiple consecutive closes outside value
Filters out weak single-candle breaks
Rejection
Flags strong rejection candles:
Large candle body
Wick outside value
Close back inside the value area
These conditions are especially effective on Gold intraday.
🔹 Optional Profile Histogram
Right-side volume/TPO histogram
Buy/sell imbalance visualization
Fully optional to reduce chart clutter and improve performance
🔹 Best Use Cases
Recommended markets
XAUUSD (Gold)
NAS100 / US100
Other index or metal CFDs
Recommended timeframes
5m, 15m, 30m
Suggested settings
Mode: TPO
Value Area: 70%
Bin size:
Gold: 0.10
NAS100: 0.25 or 0.50
🔹 How Traders Use It
Trade rejections at VAH / VAL
Look for acceptance to confirm trend days
Use re-entries to fade failed breakouts
Combine with trend filters, EMA structure, or session context
⚠️ Disclaimer
This indicator is provided for educational and analytical purposes only and does not constitute financial advice. Always manage risk appropriately.
Look-back Value V1新增 MA10 與 MA120 的計算、繪圖、表格顯示。
新增 table_pos 參數,可選擇表格顯示位置(top_left, top_right, bottom_left, bottom_right)。
所有 table.cell 改用 具名參數 text_color,避免誤判成 width。
這樣你就能靈活選擇表格位置,並同時觀察 MA5、MA10、MA20、MA60、MA120、MA240 的扣抵分析。
Chart This in GoldProduces a historical line chart in the bottom pane to reflect how many units of spot gold (XAU) could be exchanged for one unite of the underlying asset.
Magnitude of MovementThie calculase the ratio between Mod of Open Price-Current Price and Mod of Open Volume and current volume






















