Previous day ATR is {EMPTY} in a 1-Minute intraday Chart

I am trying to display the Previous Day Average True Range (ATR) on a 1-minute timeframe chart. My approach is based on a previously addressed topic, which can be found here -->How to get Yesterday ATR or RSI of daily timeframe in today intraday chart?

Code Attempt:
Below is the code I've put together in an attempt to achieve this:

// Set the daily timeframe
TimeFrameSet(inDaily);

// Calculate ATR based on the daily data
pATR = ATR(14);

// Restore the original timeframe
TimeFrameRestore();

// Reference the ATR value from the previous day
mATR = Ref(pATR, -1);

// ATR floor and ceiling
f_ATR = floor(mATR);
c_ATR = ceil(mATR);

printf("ATR = %s\n", NumToStr(mATR));

Despite my efforts, the ATR value appears as {EMPTY}, and I'm unsure where I might be going wrong.

Am I missing something? Thanks in advance.

Hi arcee
use TimeFrameExpand

// Set the daily timeframe

tf_ATR = inDaily ;
TimeFrameSet(tf_ATR);
pATR = ATR(14); // Calculate ATR based on the daily data
mATR = Ref(pATR, -1);
// ATR floor and ceiling
f_ATR = floor(mATR);
c_ATR = ceil(mATR);
// Restore the original timeframe
TimeFrameRestore();

expandmode = expandLast;

pATR = TimeFrameExpand( pATR, tf_ATR, expandmode );
// Reference the ATR value from the previous day
mATR =  TimeFrameExpand( mATR, tf_ATR, expandmode );
// ATR floor and ceiling
mATR =  TimeFrameExpand( f_ATR, tf_ATR, expandmode );
mATR =  TimeFrameExpand( c_ATR, tf_ATR, expandmode );


printf("ATR = %s\n", NumToStr(mATR));

I hope it help you

1 Like

for 1-minute timeframe

replace time frame

tf_ATR = inDaily ;

to

tf_ATR = in1Minute ;

please check

https://www.amibroker.com/guide/afl/timeframeset.html

also check

https://forum.amibroker.com/t/exploration-multi-timeframe-chart/13249/2?u=needhelp

by Fxshrat

Thanks so much. this one worked. :smiley:

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.