Question related to accessing previous periods range

HI,

I have stuck in this part. How to access previous periods range? Let me explain it clearly.

I am developing this exploration for 15 mins time period.

I have no problem getting values of current period range like shown below. All I am doing is getting Highest High value and Lowest Low value between 11:30 AM to 12:15 PM (4 15 mins candle)

STARTRANGETIME = 113000;
ENDRANGETIME =  121500;

tn = TimeNum();
StartBar = tn == StartRangeTime;
EndBar = tn == EndRangeTime;

RANGE_HI = ValueWhen( EndBar, HighestSince( StartBar, High ) );
RANGE_LO = ValueWhen( EndBar, LowestSince( StartBar, Low ) );

The problem now is I want to compare RANGE HI and RANGE LO with previous 2 days RANGE HI and RANGE LO. I did something like shown below but didn't workout. What I am doing below is I am taking RANGE_HI variable and comparing with previous 2 days RANGE_HI, I am doing this using TIMEFRAMESET function. Problem is Always HIGHER_HIGH is coming 0, so not getting filtered out. Please Help ?

TimeFrameSet(inDaily);
HIGHER_HIGH = RANGE_HI > Ref(RANGE_HI, -1) AND Ref(RANGE_HI, -1) > Ref(RANGE_HI, -2);
TimeFrameRestore();

HIGHER_HIGH = TimeFrameExpand(HIGHER_HIGH, inDaily, expandFirst);

Filter = HIGHER_HIGH;

Thanks,
Vinay

I think you probably want to use TimeFrameCompress() rather than TimeFrameSet(). The first one applies to an array that you specify, while the second one just works on the built in arrays (Open, High, Low, Close, etc.).

Yes. Thanks. Same I did.. I achieved like shown below

tn = TimeNum();

StartBar = tn == StartRangeTime;
EndBar = tn == EndRangeTime;

RANGE_HI = ValueWhen( EndBar, HighestSince( StartBar, High ) );
RANGE_LO = ValueWhen( EndBar, LowestSince( StartBar, Low ) );

COMPRESSED_HIGH = TimeFrameCompress( RANGE_HI, inDaily );
COMPRESSED_LOW = TimeFrameCompress( RANGE_LO, inDaily );

BULL = Sum(COMPRESSED_HIGH > Ref(COMPRESSED_HIGH, -1), 2) == 2 AND 
		Sum(COMPRESSED_LOW > Ref(COMPRESSED_LOW, -1), 2) == 2 AND
		tn > ENDRANGETIME;

BEAR = Sum(COMPRESSED_HIGH < Ref(COMPRESSED_HIGH, -1), 2) == 2 AND 
		Sum(COMPRESSED_LOW < Ref(COMPRESSED_LOW, -1), 2) == 2 AND
		tn > ENDRANGETIME;
		

I would advise you to add some Exploration lines to your AFL so that you can see what values you're getting. Among other things, you will probably want to use TimeFrameExpand to get the BULL and BEAR variables back into your base (15-minute) timeframe.

Hi @mradtke, Even the BULL and BEAR will be in compressed form ? My understanding was that only COMPRESSED_HIGH and COMPRESSED_LOW will be in compressed form.

Yes, because COMPRESSED_HIGH and COMPRESSED_LOW are compressed to daily bars, and you create BULL and BEAR from those compressed arrays, that means BULL and BEAR are also compressed until you expand them.

Thanks you very much. I will check.... Now I understand. Thanks a lot again...