我收到了一个学习错误:使用xloc.bar_index定位的对象不能在未来绘制超过500个条形图。我甚至不知道该从哪里着手解决这个问题。这里的一些专家的帮助将是非常有用的。
indicator('MTF Engulfing Candles', overlay=true, max_boxes_count=500, max_lines_count=500)
tf = input.timeframe("240", "Timeframe", options=["60","240","480","720","W","M"])
O1 = request.security(syminfo.tickerid, tf, open[1])
H1 = request.security(syminfo.tickerid, tf, high[1])
L1 = request.security(syminfo.tickerid, tf, low[1])
C1 = request.security(syminfo.tickerid, tf, close[1])
O2 = request.security(syminfo.tickerid, tf, open[2])
H2 = request.security(syminfo.tickerid, tf, high[2])
L2 = request.security(syminfo.tickerid, tf, low[2])
C2 = request.security(syminfo.tickerid, tf, close[2])
barIndex = request.security(syminfo.tickerid, tf, bar_index)
barIndexMinus2 = request.security(syminfo.tickerid, tf, bar_index-2)
// FUNCTIONS
bullE()=>
r = C2 < O2 and C1 > O1 and C1 > H2 ? 1 : 0
bearE()=>
r = C2 > O2 and C1 < O1 and C1 < L2 ? 1 : 0
if bullE()
box.new(left=barIndexMinus2, right=barIndex, top=H1 ,bottom=math.min(L2,L1), border_color = color.new(color.black,65), bgcolor = color.new(#66bb6a,75))
if bearE()
box.new(left=barIndexMinus2, right=barIndex, top=math.max(H2,H1) ,bottom=L2, border_color = color.new(color.black,65), bgcolor = color.new(#ffa726, 75))发布于 2022-09-11 21:41:25
我用bar_time而不是bar_index来解决这个问题。
发布于 2022-09-04 10:51:50
您正在从其他时间框架请求bar_index,并将其用作box.new()的left和right参数。问题是,这种差异可能很大程度上取决于您所处的时间框架。
例如,在BINANCE:BTCUSDT,1h上,当前的bar_index是23426。barIndex和barIndexMinus2分别为11051和11049。
您可以看到,如果将这些变量用作left调用的box.new()和right参数,则会导致此问题。因为当前条形索引和变量之间的距离超过500。
https://stackoverflow.com/questions/73597935
复制相似问题