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

本文标签: