我有一个问题,当两条线在烛台上相遇时,我想在指示器上触发警报。我在脚本中使用实时蜡烛,所以可以执行这种状态。不幸的是,旧的交易在一根蜡烛后被执行,在某些情况下会导致错误的交易。是否可以在下面的脚本中完全在蜡烛上执行警报?我试了好几次都没有成功。
Screen Picture
//@version=5
strategy("Test 37", process_orders_on_close=true, max_bars_back = 4000, overlay=true, max_lines_count=500, max_labels_count=500, calc_on_every_tick=true)
tick = syminfo.ticker
ZZPercent = input.float(0.45, title="Minimum % Change")
trend = 0
trend := na(trend[1]) ? 1 : trend[1]
LL = 0.0
LL := na(LL[1]) ? low : LL[1]
HH = 0.0
HH := na(HH[1]) ? high : HH[1]
PivotChg = ZZPercent * 0.01
float zigzag = na
if (trend > 0) // trend is up, look for new swing low
if (high >= HH) // new higher high detected
HH := high
//label.new(bar_index, na, "", color=color.rgb(233, 7, 7), textcolor=color.black, style=label.style_label_down, yloc=yloc.belowbar)
else
if (low < HH * (1 - PivotChg))
zigzag := high[1]
trend := -1
LL := low
// Short- Auslöser
if (low < HH * (1 - PivotChg))
label.new(bar_index, na, "", color=color.rgb(240, 53, 6), textcolor=color.black, style=label.style_label_down, yloc=yloc.abovebar)
alert("SS_Alert Short " + str.tostring(tick), alert.freq_once_per_bar) // , freq = alert.freq_all alert.freq_once_per_bar
else // trend is down, look for new swing high
if (low <= LL) // new lower low detected
LL := low
//label.new(bar_index, na, "", color=color.green, textcolor=color.black, style=label.style_label_up, yloc=yloc.belowbar)
else
if (high > LL * (1 + PivotChg))
zigzag := low[1]
trend := 1
HH := high
// Long- Auslöser
if (high > LL * (1 + PivotChg))
label.new(bar_index, na, "", color=color.green, textcolor=color.black, style=label.style_label_up, yloc=yloc.belowbar)
alert("LL_Alert Long " + str.tostring(tick), alert.freq_once_per_bar) // , freq = alert.freq_all alert.freq_once_per_bar
plot(series=zigzag, linewidth=2, style=plot.style_line, offset=-1)