How to find HHV and LLV of Previous n Days when working Intraday?

Hi,
I am trying to get the HHV and LLV of the previous 3 Days, I am working on Intraday timeframe.
I use the formula to get PREV day but cant' find anything for a different Day range.

I only came up with two options, one not so elegant

myH = Max(Max(TimeFrameGetPrice("H",inDaily,-3), TimeFrameGetPrice("H",inDaily,-2)), TimeFrameGetPrice("H",inDaily,-1));
myL = Min(Min(TimeFrameGetPrice("L",inDaily,-3), TimeFrameGetPrice("L",inDaily,-2)), TimeFrameGetPrice("L",inDaily,-1));

Another method I can think of is to use HighestSince() and LowestSinc() in combination with the first bar of 3 Days ago, but I can't figure out how to find the first bar of three days ago.

Any suggestion is welcome.

Read carefully

https://www.amibroker.com/guide/h_timeframe.html

Thanks @awilson for the suggestion.
I've figure out two ways to get what I want.

One is with TimeFrameSet()

TimeFrameSet( inDaily );
prevThreeDayHHV = Ref(HHV(H,3), -1);
TimeFrameRestore();
expandPrevThreeDayHHV = TimeFrameExpand(prevThreeDayHHV, inDaily, expandFirst);
Plot( expandPrevThreeDayHHV, "expandPrevThreeDayHHV", colorAqua, styleLine );

The second method with HHV with a period worth three days bars (15min RTH only in my case)

barSinceNewDay = BarsSince(Day()!=Ref(Day(),-1))+1;
prevThreeDaysHHV = Ref(HHV(H, 27*3),-barSinceNewDay);
prevThreeDaysLLV= Ref(LLV(L, 27*3), -barSinceNewDay);

These two methods give the same result.
I also tried to use TimeframeCompress but does not work, I can't figure out why , maybe I misunderstood how to use it

// This does not work
dayH = TimeFrameCompress(H, inDaily);
dailyHighInDaily = Ref(HHV(dayH, 3), -1);
dailyHigh = TimeFrameExpand(dailyHighInDaily, inDaily);
1 Like

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