Download MetaTrader 5
To add comments, please log in or register
Do you have questions on how to turn your idea into reality? Ask them on the Forum!
LEE Chun Wing
747
LEE Chun Wing 2010.04.18 04:24 

I want to get the last 5 bar high in MQL5

 how to do it? 

 

THANKS 

Wackena
647
Wackena 2010.04.18 18:07  
kelly posted  :

I want to get the last 5 bar high in MQL5

 how to do it? 

 

THANKS 

Here are two ways to find previous 5 bar high. Both have not been tested and I hope are correct.

input int PastBars = 5// Number of past bars to find highest bar.
double High[];
double BarHigh=0;       // Highest bar value from PastBars range.

ArraySetAsSeries(High,true);
int copied=CopyHigh(symbol,0,0,PastBars),High);
if(copied>0 && PastBars<copied) BarHigh=High[PastBars];
Print("Highest bar value from previous ",PastBars," bars is ",BarHigh);

Can use following code to find Open, High, Low, Close and Tick_Volume values.

input int PastBars = 5;  // Number of past bars to find highest bar.
double BarHigh = 0;     // Highest bar value from PastBars range.

MqlRates rates[];
ArraySetAsSeries(rates,true);
double copied=0;
copied=CopyRates(Symbol(),0,0,PastBars,rates);
   
if(copied>0)
  {
    double size=fmin(copied,PastBars);
    for(int i=0;i<size;i++)
      {
         If(rates[i].high > BarHigh) BarHigh=rates[i].high;
      }
  }
Print("Highest bar value from previous ",PastBars," bars is ",BarHigh);
LEE Chun Wing
747
LEE Chun Wing 2010.04.19 18:42  
wackena:

Here are two ways to find previous 5 bar high. Both have not been tested and I hope are correct.

Can use following code to find Open, High, Low, Close and Tick_Volume values.

 

thankyou to wavkena, it seems to be do more in mql5~ ~

/
To add comments, please log in or register