Indicator

Indicator

ATK / DEF MTF Analysis Chameleon Combo SessionATK / DEF MTF Analysis Chameleon Combo Session is a multi-timeframe market observation and visualization tool designed to examine the broader market environment through several independent analytical dimensions.
Unlike traditional single-indicator analysis, this framework combines **MTF Process, MTF Radar, Test Depth Matrix, MTF Direction, and an independent Chameleon MA** into one structured dashboard.
### Core Components
**MTF Process**
Observes changes in higher-timeframe ADX and RSI conditions and classifies the current market process into different states, from accelerating conditions to sideways or declining conditions.
**MTF Radar**
Combines ADX, RSI, and relative ATR to describe the current level of market activity and volatility.
**Test Depth Matrix**
Divides the selected MTF price range into five relative zones:
* Deep Water
* Mid Water
* Shallow Water
* Shallows
* Dry Zone
This provides a visual representation of where the observed market environment is positioned within its selected range.
**MTF Direction**
Uses EMA structure together with DI+ / DI− relationships to classify the directional condition of the selected timeframe.
**Chameleon MA**
The Chameleon component is independently configured and is **not tied to the MTF timeframe setting**. Its moving-average line changes visual state according to its position within the Test Depth Matrix, creating a dynamic zone-based visual layer.
**MTF Final Result**
Combines the independent MTF Process, Radar, Test Depth, and Direction classifications into a normalized composite score for observing the overall market state.
### Multi-Level Market Observation
The framework separates the market into different analytical levels rather than relying on a single indicator reading.
It allows the user to observe:
**Direction → Process → Activity → Depth → Chameleon State → Composite Market State**
The purpose is to provide a broader contextual view of market conditions and how different analytical dimensions interact with each other.
### User Configuration
The indicator is intentionally configurable.
Users must define their own:
* MTF Timeframe
* Chameleon MA Period
* Test Depth Zone Period
* Display settings
The Chameleon parameters are independent from the MTF configuration, allowing the two analytical layers to be adjusted separately.
Different parameter settings can produce different market classifications, so there is no single configuration intended for all symbols or market conditions.
### Important
This indicator is designed **only for market observation, analysis, and visualization**.
It does not provide tadn recommendations, ent or eit instructions, fiial advice, or forts.
The displayed scores and classifications are mathtical representations based on market data and use-selected parameters.
The indicator does not determine what action should be taken.
Use are responsible for selecting and configuring the relevant parameters for their own analysis.
Indicator

SMC Decision by SPPATLEThis Pine Script code implements a comprehensive Smart Money Concepts (SMC) trading indicator designed for PulseWire (Version 6). It combines institutional price-action structures (such as market structure breaks, change of character, and fair value gaps) with technical indicators and a real-time summary dashboard.
Here is a detailed breakdown of its core components and features:
1. Market Structure & SMC Components
Market Structure Breaks (BOS) & Change of Character (CHoCH): Tracks swing highs and lows to detect trend continuations (BOS) and trend reversals (CHoCH). It supports filtering breaks using either candle wicks or candle closing bodies (bodyBreak).
Fair Value Gaps (FVG): Automatically identifies and plots institutional imbalances (inefficiencies) where price moved rapidly, leaving an unfilled gap. Bullish and bearish gaps are tracked via dynamic arrays and cleared once mitigated.
Supply & Demand Zones: Scans up to the last 500 bars to plot dynamic high-volume supply and demand boundaries on the chart, complete with real-time status updates and distance calculations.
2. Technical Indicators & Volume Analysis
200-period Exponential Moving Average (EMA): Plots the baseline trend filter (ta.ema(close, 200)).
Volume Weighted Average Price (VWAP): Displays institutional benchmark pricing.
Relative Volume (RVOL): Calculates volume relative to a moving average lookback window, highlighting high-volume spikes visually on the chart (barcolor and dotted reference lines) when volume exceeds the set threshold.
3. Real-Time Dashboard & Recommendation Table
The indicator features an on-chart information table positioned at the top right that summarizes key market metrics in real time:
SMC Trend: Displays whether the current structure is BULLISH, BEARISH, or NEUTRAL.
Structure Rule: Shows the last detected market event (e.g., Bullish BOS or Bearish CHoCH).
S&D Status & Zone Distance: Reports whether price is inside or approaching a Supply/Demand zone along with percentage metrics.
200 EMA Filter: Shows price position relative to the 200 EMA with percentage deviation.
Current RVOL & Volume Power: Tracks current volume performance and relative buyer/seller power ratio.
Final Recommendation: Generates an automated signal (BUY, SELL, CAUTION, or HOLD) based on a combination of the trend filter, volume expansion, power momentum, and proximity to major zones. Indicator

Smart MoolahSmart Moolah — Order Blocks, FVG, Anchored VWAP & Structure
Smart Moolah combines several price-action concepts into one configurable toolkit, built for scalpers and day traders who track market structure, imbalances, and volume-weighted price.
WHAT IT DOES
- Order Blocks — automatically detects bullish and bearish order blocks anchored to actual swing highs/lows (not just the break event), extending forward with no length or count cap until price mitigates them.
- Fair Value Gaps (FVG) — identifies 3-candle imbalances, with an optional filter to only display FVGs that form within a defined window after a structural break (BOS/CHoCH), cutting out noise from flat, choppy consolidation.
- Break of Structure (BOS) / Change of Character (CHoCH) — swing-based structure detection, color-coded green for bullish breaks and red for bearish breaks, with labels centered on a dashed line connecting the swing point to the break.
- Anchored VWAP — session, weekly, monthly, or custom bar-count anchoring, with volume-weighted deviation bands (real standard deviation, not an approximation).
- Call / Put Hold Levels — a support level ("must hold above" for calls) and resistance level ("must hold below" for puts), derived from the nearest active order block or swing point, with a live on-chart table. Levels fade and mark "BREACHED" once price closes through them.
HOW TO USE IT
Every component is independently toggleable with its own color/style settings, grouped by section (Order Blocks, FVG, Anchored VWAP, Market Structure, Call/Put Hold Levels). Recommended starting points:
- Scalping (1-5min): Swing Lookback Length 5-8, Max FVG Boxes 5-8
- Day trading (15min-1h): Swing Lookback Length 10-15, Max FVG Boxes 10-15
The Call/Put Hold Levels are technical reference points derived from structure — they indicate whether the price action your trade thesis relies on is still intact, not a guarantee of direction or profitability.
DISCLAIMER
This script is for educational and informational purposes only. It does not constitute financial advice, and past structural behavior does not guarantee future price action. Order block, FVG, and structure detection are pattern-based approximations, not certainties. Always use independent judgment and proper risk management. Indicator

Indicator

Indicator

Indicator

V6 ORB Retest NY Session// ORB Retest — NY Session (MNQ)
// Live companion to the walk-forward-validated strategy in orb_retest.py.
//
// Draws and alerts only. It never places an order.
//
// DESIGNED FOR A 5-MINUTE CHART. The strategy was validated on 5-minute bars;
// on any other timeframe the breakout/retest granularity differs from what was
// tested, so the panel shows a warning.
//
// Session times are pinned to America/New_York, so the 9:30 ET open is located
// correctly no matter what timezone your chart displays, and DST is handled
// automatically. No chart timezone change needed.
//
// Install: PulseWire -> Pine Editor -> paste -> Save -> Add to chart.
//@version=6
indicator("ORB Retest — NY Session", "ORB Retest", overlay = true,
max_boxes_count = 500, max_lines_count = 500, max_labels_count = 500)
// ───────────────────────── Inputs ─────────────────────────
grpS = "Session (always New York time)"
orSessionInput = input.session("0930-0945", "Opening range window", group = grpS, display = display.none)
tradeSessionInput = input.session("0930-1555", "Trading session (flat at end)", group = grpS, display = display.none)
cutoffInput = input.session("0930-1200", "Breakout must occur before", group = grpS, display = display.none)
grpR = "Trade rules"
targetR = input.float(2.5, "Target (multiple of risk)", minval = 0.5, step = 0.5, group = grpR,
tooltip = "2.5R tested best across both 2019-2026 and 2023-onward: target is hit on 48% of trades vs 38% at 3R, win rate 58% vs 52%, slightly more total profit and a smaller drawdown.",
display = display.none)
stopBufTicks = input.int(4, "Stop buffer beyond retest extreme (ticks)", minval = 0, group = grpR, display = display.none)
touchTolTicks = input.int(2, "Retest touch tolerance (ticks)", minval = 0, group = grpR, display = display.none)
invalTicks = input.int(4, "Invalidation buffer past level (ticks)", minval = 0, group = grpR, display = display.none)
retestDeadlineM = input.int(60, "Cancel if no retest within (minutes)", minval = 5, group = grpR, display = display.none)
maxRiskPts = input.float(0, "Skip if risk exceeds (points, 0 = no limit)", minval = 0, group = grpR,
tooltip = "Off by default. On a 5-minute chart a 40-point cap improved results (+0.72R to +0.80R, drawdown roughly halved). On a 15-minute chart stops are naturally wider and the same cap removes too many good trades, so leave it at 0 there.",
display = display.none)
grpF = "Day filter"
useRangeFilter = input.bool(true, "Skip days with unusual opening-range width", group = grpF, display = display.none)
rangeLookback = input.int(20, "Lookback (days)", minval = 5, group = grpF, display = display.none)
rangeMinMult = input.float(0.5, "Minimum multiple of average", step = 0.1, group = grpF, display = display.none)
rangeMaxMult = input.float(2.0, "Maximum multiple of average", step = 0.1, group = grpF, display = display.none)
grpV = "Display"
drawSessionInput = input.session("0930-1230", "Extend drawings during (NY time)", group = grpV,
tooltip = "Boxes and lines grow only inside this window, then freeze. Default = first 3 hours of the NY session, so old days stay compact.",
display = display.none)
keepDays = input.int(120, "Keep drawings for last N days", minval = 1, maxval = 250, group = grpV,
tooltip = "PulseWire caps an indicator at 500 drawings per type; at 4 lines per traded day that is roughly 125 days of full markup. Beyond the cap the oldest drawings drop off automatically.",
display = display.none)
pointValue = input.float(2.0, "Contract $ per point (MNQ = 2)", minval = 0.01, group = grpV, display = display.none)
showPanel = input.bool(true, "Show status panel", group = grpV, display = display.none)
showBox = input.bool(true, "Opening range box", group = grpV, display = display.none)
showLevels = input.bool(true, "Entry / stop / target lines", group = grpV, display = display.none)
showMarkers = input.bool(true, "Signal markers", group = grpV, display = display.none)
showLabels = input.bool(true, "Outcome labels", group = grpV, display = display.none)
showLegend = input.bool(true, "Show symbol legend (bottom-left)", group = grpV, display = display.none)
TZ = "America/New_York"
// ───────────────────── Session detection ─────────────────────
inOR = not na(time(timeframe.period, orSessionInput, TZ))
inTrade = not na(time(timeframe.period, tradeSessionInput, TZ))
beforeCut = not na(time(timeframe.period, cutoffInput, TZ))
inDraw = not na(time(timeframe.period, drawSessionInput, TZ))
orStart = inOR and not inOR
orEnd = not inOR and inOR
tradeEnd = not inTrade and inTrade
tick = syminfo.mintick
isFiveMin = timeframe.isminutes and timeframe.multiplier == 5
// Live-chart safety: every decision waits for the bar to CLOSE, exactly like
// the backtest. On the streaming realtime bar nothing updates until it
// confirms, so signals never appear and then vanish mid-bar (no repainting).
confirmed = barstate.isconfirmed
// ───────────────────────── State ─────────────────────────
// 0 = waiting for breakout, 1 = waiting for retest, 2 = in trade, 3 = done today
var int state = 0
var int armedDir = 0
var int armTime = na
var float orH = na
var float orL = na
var float orRange = na
var bool orReady = false
var bool dayEligible = false
var float retestExtreme = na
var float entryPrice = na
var float stopPrice = na
var float targetPrice = na
var float riskPts = na
var string outcome = "—"
var array orHistory = array.new_float()
// Drawing handles for the current day
var box orBox = na
var line levelLine = na
var line entryLine = na
var line stopLine = na
var line targetLine = na
// Rolling registry so old days' drawings get cleaned up instead of piling up.
var array boxReg = array.new()
var array lineReg = array.new()
var array labelReg = array.new()
// Signal flags at global scope so plotshape / alertcondition can read them.
bool sigBreakout = false
bool sigEntry = false
bool sigInvalidated = false
bool sigExpired = false
bool sigTargetHit = false
bool sigStopHit = false
// ───────────── Build the opening range, reset for a new day ─────────────
if orStart and confirmed
orH := high
orL := low
orReady := false
state := 0
armedDir := 0
dayEligible := false
retestExtreme := na
entryPrice := na
stopPrice := na
targetPrice := na
riskPts := na
outcome := "—"
levelLine := na
entryLine := na
stopLine := na
targetLine := na
else if inOR and confirmed
orH := math.max(orH, high)
orL := math.min(orL, low)
if orEnd and confirmed
orRange := orH - orL
orReady := true
// Compare today's range against the trailing average BEFORE adding it.
// Starts judging after 5 days of history (averaging what it has, up to the
// full lookback) — demanding all 20 up front left short-history charts,
// like 5-minute ones, permanently stuck in "filtered out".
int warmup = math.min(rangeLookback, 5)
float avgRange = array.size(orHistory) >= warmup ? array.avg(orHistory) : na
dayEligible := not useRangeFilter or (not na(avgRange)
and orRange >= avgRange * rangeMinMult
and orRange <= avgRange * rangeMaxMult)
array.push(orHistory, orRange)
if array.size(orHistory) > rangeLookback
array.shift(orHistory)
if not dayEligible
outcome := na(avgRange) and useRangeFilter ? "warming up — collecting history" : "day filtered out"
if showBox
orBox := box.new(bar_index - 1, orH, bar_index, orL,
border_color = dayEligible ? color.new(color.orange, 20) : color.new(color.gray, 65),
border_style = line.style_dashed, border_width = 1,
bgcolor = dayEligible ? color.new(color.orange, 90) : color.new(color.gray, 96))
array.push(boxReg, orBox)
if array.size(boxReg) > keepDays
box.delete(array.shift(boxReg))
// Stretch the box only inside the drawing window, then freeze it.
if showBox and inDraw and orReady and not na(orBox)
box.set_right(orBox, bar_index)
// ───────────────────── State machine ─────────────────────
if orReady and inTrade and dayEligible and confirmed
// ---- Waiting for a breakout CLOSE (wicks do not count) ----
if state == 0 and beforeCut
if close > orH
armedDir := 1
state := 1
armTime := time
retestExtreme := low
sigBreakout := true
outcome := "armed long — waiting for retest"
else if close < orL
armedDir := -1
state := 1
armTime := time
retestExtreme := high
sigBreakout := true
outcome := "armed short — waiting for retest"
if sigBreakout and showLevels
float lvl = armedDir == 1 ? orH : orL
levelLine := line.new(bar_index, lvl, bar_index, lvl,
color = color.orange, width = 2)
array.push(lineReg, levelLine)
// ---- Armed: waiting for price to come back and retest the level ----
else if state == 1
bool isLong = armedDir == 1
float lvl = isLong ? orH : orL
float invalLevel = isLong ? lvl - invalTicks * tick : lvl + invalTicks * tick
bool invalidated = isLong ? close < invalLevel : close > invalLevel
bool expired = (time - armTime) / 60000 > retestDeadlineM or not beforeCut
if invalidated
state := 3
sigInvalidated := true
outcome := "invalidated — closed back inside"
if not na(levelLine)
line.set_color(levelLine, color.new(color.gray, 40))
else if expired
state := 3
sigExpired := true
outcome := "no retest — expired"
if not na(levelLine)
line.set_color(levelLine, color.new(color.gray, 40))
else
// Track how far the pullback has run — this defines the stop.
retestExtreme := isLong ? math.min(retestExtreme, low) : math.max(retestExtreme, high)
float tol = touchTolTicks * tick
bool touched = isLong ? low <= lvl + tol : high >= lvl - tol
bool pierced = isLong ? low <= lvl - tick : high >= lvl + tick
if touched and pierced
float eP = lvl
float sP = isLong ? retestExtreme - stopBufTicks * tick
: retestExtreme + stopBufTicks * tick
float rk = isLong ? eP - sP : sP - eP
if rk > 0 and (maxRiskPts == 0 or rk <= maxRiskPts)
entryPrice := eP
stopPrice := sP
riskPts := rk
targetPrice := isLong ? eP + targetR * rk : eP - targetR * rk
state := 2
sigEntry := true
outcome := (isLong ? "LONG live" : "SHORT live")
if showLevels
entryLine := line.new(bar_index, entryPrice, bar_index, entryPrice,
color = color.blue, width = 2)
stopLine := line.new(bar_index, stopPrice, bar_index, stopPrice,
color = color.red, width = 1, style = line.style_dashed)
targetLine := line.new(bar_index, targetPrice, bar_index, targetPrice,
color = color.green, width = 1, style = line.style_dashed)
array.push(lineReg, entryLine)
array.push(lineReg, stopLine)
array.push(lineReg, targetLine)
if showLabels
label lb = label.new(bar_index, isLong ? low : high,
(isLong ? "LONG " : "SHORT ")
+ str.tostring(rk, format.mintick) + " pts ($"
+ str.tostring(rk * pointValue, "#.##") + ")",
yloc = isLong ? yloc.belowbar : yloc.abovebar,
style = isLong ? label.style_label_up : label.style_label_down,
size = size.small,
color = isLong ? color.new(color.green, 20) : color.new(color.red, 20),
textcolor = color.white)
array.push(labelReg, lb)
else
state := 3
outcome := rk <= 0 ? "skipped — no risk defined" : "skipped — risk too wide"
// ---- In the trade: stop or target first? ----
else if state == 2
bool isLong = armedDir == 1
bool hitStop = isLong ? low <= stopPrice : high >= stopPrice
bool hitTarget = isLong ? high >= targetPrice : low <= targetPrice
// If one bar spans both, assume the stop filled first (matches the backtest).
if hitStop
state := 3
sigStopHit := true
outcome := "stopped out (−1R)"
else if hitTarget
state := 3
sigTargetHit := true
outcome := "target hit (+" + str.tostring(targetR, "#.#") + "R)"
// Grow active lines only inside the drawing window (no infinite extend,
// and old days stay frozen at their 3-hour width).
if inDraw
if state == 1 and not na(levelLine)
line.set_x2(levelLine, bar_index)
if state == 2
if not na(entryLine)
line.set_x2(entryLine, bar_index)
if not na(stopLine)
line.set_x2(stopLine, bar_index)
if not na(targetLine)
line.set_x2(targetLine, bar_index)
// ---- Session over: anything still open is flattened ----
if tradeEnd and state == 2 and confirmed
state := 3
outcome := "flat — session end"
if showLabels
label lb2 = label.new(bar_index, close, "flat — session end", yloc = yloc.abovebar,
style = label.style_label_down, size = size.tiny,
color = color.new(color.gray, 35), textcolor = color.white)
array.push(labelReg, lb2)
// ---- Prune old drawings so the chart doesn't fill up ----
if array.size(lineReg) > keepDays * 4
line.delete(array.shift(lineReg))
if array.size(labelReg) > keepDays * 2
label.delete(array.shift(labelReg))
// ───────────────────────── Plots ─────────────────────────
plotshape(showMarkers and sigBreakout, "Breakout close", shape.triangleup,
location.belowbar, color.new(color.orange, 0), size = size.tiny, display = display.pane)
plotshape(showMarkers and sigEntry and armedDir == 1, "Long entry", shape.labelup,
location.belowbar, color.new(color.green, 0), text = "E", textcolor = color.white,
size = size.small, display = display.pane)
plotshape(showMarkers and sigEntry and armedDir == -1, "Short entry", shape.labeldown,
location.abovebar, color.new(color.red, 0), text = "E", textcolor = color.white,
size = size.small, display = display.pane)
plotshape(showMarkers and sigTargetHit, "Target hit", shape.xcross,
location.abovebar, color.new(color.green, 0), size = size.tiny, display = display.pane)
plotshape(showMarkers and sigStopHit, "Stop hit", shape.xcross,
location.belowbar, color.new(color.red, 0), size = size.tiny, display = display.pane)
plotshape(showMarkers and sigInvalidated, "Setup invalidated", shape.circle,
location.abovebar, color.new(color.gray, 25), size = size.tiny, display = display.pane)
plotshape(showMarkers and sigExpired, "No retest — expired", shape.square,
location.abovebar, color.new(color.gray, 25), size = size.tiny, display = display.pane)
// ───────────────────────── Status panel ─────────────────────────
var table panel = table.new(position.top_right, 2, 7,
border_width = 1, border_color = color.new(color.gray, 60),
frame_width = 1, frame_color = color.new(color.gray, 60))
if showPanel and barstate.islast
color hdrBg = color.new(color.gray, 85)
color cellBg = color.new(color.gray, 92)
table.cell(panel, 0, 0, "ORB Retest", text_size = size.small, text_color = color.gray,
bgcolor = hdrBg, text_halign = text.align_left)
table.cell(panel, 1, 0, isFiveMin ? "5m ✓" : "⚠ tested on 5m",
text_size = size.small, bgcolor = hdrBg,
text_color = isFiveMin ? color.green : color.orange, text_halign = text.align_right)
table.cell(panel, 0, 1, "Status", text_size = size.small, text_color = color.gray,
bgcolor = cellBg, text_halign = text.align_left)
table.cell(panel, 1, 1, outcome, text_size = size.small, bgcolor = cellBg,
text_color = state == 2 ? color.blue : color.gray, text_halign = text.align_right)
table.cell(panel, 0, 2, "Range high", text_size = size.small, text_color = color.gray,
bgcolor = cellBg, text_halign = text.align_left)
table.cell(panel, 1, 2, na(orH) ? "—" : str.tostring(orH, format.mintick),
text_size = size.small, bgcolor = cellBg, text_color = color.orange,
text_halign = text.align_right)
table.cell(panel, 0, 3, "Range low", text_size = size.small, text_color = color.gray,
bgcolor = cellBg, text_halign = text.align_left)
table.cell(panel, 1, 3, na(orL) ? "—" : str.tostring(orL, format.mintick),
text_size = size.small, bgcolor = cellBg, text_color = color.orange,
text_halign = text.align_right)
table.cell(panel, 0, 4, "Range width", text_size = size.small, text_color = color.gray,
bgcolor = cellBg, text_halign = text.align_left)
table.cell(panel, 1, 4, na(orRange) ? "—" : str.tostring(orRange, "#.##") + " pts",
text_size = size.small, bgcolor = cellBg, text_color = color.gray,
text_halign = text.align_right)
table.cell(panel, 0, 5, "Entry / Stop", text_size = size.small, text_color = color.gray,
bgcolor = cellBg, text_halign = text.align_left)
table.cell(panel, 1, 5, na(entryPrice) ? "—"
: str.tostring(entryPrice, format.mintick) + " / " + str.tostring(stopPrice, format.mintick),
text_size = size.small, bgcolor = cellBg, text_color = color.gray,
text_halign = text.align_right)
table.cell(panel, 0, 6, "Risk", text_size = size.small, text_color = color.gray,
bgcolor = cellBg, text_halign = text.align_left)
table.cell(panel, 1, 6, na(riskPts) ? "—"
: str.tostring(riskPts, "#.##") + " pts $" + str.tostring(riskPts * pointValue, "#.##"),
text_size = size.small, bgcolor = cellBg, text_color = color.red,
text_halign = text.align_right)
// ───────────────────────── Symbol legend ─────────────────────────
var table legend = table.new(position.bottom_left, 4, 7,
border_width = 1, border_color = color.new(color.gray, 70),
frame_width = 1, frame_color = color.new(color.gray, 70))
if showLegend and barstate.islast
color lgBg = color.new(color.gray, 94)
color lgTxt = color.new(color.gray, 15)
table.cell(legend, 0, 0, "SYMBOL GUIDE", text_size = size.tiny, text_color = color.gray,
bgcolor = color.new(color.gray, 88), text_halign = text.align_left)
table.merge_cells(legend, 0, 0, 3, 0)
// column 0-1: setup phase column 2-3: trade phase
table.cell(legend, 0, 1, "▭", text_size = size.small, text_color = color.orange, bgcolor = lgBg)
table.cell(legend, 1, 1, "opening range 9:30–9:45", text_size = size.tiny, text_color = lgTxt, bgcolor = lgBg, text_halign = text.align_left)
table.cell(legend, 2, 1, "▬", text_size = size.small, text_color = color.blue, bgcolor = lgBg)
table.cell(legend, 3, 1, "entry price", text_size = size.tiny, text_color = lgTxt, bgcolor = lgBg, text_halign = text.align_left)
table.cell(legend, 0, 2, "▭", text_size = size.small, text_color = color.gray, bgcolor = lgBg)
table.cell(legend, 1, 2, "day skipped (range filter)", text_size = size.tiny, text_color = lgTxt, bgcolor = lgBg, text_halign = text.align_left)
table.cell(legend, 2, 2, "╌", text_size = size.small, text_color = color.red, bgcolor = lgBg)
table.cell(legend, 3, 2, "stop loss", text_size = size.tiny, text_color = lgTxt, bgcolor = lgBg, text_halign = text.align_left)
table.cell(legend, 0, 3, "▲", text_size = size.small, text_color = color.orange, bgcolor = lgBg)
table.cell(legend, 1, 3, "breakout close — wait for retest", text_size = size.tiny, text_color = lgTxt, bgcolor = lgBg, text_halign = text.align_left)
table.cell(legend, 2, 3, "╌", text_size = size.small, text_color = color.green, bgcolor = lgBg)
table.cell(legend, 3, 3, "take profit (3R)", text_size = size.tiny, text_color = lgTxt, bgcolor = lgBg, text_halign = text.align_left)
table.cell(legend, 0, 4, "▬", text_size = size.small, text_color = color.orange, bgcolor = lgBg)
table.cell(legend, 1, 4, "retest level = your entry", text_size = size.tiny, text_color = lgTxt, bgcolor = lgBg, text_halign = text.align_left)
table.cell(legend, 2, 4, "✕", text_size = size.small, text_color = color.green, bgcolor = lgBg)
table.cell(legend, 3, 4, "target hit (win)", text_size = size.tiny, text_color = lgTxt, bgcolor = lgBg, text_halign = text.align_left)
table.cell(legend, 0, 5, "E", text_size = size.small, text_color = color.green, bgcolor = lgBg)
table.cell(legend, 1, 5, "long entry filled", text_size = size.tiny, text_color = lgTxt, bgcolor = lgBg, text_halign = text.align_left)
table.cell(legend, 2, 5, "✕", text_size = size.small, text_color = color.red, bgcolor = lgBg)
table.cell(legend, 3, 5, "stop hit (−1R)", text_size = size.tiny, text_color = lgTxt, bgcolor = lgBg, text_halign = text.align_left)
table.cell(legend, 0, 6, "E", text_size = size.small, text_color = color.red, bgcolor = lgBg)
table.cell(legend, 1, 6, "short entry filled", text_size = size.tiny, text_color = lgTxt, bgcolor = lgBg, text_halign = text.align_left)
table.cell(legend, 2, 6, "● ■", text_size = size.small, text_color = color.gray, bgcolor = lgBg)
table.cell(legend, 3, 6, "invalidated / no retest — no trade", text_size = size.tiny, text_color = lgTxt, bgcolor = lgBg, text_halign = text.align_left)
// ───────────────────────── Alerts ─────────────────────────
alertcondition(sigBreakout, "ORB: breakout close", "Opening range broken on the close — watch for a retest")
alertcondition(sigEntry, "ORB: retest entry", "Retest reached — entry level touched")
alertcondition(sigTargetHit, "ORB: target hit", "Target reached")
alertcondition(sigStopHit, "ORB: stop hit", "Stop hit")
alertcondition(sigInvalidated, "ORB: setup invalid", "Price closed back inside the range — setup dead")
alertcondition(sigExpired, "ORB: no retest", "Retest window expired — no trade today") Indicator

