I have a strategy that uses intraday bars, but I need to get an average of the last X daily closing prices only when the daily open was greater than the daily close. So I need to find the last X occurrences of "dOpen > dClose" and then average the daily closing prices of those days.
I can successfully accomplish this with a loop on the intraday bars, but I need it on the daily bars from the intraday chart/analysis.
I originally tried it like this:
TimeFrameSet( inDaily );
for (i = 0; i < BarCount; i++)
But that does not work. It seems you cannot switch timeframes then loop. I've read in the manual how you can acquire daily data from intraday using:
dClose = TimeFrameGetPrice( "C", inDaily, -1 );
But the issue is that I do not know how many daily bars back I must go to find the last X qualified daily occurrences to then average. Could anyone please give me insight on how to accomplish this?