Pine Script求助:如何让Heikin Ashi图表自定义线条显示在K线上层?
在Heikin Ashi图表上让自定义线条显示在K线上层的方法
在Heikin Ashi图表中,默认K线会覆盖指标绘制的线条。要让自定义线条显示在K线上层,只需在plot()函数中添加display=display.top参数即可。
修改后的代码
//@version=5 indicator("Real OHLC with Open Line on Heikin Ashi", overlay=true) t = ticker.new(syminfo.prefix, syminfo.ticker) real_open = request.security(t, timeframe.period, open) real_high = request.security(t, timeframe.period, high) real_low = request.security(t, timeframe.period, low) real_close = request.security(t, timeframe.period, close) label.new( x=bar_index, y=real_high, text="O: " + str.tostring(real_open) + "\nH: " + str.tostring(real_high) + "\nL: " + str.tostring(real_low) + "\nC: " + str.tostring(real_close), color=color.blue, textcolor=color.white, style=label.style_label_down, yloc=yloc.abovebar ) // 添加display=display.top参数,让线条显示在K线上层 plot(real_open, style=plot.style_cross, color=color.white, linewidth=2, title="Open Line", display=display.top)
说明
display.top是Pine Script v5中plot()函数的可选参数,作用是将当前绘制的系列(这里是开盘价线条)置于图表所有元素的最顶层,包括Heikin Ashi K线,避免线条被K线遮挡。
内容的提问来源于stack exchange,提问作者Trader Pfaffi
相关产品推荐
相关产品推荐

