Pine 脚本:是否可以评估下一个蜡烛值?获得相对最低
Pine script: ist it possible to evaluate next candle values? to get relative lowest
我正在尝试检测每根蜡烛是否为最低值,检查之前的 5 个蜡烛低点和接下来的 5 个蜡烛低点
我发现之前没有问题:
<code>if ta.lowest(low, 5) == low
line.new(bar_index - 1, low, bar_index + 1, low, color = color.red, width = 1)
为了评估当前的 canle 是否低于下一个 canle,我尝试在“ta.lowest(low, -5)”上使用负值,但它不起作用。
你能帮帮我吗?
在 PineScript 中不可能“展望未来”。 PineScript 旨在制定交易策略,如果有可能展望未来,它会变得有点破旧。这就是为什么你不能看“下一根蜡烛”的原因。
I'm trying to detect the if each candle is the lowest value, checking
5 previous candles lows and 5 next candles lows
你所描述的是在 built-in ta.pivotlow() 函数中实现的,它搜索一个模式并找到左边给定范围内的最低值(leftbars= 参数)和向右 (rightbars=).
如前所述,您无法查看未来的柱线,因此枢轴函数的结果滞后于使用 rightbars= 参数声明的柱线数量。请注意,plotshape() 函数使用与 rightbars= 参数相同的偏移量。
//@version=5
indicator("pivotlow", overlay = true)
leftbars = 5
rightbars = 5
pivLow = ta.pivotlow(leftbars, rightbars)
plotshape(pivLow, style = shape.labelup, location = location.belowbar, offset = - rightbars)
我正在尝试检测每根蜡烛是否为最低值,检查之前的 5 个蜡烛低点和接下来的 5 个蜡烛低点
我发现之前没有问题:
<code>if ta.lowest(low, 5) == low
line.new(bar_index - 1, low, bar_index + 1, low, color = color.red, width = 1)
为了评估当前的 canle 是否低于下一个 canle,我尝试在“ta.lowest(low, -5)”上使用负值,但它不起作用。 你能帮帮我吗?
在 PineScript 中不可能“展望未来”。 PineScript 旨在制定交易策略,如果有可能展望未来,它会变得有点破旧。这就是为什么你不能看“下一根蜡烛”的原因。
I'm trying to detect the if each candle is the lowest value, checking 5 previous candles lows and 5 next candles lows
你所描述的是在 built-in ta.pivotlow() 函数中实现的,它搜索一个模式并找到左边给定范围内的最低值(leftbars= 参数)和向右 (rightbars=).
如前所述,您无法查看未来的柱线,因此枢轴函数的结果滞后于使用 rightbars= 参数声明的柱线数量。请注意,plotshape() 函数使用与 rightbars= 参数相同的偏移量。
//@version=5
indicator("pivotlow", overlay = true)
leftbars = 5
rightbars = 5
pivLow = ta.pivotlow(leftbars, rightbars)
plotshape(pivLow, style = shape.labelup, location = location.belowbar, offset = - rightbars)