How to calculate the higest/lowest middle price of the past 20 bars?middle price=(high+low+close)/3

 
double prices[20];

for (int bar=0; bar < 20; bar++) {
   prices[bar] = iMA(NULL, NULL, 1, 0, MODE_SMA, PRICE_TYPICAL, bar);
}

double high = prices[ArrayMaximum(prices)];
double low  = prices[ArrayMinimum(prices)];
 
alphatrading:
wonderful,thank u.
 
sunyc1982:

Why have you posted a new topic today with the same question?

Do not double post.

Your other topic has been deleted.

 
Keith Watford:

Why have you posted a new topic today with the same question?

Do not double post.

Your other topic has been deleted.

The code above calculate the bar begin with number 1(bar number 0,1,2,3 and so on). I want to calculate the bar begin with number 2.
 
I simple change the code iMA(NULLNULL10MODE_SMAPRICE_TYPICAL, bar)  to  iMA(NULLNULL10MODE_SMAPRICE_TYPICAL, bar+1).and it works.