Alert when price enters an Effort Zone
Reading a chart indicator by name: a marker the moment a bar closes inside one of the zones Effort Zones drew, coloured by the zone's side, candles tinted while price sits in a zone, and a readout of how many ticks away the nearest zone above and below are. Turn on the Alert tab and every entry marker raises a sound and a popup. Needs Effort Zones on the chart; without it the readout says so.
//@xfscript 1
indicator("Effort Zone Entry")
let buy_color: color = input.color("#22C55E", "buyColor", "Buy side zone")
let sell_color: color = input.color("#EF4444", "sellColor", "Sell side zone")
let tint: float = input.float(0.45, "tint", "Candle tint while inside", 0, 1, 0.05)
let has_zones: bool = effort_zones.available()
let zone: int = effort_zones.at(close)
let in_zone: bool = zone >= 0
let entered: bool = bar_index > 0 && has_zones && in_zone && !in_zone[1]
let zone_side: side = effort_zones.side(zone)
plot.marker(entered && zone_side == "BUY", low, buy_color, "triangle", "below", 12, 4)
plot.marker(entered && zone_side == "SELL", high, sell_color, "triangle", "above", 12, 4)
plot.marker(entered && zone_side == "UNDEFINED", close, "#9CA3AF", "diamond", "above", 10, 4)
plot.candle_color(in_zone && zone_side == "BUY", buy_color, tint)
plot.candle_color(in_zone && zone_side == "SELL", sell_color, tint)
plot.dot(effort_zones.started() > 0, high, "#F59E0B", 4)
let tick: float = nz(chart.tick_size(), 0.25)
let up: int = effort_zones.above(close)
let down: int = effort_zones.below(close)
let to_up: float = (effort_zones.low(up) - close) / tick
let to_down: float = (close - effort_zones.high(down)) / tick
if has_zones {
plot.label(str.concat("ZONES ON THIS BAR ", format.compact(effort_zones.count()), " UP ", format.fixed(nz(to_up, 0), 0), " DOWN ", format.fixed(nz(to_down, 0), 0), " TICKS"), "#E5E7EB")
} else {
plot.label("ADD EFFORT ZONES TO THIS CHART", "#6B7280")
}