Jimmy
Jimmy

Reputation: 43

accurate data from lower time frame in pinescript

I'm trying to code a series of labels that prints the status of ADX/DMI at various timeframes, so one can see at a glance what timeframes are trending and what arent.

I pass the DMI function to the security() function to get the values at 15 different timeframes.

ADXM  = security(syminfo.tickerid, res15, adxcol,barmerge.gaps_off, barmerge.lookahead_off)  

now I understand that the security function works best when requesting higher timeframe data, not so much the other way, so my code and the lables are correct when I look at it from a 1 minute chart but values start to change if I'm in a higher timeframe like 1h.

is there a workaround to calculate this on the 1m and show the same data no matter what timeframe my chart currently is?

Upvotes: 0

Views: 1453

Answers (1)

Bjorgum
Bjorgum

Reputation: 2310

No we cannot reliably request data from below. This is because we reduce the resolution of that data. Historical data is OHLC, and in real time we are building candles in the same manner to have one close per 1hr bar. So data requested from a lower chart is subject to give us only the last value that the lower time frame was at the time of the higher time frame close. If we want all those time frames we must drop down and pull the data from above as we will have the resolution necessary to see all of the values.

Cheers

Upvotes: 3

Related Questions