admin管理员组文章数量:1356873
I am trying to make an indicator that can get data from the one minute chart but apply it to the 5 second chart. I want a line to turn green on the 5 second chart indicator when the 1 minute line is going up, and to turn pink when the 1 minute line is going down.
When using reqquest.security I tried to use barmerge.gaps_off so that it can still check the value between the completion of the full minute but it is not doing it. It only checks once per minute and only returns a signal on that bar instead of all the bars in between.
One workaround I did was to make it look back 12 bars (12x 5sec = 1min). This seems to give me a continuous line, but it also tends to lag very much so it gives a lot of false signals.
I am certain that I am doing something wrong with the request.security/barmerge.gaps code but I am very much a newbie and I can't figure out what I am doing wrong. If someone can help me figure out what I am doing wrong, I would greatly appreciate it.
This code just gives me hits on every one minute bar.
FinalYellow_5s = request.security(syminfo.tickerid, '5S', FinalYellow, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_on)
FinalYellow_1m = request.security(syminfo.tickerid, '1', FinalYellow, gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_on)
/// --- turn line color green
Yellow_1m_Increasing = FinalYellow_1m > FinalYellow_1m[1]
Change_Yellow_Green = Yellow_1m_increasing
/// --- turn line color pink
Yellow_1m_Decreasing = FinalYellow_1m < FinalYellow_1m[1]
Change_Yellow_Pink = Yellow_1m_decreasing
This code gives me a continuous line but it lags significnatly.
FinalBlue_5s = request.security(syminfo.tickerid, '5S', FinalBlue)
FinalYellow_5s = request.security(syminfo.tickerid, '5S', FinalYellow)
FinalBlue_1m = request.security(syminfo.tickerid, '1', FinalBlue)
FinalYellow_1m = request.security(syminfo.tickerid, '1', FinalYellow)
/// --- turn line color green
Yellow_1m_Increasing = FinalYellow_1m > FinalYellow_1m[12] // 12x 5sec bars = 1x 1min bar
Change_Yellow_Green = Yellow_1m_increasing
/// --- turn line color pink
Yellow_1m_Decreasing = FinalYellow_1m < FinalYellow_1m[12]
Change_Yellow_Pink = Yellow_1m_decreasing
I am attaching a screenshot to see how the two look like. The one called "with estimates" is the one where I tried to estimate the lookback value (making it 12, instead of 1). On the bottom, I have the 1 minute chart with it's own indicator that turns green when going up and pink when going down. I drew the green lines for reference for where it turns green to compare to how the indicators compare with it on the 5 second chart.
Screenshot of indicators
本文标签:
版权声明:本文标题:pine script - Get request.security to fill the gaps when checking a higher timeframe - make barmerge.gaps_off work properly - St 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744056708a2583387.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论