首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在LTF图上绘制HTF吞吐蜡烛时的误差研究

在LTF图上绘制HTF吞吐蜡烛时的误差研究
EN

Stack Overflow用户
提问于 2022-09-04 08:40:44
回答 2查看 98关注 0票数 1

我收到了一个学习错误:使用xloc.bar_index定位的对象不能在未来绘制超过500个条形图。我甚至不知道该从哪里着手解决这个问题。这里的一些专家的帮助将是非常有用的。

代码语言:javascript
复制
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))
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-09-11 21:41:25

我用bar_time而不是bar_index来解决这个问题。

票数 0
EN

Stack Overflow用户

发布于 2022-09-04 10:51:50

您正在从其他时间框架请求bar_index,并将其用作box.new()leftright参数。问题是,这种差异可能很大程度上取决于您所处的时间框架。

例如,在BINANCE:BTCUSDT,1h上,当前的bar_index23426barIndexbarIndexMinus2分别为1105111049

您可以看到,如果将这些变量用作left调用的box.new()right参数,则会导致此问题。因为当前条形索引和变量之间的距离超过500。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73597935

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档