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

To add comments, please log in or register
sunyc1982
45
sunyc1982  
please show me the code,thank u.
alphatrading
102
alphatrading  
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)];
sunyc1982
45
sunyc1982  
alphatrading:
wonderful,thank u.
Keith Watford
Moderator
20380
Keith Watford  
sunyc1982:

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

Do not double post.

Your other topic has been deleted.

sunyc1982
45
sunyc1982  
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.
sunyc1982
45
sunyc1982  
I simple change the code iMA(NULLNULL10MODE_SMAPRICE_TYPICAL, bar)  to  iMA(NULLNULL10MODE_SMAPRICE_TYPICAL, bar+1).and it works.
To add comments, please log in or register