【发布时间】:2021-08-27 18:15:22
【问题描述】:
我是 Pine 脚本的新手,想编写一个简单的指标来检测蜡烛收盘价是高于枢轴高点还是低于枢轴低点。
我成功实现了枢轴点并正确标记了它们。
问题在于检查蜡烛的收盘价是否高于/低于枢轴高点/低点不起作用。突破枢轴点的蜡烛标签没有显示,即使它们应该显示。
我正在使用一个简单的 if 语句来检查收盘价是否更高/更低。
这是我的代码:
//@version=4
study("Test", overlay=true)
// Pivot points implementation
leftbars = input(7)
rightbars = input(7)
phigh = pivothigh(high, leftbars, rightbars)
plow = pivotlow (low , leftbars, rightbars)
// Printing a label at pivot points
label1 = phigh ? label.new(bar_index[rightbars], high[rightbars], text=tostring(phigh), style=label.style_labeldown, color=color.white) : na
label2 = plow ? label.new(bar_index[rightbars], low[rightbars], text=tostring(plow), style=label.style_labelup, color=color.white) : na
// Checking if close is higher than the pivot high or lower than the pivot low
if (close > phigh)
label.new(bar_index, close, text="Breakout Candle Pivot High")
if (close < plow)
label.new(bar_index, close, text="Breakout Candle Pivot Low")
【问题讨论】:
标签: pine-script