Liquidity + Order Blocks Liquidity & Order Blocks [Pine Script
📌 Overview
Liquidity & Order Blocks is a price-action and Smart Money Concepts (SMC) style indicator designed to help traders visually identify important liquidity areas, liquidity sweeps, and potential order-block zones directly on the chart.
The indicator is designed primarily as a market-structure and price-action analysis tool. It does not guarantee profitable trades and should not be used as a standalone trading system.
---
🔹 What Does This Indicator Show?
1. Buy-Side Liquidity (BSL)
Buy-side liquidity is generally found above previous swing highs.
The indicator identifies swing highs and projects liquidity levels from them.
When price moves above a previous swing high and then closes back below that level, the indicator can identify it as a:
BSL Sweep — Buy-Side Liquidity Sweep
This can be useful when studying potential bearish reactions after liquidity has been taken.
---
2. Sell-Side Liquidity (SSL)
Sell-side liquidity is generally found below previous swing lows.
The indicator identifies swing lows and projects liquidity levels from them.
When price moves below a previous swing low and then closes back above that level, the indicator can identify it as:
SSL Sweep — Sell-Side Liquidity Sweep
This can be useful when studying potential bullish reactions after liquidity has been taken.
---
🔹 Order Blocks
The indicator automatically searches for potential order blocks following liquidity sweeps.
🟢 Bullish Order Block
A bullish order block is identified after a sell-side liquidity sweep when bullish price action appears.
The indicator searches backward for the most recent bearish candle and uses that candle's high/low as the potential bullish order-block zone.
🔴 Bearish Order Block
A bearish order block is identified after a buy-side liquidity sweep when bearish price action appears.
The indicator searches backward for the most recent bullish candle and uses that candle's high/low as the potential bearish order-block zone.
---
📚 How To Use It
A simple workflow is:
Step 1 — Identify the Market Structure
Start by looking at the overall trend and recent swing highs/lows.
Ask yourself:
- Is price making higher highs and higher lows?
- Is price making lower highs and lower lows?
- Where are the obvious swing points?
- Where might liquidity be resting?
Do not immediately enter a trade just because an order block appears.
---
Step 2 — Find Liquidity
Look for obvious:
Buy-side liquidity
- Previous swing highs
- Equal/near-equal highs
- Areas where traders may have placed stop orders
Sell-side liquidity
- Previous swing lows
- Equal/near-equal lows
- Areas where traders may have placed stop orders
---
Step 3 — Wait for the Sweep
Instead of chasing price into liquidity, watch how price reacts when the liquidity level is taken.
For example:
Price moves below a previous low → takes sell-side liquidity → closes back above the level.
This can indicate that the liquidity below the low has been taken.
The indicator marks this as an SSL Sweep.
---
Step 4 — Look for the Order Block
After a liquidity sweep, look for the corresponding order-block zone.
For a potential bullish setup:
SSL Sweep → Bullish reaction → Bullish Order Block
For a potential bearish setup:
BSL Sweep → Bearish reaction → Bearish Order Block
The order block should be treated as an area of interest, not an automatic entry.
---
Step 5 — Wait for Confirmation
Before entering a trade, consider additional confirmation such as:
- Market Structure Shift
- Break of Structure (BOS)
- Change of Character (CHoCH)
- Strong displacement
- Fair Value Gap (FVG)
- Retest of the order block
- Higher-timeframe direction
- Risk/reward conditions
The more confluence you have, the more selective your setup can become.
---
🎯 Example Bullish Setup
A simplified bullish sequence can look like:
Sell-Side Liquidity → SSL Sweep → Bullish Displacement → Bullish Order Block → Retest → Confirmation
Instead of buying immediately after the sweep, study whether price actually produces a meaningful bullish reaction.
---
🎯 Example Bearish Setup
A simplified bearish sequence can look like:
Buy-Side Liquidity → BSL Sweep → Bearish Displacement → Bearish Order Block → Retest → Confirmation
Again, the indicator is intended to help identify the area for further analysis rather than automatically telling you to sell.
---
⚙️ Important Settings
Swing Length
Controls how sensitive swing-high and swing-low detection is.
Lower value
- More swing points
- More liquidity levels
- More signals
- More noise
Higher value
- Fewer swing points
- Larger structural levels
- Less noise
- More selective analysis
Start with a moderate value and adjust it according to the market and timeframe.
---
Order Block Search Bars
Controls how far back the indicator searches for the candle used to create the potential order block.
A larger value allows the indicator to search farther back, but may also produce zones that are less relevant to the immediate price action.
---
Order Block Extension
Controls how far the order-block zone extends into the future.
---
Maximum Order Blocks
Controls the number of historical order-block zones displayed on the chart.
---
Remove Broken Order Blocks
When enabled, an order block can be removed after price invalidates it according to the indicator's rules.
---
📖 How To Learn Liquidity & Order Blocks
If you are new to this concept, don't try to memorize dozens of SMC terms at once.
Learn in this order:
1️⃣ Market Structure
Learn:
- Swing High
- Swing Low
- Higher High (HH)
- Higher Low (HL)
- Lower High (LH)
- Lower Low (LL)
2️⃣ Liquidity
Learn why liquidity can form around:
- Previous highs
- Previous lows
- Equal highs
- Equal lows
- Obvious support/resistance
3️⃣ Liquidity Sweeps
Study what happens when price trades beyond an obvious high/low and then reverses.
4️⃣ Displacement
Learn to recognize strong directional price movement following a liquidity event.
5️⃣ Order Blocks
Study the relationship between the final opposing candle, displacement, and subsequent price reaction.
6️⃣ Confluence
Finally, combine liquidity and order blocks with market structure, FVGs, higher-timeframe bias, and risk management.
⭐ Recommended Workflow
For a simple approach:
Higher-Timeframe Bias
↓
Identify Liquidity
↓
Wait for Liquidity Sweep
↓
Look for Displacement
↓
Identify Order Block
↓
Wait for Retest
↓
Look for Confirmation
↓
Manage Risk
The goal is not to take every signal.
The goal is to use the indicator to help you understand where liquidity may be located, what price does when that liquidity is taken, and where potential order-block zones may exist.
---
🔔 Alerts
The indicator includes alert conditions for:
- Buy-Side Liquidity Sweep
- Sell-Side Liquidity Sweep
- Bullish Order Block
- Bearish Order Block
You can create PulseWire alerts from these conditions and use them as notifications for further analysis.
---
Trade smart. Study the chart. Manage your risk. Indicator

Indicator

XAUUSD ICC SMC PRO 4H 15M 5MXAU/USD ICC + SMC Multi-Timeframe Indicator
The XAU/USD ICC + SMC Multi-Timeframe Indicator is designed to identify high-probability continuation setups by combining Indication, Correction and Continuation (ICC) with Supply & Demand, Liquidity Sweeps, CHoCH, BOS and multi-timeframe market structure.
The indicator follows a strict top-down process using 4H → 15M → 5M analysis.
4H – Indication and Supply/Demand
The 4-hour timeframe defines the main market direction and the institutional area of interest.
When price creates a confirmed Break of Structure (BOS), the indicator searches for the last opposite candle responsible for the displacement.
For a bullish structure, this area is marked as a 4H Demand Zone.
For a bearish structure, it is marked as a 4H Supply Zone.
The zone is automatically displayed as a rectangle and extended forward until price returns to it.
The 4H stage represents the INDICATION phase of the ICC model.
15M – Liquidity Sweep and CHoCH
Once price returns inside the 4H Supply or Demand zone, the indicator begins analyzing the 15-minute structure.
For a bullish setup, price must first take Sell-Side Liquidity below a previous 15M low and then close back above that level.
For a bearish setup, price must take Buy-Side Liquidity above a previous 15M high and close back below it.
A liquidity sweep alone is not considered an entry signal.
The indicator waits for a Change of Character (CHoCH) confirming that the short-term market structure is beginning to reverse.
The relationship between liquidity sweeps, displacement, CHoCH and BOS is similar to the structure shown in the example diagrams above.
15M – BOS Confirmation
After CHoCH, the system waits for another structural break in the same direction.
This second break is identified as the 15M BOS confirmation.
For a bullish setup:
Sell-Side Liquidity Sweep → Bullish CHoCH → Bullish BOS
For a bearish setup:
Buy-Side Liquidity Sweep → Bearish CHoCH → Bearish BOS
BOS is used primarily as a continuation confirmation, while CHoCH indicates a possible structural transition.
15M – Correction
After the BOS confirmation, the indicator waits for the market to retrace.
This retracement becomes the CORRECTION phase of the ICC model.
For a bullish setup, bearish 15-minute candles forming after the bullish BOS are monitored.
For a bearish setup, bullish candles forming after the bearish BOS are monitored.
The entire correction area is highlighted with an orange rectangle.
The indicator continuously tracks the highest and lowest points of the correction.
Correction Trendline
During the correction, the indicator automatically searches for swing points that allow it to build a correction trendline.
For a bullish setup, the correction normally creates a descending structure.
The indicator therefore draws a descending resistance trendline across the correction highs.
For a bearish setup, it draws an ascending support trendline across the correction lows.
The trendline is important because the indicator does not consider the correction finished simply because price touches an Order Block.
End of Correction
The correction ends only when price breaks the correction trendline in the direction of the original 4H setup.
Bullish sequence:
Correction → Descending Trendline → Bullish Trendline Break
Bearish sequence:
Correction → Ascending Trendline → Bearish Trendline Break
At this stage the indicator displays:
CORRECTION ENDED
TRENDLINE BREAK
CONTINUATION
This represents the transition from Correction → Continuation.
5M – Execution Zone
After the 15M continuation is confirmed, the indicator moves to the 5-minute execution logic.
For a bullish setup, it waits for a 5M bullish BOS and identifies the last bearish candle that created the displacement.
That candle becomes the new 5M Demand Zone.
For a bearish setup, the last bullish candle before the bearish displacement becomes the 5M Supply Zone.
Order Blocks combined with structural breaks are commonly visualized in this way, as shown in the example chart above.
The indicator then displays:
5M DEMAND – WAIT FOR RETEST
or
5M SUPPLY – WAIT FOR RETEST
Final BUY Signal
A BUY signal requires the complete sequence:
4H Bullish BOS
→ 4H Demand
→ Sell-Side Liquidity Sweep
→ 15M Bullish CHoCH
→ 15M Bullish BOS
→ 15M Correction
→ Correction Trendline Break
→ 5M Bullish BOS
→ 5M Demand
→ Demand Retest
→ Bullish Reaction
→ STRONG BUY
The indicator will not generate a BUY signal simply because price enters a Demand zone.
Final SELL Signal
The bearish process is the exact opposite:
4H Bearish BOS
→ 4H Supply
→ Buy-Side Liquidity Sweep
→ 15M Bearish CHoCH
→ 15M Bearish BOS
→ 15M Correction
→ Correction Trendline Break
→ 5M Bearish BOS
→ 5M Supply
→ Supply Retest
→ Bearish Reaction
→ STRONG SELL
Visual Color Guide
Green rectangle: 4H/5M Demand Zone
Red rectangle: 4H/5M Supply Zone
Yellow label: Liquidity Sweep
Aqua label: CHoCH
Blue label: BOS
Orange rectangle: Correction
Green/Red trendline: Correction structure
Large green label: STRONG BUY
Large red label: STRONG SELL
ICC Logic
The complete model can therefore be summarized as:
INDICATION
4H BOS + Supply/Demand
↓
CORRECTION PREPARATION
Liquidity Sweep + CHoCH + 15M BOS
↓
CORRECTION
15M retracement + correction trendline
↓
CONTINUATION
Trendline Break + 5M BOS + Demand/Supply retest
↓
EXECUTION
STRONG BUY or STRONG SELL
This structure is intentionally strict. Its purpose is to filter out ordinary Order Block touches and wait for liquidity manipulation, structural confirmation, correction and continuation before displaying the final trading signal.
Instant
Indicator

Indicator

MTF Daily Bias DashboardOverview
The "MTF Daily Bias Dashboard" is a streamlined, non-intrusive utility designed specifically for Smart Money Concepts (SMC) and Inner Circle Trader (ICT) methodologies. Multi-timeframe analysis is the backbone of finding high-probability setups, but constantly switching between charts to check the higher-timeframe narrative can lead to missed lower-timeframe entries.
This indicator solves that problem by providing a clean, customizable on-chart dashboard that displays real-time, objective market bias across three different timeframes simultaneously.
Core Features
Objective Bias Detection: Bias is determined mechanically using a customizable Exponential Moving Average (EMA) and price action closes, removing emotion and guesswork from your directional bias.
Multi-Timeframe Synchronization: By default, it tracks the Daily (1D), 4-Hour (4H), and 15-Minute (15m) timeframes, giving you a complete top-down narrative at a glance.
Non-Repainting Logic: The multi-timeframe data is pulled securely, ensuring that historical signals remain accurate and current data does not repaint past the current candle formation.
Dynamic Visual Dashboard: A color-coded table (Green for Bullish, Red for Bearish) provides immediate visual confirmation of market alignment.
How It Works
The indicator evaluates the current price action against your chosen baseline (EMA).
Bullish (Green):Price closes above the EMA, and the current candle closes higher than the previous candle.
Bearish (Red): Price closes below the EMA, and the current candle closes lower than the previous candle.
Confluence: When all three timeframes show the same color, you have high-probability directional alignment, perfect for looking for lower-timeframe sweeps, order blocks, or fair value gaps in the direction of the trend.
Customization & Settings
Timeframes: Fully adjustable inputs allow you to change the three monitored timeframes to fit your specific trading model (e.g., Weekly/Daily/1H or 4H/1H/5m).
Dashboard Positioning: You can move the dashboard to any corner of your chart to ensure it never obstructs current price action.
Trend Logic: Adjust the EMA length used to calculate the bias to make the indicator more or less sensitive to recent price action.
Who is this for?
This tool is ideal for SMC, ICT, and pure price action traders who rely on the daily narrative but execute on intraday timeframes. It keeps you aligned with the macro trend while you focus on micro executions. Indicator

Indicator

Indicator

Indicator

2.0- Killzones EUR/GBP - Manuel De Jesus Leiva// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// © tradeforopp
//@version=6
indicator("Killzones EUR/GBP - Manuel De Jesus Leiva", "Killzones EUR/GBP - Manuel De Jesus Leiva", true, max_labels_count = 500, max_lines_count = 500, max_boxes_count = 500)
// ---------------------------------------- Constant Functions --------------------------------------------------
get_line_type(_style) =>
switch _style
"Solid" => line.style_solid
"Dotted" => line.style_dotted
"Dashed" => line.style_dashed
get_size(x) =>
switch x
"Auto" => size.auto
"Tiny" => size.tiny
"Small" => size.small
"Normal" => size.normal
"Large" => size.large
"Huge" => size.huge
get_table_pos(pos) =>
switch pos
"Bottom Center" => position.bottom_center
"Bottom Left" => position.bottom_left
"Bottom Right" => position.bottom_right
"Middle Center" => position.middle_center
"Middle Left" => position.middle_left
"Middle Right" => position.middle_right
"Top Center" => position.top_center
"Top Left" => position.top_left
"Top Right" => position.top_right
// ---------------------------------------- Constant Functions --------------------------------------------------
// ---------------------------------------- Inputs --------------------------------------------------
var g_SETTINGS = "Settings"
max_days = input.int(1000, "Session Drawing Limit", 1, tooltip = "Only this many drawings will be kept on the chart, for each selected drawing type (killzone boxes, pivot lines, open lines, etc.). Set to 200 for ~6 months of sessions.", group = g_SETTINGS)
tf_limit = input.timeframe("60", "Timeframe Limit", tooltip = "Drawings will not appear on timeframes greater than or equal to this", group = g_SETTINGS)
gmt_tz = input.string('America/New_York', "Timezone", options = , tooltip = "Note GMT is not adjusted to reflect Daylight Saving Time changes", group = g_SETTINGS)
lbl_size = get_size(input.string('Normal', "Label Size", options = , tooltip = "The size of all labels", group = g_SETTINGS))
txt_color = input.color(color.black, "Text Color", tooltip = "The color of all label and table text", group = g_SETTINGS)
use_cutoff = input.bool(false, "Drawing Cutoff Time", inline = "CO", tooltip = "When enabled, all pivots and open price lines will stop extending at this time", group = g_SETTINGS)
cutoff = input.session("1800-1801", "", inline = "CO", group = g_SETTINGS)
var tf_limit_is_equal_or_more_chart_tf = timeframe.in_seconds('') <= timeframe.in_seconds(tf_limit)
var g_KZ = "Killzones"
// General Killzone Settings
show_kz = input.bool(true, "Show Killzone Boxes", inline = "KZ", group = g_KZ)
show_kz_text = input.bool(false, "Display Text", inline = "KZ", group = g_KZ)
box_transparency = input.int(70, "Box Transparency", 0, 100, group = g_KZ)
text_transparency = input.int(50, "Text Transparency", 0, 100, group = g_KZ)
// ==================== KILLZONE 01 ====================
use_kz01 = input.bool(true, "00:00-01:00", inline = "KZ01", group = g_KZ)
kz01_txt = input.string("00-01", "", inline = "KZ01", group = g_KZ)
kz01 = input.session("0000-0100", "", inline = "KZ01", group = g_KZ)
kz01_color = input.color(color.blue, "", inline = "KZ01", group = g_KZ)
// ==================== KILLZONE 02 ====================
use_kz02 = input.bool(true, "01:00-02:00", inline = "KZ02", group = g_KZ)
kz02_txt = input.string("01-02", "", inline = "KZ02", group = g_KZ)
kz02 = input.session("0100-0200", "", inline = "KZ02", group = g_KZ)
kz02_color = input.color(color.blue, "", inline = "KZ02", group = g_KZ)
// ==================== KILLZONE 03 ====================
use_kz03 = input.bool(true, "02:00-03:00", inline = "KZ03", group = g_KZ)
kz03_txt = input.string("02-03", "", inline = "KZ03", group = g_KZ)
kz03 = input.session("0200-0300", "", inline = "KZ03", group = g_KZ)
kz03_color = input.color(color.blue, "", inline = "KZ03", group = g_KZ)
// ==================== KILLZONE 04 ====================
use_kz04 = input.bool(true, "03:00-04:00", inline = "KZ04", group = g_KZ)
kz04_txt = input.string("03-04", "", inline = "KZ04", group = g_KZ)
kz04 = input.session("0300-0400", "", inline = "KZ04", group = g_KZ)
kz04_color = input.color(color.blue, "", inline = "KZ04", group = g_KZ)
// ==================== KILLZONE 05 ====================
use_kz05 = input.bool(true, "04:00-05:00", inline = "KZ05", group = g_KZ)
kz05_txt = input.string("04-05", "", inline = "KZ05", group = g_KZ)
kz05 = input.session("0400-0500", "", inline = "KZ05", group = g_KZ)
kz05_color = input.color(color.blue, "", inline = "KZ05", group = g_KZ)
// ==================== KILLZONE 06 ====================
use_kz06 = input.bool(true, "05:00-06:00", inline = "KZ06", group = g_KZ)
kz06_txt = input.string("05-06", "", inline = "KZ06", group = g_KZ)
kz06 = input.session("0500-0600", "", inline = "KZ06", group = g_KZ)
kz06_color = input.color(color.blue, "", inline = "KZ06", group = g_KZ)
// ==================== KILLZONE 07 ====================
use_kz07 = input.bool(true, "06:00-07:00", inline = "KZ07", group = g_KZ)
kz07_txt = input.string("06-07", "", inline = "KZ07", group = g_KZ)
kz07 = input.session("0600-0700", "", inline = "KZ07", group = g_KZ)
kz07_color = input.color(color.blue, "", inline = "KZ07", group = g_KZ)
// ==================== KILLZONE 08 ====================
use_kz08 = input.bool(true, "07:00-08:00", inline = "KZ08", group = g_KZ)
kz08_txt = input.string("07-08", "", inline = "KZ08", group = g_KZ)
kz08 = input.session("0700-0800", "", inline = "KZ08", group = g_KZ)
kz08_color = input.color(color.blue, "", inline = "KZ08", group = g_KZ)
// ==================== KILLZONE 09 ====================
use_kz09 = input.bool(true, "08:00-09:00", inline = "KZ09", group = g_KZ)
kz09_txt = input.string("08-09", "", inline = "KZ09", group = g_KZ)
kz09 = input.session("0800-0900", "", inline = "KZ09", group = g_KZ)
kz09_color = input.color(color.blue, "", inline = "KZ09", group = g_KZ)
// ==================== KILLZONE 10 ====================
use_kz10 = input.bool(true, "09:00-10:00", inline = "KZ10", group = g_KZ)
kz10_txt = input.string("09-10", "", inline = "KZ10", group = g_KZ)
kz10 = input.session("0900-1000", "", inline = "KZ10", group = g_KZ)
kz10_color = input.color(color.blue, "", inline = "KZ10", group = g_KZ)
// ==================== KILLZONE 11 ====================
use_kz11 = input.bool(true, "10:00-11:00", inline = "KZ11", group = g_KZ)
kz11_txt = input.string("10-11", "", inline = "KZ11", group = g_KZ)
kz11 = input.session("1000-1100", "", inline = "KZ11", group = g_KZ)
kz11_color = input.color(color.blue, "", inline = "KZ11", group = g_KZ)
// ==================== KILLZONE 12 ====================
use_kz12 = input.bool(true, "11:00-12:00", inline = "KZ12", group = g_KZ)
kz12_txt = input.string("11-12", "", inline = "KZ12", group = g_KZ)
kz12 = input.session("1100-1200", "", inline = "KZ12", group = g_KZ)
kz12_color = input.color(color.blue, "", inline = "KZ12", group = g_KZ)
// ==================== KILLZONE 13 ====================
use_kz13 = input.bool(true, "12:00-13:00", inline = "KZ13", group = g_KZ)
kz13_txt = input.string("12-13", "", inline = "KZ13", group = g_KZ)
kz13 = input.session("1200-1300", "", inline = "KZ13", group = g_KZ)
kz13_color = input.color(color.blue, "", inline = "KZ13", group = g_KZ)
// ==================== KILLZONE 14 ====================
use_kz14 = input.bool(true, "13:00-14:00", inline = "KZ14", group = g_KZ)
kz14_txt = input.string("13-14", "", inline = "KZ14", group = g_KZ)
kz14 = input.session("1300-1400", "", inline = "KZ14", group = g_KZ)
kz14_color = input.color(color.blue, "", inline = "KZ14", group = g_KZ)
// ==================== KILLZONE 15 ====================
use_kz15 = input.bool(true, "14:00-15:00", inline = "KZ15", group = g_KZ)
kz15_txt = input.string("14-15", "", inline = "KZ15", group = g_KZ)
kz15 = input.session("1400-1500", "", inline = "KZ15", group = g_KZ)
kz15_color = input.color(color.blue, "", inline = "KZ15", group = g_KZ)
// ==================== KILLZONE 16 ====================
use_kz16 = input.bool(true, "15:00-16:00", inline = "KZ16", group = g_KZ)
kz16_txt = input.string("15-16", "", inline = "KZ16", group = g_KZ)
kz16 = input.session("1500-1600", "", inline = "KZ16", group = g_KZ)
kz16_color = input.color(color.blue, "", inline = "KZ16", group = g_KZ)
// ==================== KILLZONE 17 ====================
use_kz17 = input.bool(true, "16:00-17:00", inline = "KZ17", group = g_KZ)
kz17_txt = input.string("16-17", "", inline = "KZ17", group = g_KZ)
kz17 = input.session("1600-1700", "", inline = "KZ17", group = g_KZ)
kz17_color = input.color(color.blue, "", inline = "KZ17", group = g_KZ)
// ==================== KILLZONE 18 ====================
use_kz18 = input.bool(true, "17:00-18:00", inline = "KZ18", group = g_KZ)
kz18_txt = input.string("17-18", "", inline = "KZ18", group = g_KZ)
kz18 = input.session("1700-1800", "", inline = "KZ18", group = g_KZ)
kz18_color = input.color(color.blue, "", inline = "KZ18", group = g_KZ)
// ==================== KILLZONE 19 ====================
use_kz19 = input.bool(true, "18:00-19:00", inline = "KZ19", group = g_KZ)
kz19_txt = input.string("18-19", "", inline = "KZ19", group = g_KZ)
kz19 = input.session("1800-1900", "", inline = "KZ19", group = g_KZ)
kz19_color = input.color(color.blue, "", inline = "KZ19", group = g_KZ)
// ==================== KILLZONE 20 ====================
use_kz20 = input.bool(true, "19:00-20:00", inline = "KZ20", group = g_KZ)
kz20_txt = input.string("19-20", "", inline = "KZ20", group = g_KZ)
kz20 = input.session("1900-2000", "", inline = "KZ20", group = g_KZ)
kz20_color = input.color(color.blue, "", inline = "KZ20", group = g_KZ)
// ==================== KILLZONE 21 ====================
use_kz21 = input.bool(true, "20:00-21:00", inline = "KZ21", group = g_KZ)
kz21_txt = input.string("20-21", "", inline = "KZ21", group = g_KZ)
kz21 = input.session("2000-2100", "", inline = "KZ21", group = g_KZ)
kz21_color = input.color(color.blue, "", inline = "KZ21", group = g_KZ)
// ==================== KILLZONE 22 ====================
use_kz22 = input.bool(true, "21:00-22:00", inline = "KZ22", group = g_KZ)
kz22_txt = input.string("21-22", "", inline = "KZ22", group = g_KZ)
kz22 = input.session("2100-2200", "", inline = "KZ22", group = g_KZ)
kz22_color = input.color(color.blue, "", inline = "KZ22", group = g_KZ)
// ==================== KILLZONE 23 ====================
use_kz23 = input.bool(true, "22:00-23:00", inline = "KZ23", group = g_KZ)
kz23_txt = input.string("22-23", "", inline = "KZ23", group = g_KZ)
kz23 = input.session("2200-2300", "", inline = "KZ23", group = g_KZ)
kz23_color = input.color(color.blue, "", inline = "KZ23", group = g_KZ)
// ==================== KILLZONE 24 ====================
use_kz24 = input.bool(true, "23:00-00:00", inline = "KZ24", group = g_KZ)
kz24_txt = input.string("23-00", "", inline = "KZ24", group = g_KZ)
kz24 = input.session("2300-0000", "", inline = "KZ24", group = g_KZ)
kz24_color = input.color(color.blue, "", inline = "KZ24", group = g_KZ)
// ==================== KILLZONE 25 ====================
use_kz25 = input.bool(true, "17:00-21:00", inline = "KZ25", group = g_KZ)
kz25_txt = input.string("H4", "", inline = "KZ25", group = g_KZ)
kz25 = input.session("1700-2100", "", inline = "KZ25", group = g_KZ)
kz25_color = input.color(color.orange, "", inline = "KZ25", group = g_KZ)
// ==================== KILLZONE 26 ====================
use_kz26 = input.bool(true, "21:00-01:00", inline = "KZ26", group = g_KZ)
kz26_txt = input.string("H4", "", inline = "KZ26", group = g_KZ)
kz26 = input.session("2100-0100", "", inline = "KZ26", group = g_KZ)
kz26_color = input.color(color.aqua, "", inline = "KZ26", group = g_KZ)
// ==================== KILLZONE 27 ====================
use_kz27 = input.bool(true, "01:00-05:00", inline = "KZ27", group = g_KZ)
kz27_txt = input.string("H4", "", inline = "KZ27", group = g_KZ)
kz27 = input.session("0100-0500", "", inline = "KZ27", group = g_KZ)
kz27_color = input.color(color.green, "", inline = "KZ27", group = g_KZ)
// ==================== KILLZONE 28 ====================
use_kz28 = input.bool(true, "05:00-09:00", inline = "KZ28", group = g_KZ)
kz28_txt = input.string("H4", "", inline = "KZ28", group = g_KZ)
kz28 = input.session("0500-0900", "", inline = "KZ28", group = g_KZ)
kz28_color = input.color(color.yellow, "", inline = "KZ28", group = g_KZ)
// ==================== KILLZONE 29 ====================
use_kz29 = input.bool(true, "09:00-13:00", inline = "KZ29", group = g_KZ)
kz29_txt = input.string("H4", "", inline = "KZ29", group = g_KZ)
kz29 = input.session("0900-1300", "", inline = "KZ29", group = g_KZ)
kz29_color = input.color(color.red, "", inline = "KZ29", group = g_KZ)
// ==================== KILLZONE 30 ====================
use_kz30 = input.bool(true, "13:00-17:00", inline = "KZ30", group = g_KZ)
kz30_txt = input.string("H4", "", inline = "KZ30", group = g_KZ)
kz30 = input.session("1300-1700", "", inline = "KZ30", group = g_KZ)
kz30_color = input.color(color.purple, "", inline = "KZ30", group = g_KZ)
// ==================== KILLZONE 31 ====================
use_kz31 = input.bool(false, "05:00-17:00", inline = "KZ31", group = g_KZ)
kz31_txt = input.string("H12", "", inline = "KZ31", group = g_KZ)
kz31 = input.session("0500-1700", "", inline = "KZ31", group = g_KZ)
kz31_color = input.color(color.purple, "", inline = "KZ31", group = g_KZ)
// ==================== KILLZONE 32 ====================
use_kz32 = input.bool(false, "17:00-05:00", inline = "KZ32", group = g_KZ)
kz32_txt = input.string("H12", "", inline = "KZ32", group = g_KZ)
kz32 = input.session("1700-0500", "", inline = "KZ32", group = g_KZ)
kz32_color = input.color(color.purple, "", inline = "KZ32", group = g_KZ)
// ==================== KILLZONE 33 ====================
use_kz33 = input.bool(false, "17:00-01:00", inline = "KZ33", group = g_KZ)
kz33_txt = input.string("H8", "", inline = "KZ33", group = g_KZ)
kz33 = input.session("1700-0100", "", inline = "KZ33", group = g_KZ)
kz33_color = input.color(color.purple, "", inline = "KZ33", group = g_KZ)
// ==================== KILLZONE 34 ====================
use_kz34 = input.bool(false, "01:00-09:00", inline = "KZ34", group = g_KZ)
kz34_txt = input.string("H8", "", inline = "KZ34", group = g_KZ)
kz34 = input.session("0100-0900", "", inline = "KZ34", group = g_KZ)
kz34_color = input.color(color.purple, "", inline = "KZ34", group = g_KZ)
// ==================== KILLZONE 35 ====================
use_kz35 = input.bool(false, "09:00-17:00", inline = "KZ35", group = g_KZ)
kz35_txt = input.string("H8", "", inline = "KZ35", group = g_KZ)
kz35 = input.session("0900-1700", "", inline = "KZ35", group = g_KZ)
kz35_color = input.color(color.purple, "", inline = "KZ35", group = g_KZ)
// ==================== KILLZONE 36 ====================
use_kz36 = input.bool(false, "17:00-23:00", inline = "KZ36", group = g_KZ)
kz36_txt = input.string("H6", "", inline = "KZ36", group = g_KZ)
kz36 = input.session("1700-2300", "", inline = "KZ36", group = g_KZ)
kz36_color = input.color(color.purple, "", inline = "KZ36", group = g_KZ)
// ==================== KILLZONE 37 ====================
use_kz37 = input.bool(false, "23:00-05:00", inline = "KZ37", group = g_KZ)
kz37_txt = input.string("H6", "", inline = "KZ37", group = g_KZ)
kz37 = input.session("2300-0500", "", inline = "KZ37", group = g_KZ)
kz37_color = input.color(color.purple, "", inline = "KZ37", group = g_KZ)
// ==================== KILLZONE 38 ====================
use_kz38 = input.bool(false, "05:00-11:00", inline = "KZ38", group = g_KZ)
kz38_txt = input.string("H6", "", inline = "KZ38", group = g_KZ)
kz38 = input.session("0500-1100", "", inline = "KZ38", group = g_KZ)
kz38_color = input.color(color.purple, "", inline = "KZ38", group = g_KZ)
// ==================== KILLZONE 39 ====================
use_kz39 = input.bool(false, "11:00-17:00", inline = "KZ39", group = g_KZ)
kz39_txt = input.string("H6", "", inline = "KZ39", group = g_KZ)
kz39 = input.session("1100-1700", "", inline = "KZ39", group = g_KZ)
kz39_color = input.color(color.purple, "", inline = "KZ39", group = g_KZ)
var g_LABELS = "Killzone Pivots"
show_pivots = input.bool(false, "Show Pivots", inline = "PV", group = g_LABELS)
use_alerts = input.bool(false, "Alert Broken Pivots", inline = "PV", tooltip = "The desired killzones must be enabled at the time that an alert is created, along with the show pivots option, in order for alerts to work", group = g_LABELS)
show_midpoints = input.bool(false, "Show Pivot Midpoints", inline = "mp", group = g_LABELS)
stop_midpoints = input.bool(false, "Stop Once Mitigated", inline = "mp", group = g_LABELS)
show_labels = input.bool(false, "Show Pivot Labels", inline = "LB", tooltip = "Show labels denoting each killzone's high and low. Optionally choose to show the price of each level. Right side will show labels on the right-hand side of the chart until they are reached", group = g_LABELS)
label_price = input.bool(false, "Display Price", inline = "LB", group = g_LABELS)
label_right = input.bool(false, "Right Side", inline = "LB", group = g_LABELS)
ext_pivots = input.string("Until Mitigated", "Extend Pivots...", options = , group = g_LABELS)
ext_which = input.string("All", "...From Which Sessions", options = , group = g_LABELS)
ash_str = input.string("AS.H", "Killzone 1 Labels", inline = "L_AS", group = g_LABELS)
asl_str = input.string("AS.L", "", inline = "L_AS", group = g_LABELS)
loh_str = input.string("LO.H", "Killzone 2 Labels", inline = "L_LO", group = g_LABELS)
lol_str = input.string("LO.L", "", inline = "L_LO", group = g_LABELS)
nah_str = input.string("NYAM.H", "Killzone 3 Labels", inline = "L_NA", group = g_LABELS)
nal_str = input.string("NYAM.L", "", inline = "L_NA", group = g_LABELS)
nlh_str = input.string("NYL.H", "Killzone 4 Labels", inline = "L_NL", group = g_LABELS)
nll_str = input.string("NYL.L", "", inline = "L_NL", group = g_LABELS)
nph_str = input.string("NYPM.H", "Killzone 5 Labels", inline = "L_NP", group = g_LABELS)
npl_str = input.string("NYPM.L", "", inline = "L_NP", group = g_LABELS)
kzp_style = get_line_type(input.string(defval = 'Solid', title = "Pivot Style", options = , inline = "KZP", group = g_LABELS))
kzp_width = input.int(1, "", inline = "KZP", group = g_LABELS)
kzm_style = get_line_type(input.string(defval = 'Dotted', title = "Midpoint Style", options = , inline = "KZM", group = g_LABELS))
kzm_width = input.int(1, "", inline = "KZM", group = g_LABELS)
var g_RNG = "Killzone Range"
show_range = input.bool(false, "Show Killzone Range", tooltip = "Show the most recent ranges of each selected killzone, from high to low", group = g_RNG)
show_range_avg = input.bool(false, "Show Average", tooltip = "Show the average range of each selected killzone", group = g_RNG)
range_avg = input.int(5, "Average Length", 0, tooltip = "This many previous sessions will be used to calculate the average. If there isn't enough data on the current chart, it will use as many sessions as possible", group = g_RNG)
range_pos = get_table_pos(input.string('Top Right', "Table Position", options = , group = g_RNG))
range_size = get_size(input.string('Normal', "Table Size", options = , group = g_RNG))
var g_DWM = "Day - Week - Month"
sep_unlimited = input.bool(false, "Unlimited", tooltip = "Unlimited will show as many of the selected lines as possible. Otherwise, the session drawing limit will be used", group = g_DWM)
alert_HL = input.bool(false, "Alert High/Low Break", tooltip = "Alert when any selected highs and lows are traded through. The desired timeframe's high/low option must be enabled at the time that an alert is created", group = g_DWM)
show_d_open = input.bool(false, "D Open", inline = "DO", group = g_DWM)
dhl = input.bool(false, "High/Low", inline = "DO", tooltip = "", group = g_DWM)
ds = input.bool(false, "Separators", inline = "DO", tooltip = "Mark where a new day begins", group = g_DWM)
d_color = input.color(color.blue, "", inline = "DO", group = g_DWM)
show_w_open = input.bool(false, "W Open", inline = "WO", group = g_DWM)
whl = input.bool(false, "High/Low", inline = "WO", tooltip = "", group = g_DWM)
ws = input.bool(false, "Separators", inline = "WO", tooltip = "Mark where a new week begins", group = g_DWM)
w_color = input.color(#089981, "", inline = "WO", group = g_DWM)
show_m_open = input.bool(false, "M Open", inline = "MO", group = g_DWM)
mhl = input.bool(false, "High/Low", inline = "MO", tooltip = "", group = g_DWM)
ms = input.bool(false, "Separators", inline = "MO", tooltip = "Mark where a new month begins", group = g_DWM)
m_color = input.color(color.red, "", inline = "MO", group = g_DWM)
htf_style = get_line_type(input.string(defval = 'Solid', title = "Style", options = , inline = "D0", group = g_DWM))
htf_width = input.int(1, "", inline = "D0", group = g_DWM)
dow_labels = input.bool(false, "Day of Week Labels", inline = "DOW", group = g_DWM)
dow_yloc = input.string('Bottom', "", options = , inline = "DOW", group = g_DWM)
dow_xloc = input.string('Midnight', "", options = , inline = "DOW", group = g_DWM)
dow_hide_wknd = input.bool(false, "Hide Weekend Labels", group = g_DWM)
var g_OPEN = "Opening Prices"
open_unlimited = input.bool(false, "Unlimited", tooltip = "Unlimited will show as many of the selected lines as possible. Otherwise, the session drawing limit will be used", group = g_OPEN)
use_h1 = input.bool(false, "", inline = "H1", group = g_OPEN)
h1_text = input.string("17:00 H12/H8/H6/H4", "", inline = "H1", group = g_OPEN)
h1 = input.session("1700-1701", "", inline = "H1", group = g_OPEN)
h1_color = input.color(color.black, "", inline = "H1", group = g_OPEN)
use_h2 = input.bool(false, "", inline = "H2", group = g_OPEN)
h2_text = input.string("05:00 H12/H6/H4", "", inline = "H2", group = g_OPEN)
h2 = input.session("0500-0501", "", inline = "H2", group = g_OPEN)
h2_color = input.color(color.black, "", inline = "H2", group = g_OPEN)
use_h3 = input.bool(false, "", inline = "H3", group = g_OPEN)
h3_text = input.string("01:00 H8/H4", "", inline = "H3", group = g_OPEN)
h3 = input.session("0100-0101", "", inline = "H3", group = g_OPEN)
h3_color = input.color(color.black, "", inline = "H3", group = g_OPEN)
use_h4 = input.bool(false, "", inline = "H4", group = g_OPEN)
h4_text = input.string("09:00 H8/H4", "", inline = "H4", group = g_OPEN)
h4 = input.session("0900-0901", "", inline = "H4", group = g_OPEN)
h4_color = input.color(color.black, "", inline = "H4", group = g_OPEN)
use_h5 = input.bool(false, "", inline = "H5", group = g_OPEN)
h5_text = input.string("23:00 H6", "", inline = "H5", group = g_OPEN)
h5 = input.session("2300-2301", "", inline = "H5", group = g_OPEN)
h5_color = input.color(color.black, "", inline = "H5", group = g_OPEN)
use_h6 = input.bool(false, "", inline = "H6", group = g_OPEN)
h6_text = input.string("11:00 H6", "", inline = "H6", group = g_OPEN)
h6 = input.session("1100-1101", "", inline = "H6", group = g_OPEN)
h6_color = input.color(color.black, "", inline = "H6", group = g_OPEN)
use_h7 = input.bool(false, "", inline = "H7", group = g_OPEN)
h7_text = input.string("21:00 H4", "", inline = "H7", group = g_OPEN)
h7 = input.session("2100-2101", "", inline = "H7", group = g_OPEN)
h7_color = input.color(color.black, "", inline = "H7", group = g_OPEN)
use_h8 = input.bool(false, "", inline = "H8", group = g_OPEN)
h8_text = input.string("13:00 H4", "", inline = "H8", group = g_OPEN)
h8 = input.session("1300-1301", "", inline = "H8", group = g_OPEN)
h8_color = input.color(color.black, "", inline = "H8", group = g_OPEN)
hz_style = get_line_type(input.string(defval = 'Dotted', title = "Style", options = , inline = "H0", group = g_OPEN))
hz_width = input.int(1, "", inline = "H0", group = g_OPEN)
var g_VERTICAL = "Timestamps"
v_unlimited = input.bool(false, "Unlimited", tooltip = "Unlimited will show as many of the selected lines as possible. Otherwise, the session drawing limit will be used", group = g_VERTICAL)
use_v1 = input.bool(false, "", inline = "V1", group = g_VERTICAL)
v1 = input.session("0000-0001", "", inline = "V1", group = g_VERTICAL)
v1_color = input.color(color.black, "", inline = "V1", group = g_VERTICAL)
use_v2 = input.bool(false, "", inline = "V2", group = g_VERTICAL)
v2 = input.session("0800-0801", "", inline = "V2", group = g_VERTICAL)
v2_color = input.color(color.black, "", inline = "V2", group = g_VERTICAL)
use_v3 = input.bool(false, "", inline = "V3", group = g_VERTICAL)
v3 = input.session("1000-1001", "", inline = "V3", group = g_VERTICAL)
v3_color = input.color(color.black, "", inline = "V3", group = g_VERTICAL)
use_v4 = input.bool(false, "", inline = "V4", group = g_VERTICAL)
v4 = input.session("1200-1201", "", inline = "V4", group = g_VERTICAL)
v4_color = input.color(color.black, "", inline = "V4", group = g_VERTICAL)
vl_style = get_line_type(input.string(defval = 'Dotted', title = "Style", options = , inline = "V0", group = g_VERTICAL))
vl_width = input.int(1, "", inline = "V0", group = g_VERTICAL)
// ---------------------------------------- Inputs --------------------------------------------------
// ---------------------------------------- Variables & Constants --------------------------------------------------
type kz
string _title
array _box
array _hi_line
array _md_line
array _lo_line
array _hi_label
array _lo_label
array _hi_valid
array _md_valid
array _lo_valid
array _range_store
float _range_current
type hz
array LN
array LB
array CO
type dwm_hl
array hi_line
array lo_line
array hi_label
array lo_label
bool hit_high = false
bool hit_low = false
type dwm_info
string tf
float o = na
float h = na
float l = na
float ph = na
float pl = na
type lines_helper
hz _hz
string h
string h_text
color h_color
initLines() =>
array res = array.new()
if use_h1
res.push(lines_helper.new(hz.new(array.new_line(), array.new_label(), array.new_bool()), h1, h1_text, h1_color))
if use_h2
res.push(lines_helper.new(hz.new(array.new_line(), array.new_label(), array.new_bool()), h2, h2_text, h2_color))
if use_h3
res.push(lines_helper.new(hz.new(array.new_line(), array.new_label(), array.new_bool()), h3, h3_text, h3_color))
if use_h4
res.push(lines_helper.new(hz.new(array.new_line(), array.new_label(), array.new_bool()), h4, h4_text, h4_color))
if use_h5
res.push(lines_helper.new(hz.new(array.new_line(), array.new_label(), array.new_bool()), h5, h5_text, h5_color))
if use_h6
res.push(lines_helper.new(hz.new(array.new_line(), array.new_label(), array.new_bool()), h6, h6_text, h6_color))
if use_h7
res.push(lines_helper.new(hz.new(array.new_line(), array.new_label(), array.new_bool()), h7, h7_text, h7_color))
if use_h8
res.push(lines_helper.new(hz.new(array.new_line(), array.new_label(), array.new_bool()), h8, h8_text, h8_color))
res
var array lines = initLines()
type kz_helper
kz _kz
string session
color c
string box_txt
string hi_txt
string lo_txt
initKZ() =>
array res = array.new()
if use_kz01
res.push(kz_helper.new(
kz.new(kz01_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz01, kz01_color, kz01_txt, "KZ01.H", "KZ01.L"
))
if use_kz02
res.push(kz_helper.new(
kz.new(kz02_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz02, kz02_color, kz02_txt, "KZ02.H", "KZ02.L"
))
if use_kz03
res.push(kz_helper.new(
kz.new(kz03_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz03, kz03_color, kz03_txt, "KZ03.H", "KZ03.L"
))
if use_kz04
res.push(kz_helper.new(
kz.new(kz04_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz04, kz04_color, kz04_txt, "KZ04.H", "KZ04.L"
))
if use_kz05
res.push(kz_helper.new(
kz.new(kz05_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz05, kz05_color, kz05_txt, "KZ05.H", "KZ05.L"
))
if use_kz06
res.push(kz_helper.new(
kz.new(kz06_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz06, kz06_color, kz06_txt, "KZ06.H", "KZ06.L"
))
if use_kz07
res.push(kz_helper.new(
kz.new(kz07_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz07, kz07_color, kz07_txt, "KZ07.H", "KZ07.L"
))
if use_kz08
res.push(kz_helper.new(
kz.new(kz08_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz08, kz08_color, kz08_txt, "KZ08.H", "KZ08.L"
))
if use_kz09
res.push(kz_helper.new(
kz.new(kz09_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz09, kz09_color, kz09_txt, "KZ09.H", "KZ09.L"
))
if use_kz10
res.push(kz_helper.new(
kz.new(kz10_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz10, kz10_color, kz10_txt, "KZ10.H", "KZ10.L"
))
if use_kz11
res.push(kz_helper.new(
kz.new(kz11_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz11, kz11_color, kz11_txt, "KZ11.H", "KZ11.L"
))
if use_kz12
res.push(kz_helper.new(
kz.new(kz12_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz12, kz12_color, kz12_txt, "KZ12.H", "KZ12.L"
))
if use_kz13
res.push(kz_helper.new(
kz.new(kz13_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz13, kz13_color, kz13_txt, "KZ13.H", "KZ13.L"
))
if use_kz14
res.push(kz_helper.new(
kz.new(kz14_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz14, kz14_color, kz14_txt, "KZ14.H", "KZ14.L"
))
if use_kz15
res.push(kz_helper.new(
kz.new(kz15_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz15, kz15_color, kz15_txt, "KZ15.H", "KZ15.L"
))
if use_kz16
res.push(kz_helper.new(
kz.new(kz16_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz16, kz16_color, kz16_txt, "KZ16.H", "KZ16.L"
))
if use_kz17
res.push(kz_helper.new(
kz.new(kz17_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz17, kz17_color, kz17_txt, "KZ17.H", "KZ17.L"
))
if use_kz18
res.push(kz_helper.new(
kz.new(kz18_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz18, kz18_color, kz18_txt, "KZ18.H", "KZ18.L"
))
if use_kz19
res.push(kz_helper.new(
kz.new(kz19_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz19, kz19_color, kz19_txt, "KZ19.H", "KZ19.L"
))
if use_kz20
res.push(kz_helper.new(
kz.new(kz20_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz20, kz20_color, kz20_txt, "KZ20.H", "KZ20.L"
))
if use_kz21
res.push(kz_helper.new(
kz.new(kz21_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz21, kz21_color, kz21_txt, "KZ21.H", "KZ21.L"
))
if use_kz22
res.push(kz_helper.new(
kz.new(kz22_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz22, kz22_color, kz22_txt, "KZ22.H", "KZ22.L"
))
if use_kz23
res.push(kz_helper.new(
kz.new(kz23_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz23, kz23_color, kz23_txt, "KZ23.H", "KZ23.L"
))
if use_kz24
res.push(kz_helper.new(
kz.new(kz24_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz24, kz24_color, kz24_txt, "KZ24.H", "KZ24.L"
))
if use_kz25
res.push(kz_helper.new(
kz.new(kz25_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz25, kz25_color, kz25_txt, "KZ25.H", "KZ25.L"
))
if use_kz26
res.push(kz_helper.new(
kz.new(kz26_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz26, kz26_color, kz26_txt, "KZ26.H", "KZ26.L"
))
if use_kz27
res.push(kz_helper.new(
kz.new(kz27_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz27, kz27_color, kz27_txt, "KZ27.H", "KZ27.L"
))
if use_kz28
res.push(kz_helper.new(
kz.new(kz28_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz28, kz28_color, kz28_txt, "KZ28.H", "KZ28.L"
))
if use_kz29
res.push(kz_helper.new(
kz.new(kz29_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz29, kz29_color, kz29_txt, "KZ29.H", "KZ29.L"
))
if use_kz30
res.push(kz_helper.new(
kz.new(kz30_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz30, kz30_color, kz30_txt, "KZ30.H", "KZ30.L"
))
if use_kz31
res.push(kz_helper.new(
kz.new(kz31_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz31, kz31_color, kz31_txt, "KZ31.H", "KZ31.L"
))
if use_kz32
res.push(kz_helper.new(
kz.new(kz32_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz32, kz32_color, kz32_txt, "KZ32.H", "KZ32.L"
))
if use_kz33
res.push(kz_helper.new(
kz.new(kz33_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz33, kz33_color, kz33_txt, "KZ33.H", "KZ33.L"
))
if use_kz34
res.push(kz_helper.new(
kz.new(kz34_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz34, kz34_color, kz34_txt, "KZ34.H", "KZ34.L"
))
if use_kz35
res.push(kz_helper.new(
kz.new(kz35_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz35, kz35_color, kz35_txt, "KZ35.H", "KZ35.L"
))
if use_kz36
res.push(kz_helper.new(
kz.new(kz36_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz36, kz36_color, kz36_txt, "KZ36.H", "KZ36.L"
))
if use_kz37
res.push(kz_helper.new(
kz.new(kz37_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz37, kz37_color, kz37_txt, "KZ37.H", "KZ37.L"
))
if use_kz38
res.push(kz_helper.new(
kz.new(kz38_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz38, kz38_color, kz38_txt, "KZ38.H", "KZ38.L"
))
if use_kz39
res.push(kz_helper.new(
kz.new(kz39_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz39, kz39_color, kz39_txt, "KZ39.H", "KZ39.L"
))
res
var array _kz = initKZ()
var d_hl = dwm_hl.new(array.new_line(), array.new_line(), array.new_label(), array.new_label())
var w_hl = dwm_hl.new(array.new_line(), array.new_line(), array.new_label(), array.new_label())
var m_hl = dwm_hl.new(array.new_line(), array.new_line(), array.new_label(), array.new_label())
var d_info = dwm_info.new("D")
var w_info = dwm_info.new("W")
var m_info = dwm_info.new("M")
t_co = not na(time("", cutoff, gmt_tz))
type ts_helper
string session
array lines
color c
initTS() =>
array res = array.new()
if use_v1
res.push(ts_helper.new(v1, array.new_line(), v1_color))
if use_v2
res.push(ts_helper.new(v2, array.new_line(), v2_color))
if use_v3
res.push(ts_helper.new(v3, array.new_line(), v3_color))
if use_v4
res.push(ts_helper.new(v4, array.new_line(), v4_color))
res
var array ts_data = initTS()
var d_sep_line = array.new_line()
var w_sep_line = array.new_line()
var m_sep_line = array.new_line()
var d_line = array.new_line()
var w_line = array.new_line()
var m_line = array.new_line()
var d_label = array.new_label()
var w_label = array.new_label()
var m_label = array.new_label()
var transparent = #ffffff00
var ext_current = ext_which == 'Most Recent'
var ext_past = ext_pivots == 'Past Mitigation'
update_dwm_info(dwm_info n) =>
if timeframe.change(n.tf)
n.ph := n.h
n.pl := n.l
n.o := open
n.h := high
n.l := low
else
n.h := math.max(high, n.h)
n.l := math.min(low, n.l)
if dhl or show_d_open
update_dwm_info(d_info)
if whl or show_w_open
update_dwm_info(w_info)
if mhl or show_m_open
update_dwm_info(m_info)
// ---------------------------------------- Variables & Constants --------------------------------------------------
// ---------------------------------------- Functions --------------------------------------------------
get_box_color(color c) =>
color.new(c, box_transparency)
get_text_color(color c) =>
color.new(c, text_transparency)
// ---------------------------------------- Functions --------------------------------------------------
// ---------------------------------------- Core Logic --------------------------------------------------
dwm_sep(string tf, bool use, array arr, color col) =>
if use
if timeframe.change(tf)
arr.unshift(line.new(bar_index, high * 1.0001, bar_index, low, style = htf_style, width = htf_width, extend = extend.both, color = col))
if not sep_unlimited and arr.size() > max_days
arr.pop().delete()
dwm_open(string tf, bool use, array lns, array lbls, dwm_info n, color col) =>
if use
if lns.size() > 0
lns.get(0).set_x2(time)
lbls.get(0).set_x(time)
if timeframe.change(tf)
lns.unshift(line.new(time, n.o, time, n.o, xloc = xloc.bar_time, style = htf_style, width = htf_width, color = col))
lbls.unshift(label.new(time, n.o, tf + " OPEN", xloc = xloc.bar_time, style = label.style_label_left, color = transparent, textcolor = txt_color, size = lbl_size))
if not sep_unlimited and lns.size() > max_days
lns.pop().delete()
lbls.pop().delete()
dwm_hl(string tf, bool use, dwm_hl hl, dwm_info n, color col) =>
if use
if hl.hi_line.size() > 0
hl.hi_line.get(0).set_x2(time)
hl.lo_line.get(0).set_x2(time)
hl.hi_label.get(0).set_x(time)
hl.lo_label.get(0).set_x(time)
if timeframe.change(tf)
hl.hi_line.unshift(line.new(time, n.ph, time, n.ph, xloc = xloc.bar_time, style = htf_style, width = htf_width, color = col))
hl.lo_line.unshift(line.new(time, n.pl, time, n.pl, xloc = xloc.bar_time, style = htf_style, width = htf_width, color = col))
hl.hi_label.unshift(label.new(time, n.ph, "P" + tf + "H", xloc = xloc.bar_time, style = label.style_label_left, color = transparent, textcolor = txt_color, size = lbl_size))
hl.lo_label.unshift(label.new(time, n.pl, "P" + tf + "L", xloc = xloc.bar_time, style = label.style_label_left, color = transparent, textcolor = txt_color, size = lbl_size))
hl.hit_high := false
hl.hit_low := false
if not sep_unlimited and hl.hi_line.size() > max_days
hl.hi_line.pop().delete()
hl.lo_line.pop().delete()
hl.hi_label.pop().delete()
hl.lo_label.pop().delete()
if hl.hi_line.size() > 0 and alert_HL
if not hl.hit_high and high > hl.hi_line.get(0).get_y1()
hl.hit_high := true
alert(str.format("Hit P{0}H", tf))
if not hl.hit_low and low < hl.lo_line.get(0).get_y1()
hl.hit_low := true
alert(str.format("Hit P{0}L", tf))
dwm() =>
if tf_limit_is_equal_or_more_chart_tf
// DWM - Separators
dwm_sep("D", ds, d_sep_line, d_color)
dwm_sep("W", ws, w_sep_line, w_color)
dwm_sep("M", ms, m_sep_line, m_color)
// DWM - Open Lines
dwm_open("D", show_d_open, d_line, d_label, d_info, d_color)
dwm_open("W", show_w_open, w_line, w_label, w_info, w_color)
dwm_open("M", show_m_open, m_line, m_label, m_info, m_color)
// DWM - Highs and Lows
dwm_hl("D", dhl, d_hl, d_info, d_color)
dwm_hl("W", whl, w_hl, w_info, w_color)
dwm_hl("M", mhl, m_hl, m_info, m_color)
method vline(ts_helper this) =>
bool t = not na(time("", this.session, gmt_tz))
bool t_prev = not na(time("", this.session, gmt_tz, bars_back = 1))
array arr = this.lines
color col = this.c
if t and not t_prev
arr.unshift(line.new(bar_index, high * 1.0001, bar_index, low, style = vl_style, width = vl_width, extend = extend.both, color = col))
if not v_unlimited
if arr.size() > max_days
arr.pop().delete()
vlines() =>
if tf_limit_is_equal_or_more_chart_tf
for in ts_data
vline(value)
method hz_line(lines_helper this) =>
bool t = not na(time("", this.h, gmt_tz))
bool t_prev = not na(time("", this.h, gmt_tz, bars_back = 1))
hz hz = this._hz
string txt = this.h_text
color col = this.h_color
if t and not t_prev
hz.LN.unshift(line.new(bar_index, open, bar_index, open, style = hz_style, width = hz_width, color = col))
hz.LB.unshift(label.new(bar_index, open, txt, style = label.style_label_left, color = transparent, textcolor = txt_color, size = lbl_size))
array.unshift(hz.CO, false)
if not open_unlimited and hz.LN.size() > max_days
hz.LN.pop().delete()
hz.LB.pop().delete()
hz.CO.pop()
if not t and hz.CO.size() > 0
if not hz.CO.get(0)
hz.LN.get(0).set_x2(bar_index)
hz.LB.get(0).set_x(bar_index)
if (use_cutoff ? t_co : false)
hz.CO.set(0, true)
hz_lines() =>
if tf_limit_is_equal_or_more_chart_tf
for in lines
hz_line(value)
del_kz(kz k) =>
if k._box.size() > max_days
k._box.pop().delete()
if k._hi_line.size() > max_days
k._hi_line.pop().delete()
k._lo_line.pop().delete()
k._hi_valid.pop()
k._lo_valid.pop()
if show_midpoints
k._md_line.pop().delete()
k._md_valid.pop()
if k._hi_label.size() > max_days
k._hi_label.pop().delete()
k._lo_label.pop().delete()
update_price_string(label L, float P) =>
S = L.get_text()
pre = str.substring(S, 0, str.pos(S, " "))
str.trim(pre)
L.set_text(str.format("{0} ({1})", pre, P))
adjust_in_kz(kz kz, bool t) =>
if t
kzBox0 = kz._box.get(0)
kzBox0.set_right(time)
newTop = math.max(kzBox0.get_top(), high)
kzBox0.set_top(newTop)
newBottom = math.min(kzBox0.get_bottom(), low)
kzBox0.set_bottom(newBottom)
kz._range_current := newTop - newBottom
if show_pivots and kz._hi_line.size() > 0
kzHiLine0 = kz._hi_line.get(0)
kzHiLine0.set_x2(time)
if high > kzHiLine0.get_y1()
kzHiLine0.set_xy1(time, high)
kzHiLine0.set_xy2(time, high)
kzLoLine0 = kz._lo_line.get(0)
kzLoLine0.set_x2(time)
if low < kzLoLine0.get_y1()
kzLoLine0.set_xy1(time, low)
kzLoLine0.set_xy2(time, low)
if show_midpoints
kzMidLine0 = kz._md_line.get(0)
kzMidLine0.set_x2(time)
kzMidLine0.set_xy1(time, math.avg(kzHiLine0.get_y2(), kzLoLine0.get_y2()))
kzMidLine0.set_xy2(time, math.avg(kzHiLine0.get_y2(), kzLoLine0.get_y2()))
if show_labels and kz._hi_label.size() > 0
if label_right
kz._hi_label.get(0).set_x(time)
kz._lo_label.get(0).set_x(time)
if high > kz._hi_label.get(0).get_y()
kz._hi_label.get(0).set_xy(time, high)
if label_price
update_price_string(kz._hi_label.get(0), high)
if low < kz._lo_label.get(0).get_y()
kz._lo_label.get(0).set_xy(time, low)
if label_price
update_price_string(kz._lo_label.get(0), low)
adjust_out_kz(kz kz, bool t, bool t_prev) =>
boxCount = kz._box.size()
if not t and boxCount > 0
if t_prev
array.unshift(kz._range_store, kz._range_current)
if kz._range_store.size() > range_avg
kz._range_store.pop()
if show_pivots and boxCount > 0
for i = 0 to boxCount - 1 by 1
if not ext_current or i == 0
kzHiValid = kz._hi_valid.get(i)
if ext_past or kzHiValid
kz._hi_line.get(i).set_x2(time)
if show_labels and label_right
kz._hi_label.get(i).set_x(time)
if kzHiValid and high > kz._hi_line.get(i).get_y1()
if use_alerts and i == 0
alert('Broke ' + kz._title + ' High', alert.freq_once_per_bar)
kz._hi_valid.set(i, false)
if show_labels and label_right
kz._hi_label.get(i).set_style(label.style_label_down)
else if use_cutoff ? t_co : false
kz._hi_valid.set(i, false)
kzLoValid = kz._lo_valid.get(i)
if ext_past or kzLoValid
kz._lo_line.get(i).set_x2(time)
if show_labels and label_right
kz._lo_label.get(i).set_x(time)
if kzLoValid and low < kz._lo_line.get(i).get_y1()
if use_alerts and i == 0
alert("Broke " + kz._title + " Low", alert.freq_once_per_bar)
kz._lo_valid.set(i, false)
if show_labels and label_right
kz._lo_label.get(i).set_style(label.style_label_up)
else if use_cutoff ? t_co : false
kz._lo_valid.set(i, false)
if show_midpoints and not t
if stop_midpoints ? kz._md_valid.get(i) : true
kz._md_line.get(i).set_x2(time)
if kz._md_valid.get(i) and low <= kz._md_line.get(i).get_y1() and high >= kz._md_line.get(i).get_y1()
kz._md_valid.set(i, false)
else
break
method manage_kz(kz_helper this) =>
kz kz = this._kz
c = this.c
string box_txt = this.box_txt
string hi_txt = this.hi_txt
string lo_txt = this.lo_txt
if tf_limit_is_equal_or_more_chart_tf
t = not na(time("", this.session, gmt_tz))
t_prev = not na(time("", this.session, gmt_tz, bars_back = 1))
if t and not t_prev
_c = get_box_color(c)
_t = get_text_color(c)
kz._box.unshift(box.new(time, high, time, low, xloc = xloc.bar_time, border_color = show_kz ? _c : na, bgcolor = show_kz ? _c : na, text = show_kz and show_kz_text ? box_txt : na, text_color = _t))
if show_pivots
kz._hi_line.unshift(line.new(time, high, time, high, xloc = xloc.bar_time, style = kzp_style, color = c, width = kzp_width))
kz._lo_line.unshift(line.new(time, low, time, low, xloc = xloc.bar_time, style = kzp_style, color = c, width = kzp_width))
if show_midpoints
kz._md_line.unshift(line.new(time, math.avg(high, low), time, math.avg(high, low), xloc = xloc.bar_time, style = kzm_style, color = c, width = kzm_width))
array.unshift(kz._md_valid, true)
array.unshift(kz._hi_valid, true)
array.unshift(kz._lo_valid, true)
if show_labels
_hi_txt = label_price ? str.format('{0} ({1})', hi_txt, high) : hi_txt
_lo_txt = label_price ? str.format('{0} ({1})', lo_txt, low) : lo_txt
if label_right
kz._hi_label.unshift(label.new(time, high, _hi_txt, xloc = xloc.bar_time, color = transparent, textcolor = txt_color, style = label.style_label_left, size = lbl_size))
kz._lo_label.unshift(label.new(time, low, _lo_txt, xloc = xloc.bar_time, color = transparent, textcolor = txt_color, style = label.style_label_left, size = lbl_size))
else
kz._hi_label.unshift(label.new(time, high, _hi_txt, xloc = xloc.bar_time, color = transparent, textcolor = txt_color, style = label.style_label_down, size = lbl_size))
kz._lo_label.unshift(label.new(time, low, _lo_txt, xloc = xloc.bar_time, color = transparent, textcolor = txt_color, style = label.style_label_up, size = lbl_size))
del_kz(kz)
adjust_in_kz(kz, t)
adjust_out_kz(kz, t, t_prev)
for in _kz
manage_kz(value)
dwm()
vlines()
hz_lines()
new_dow_time = dow_xloc == 'Midday' ? time - timeframe.in_seconds("D") / 2 * 1000 : time
new_day = dayofweek(new_dow_time, gmt_tz) != dayofweek(new_dow_time, gmt_tz)
var dow_top = dow_yloc == 'Top'
var saturday = "SATURDAY"
var sunday = "SUNDAY"
var monday = "MONDAY"
var tuesday = "TUESDAY"
var wednesday = "WEDNESDAY"
var thursday = "THURSDAY"
var friday = "FRIDAY"
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 1 and new_day and not dow_hide_wknd, location = dow_top ? location.top : location.bottom, char = '', textcolor = txt_color, text = sunday)
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 2 and new_day, location = dow_top ? location.top : location.bottom, char = '', textcolor = txt_color, text = monday)
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 3 and new_day, location = dow_top ? location.top : location.bottom, char = '', textcolor = txt_color, text = tuesday)
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 4 and new_day, location = dow_top ? location.top : location.bottom, char = '', textcolor = txt_color, text = wednesday)
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 5 and new_day, location = dow_top ? location.top : location.bottom, char = '', textcolor = txt_color, text = thursday)
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 6 and new_day, location = dow_top ? location.top : location.bottom, char = '', textcolor = txt_color, text = friday)
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 7 and new_day and not dow_hide_wknd, location = dow_top ? location.top : location.bottom, char = '', textcolor = txt_color, text = saturday)
get_min_days_stored() =>
store = array.new_int()
for in _kz
int tmpStoreSize = value._kz._range_store.size()
if tmpStoreSize > 0
store.push(tmpStoreSize)
store.min()
method set_table(table tbl, kz kz, int row, string txt, bool t, color col) =>
table.cell(tbl, 0, row, txt, text_size = range_size, bgcolor = get_box_color(col), text_color = txt_color)
table.cell(tbl, 1, row, str.tostring(kz._range_current), text_size = range_size, bgcolor = t ? get_box_color(col) : na, text_color = txt_color)
if show_range_avg
table.cell(tbl, 2, row, str.tostring(kz._range_store.avg()), text_size = range_size, text_color = txt_color)
if show_range and barstate.islast
var tbl = table.new(range_pos, 10, 10, chart.bg_color, chart.fg_color, 2, chart.fg_color, 1)
table.cell(tbl, 0, 0, "Killzone", text_size = range_size, text_color = txt_color)
table.cell(tbl, 1, 0, "Range", text_size = range_size, text_color = txt_color)
if show_range_avg
table.cell(tbl, 2, 0, "Avg (" + str.tostring(get_min_days_stored()) + ")", text_size = range_size, text_color = txt_color)
for in _kz
set_table(tbl, value._kz, index + 1, value.box_txt, not na(time("", value.session, gmt_tz)), value.c)
// ---------------------------------------- Core Logic --------------------------------------------------
Indicator

Indicator

ATK/DEF MOON Cycle# ATK/DEF MOON Cycle
ATK/DEF MOON Cycle is a market observation framework designed to examine price behavior through a different analytical structure from conventional technical analysis.
Instead of reducing market behavior to a single trend, indicator, or directional classification, this framework observes several measuble properties of the market simuaneously, including **price position, range depth, movement velocity, volatility, activity, structural distance, price expansion and contraction, and session conditions**.
The framework uses a physics-inspired conceual vocabary to organize these observations. Terms such as **Moon Phase, Water Depth, Resonance, Rotation, Black Hole, Satellite, Velocity and Burst** are names for calculated market conditions within the indicator. They are conceptual analytical labels and do not repreent literal astromical forces, gravitional effects, or claims that physical objects control fin markets.
The objective is to provide another way of ohow market conditions develop and intect.
## 🌙 MO Moon Phase — Cyclical Price Position
The Moon Phase module divies the current price position within a confurable obsertion range into eight stages:
* 🌑 New Moon
* 🌒 Waxing Crescent
* 🌓 First Quarter
* 🌔 Waxing Gibbous
* 🌕 Full Moon
* 🌖 Waning Gibbous
* 🌗 Last Quarter
* 🌘 Waning Crescent
The calcation uses the highest and lowest prices within the selected cy length.
The current closing price is noalized between these two bdaries and expreed as a percentage
This creates a visual reprention of where price is currently posioned inside its measured range.
The eight phas theefore describe **progressive positnal changes inside the market range**, rather than reprenting an actual astrmical moon cycle.
The default observation length is 28 bars and can be adjued through the indicator settings.
## 🌊 MO Test Depth — Range Depth
Test Depth measures how deeply the current price is positioned within the observed price range.
The calcation compares the current close with the cycle high and cycle low and converts the result into a normalied percentage.
The indicator divides this position into several zones:
* 🔵 Shallows
* 🟢 Shallow Water
* 🟡 Mid Water
* 🔴 Deep Water
This proides a diffent perective from siply describg price as bullish or bearish.
The same directional movement can have very different structural meanings depeding on wther price is located near the lower portion, middle portion, or upper portion of its observed range.
Test Depth is therefore primarily a **positional measurement**.
## 🔄 MO Resonance Rotation — Movement Velocity
Resonance Rotation measures the magtude of recent pric displacement relative to ATR.
The indicator calcates price change over several bas and compares that movement with the current ATR environment.
The result is normalized into a scale and classified into:
* Lo Speed
* M Speed
* Hg Speed
This allows the framework to distinguish between relatively small price movement and movement that is large comred with the current volatity environment.
The rm “Rotation” is a coptual descrtion of changing market movement. It does not iply literal physical rotation.
## 🌀 MO Black Hole Trap — Compression and Expansion
Black Hole Trap examines the relationship between **candle range and relative volume**.
The cunt candle range is comred with the brder cycle range, while current volume is comped with its moving average.
Several conditions can therefre be observed:
* relatiely compresed price rane with reced actity
* comessed range with very low relive activity
* expaded range with eleted activity
* more orary range and activity conditions
These conditions are converted into a normaled Black Hole Score
The resulting classifications are:
* No Tra
* Weak Tra
* Mid Tr
* Strong Tr
The purpose of this module is to describe unul combitions of **range compression, range expansion and market activity**.
“Black Hole” is a conceptual name for this calculd condition. It does not reprent an acal phcal black hole, gravitanal fild, or phycal force acng on price.
## ⚡ MO Price Action Resonance — Condition Alignment
Price Action Resonance examines several market characstics together.
The calculation considers:
* current price relative to the cycle high
* current price relative to the cycle low
* price relationship with the per
* relative volume
Each condition contrutes to a combined resonance score.
The score is classified into:
* No Reonace
* Weak Resnance
* Mid Resonace
* Strong Renance
This component is desned to show when seral difrent market obseations are ocuing together.
Raer than trting one measurent as the comlete descption of market behavior, the module presves several dimions and combes them into a single descrtive state.
## ⚡ MO Smooth Velocity — Smoothed Directional Movement
Smooth Velocity measures the rate of change of an EMA-smoothed price series.
The price is first smoothed with an EMA, after which the change in the smoothed series is measured over several bars and normazed relative to the smoothed price.
The resulting state is classified as:
* 🚀 Fast Up
* ⬆️ Slow Up
* ➡️ Sideways
* ⬇️ Slow Down
* 📉 Fast Down
This provides information about both **direction and movement rate**.
The purpose is not simply to ideify whether price is above or below a moving average, but to obrve how the smoothed price itelf is changing.
## 💥 MO Price Burst — Candle Displacement and Activity
Price Burst examines the relationship between candle body movement, total candle range and relative volume.
The open-to-close movement is normaled agaist the candle's high-to-low range.
The resulting directional movement is then combined with the current volume ratio.
This produces a Burst Strength measurement that is classified into:
* 💤 No Burst
* 💥 Weak Burst
* 💥 Mid Burst
* 💥 Strong Burst
This module descibes periods where candle displacement becomes more pronnced relative to the candle's total range and surrnding activity.
It provides another way of observing changes in the intesity of price movement.
## 🌍 MO Session Disruption Radar — Session Volatility
Session Radar divides the d into three broad observation periods:
* 🌏 Asia
* 🌍 Europe
* 🌎 America
The current ATR is compared with a session-specific volatility reference.
This produces a normalized session activity value and corsponding state.
The module therefore examines whether current volatility is relatively subdd or eleted within the defied session environment.
It is designed as a **session cont measurement**, allowing volatity conditions to be observed alonside the other componts of the framework.
## 🛰️ MO Moon Satellite — Secondary Price Position
The Satellite module introdes a secondary observation range derived from the main cycle length.
The current price is measured between the sateite high and salite low and normaled
The resulting states are:
* Very Low Sateite
* Low Sateite
* Balance Sateite
* Mid Sateite
* High Sateite
This creates a second positnal layer.
The main Moon Phase describes the broer range posion, while the Satelte measument provides another view of where price is locatd inside a smller obseation range.
“Satellite” is a conceptual naming system for this secondary range relationship.
## ⛰️ MO Structure Distance — Structural Location
Structure Distance evaates the current price against an expded structural range.
The indicator idtifies the highest and lowest prices over a larger obsvation window and calates the distance from the current close to both boundies.
The resulting conditions include:
* ⛰️ Near Re
* 🏔️ Near Sort
* 📈 Near Hh
* 📉 Near Lw
* 〰️ Mid Zo
This allows the current market locaon to be descbed in relation to its brder obseed exemes.
The measurement is based on distance rather than a manally drn level.
# 📍 Swing Point Context
The indicator also uses confirmed pivot-based swing highs and swing lows.
When a swing point is confirmed, its label can disay several pieces of conte information simaneously:
* swing price
* current MO Phase
* Satellite position
* structural location
* structural distance
This connects individual swing points with the broader market state being observed by the framework.
The pivot parameters can be adjusted through the Left Bars and Right Bars settings.
# 🧭 A Different Way to Observe Market Direction
The central concept of ATK/DEF MOON Cycle is that market direction does not have to be repreted by one conveional trend calcuion.
The framework separates several different questions:
**Where is price?**
MO Moon Phase, Test Depth and Satellite Position describe price location within different observation ranges.
**How fast is price moving?**
Resonance Rotation and Smooth Velocity describe the rate of price movement.
**How large is the current movement?**
ATR, candle range and Price Burst provide volatility and displacement information.
**How active is the market?**
Relative volume contributes information about the current activity environment.
**Where is price within the broader structure?**
Structure Distance describes the relationship between current price and observed structural extremes.
**Are several conditions occurring together?**
Price Action Resonance combines multiple observations into a common descriptive score.
This separation is important because market position and market movement are not necearily the same thing.
Price can be positioned near an extreme while movement remains weak.
Price can also move rapidly while remaining inside the middle portion of a larger structure.
A compressed range can occur with low activity, while an expanded range can occur with elevated activity.
ATK/DEF MOON Cycle keeps these characteristics visible instead of forcing them into a single conventional trend definition.
# 🧠 Conceptual Architecture
The indicator uses a phycs-inspired voculary as an alrnative organizational language for market obervation.
The terology can be understood as follows:
**Moon Phase**
→ progressive position inside a measured price cycle.
**Water Depth**
→ depth of current price inside the observed range.
**Rotation**
→ normalized magnitude of recent price movement.
**Resonance**
→ simultaneous presence of several measurable market conditions.
**Black Hole**
→ unusual range and activity conditions.
**Velocity**
→ rate of change of price movement.
**Burst**
→ concentrated candle displacement combined with activity.
**Satellite**
→ position inside a secondary observation range.
**Structure Distance**
→ distance between current price and observed structural extremes.
These terms form one consistent analytical language while the underlng calculations remain based on chart data.
The indicator transrms these values into normazed measurements and desiptive states.
The percentages displayed by the indicator repsent **normazed analytical values**. They are not probality estates and should not be intereted as guateed forecasts.
# 📊 Dashboard Design
The MOON Cycle dashboard presents several indepdent obseations in one compact structure.
The dashboard includes:
* Test Depth
* Resonance Rotation
* Black Hole Trap
* Price Action Resonance
* Smooth Velocity
* Price Burst
* Session Radar
Each row reprents a different charactertic of the current market environment.
The purpose of the dashboard is to make the relationship between different market properties eaier to observe without reding the ente chart to a single numeral value.
# 🔬 Analytical Philosophy
ATK/DEF MOON Cycle is based on a simple principle:
**Observe the market from multiple dimensns instead of descring it through only one contional concept.**
Price is treated not only as a seqnce of candles, but as a changing system of:
* position
* movement
* velocity
* range
* activity
* expansion
* contraction
* structural distance
* cyclical progression
* session environment
The physics-inspired terminology provides a separate conceptual language for organizing these observations.
It is not preseed as a claim that finl markets are goverd by lital astroal or phycal mechanms.
The undeying measements remain derived from market data available on the chart.
# ⚠️ Important Information
ATK/DEF MOON Cycle is an analytical and visualization framework for stu market behavior.
The ter used by the indicator is concal. References to Moon, Satellite, Black Hole, Resonance, Rotation, Water Depth and similar terms describe calcul market conditions and are not claims about leral physical forces affting fin mars.
The indicator does not provide fin advice Its purpose is to provide an altetive framework for obsing and analyzing the changing chararistics of market da.
Indicator

CPR by SubashCPR — Central Pivot Range with Multi-Timeframe Pivots
This indicator plots the Central Pivot Range (CPR) along with standard floor-trader pivot levels across four timeframes — daily, weekly, monthly and yearly — on a single chart. It also plots the previous period's high and low for each timeframe, and can optionally project the next period's CPR forward.
**What the Central Pivot Range is**
The CPR is a three-line zone derived from the previous period's high, low and close:
- Pivot (PP) = (High + Low + Close) / 3
- Bottom Central (BC) = (High + Low) / 2
- Top Central (TC) = Pivot − BC + Pivot
The width of the band between TC and BC reflects how balanced the previous period was. A narrow CPR indicates the prior period closed near the middle of a tight range; a wide CPR indicates a broader distribution. Traders commonly use the relationship between successive CPR bands, and price's position relative to them, as context for the session.
**Support and resistance levels**
Standard pivot-derived levels R1–R4 and S1–S4 are calculated for each timeframe using the conventional floor-trader formulas. These are geometric projections from the previous period's range, not predictions.
**Timeframe visibility**
Each set of levels only renders on chart timeframes below its own period, so the chart does not fill with irrelevant lines:
- Daily levels — intraday charts only
- Weekly levels — intraday and daily
- Monthly levels — intraday, daily and weekly
- Yearly levels — intraday through monthly
**Settings**
Every timeframe group has independent toggles for its pivot, its support/resistance set, its CPR band, and its previous-period high and low. Daily, weekly and monthly pivots plus support/resistance are enabled by default; yearly levels and all CPR bands beyond the daily one are off by default to keep the initial chart readable. A single line-width input controls all plots.
**Next CPR projection (off by default)**
The "Show Next CPR" option projects the upcoming period's CPR and pivot levels forward on the chart by a configurable bar offset. Choose the projection period — daily, weekly, monthly or yearly — with the resolution input.
**Important — this section repaints by design.** It reads the current, still-incomplete period's high, low and close in order to compute where the next period's levels would fall. Those values change as the current period develops, so the projected lines move until the period closes. This is inherent to what a forward projection is; it is not a bug, but it does mean these particular lines must not be used for signal generation, backtesting, or alerts. All other levels in the script are calculated from completed prior periods and do not repaint.
**Notes on use**
These are reference levels, not entry signals. The script produces no buy or sell markers and makes no directional claims. How useful any given level is depends entirely on the instrument, the timeframe, and the volatility regime — verify the behaviour on your own instrument before relying on it.
Indicator

Indicator

Killzones EUR/GBP - Manuel De Jesus Leiva// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// © tradeforopp
//@version=6
indicator("Killzones EUR/GBP - Manuel De Jesus Leiva", "Killzones EUR/GBP - Manuel De Jesus Leiva", true, max_labels_count = 500, max_lines_count = 500, max_boxes_count = 500)
// ---------------------------------------- Constant Functions --------------------------------------------------
get_line_type(_style) =>
switch _style
"Solid" => line.style_solid
"Dotted" => line.style_dotted
"Dashed" => line.style_dashed
get_size(x) =>
switch x
"Auto" => size.auto
"Tiny" => size.tiny
"Small" => size.small
"Normal" => size.normal
"Large" => size.large
"Huge" => size.huge
get_table_pos(pos) =>
switch pos
"Bottom Center" => position.bottom_center
"Bottom Left" => position.bottom_left
"Bottom Right" => position.bottom_right
"Middle Center" => position.middle_center
"Middle Left" => position.middle_left
"Middle Right" => position.middle_right
"Top Center" => position.top_center
"Top Left" => position.top_left
"Top Right" => position.top_right
// ---------------------------------------- Constant Functions --------------------------------------------------
// ---------------------------------------- Inputs --------------------------------------------------
var g_SETTINGS = "Settings"
max_days = input.int(1000, "Session Drawing Limit", 1, tooltip = "Only this many drawings will be kept on the chart, for each selected drawing type (killzone boxes, pivot lines, open lines, etc.). Set to 200 for ~6 months of sessions.", group = g_SETTINGS)
tf_limit = input.timeframe("60", "Timeframe Limit", tooltip = "Drawings will not appear on timeframes greater than or equal to this", group = g_SETTINGS)
gmt_tz = input.string('America/New_York', "Timezone", options = , tooltip = "Note GMT is not adjusted to reflect Daylight Saving Time changes", group = g_SETTINGS)
lbl_size = get_size(input.string('Normal', "Label Size", options = , tooltip = "The size of all labels", group = g_SETTINGS))
txt_color = input.color(color.black, "Text Color", tooltip = "The color of all label and table text", group = g_SETTINGS)
use_cutoff = input.bool(false, "Drawing Cutoff Time", inline = "CO", tooltip = "When enabled, all pivots and open price lines will stop extending at this time", group = g_SETTINGS)
cutoff = input.session("1800-1801", "", inline = "CO", group = g_SETTINGS)
var tf_limit_is_equal_or_more_chart_tf = timeframe.in_seconds('') <= timeframe.in_seconds(tf_limit)
var g_KZ = "Killzones"
// General Killzone Settings
show_kz = input.bool(true, "Show Killzone Boxes", inline = "KZ", group = g_KZ)
show_kz_text = input.bool(false, "Display Text", inline = "KZ", group = g_KZ)
box_transparency = input.int(70, "Box Transparency", 0, 100, group = g_KZ)
text_transparency = input.int(50, "Text Transparency", 0, 100, group = g_KZ)
// ==================== KILLZONE 01 ====================
use_kz01 = input.bool(true, "00:00-01:00", inline = "KZ01", group = g_KZ)
kz01_txt = input.string("00-01", "", inline = "KZ01", group = g_KZ)
kz01 = input.session("0000-0100", "", inline = "KZ01", group = g_KZ)
kz01_color = input.color(color.blue, "", inline = "KZ01", group = g_KZ)
// ==================== KILLZONE 02 ====================
use_kz02 = input.bool(true, "01:00-02:00", inline = "KZ02", group = g_KZ)
kz02_txt = input.string("01-02", "", inline = "KZ02", group = g_KZ)
kz02 = input.session("0100-0200", "", inline = "KZ02", group = g_KZ)
kz02_color = input.color(color.blue, "", inline = "KZ02", group = g_KZ)
// ==================== KILLZONE 03 ====================
use_kz03 = input.bool(true, "02:00-03:00", inline = "KZ03", group = g_KZ)
kz03_txt = input.string("02-03", "", inline = "KZ03", group = g_KZ)
kz03 = input.session("0200-0300", "", inline = "KZ03", group = g_KZ)
kz03_color = input.color(color.blue, "", inline = "KZ03", group = g_KZ)
// ==================== KILLZONE 04 ====================
use_kz04 = input.bool(true, "03:00-04:00", inline = "KZ04", group = g_KZ)
kz04_txt = input.string("03-04", "", inline = "KZ04", group = g_KZ)
kz04 = input.session("0300-0400", "", inline = "KZ04", group = g_KZ)
kz04_color = input.color(color.blue, "", inline = "KZ04", group = g_KZ)
// ==================== KILLZONE 05 ====================
use_kz05 = input.bool(true, "04:00-05:00", inline = "KZ05", group = g_KZ)
kz05_txt = input.string("04-05", "", inline = "KZ05", group = g_KZ)
kz05 = input.session("0400-0500", "", inline = "KZ05", group = g_KZ)
kz05_color = input.color(color.blue, "", inline = "KZ05", group = g_KZ)
// ==================== KILLZONE 06 ====================
use_kz06 = input.bool(true, "05:00-06:00", inline = "KZ06", group = g_KZ)
kz06_txt = input.string("05-06", "", inline = "KZ06", group = g_KZ)
kz06 = input.session("0500-0600", "", inline = "KZ06", group = g_KZ)
kz06_color = input.color(color.blue, "", inline = "KZ06", group = g_KZ)
// ==================== KILLZONE 07 ====================
use_kz07 = input.bool(true, "06:00-07:00", inline = "KZ07", group = g_KZ)
kz07_txt = input.string("06-07", "", inline = "KZ07", group = g_KZ)
kz07 = input.session("0600-0700", "", inline = "KZ07", group = g_KZ)
kz07_color = input.color(color.blue, "", inline = "KZ07", group = g_KZ)
// ==================== KILLZONE 08 ====================
use_kz08 = input.bool(true, "07:00-08:00", inline = "KZ08", group = g_KZ)
kz08_txt = input.string("07-08", "", inline = "KZ08", group = g_KZ)
kz08 = input.session("0700-0800", "", inline = "KZ08", group = g_KZ)
kz08_color = input.color(color.blue, "", inline = "KZ08", group = g_KZ)
// ==================== KILLZONE 09 ====================
use_kz09 = input.bool(true, "08:00-09:00", inline = "KZ09", group = g_KZ)
kz09_txt = input.string("08-09", "", inline = "KZ09", group = g_KZ)
kz09 = input.session("0800-0900", "", inline = "KZ09", group = g_KZ)
kz09_color = input.color(color.blue, "", inline = "KZ09", group = g_KZ)
// ==================== KILLZONE 10 ====================
use_kz10 = input.bool(true, "09:00-10:00", inline = "KZ10", group = g_KZ)
kz10_txt = input.string("09-10", "", inline = "KZ10", group = g_KZ)
kz10 = input.session("0900-1000", "", inline = "KZ10", group = g_KZ)
kz10_color = input.color(color.blue, "", inline = "KZ10", group = g_KZ)
// ==================== KILLZONE 11 ====================
use_kz11 = input.bool(true, "10:00-11:00", inline = "KZ11", group = g_KZ)
kz11_txt = input.string("10-11", "", inline = "KZ11", group = g_KZ)
kz11 = input.session("1000-1100", "", inline = "KZ11", group = g_KZ)
kz11_color = input.color(color.blue, "", inline = "KZ11", group = g_KZ)
// ==================== KILLZONE 12 ====================
use_kz12 = input.bool(true, "11:00-12:00", inline = "KZ12", group = g_KZ)
kz12_txt = input.string("11-12", "", inline = "KZ12", group = g_KZ)
kz12 = input.session("1100-1200", "", inline = "KZ12", group = g_KZ)
kz12_color = input.color(color.blue, "", inline = "KZ12", group = g_KZ)
// ==================== KILLZONE 13 ====================
use_kz13 = input.bool(true, "12:00-13:00", inline = "KZ13", group = g_KZ)
kz13_txt = input.string("12-13", "", inline = "KZ13", group = g_KZ)
kz13 = input.session("1200-1300", "", inline = "KZ13", group = g_KZ)
kz13_color = input.color(color.blue, "", inline = "KZ13", group = g_KZ)
// ==================== KILLZONE 14 ====================
use_kz14 = input.bool(true, "13:00-14:00", inline = "KZ14", group = g_KZ)
kz14_txt = input.string("13-14", "", inline = "KZ14", group = g_KZ)
kz14 = input.session("1300-1400", "", inline = "KZ14", group = g_KZ)
kz14_color = input.color(color.blue, "", inline = "KZ14", group = g_KZ)
// ==================== KILLZONE 15 ====================
use_kz15 = input.bool(true, "14:00-15:00", inline = "KZ15", group = g_KZ)
kz15_txt = input.string("14-15", "", inline = "KZ15", group = g_KZ)
kz15 = input.session("1400-1500", "", inline = "KZ15", group = g_KZ)
kz15_color = input.color(color.blue, "", inline = "KZ15", group = g_KZ)
// ==================== KILLZONE 16 ====================
use_kz16 = input.bool(true, "15:00-16:00", inline = "KZ16", group = g_KZ)
kz16_txt = input.string("15-16", "", inline = "KZ16", group = g_KZ)
kz16 = input.session("1500-1600", "", inline = "KZ16", group = g_KZ)
kz16_color = input.color(color.blue, "", inline = "KZ16", group = g_KZ)
// ==================== KILLZONE 17 ====================
use_kz17 = input.bool(true, "16:00-17:00", inline = "KZ17", group = g_KZ)
kz17_txt = input.string("16-17", "", inline = "KZ17", group = g_KZ)
kz17 = input.session("1600-1700", "", inline = "KZ17", group = g_KZ)
kz17_color = input.color(color.blue, "", inline = "KZ17", group = g_KZ)
// ==================== KILLZONE 18 ====================
use_kz18 = input.bool(true, "17:00-18:00", inline = "KZ18", group = g_KZ)
kz18_txt = input.string("17-18", "", inline = "KZ18", group = g_KZ)
kz18 = input.session("1700-1800", "", inline = "KZ18", group = g_KZ)
kz18_color = input.color(color.blue, "", inline = "KZ18", group = g_KZ)
// ==================== KILLZONE 19 ====================
use_kz19 = input.bool(true, "18:00-19:00", inline = "KZ19", group = g_KZ)
kz19_txt = input.string("18-19", "", inline = "KZ19", group = g_KZ)
kz19 = input.session("1800-1900", "", inline = "KZ19", group = g_KZ)
kz19_color = input.color(color.blue, "", inline = "KZ19", group = g_KZ)
// ==================== KILLZONE 20 ====================
use_kz20 = input.bool(true, "19:00-20:00", inline = "KZ20", group = g_KZ)
kz20_txt = input.string("19-20", "", inline = "KZ20", group = g_KZ)
kz20 = input.session("1900-2000", "", inline = "KZ20", group = g_KZ)
kz20_color = input.color(color.blue, "", inline = "KZ20", group = g_KZ)
// ==================== KILLZONE 21 ====================
use_kz21 = input.bool(true, "20:00-21:00", inline = "KZ21", group = g_KZ)
kz21_txt = input.string("20-21", "", inline = "KZ21", group = g_KZ)
kz21 = input.session("2000-2100", "", inline = "KZ21", group = g_KZ)
kz21_color = input.color(color.blue, "", inline = "KZ21", group = g_KZ)
// ==================== KILLZONE 22 ====================
use_kz22 = input.bool(true, "21:00-22:00", inline = "KZ22", group = g_KZ)
kz22_txt = input.string("21-22", "", inline = "KZ22", group = g_KZ)
kz22 = input.session("2100-2200", "", inline = "KZ22", group = g_KZ)
kz22_color = input.color(color.blue, "", inline = "KZ22", group = g_KZ)
// ==================== KILLZONE 23 ====================
use_kz23 = input.bool(true, "22:00-23:00", inline = "KZ23", group = g_KZ)
kz23_txt = input.string("22-23", "", inline = "KZ23", group = g_KZ)
kz23 = input.session("2200-2300", "", inline = "KZ23", group = g_KZ)
kz23_color = input.color(color.blue, "", inline = "KZ23", group = g_KZ)
// ==================== KILLZONE 24 ====================
use_kz24 = input.bool(true, "23:00-00:00", inline = "KZ24", group = g_KZ)
kz24_txt = input.string("23-00", "", inline = "KZ24", group = g_KZ)
kz24 = input.session("2300-0000", "", inline = "KZ24", group = g_KZ)
kz24_color = input.color(color.blue, "", inline = "KZ24", group = g_KZ)
// ==================== KILLZONE 25 ====================
use_kz25 = input.bool(true, "17:00-21:00", inline = "KZ25", group = g_KZ)
kz25_txt = input.string("17-21", "", inline = "KZ25", group = g_KZ)
kz25 = input.session("1700-2100", "", inline = "KZ25", group = g_KZ)
kz25_color = input.color(color.orange, "", inline = "KZ25", group = g_KZ)
// ==================== KILLZONE 26 ====================
use_kz26 = input.bool(true, "21:00-01:00", inline = "KZ26", group = g_KZ)
kz26_txt = input.string("21-01", "", inline = "KZ26", group = g_KZ)
kz26 = input.session("2100-0100", "", inline = "KZ26", group = g_KZ)
kz26_color = input.color(color.aqua, "", inline = "KZ26", group = g_KZ)
// ==================== KILLZONE 27 ====================
use_kz27 = input.bool(true, "01:00-05:00", inline = "KZ27", group = g_KZ)
kz27_txt = input.string("01-05", "", inline = "KZ27", group = g_KZ)
kz27 = input.session("0100-0500", "", inline = "KZ27", group = g_KZ)
kz27_color = input.color(color.green, "", inline = "KZ27", group = g_KZ)
// ==================== KILLZONE 28 ====================
use_kz28 = input.bool(true, "05:00-09:00", inline = "KZ28", group = g_KZ)
kz28_txt = input.string("05-09", "", inline = "KZ28", group = g_KZ)
kz28 = input.session("0500-0900", "", inline = "KZ28", group = g_KZ)
kz28_color = input.color(color.yellow, "", inline = "KZ28", group = g_KZ)
// ==================== KILLZONE 29 ====================
use_kz29 = input.bool(true, "09:00-13:00", inline = "KZ29", group = g_KZ)
kz29_txt = input.string("09-13", "", inline = "KZ29", group = g_KZ)
kz29 = input.session("0900-1300", "", inline = "KZ29", group = g_KZ)
kz29_color = input.color(color.red, "", inline = "KZ29", group = g_KZ)
// ==================== KILLZONE 30 ====================
use_kz30 = input.bool(true, "13:00-17:00", inline = "KZ30", group = g_KZ)
kz30_txt = input.string("13-17", "", inline = "KZ30", group = g_KZ)
kz30 = input.session("1300-1700", "", inline = "KZ30", group = g_KZ)
kz30_color = input.color(color.purple, "", inline = "KZ30", group = g_KZ)
var g_LABELS = "Killzone Pivots"
show_pivots = input.bool(false, "Show Pivots", inline = "PV", group = g_LABELS)
use_alerts = input.bool(false, "Alert Broken Pivots", inline = "PV", tooltip = "The desired killzones must be enabled at the time that an alert is created, along with the show pivots option, in order for alerts to work", group = g_LABELS)
show_midpoints = input.bool(false, "Show Pivot Midpoints", inline = "mp", group = g_LABELS)
stop_midpoints = input.bool(false, "Stop Once Mitigated", inline = "mp", group = g_LABELS)
show_labels = input.bool(false, "Show Pivot Labels", inline = "LB", tooltip = "Show labels denoting each killzone's high and low. Optionally choose to show the price of each level. Right side will show labels on the right-hand side of the chart until they are reached", group = g_LABELS)
label_price = input.bool(false, "Display Price", inline = "LB", group = g_LABELS)
label_right = input.bool(false, "Right Side", inline = "LB", group = g_LABELS)
ext_pivots = input.string("Until Mitigated", "Extend Pivots...", options = , group = g_LABELS)
ext_which = input.string("All", "...From Which Sessions", options = , group = g_LABELS)
ash_str = input.string("AS.H", "Killzone 1 Labels", inline = "L_AS", group = g_LABELS)
asl_str = input.string("AS.L", "", inline = "L_AS", group = g_LABELS)
loh_str = input.string("LO.H", "Killzone 2 Labels", inline = "L_LO", group = g_LABELS)
lol_str = input.string("LO.L", "", inline = "L_LO", group = g_LABELS)
nah_str = input.string("NYAM.H", "Killzone 3 Labels", inline = "L_NA", group = g_LABELS)
nal_str = input.string("NYAM.L", "", inline = "L_NA", group = g_LABELS)
nlh_str = input.string("NYL.H", "Killzone 4 Labels", inline = "L_NL", group = g_LABELS)
nll_str = input.string("NYL.L", "", inline = "L_NL", group = g_LABELS)
nph_str = input.string("NYPM.H", "Killzone 5 Labels", inline = "L_NP", group = g_LABELS)
npl_str = input.string("NYPM.L", "", inline = "L_NP", group = g_LABELS)
kzp_style = get_line_type(input.string(defval = 'Solid', title = "Pivot Style", options = , inline = "KZP", group = g_LABELS))
kzp_width = input.int(1, "", inline = "KZP", group = g_LABELS)
kzm_style = get_line_type(input.string(defval = 'Dotted', title = "Midpoint Style", options = , inline = "KZM", group = g_LABELS))
kzm_width = input.int(1, "", inline = "KZM", group = g_LABELS)
var g_RNG = "Killzone Range"
show_range = input.bool(false, "Show Killzone Range", tooltip = "Show the most recent ranges of each selected killzone, from high to low", group = g_RNG)
show_range_avg = input.bool(false, "Show Average", tooltip = "Show the average range of each selected killzone", group = g_RNG)
range_avg = input.int(5, "Average Length", 0, tooltip = "This many previous sessions will be used to calculate the average. If there isn't enough data on the current chart, it will use as many sessions as possible", group = g_RNG)
range_pos = get_table_pos(input.string('Top Right', "Table Position", options = , group = g_RNG))
range_size = get_size(input.string('Normal', "Table Size", options = , group = g_RNG))
var g_DWM = "Day - Week - Month"
sep_unlimited = input.bool(false, "Unlimited", tooltip = "Unlimited will show as many of the selected lines as possible. Otherwise, the session drawing limit will be used", group = g_DWM)
alert_HL = input.bool(false, "Alert High/Low Break", tooltip = "Alert when any selected highs and lows are traded through. The desired timeframe's high/low option must be enabled at the time that an alert is created", group = g_DWM)
show_d_open = input.bool(false, "D Open", inline = "DO", group = g_DWM)
dhl = input.bool(false, "High/Low", inline = "DO", tooltip = "", group = g_DWM)
ds = input.bool(false, "Separators", inline = "DO", tooltip = "Mark where a new day begins", group = g_DWM)
d_color = input.color(color.blue, "", inline = "DO", group = g_DWM)
show_w_open = input.bool(false, "W Open", inline = "WO", group = g_DWM)
whl = input.bool(false, "High/Low", inline = "WO", tooltip = "", group = g_DWM)
ws = input.bool(false, "Separators", inline = "WO", tooltip = "Mark where a new week begins", group = g_DWM)
w_color = input.color(#089981, "", inline = "WO", group = g_DWM)
show_m_open = input.bool(false, "M Open", inline = "MO", group = g_DWM)
mhl = input.bool(false, "High/Low", inline = "MO", tooltip = "", group = g_DWM)
ms = input.bool(false, "Separators", inline = "MO", tooltip = "Mark where a new month begins", group = g_DWM)
m_color = input.color(color.red, "", inline = "MO", group = g_DWM)
htf_style = get_line_type(input.string(defval = 'Solid', title = "Style", options = , inline = "D0", group = g_DWM))
htf_width = input.int(1, "", inline = "D0", group = g_DWM)
dow_labels = input.bool(false, "Day of Week Labels", inline = "DOW", group = g_DWM)
dow_yloc = input.string('Bottom', "", options = , inline = "DOW", group = g_DWM)
dow_xloc = input.string('Midnight', "", options = , inline = "DOW", group = g_DWM)
dow_hide_wknd = input.bool(false, "Hide Weekend Labels", group = g_DWM)
var g_OPEN = "Opening Prices"
open_unlimited = input.bool(false, "Unlimited", tooltip = "Unlimited will show as many of the selected lines as possible. Otherwise, the session drawing limit will be used", group = g_OPEN)
use_h1 = input.bool(false, "", inline = "H1", group = g_OPEN)
h1_text = input.string("17:00 H12/H8/H6/H4", "", inline = "H1", group = g_OPEN)
h1 = input.session("1700-1701", "", inline = "H1", group = g_OPEN)
h1_color = input.color(color.black, "", inline = "H1", group = g_OPEN)
use_h2 = input.bool(false, "", inline = "H2", group = g_OPEN)
h2_text = input.string("05:00 H12/H6/H4", "", inline = "H2", group = g_OPEN)
h2 = input.session("0500-0501", "", inline = "H2", group = g_OPEN)
h2_color = input.color(color.black, "", inline = "H2", group = g_OPEN)
use_h3 = input.bool(false, "", inline = "H3", group = g_OPEN)
h3_text = input.string("01:00 H8/H4", "", inline = "H3", group = g_OPEN)
h3 = input.session("0100-0101", "", inline = "H3", group = g_OPEN)
h3_color = input.color(color.black, "", inline = "H3", group = g_OPEN)
use_h4 = input.bool(false, "", inline = "H4", group = g_OPEN)
h4_text = input.string("09:00 H8/H4", "", inline = "H4", group = g_OPEN)
h4 = input.session("0900-0901", "", inline = "H4", group = g_OPEN)
h4_color = input.color(color.black, "", inline = "H4", group = g_OPEN)
use_h5 = input.bool(false, "", inline = "H5", group = g_OPEN)
h5_text = input.string("23:00 H6", "", inline = "H5", group = g_OPEN)
h5 = input.session("2300-2301", "", inline = "H5", group = g_OPEN)
h5_color = input.color(color.black, "", inline = "H5", group = g_OPEN)
use_h6 = input.bool(false, "", inline = "H6", group = g_OPEN)
h6_text = input.string("11:00 H6", "", inline = "H6", group = g_OPEN)
h6 = input.session("1100-1101", "", inline = "H6", group = g_OPEN)
h6_color = input.color(color.black, "", inline = "H6", group = g_OPEN)
use_h7 = input.bool(false, "", inline = "H7", group = g_OPEN)
h7_text = input.string("21:00 H4", "", inline = "H7", group = g_OPEN)
h7 = input.session("2100-2101", "", inline = "H7", group = g_OPEN)
h7_color = input.color(color.black, "", inline = "H7", group = g_OPEN)
use_h8 = input.bool(false, "", inline = "H8", group = g_OPEN)
h8_text = input.string("13:00 H4", "", inline = "H8", group = g_OPEN)
h8 = input.session("1300-1301", "", inline = "H8", group = g_OPEN)
h8_color = input.color(color.black, "", inline = "H8", group = g_OPEN)
hz_style = get_line_type(input.string(defval = 'Dotted', title = "Style", options = , inline = "H0", group = g_OPEN))
hz_width = input.int(1, "", inline = "H0", group = g_OPEN)
var g_VERTICAL = "Timestamps"
v_unlimited = input.bool(false, "Unlimited", tooltip = "Unlimited will show as many of the selected lines as possible. Otherwise, the session drawing limit will be used", group = g_VERTICAL)
use_v1 = input.bool(false, "", inline = "V1", group = g_VERTICAL)
v1 = input.session("0000-0001", "", inline = "V1", group = g_VERTICAL)
v1_color = input.color(color.black, "", inline = "V1", group = g_VERTICAL)
use_v2 = input.bool(false, "", inline = "V2", group = g_VERTICAL)
v2 = input.session("0800-0801", "", inline = "V2", group = g_VERTICAL)
v2_color = input.color(color.black, "", inline = "V2", group = g_VERTICAL)
use_v3 = input.bool(false, "", inline = "V3", group = g_VERTICAL)
v3 = input.session("1000-1001", "", inline = "V3", group = g_VERTICAL)
v3_color = input.color(color.black, "", inline = "V3", group = g_VERTICAL)
use_v4 = input.bool(false, "", inline = "V4", group = g_VERTICAL)
v4 = input.session("1200-1201", "", inline = "V4", group = g_VERTICAL)
v4_color = input.color(color.black, "", inline = "V4", group = g_VERTICAL)
vl_style = get_line_type(input.string(defval = 'Dotted', title = "Style", options = , inline = "V0", group = g_VERTICAL))
vl_width = input.int(1, "", inline = "V0", group = g_VERTICAL)
// ---------------------------------------- Inputs --------------------------------------------------
// ---------------------------------------- Variables & Constants --------------------------------------------------
type kz
string _title
array _box
array _hi_line
array _md_line
array _lo_line
array _hi_label
array _lo_label
array _hi_valid
array _md_valid
array _lo_valid
array _range_store
float _range_current
type hz
array LN
array LB
array CO
type dwm_hl
array hi_line
array lo_line
array hi_label
array lo_label
bool hit_high = false
bool hit_low = false
type dwm_info
string tf
float o = na
float h = na
float l = na
float ph = na
float pl = na
type lines_helper
hz _hz
string h
string h_text
color h_color
initLines() =>
array res = array.new()
if use_h1
res.push(lines_helper.new(hz.new(array.new_line(), array.new_label(), array.new_bool()), h1, h1_text, h1_color))
if use_h2
res.push(lines_helper.new(hz.new(array.new_line(), array.new_label(), array.new_bool()), h2, h2_text, h2_color))
if use_h3
res.push(lines_helper.new(hz.new(array.new_line(), array.new_label(), array.new_bool()), h3, h3_text, h3_color))
if use_h4
res.push(lines_helper.new(hz.new(array.new_line(), array.new_label(), array.new_bool()), h4, h4_text, h4_color))
if use_h5
res.push(lines_helper.new(hz.new(array.new_line(), array.new_label(), array.new_bool()), h5, h5_text, h5_color))
if use_h6
res.push(lines_helper.new(hz.new(array.new_line(), array.new_label(), array.new_bool()), h6, h6_text, h6_color))
if use_h7
res.push(lines_helper.new(hz.new(array.new_line(), array.new_label(), array.new_bool()), h7, h7_text, h7_color))
if use_h8
res.push(lines_helper.new(hz.new(array.new_line(), array.new_label(), array.new_bool()), h8, h8_text, h8_color))
res
var array lines = initLines()
type kz_helper
kz _kz
string session
color c
string box_txt
string hi_txt
string lo_txt
initKZ() =>
array res = array.new()
if use_kz01
res.push(kz_helper.new(
kz.new(kz01_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz01, kz01_color, kz01_txt, "KZ01.H", "KZ01.L"
))
if use_kz02
res.push(kz_helper.new(
kz.new(kz02_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz02, kz02_color, kz02_txt, "KZ02.H", "KZ02.L"
))
if use_kz03
res.push(kz_helper.new(
kz.new(kz03_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz03, kz03_color, kz03_txt, "KZ03.H", "KZ03.L"
))
if use_kz04
res.push(kz_helper.new(
kz.new(kz04_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz04, kz04_color, kz04_txt, "KZ04.H", "KZ04.L"
))
if use_kz05
res.push(kz_helper.new(
kz.new(kz05_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz05, kz05_color, kz05_txt, "KZ05.H", "KZ05.L"
))
if use_kz06
res.push(kz_helper.new(
kz.new(kz06_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz06, kz06_color, kz06_txt, "KZ06.H", "KZ06.L"
))
if use_kz07
res.push(kz_helper.new(
kz.new(kz07_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz07, kz07_color, kz07_txt, "KZ07.H", "KZ07.L"
))
if use_kz08
res.push(kz_helper.new(
kz.new(kz08_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz08, kz08_color, kz08_txt, "KZ08.H", "KZ08.L"
))
if use_kz09
res.push(kz_helper.new(
kz.new(kz09_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz09, kz09_color, kz09_txt, "KZ09.H", "KZ09.L"
))
if use_kz10
res.push(kz_helper.new(
kz.new(kz10_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz10, kz10_color, kz10_txt, "KZ10.H", "KZ10.L"
))
if use_kz11
res.push(kz_helper.new(
kz.new(kz11_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz11, kz11_color, kz11_txt, "KZ11.H", "KZ11.L"
))
if use_kz12
res.push(kz_helper.new(
kz.new(kz12_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz12, kz12_color, kz12_txt, "KZ12.H", "KZ12.L"
))
if use_kz13
res.push(kz_helper.new(
kz.new(kz13_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz13, kz13_color, kz13_txt, "KZ13.H", "KZ13.L"
))
if use_kz14
res.push(kz_helper.new(
kz.new(kz14_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz14, kz14_color, kz14_txt, "KZ14.H", "KZ14.L"
))
if use_kz15
res.push(kz_helper.new(
kz.new(kz15_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz15, kz15_color, kz15_txt, "KZ15.H", "KZ15.L"
))
if use_kz16
res.push(kz_helper.new(
kz.new(kz16_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz16, kz16_color, kz16_txt, "KZ16.H", "KZ16.L"
))
if use_kz17
res.push(kz_helper.new(
kz.new(kz17_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz17, kz17_color, kz17_txt, "KZ17.H", "KZ17.L"
))
if use_kz18
res.push(kz_helper.new(
kz.new(kz18_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz18, kz18_color, kz18_txt, "KZ18.H", "KZ18.L"
))
if use_kz19
res.push(kz_helper.new(
kz.new(kz19_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz19, kz19_color, kz19_txt, "KZ19.H", "KZ19.L"
))
if use_kz20
res.push(kz_helper.new(
kz.new(kz20_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz20, kz20_color, kz20_txt, "KZ20.H", "KZ20.L"
))
if use_kz21
res.push(kz_helper.new(
kz.new(kz21_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz21, kz21_color, kz21_txt, "KZ21.H", "KZ21.L"
))
if use_kz22
res.push(kz_helper.new(
kz.new(kz22_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz22, kz22_color, kz22_txt, "KZ22.H", "KZ22.L"
))
if use_kz23
res.push(kz_helper.new(
kz.new(kz23_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz23, kz23_color, kz23_txt, "KZ23.H", "KZ23.L"
))
if use_kz24
res.push(kz_helper.new(
kz.new(kz24_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz24, kz24_color, kz24_txt, "KZ24.H", "KZ24.L"
))
if use_kz25
res.push(kz_helper.new(
kz.new(kz25_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz25, kz25_color, kz25_txt, "KZ25.H", "KZ25.L"
))
if use_kz26
res.push(kz_helper.new(
kz.new(kz26_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz26, kz26_color, kz26_txt, "KZ26.H", "KZ26.L"
))
if use_kz27
res.push(kz_helper.new(
kz.new(kz27_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz27, kz27_color, kz27_txt, "KZ27.H", "KZ27.L"
))
if use_kz28
res.push(kz_helper.new(
kz.new(kz28_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz28, kz28_color, kz28_txt, "KZ28.H", "KZ28.L"
))
if use_kz29
res.push(kz_helper.new(
kz.new(kz29_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz29, kz29_color, kz29_txt, "KZ29.H", "KZ29.L"
))
if use_kz30
res.push(kz_helper.new(
kz.new(kz30_txt, array.new_box(), array.new_line(), array.new_line(), array.new_line(), array.new_label(), array.new_label(), array.new_bool(), array.new_bool(), array.new_bool(), array.new_float()),
kz30, kz30_color, kz30_txt, "KZ30.H", "KZ30.L"
))
res
var array _kz = initKZ()
var d_hl = dwm_hl.new(array.new_line(), array.new_line(), array.new_label(), array.new_label())
var w_hl = dwm_hl.new(array.new_line(), array.new_line(), array.new_label(), array.new_label())
var m_hl = dwm_hl.new(array.new_line(), array.new_line(), array.new_label(), array.new_label())
var d_info = dwm_info.new("D")
var w_info = dwm_info.new("W")
var m_info = dwm_info.new("M")
t_co = not na(time("", cutoff, gmt_tz))
type ts_helper
string session
array lines
color c
initTS() =>
array res = array.new()
if use_v1
res.push(ts_helper.new(v1, array.new_line(), v1_color))
if use_v2
res.push(ts_helper.new(v2, array.new_line(), v2_color))
if use_v3
res.push(ts_helper.new(v3, array.new_line(), v3_color))
if use_v4
res.push(ts_helper.new(v4, array.new_line(), v4_color))
res
var array ts_data = initTS()
var d_sep_line = array.new_line()
var w_sep_line = array.new_line()
var m_sep_line = array.new_line()
var d_line = array.new_line()
var w_line = array.new_line()
var m_line = array.new_line()
var d_label = array.new_label()
var w_label = array.new_label()
var m_label = array.new_label()
var transparent = #ffffff00
var ext_current = ext_which == 'Most Recent'
var ext_past = ext_pivots == 'Past Mitigation'
update_dwm_info(dwm_info n) =>
if timeframe.change(n.tf)
n.ph := n.h
n.pl := n.l
n.o := open
n.h := high
n.l := low
else
n.h := math.max(high, n.h)
n.l := math.min(low, n.l)
if dhl or show_d_open
update_dwm_info(d_info)
if whl or show_w_open
update_dwm_info(w_info)
if mhl or show_m_open
update_dwm_info(m_info)
// ---------------------------------------- Variables & Constants --------------------------------------------------
// ---------------------------------------- Functions --------------------------------------------------
get_box_color(color c) =>
color.new(c, box_transparency)
get_text_color(color c) =>
color.new(c, text_transparency)
// ---------------------------------------- Functions --------------------------------------------------
// ---------------------------------------- Core Logic --------------------------------------------------
dwm_sep(string tf, bool use, array arr, color col) =>
if use
if timeframe.change(tf)
arr.unshift(line.new(bar_index, high * 1.0001, bar_index, low, style = htf_style, width = htf_width, extend = extend.both, color = col))
if not sep_unlimited and arr.size() > max_days
arr.pop().delete()
dwm_open(string tf, bool use, array lns, array lbls, dwm_info n, color col) =>
if use
if lns.size() > 0
lns.get(0).set_x2(time)
lbls.get(0).set_x(time)
if timeframe.change(tf)
lns.unshift(line.new(time, n.o, time, n.o, xloc = xloc.bar_time, style = htf_style, width = htf_width, color = col))
lbls.unshift(label.new(time, n.o, tf + " OPEN", xloc = xloc.bar_time, style = label.style_label_left, color = transparent, textcolor = txt_color, size = lbl_size))
if not sep_unlimited and lns.size() > max_days
lns.pop().delete()
lbls.pop().delete()
dwm_hl(string tf, bool use, dwm_hl hl, dwm_info n, color col) =>
if use
if hl.hi_line.size() > 0
hl.hi_line.get(0).set_x2(time)
hl.lo_line.get(0).set_x2(time)
hl.hi_label.get(0).set_x(time)
hl.lo_label.get(0).set_x(time)
if timeframe.change(tf)
hl.hi_line.unshift(line.new(time, n.ph, time, n.ph, xloc = xloc.bar_time, style = htf_style, width = htf_width, color = col))
hl.lo_line.unshift(line.new(time, n.pl, time, n.pl, xloc = xloc.bar_time, style = htf_style, width = htf_width, color = col))
hl.hi_label.unshift(label.new(time, n.ph, "P" + tf + "H", xloc = xloc.bar_time, style = label.style_label_left, color = transparent, textcolor = txt_color, size = lbl_size))
hl.lo_label.unshift(label.new(time, n.pl, "P" + tf + "L", xloc = xloc.bar_time, style = label.style_label_left, color = transparent, textcolor = txt_color, size = lbl_size))
hl.hit_high := false
hl.hit_low := false
if not sep_unlimited and hl.hi_line.size() > max_days
hl.hi_line.pop().delete()
hl.lo_line.pop().delete()
hl.hi_label.pop().delete()
hl.lo_label.pop().delete()
if hl.hi_line.size() > 0 and alert_HL
if not hl.hit_high and high > hl.hi_line.get(0).get_y1()
hl.hit_high := true
alert(str.format("Hit P{0}H", tf))
if not hl.hit_low and low < hl.lo_line.get(0).get_y1()
hl.hit_low := true
alert(str.format("Hit P{0}L", tf))
dwm() =>
if tf_limit_is_equal_or_more_chart_tf
// DWM - Separators
dwm_sep("D", ds, d_sep_line, d_color)
dwm_sep("W", ws, w_sep_line, w_color)
dwm_sep("M", ms, m_sep_line, m_color)
// DWM - Open Lines
dwm_open("D", show_d_open, d_line, d_label, d_info, d_color)
dwm_open("W", show_w_open, w_line, w_label, w_info, w_color)
dwm_open("M", show_m_open, m_line, m_label, m_info, m_color)
// DWM - Highs and Lows
dwm_hl("D", dhl, d_hl, d_info, d_color)
dwm_hl("W", whl, w_hl, w_info, w_color)
dwm_hl("M", mhl, m_hl, m_info, m_color)
method vline(ts_helper this) =>
bool t = not na(time("", this.session, gmt_tz))
bool t_prev = not na(time("", this.session, gmt_tz, bars_back = 1))
array arr = this.lines
color col = this.c
if t and not t_prev
arr.unshift(line.new(bar_index, high * 1.0001, bar_index, low, style = vl_style, width = vl_width, extend = extend.both, color = col))
if not v_unlimited
if arr.size() > max_days
arr.pop().delete()
vlines() =>
if tf_limit_is_equal_or_more_chart_tf
for in ts_data
vline(value)
method hz_line(lines_helper this) =>
bool t = not na(time("", this.h, gmt_tz))
bool t_prev = not na(time("", this.h, gmt_tz, bars_back = 1))
hz hz = this._hz
string txt = this.h_text
color col = this.h_color
if t and not t_prev
hz.LN.unshift(line.new(bar_index, open, bar_index, open, style = hz_style, width = hz_width, color = col))
hz.LB.unshift(label.new(bar_index, open, txt, style = label.style_label_left, color = transparent, textcolor = txt_color, size = lbl_size))
array.unshift(hz.CO, false)
if not open_unlimited and hz.LN.size() > max_days
hz.LN.pop().delete()
hz.LB.pop().delete()
hz.CO.pop()
if not t and hz.CO.size() > 0
if not hz.CO.get(0)
hz.LN.get(0).set_x2(bar_index)
hz.LB.get(0).set_x(bar_index)
if (use_cutoff ? t_co : false)
hz.CO.set(0, true)
hz_lines() =>
if tf_limit_is_equal_or_more_chart_tf
for in lines
hz_line(value)
del_kz(kz k) =>
if k._box.size() > max_days
k._box.pop().delete()
if k._hi_line.size() > max_days
k._hi_line.pop().delete()
k._lo_line.pop().delete()
k._hi_valid.pop()
k._lo_valid.pop()
if show_midpoints
k._md_line.pop().delete()
k._md_valid.pop()
if k._hi_label.size() > max_days
k._hi_label.pop().delete()
k._lo_label.pop().delete()
update_price_string(label L, float P) =>
S = L.get_text()
pre = str.substring(S, 0, str.pos(S, " "))
str.trim(pre)
L.set_text(str.format("{0} ({1})", pre, P))
adjust_in_kz(kz kz, bool t) =>
if t
kzBox0 = kz._box.get(0)
kzBox0.set_right(time)
newTop = math.max(kzBox0.get_top(), high)
kzBox0.set_top(newTop)
newBottom = math.min(kzBox0.get_bottom(), low)
kzBox0.set_bottom(newBottom)
kz._range_current := newTop - newBottom
if show_pivots and kz._hi_line.size() > 0
kzHiLine0 = kz._hi_line.get(0)
kzHiLine0.set_x2(time)
if high > kzHiLine0.get_y1()
kzHiLine0.set_xy1(time, high)
kzHiLine0.set_xy2(time, high)
kzLoLine0 = kz._lo_line.get(0)
kzLoLine0.set_x2(time)
if low < kzLoLine0.get_y1()
kzLoLine0.set_xy1(time, low)
kzLoLine0.set_xy2(time, low)
if show_midpoints
kzMidLine0 = kz._md_line.get(0)
kzMidLine0.set_x2(time)
kzMidLine0.set_xy1(time, math.avg(kzHiLine0.get_y2(), kzLoLine0.get_y2()))
kzMidLine0.set_xy2(time, math.avg(kzHiLine0.get_y2(), kzLoLine0.get_y2()))
if show_labels and kz._hi_label.size() > 0
if label_right
kz._hi_label.get(0).set_x(time)
kz._lo_label.get(0).set_x(time)
if high > kz._hi_label.get(0).get_y()
kz._hi_label.get(0).set_xy(time, high)
if label_price
update_price_string(kz._hi_label.get(0), high)
if low < kz._lo_label.get(0).get_y()
kz._lo_label.get(0).set_xy(time, low)
if label_price
update_price_string(kz._lo_label.get(0), low)
adjust_out_kz(kz kz, bool t, bool t_prev) =>
boxCount = kz._box.size()
if not t and boxCount > 0
if t_prev
array.unshift(kz._range_store, kz._range_current)
if kz._range_store.size() > range_avg
kz._range_store.pop()
if show_pivots and boxCount > 0
for i = 0 to boxCount - 1 by 1
if not ext_current or i == 0
kzHiValid = kz._hi_valid.get(i)
if ext_past or kzHiValid
kz._hi_line.get(i).set_x2(time)
if show_labels and label_right
kz._hi_label.get(i).set_x(time)
if kzHiValid and high > kz._hi_line.get(i).get_y1()
if use_alerts and i == 0
alert('Broke ' + kz._title + ' High', alert.freq_once_per_bar)
kz._hi_valid.set(i, false)
if show_labels and label_right
kz._hi_label.get(i).set_style(label.style_label_down)
else if use_cutoff ? t_co : false
kz._hi_valid.set(i, false)
kzLoValid = kz._lo_valid.get(i)
if ext_past or kzLoValid
kz._lo_line.get(i).set_x2(time)
if show_labels and label_right
kz._lo_label.get(i).set_x(time)
if kzLoValid and low < kz._lo_line.get(i).get_y1()
if use_alerts and i == 0
alert("Broke " + kz._title + " Low", alert.freq_once_per_bar)
kz._lo_valid.set(i, false)
if show_labels and label_right
kz._lo_label.get(i).set_style(label.style_label_up)
else if use_cutoff ? t_co : false
kz._lo_valid.set(i, false)
if show_midpoints and not t
if stop_midpoints ? kz._md_valid.get(i) : true
kz._md_line.get(i).set_x2(time)
if kz._md_valid.get(i) and low <= kz._md_line.get(i).get_y1() and high >= kz._md_line.get(i).get_y1()
kz._md_valid.set(i, false)
else
break
method manage_kz(kz_helper this) =>
kz kz = this._kz
c = this.c
string box_txt = this.box_txt
string hi_txt = this.hi_txt
string lo_txt = this.lo_txt
if tf_limit_is_equal_or_more_chart_tf
t = not na(time("", this.session, gmt_tz))
t_prev = not na(time("", this.session, gmt_tz, bars_back = 1))
if t and not t_prev
_c = get_box_color(c)
_t = get_text_color(c)
kz._box.unshift(box.new(time, high, time, low, xloc = xloc.bar_time, border_color = show_kz ? _c : na, bgcolor = show_kz ? _c : na, text = show_kz and show_kz_text ? box_txt : na, text_color = _t))
if show_pivots
kz._hi_line.unshift(line.new(time, high, time, high, xloc = xloc.bar_time, style = kzp_style, color = c, width = kzp_width))
kz._lo_line.unshift(line.new(time, low, time, low, xloc = xloc.bar_time, style = kzp_style, color = c, width = kzp_width))
if show_midpoints
kz._md_line.unshift(line.new(time, math.avg(high, low), time, math.avg(high, low), xloc = xloc.bar_time, style = kzm_style, color = c, width = kzm_width))
array.unshift(kz._md_valid, true)
array.unshift(kz._hi_valid, true)
array.unshift(kz._lo_valid, true)
if show_labels
_hi_txt = label_price ? str.format('{0} ({1})', hi_txt, high) : hi_txt
_lo_txt = label_price ? str.format('{0} ({1})', lo_txt, low) : lo_txt
if label_right
kz._hi_label.unshift(label.new(time, high, _hi_txt, xloc = xloc.bar_time, color = transparent, textcolor = txt_color, style = label.style_label_left, size = lbl_size))
kz._lo_label.unshift(label.new(time, low, _lo_txt, xloc = xloc.bar_time, color = transparent, textcolor = txt_color, style = label.style_label_left, size = lbl_size))
else
kz._hi_label.unshift(label.new(time, high, _hi_txt, xloc = xloc.bar_time, color = transparent, textcolor = txt_color, style = label.style_label_down, size = lbl_size))
kz._lo_label.unshift(label.new(time, low, _lo_txt, xloc = xloc.bar_time, color = transparent, textcolor = txt_color, style = label.style_label_up, size = lbl_size))
del_kz(kz)
adjust_in_kz(kz, t)
adjust_out_kz(kz, t, t_prev)
for in _kz
manage_kz(value)
dwm()
vlines()
hz_lines()
new_dow_time = dow_xloc == 'Midday' ? time - timeframe.in_seconds("D") / 2 * 1000 : time
new_day = dayofweek(new_dow_time, gmt_tz) != dayofweek(new_dow_time, gmt_tz)
var dow_top = dow_yloc == 'Top'
var saturday = "SATURDAY"
var sunday = "SUNDAY"
var monday = "MONDAY"
var tuesday = "TUESDAY"
var wednesday = "WEDNESDAY"
var thursday = "THURSDAY"
var friday = "FRIDAY"
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 1 and new_day and not dow_hide_wknd, location = dow_top ? location.top : location.bottom, char = '', textcolor = txt_color, text = sunday)
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 2 and new_day, location = dow_top ? location.top : location.bottom, char = '', textcolor = txt_color, text = monday)
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 3 and new_day, location = dow_top ? location.top : location.bottom, char = '', textcolor = txt_color, text = tuesday)
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 4 and new_day, location = dow_top ? location.top : location.bottom, char = '', textcolor = txt_color, text = wednesday)
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 5 and new_day, location = dow_top ? location.top : location.bottom, char = '', textcolor = txt_color, text = thursday)
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 6 and new_day, location = dow_top ? location.top : location.bottom, char = '', textcolor = txt_color, text = friday)
plotchar(dow_labels and timeframe.isintraday and dayofweek(new_dow_time, gmt_tz) == 7 and new_day and not dow_hide_wknd, location = dow_top ? location.top : location.bottom, char = '', textcolor = txt_color, text = saturday)
get_min_days_stored() =>
store = array.new_int()
for in _kz
int tmpStoreSize = value._kz._range_store.size()
if tmpStoreSize > 0
store.push(tmpStoreSize)
store.min()
method set_table(table tbl, kz kz, int row, string txt, bool t, color col) =>
table.cell(tbl, 0, row, txt, text_size = range_size, bgcolor = get_box_color(col), text_color = txt_color)
table.cell(tbl, 1, row, str.tostring(kz._range_current), text_size = range_size, bgcolor = t ? get_box_color(col) : na, text_color = txt_color)
if show_range_avg
table.cell(tbl, 2, row, str.tostring(kz._range_store.avg()), text_size = range_size, text_color = txt_color)
if show_range and barstate.islast
var tbl = table.new(range_pos, 10, 10, chart.bg_color, chart.fg_color, 2, chart.fg_color, 1)
table.cell(tbl, 0, 0, "Killzone", text_size = range_size, text_color = txt_color)
table.cell(tbl, 1, 0, "Range", text_size = range_size, text_color = txt_color)
if show_range_avg
table.cell(tbl, 2, 0, "Avg (" + str.tostring(get_min_days_stored()) + ")", text_size = range_size, text_color = txt_color)
for in _kz
set_table(tbl, value._kz, index + 1, value.box_txt, not na(time("", value.session, gmt_tz)), value.c)
// ---------------------------------------- Core Logic --------------------------------------------------
Indicator
