要记录的当天第一个蜡烛的高点和低点



在盘中,我需要在第二个蜡烛上放置一个买入或卖出标签,每当它越过第一个蜡烛的高点或低点。需要正确的工作代码。我只需要做一次比较,即当第一个蜡烛的高点被打破或低点被突破时,不要超过多次。

我试图建立这个逻辑,但它正在发射多个信号。我需要在第一次满足条件时将其限制为仅一次。

//@version=4
study("Close of first bar of a day", overlay=true)
isNewDay = time("D") != time("D")[1]
var firstBarHighValue = high
var firstBarLowValue = low
if isNewDay
firstBarLowValue := low
firstBarHighValue := high
buy  = close > firstBarHighValue and close>open
sell = close < firstBarLowValue and close<open
plotshape(buy,  title = "Buy",  text = 'Buy',  style = shape.labelup,   
location = location.belowbar, color= color.green, textcolor = 
color.white, transp = 0, size = size.large)
plotshape(sell, title = "Sell", text = 'Sell', style = 
shape.labeldown, location = location.abovebar, color= color.red,   
textcolor = color.white, transp = 0, size = size.large)

像这样:

//@version=4
study("Close of first bar of a day", overlay=true)

isNewDay = time("D") != time("D")[1] 
var plotcond = false
var firstBarHighValue = high
var firstBarLowValue = low
if isNewDay
firstBarLowValue := low
firstBarHighValue := high
plotcond := true

buy  = close > firstBarHighValue and close>open and plotcond
sell = close < firstBarLowValue and close<open and plotcond
if (buy or sell) and (not isNewDay)
plotcond := false

plotshape(buy,  title = "Buy",  text = 'Buy',  style = shape.labelup,   location = location.belowbar, color= color.green, textcolor = color.white, transp = 0, size = size.large)
plotshape(sell, title = "Sell", text = 'Sell', style = shape.labeldown, location = location.abovebar, color= color.red,   textcolor = color.white, transp = 0, size = size.large)

相关内容

  • 没有找到相关文章