本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("Amari's Killzone Timings", overlay=true, max_boxes_count=500)
// ───── Only show on intraday timeframes ─────
showIndicator = timeframe.isintraday
// ───── Colors ─────
asiaColor = input.color(color.new(color.blue, 85), "Asia")
londonColor = input.color(color.new(color.orange, 85), "London")
newYorkColor = input.color(color.new(color.red, 85), "New York")
londonCloseColor = input.color(color.new(color.purple, 85), "London Close")
// ───── Session times ─────
asiaSession = "2200-0700"
londonSession = "0800-0900"
newYorkSession = "1400-1500"
londonCloseSession = "1600-2000"
tz = "Europe/London"
// ───── Session states ─────
inAsia = showIndicator and not na(time(timeframe.period, asiaSession, tz))
inLondon = showIndicator and not na(time(timeframe.period, londonSession, tz))
inNewYork = showIndicator and not na(time(timeframe.period, newYorkSession, tz))
inLondonClose = showIndicator and not na(time(timeframe.period, londonCloseSession, tz))
// ───── Variables ─────
var box asiaBox = na
var float asiaHigh = na
var float asiaLow = na
var box londonBox = na
var float londonHigh = na
var float londonLow = na
var box nyBox = na
var float nyHigh = na
var float nyLow = na
var box lcBox = na
var float lcHigh = na
var float lcLow = na
// ═══════════════════════════════════════
// ASIA
// ═══════════════════════════════════════
asiaStart = inAsia and not inAsia[1]
if asiaStart
asiaHigh := high
asiaLow := low
asiaBox := box.new(
left=bar_index,
top=high,
right=bar_index,
bottom=low,
bgcolor=asiaColor,
border_color=na)
if inAsia
asiaHigh := math.max(asiaHigh, high)
asiaLow := math.min(asiaLow, low)
box.set_top(asiaBox, asiaHigh)
box.set_bottom(asiaBox, asiaLow)
box.set_right(asiaBox, bar_index)
// ═══════════════════════════════════════
// LONDON
// ═══════════════════════════════════════
londonStart = inLondon and not inLondon[1]
if londonStart
londonHigh := high
londonLow := low
londonBox := box.new(
left=bar_index,
top=high,
right=bar_index,
bottom=low,
bgcolor=londonColor,
border_color=na)
if inLondon
londonHigh := math.max(londonHigh, high)
londonLow := math.min(londonLow, low)
box.set_top(londonBox, londonHigh)
box.set_bottom(londonBox, londonLow)
box.set_right(londonBox, bar_index)
// ═══════════════════════════════════════
// NEW YORK
// ═══════════════════════════════════════
nyStart = inNewYork and not inNewYork[1]
if nyStart
nyHigh := high
nyLow := low
nyBox := box.new(
left=bar_index,
top=high,
right=bar_index,
bottom=low,
bgcolor=newYorkColor,
border_color=na)
if inNewYork
nyHigh := math.max(nyHigh, high)
nyLow := math.min(nyLow, low)
box.set_top(nyBox, nyHigh)
box.set_bottom(nyBox, nyLow)
box.set_right(nyBox, bar_index)
// ═══════════════════════════════════════
// LONDON CLOSE
// ═══════════════════════════════════════
lcStart = inLondonClose and not inLondonClose[1]
if lcStart
lcHigh := high
lcLow := low
lcBox := box.new(
left=bar_index,
top=high,
right=bar_index,
bottom=low,
bgcolor=londonCloseColor,
border_color=na)
if inLondonClose
lcHigh := math.max(lcHigh, high)
lcLow := math.min(lcLow, low)
box.set_top(lcBox, lcHigh)
box.set_bottom(lcBox, lcLow)
box.set_right(lcBox, bar_index)