查找每个交易日的前四根连续红色蜡烛

Finding the first four consecutive red candles of each trading day

我试图为每个交易日分离出一个简单的模式,只是第一组连续的红色蜡烛。

strategy("fourRed", overlay=true)

var fourRedOccur = false

fourRedCandles = not fourRedOccur and (close[3] < open[3]) and (close[2] < open[2]) and (close[1] < open[1]) and (close < open)

if (fourRedCandles)
    fourRedOccur := true

plotshape(series=fourRedCandles, style=shape.xcross, color=white, location=location.belowbar)

到目前为止,我似乎无法:

1) 仅隔离第一次出现
2)让它每天只显示一次(需要介绍time吗?)

您可以使用它来定义您的基本条件:

fourRedCandles = sum(close < open ? 1 : 0, 4) == 4