[英]How can I plot repeating price levels in pinescript?
我正在尝试 plot 价格水平,我想轻松地将其视为 Pinescript 中的网格。 从我所见,我不能在循环中使用hline
,有什么想法可以以不同的方式实现吗?
示例:plot 图表上每 1000 美元有一条水平线。
这应该这样做。
//@version=5
indicator('Lines', max_lines_count=500, overlay=true)
var float minPrice = input.float(0, 'Price : From', 0, inline='price')
var float maxPrice = input.float(50, 'To', 0, inline='price')
var float interval = input.float(5, 'Step', 0, inline='price')
var bool betweenHiLo = input.bool(false, 'Only show lines between highest and lowest price of the ticker')
var int timeFirst = na
var float atl = 1e20
var float ath = 0
if barstate.isfirst
timeFirst := time
if betweenHiLo
atl := math.min(atl, low)
ath := math.max(ath, high)
if barstate.islast
atl := math.floor(atl / interval) * interval
ath := math.ceil(ath / interval) * interval
fromY = betweenHiLo ? atl : minPrice
toY = betweenHiLo ? ath : maxPrice
for i = fromY to toY by interval
line.new(timeFirst, i, timeFirst+1, i, xloc.bar_time, extend.right)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.