Get time of High & Low since Open[8] ?

 

Hello everyone,

Please can I have some help with this coding problem. I need to assign values to 4 variables for further use in my simple EA.

double HighVal          //HighVal is the highest bid value since Open[8] 

datetime HighTime    //HighTime is the time of the highest bid since Open[8]

double LowVal          //LowVal is the lowest bid value since Open[8]

datetime LowTime   //LowTime is the time of the lowest bid since Open[8]

Many thanks to you all. 

 

Hi,

Please check here:

http://www.mql5.com/en/docs/standardlibrary/technicalindicators/timeseries

It's very good place for you to started to solve this problem.

Cheers.

 
Vos77:

Hello everyone,

Please can I have some help with this coding problem. I need to assign values to 4 variables for further use in my simple EA.

double HighVal          //HighVal is the highest bid value since Open[8] 

datetime HighTime    //HighTime is the time of the highest bid since Open[8]

double LowVal          //LowVal is the lowest bid value since Open[8]

datetime LowTime   //LowTime is the time of the lowest bid since Open[8]

Many thanks to you all. 


If I understand you properly, for the values you can use CopyHigh e.g. 1st variant of call:

double targetArray[]; 
CopyHigh("EURUSD",PERIOD_M1,0,9,targetArray);

 and then ArrayMaximum to find the highest High value among the copied elements:

int highIndex = ArrayMaximum(targetArray,0,WHOLE_ARRAY);

 So that you know that the highest value is in

targetArray[highIndex]

Then to get time of this bar:

datetime timeArray[];
CopyTime("EURUSD",PERIOD_M1,highIndex,1,timeArray);

 And then you have time of the bar in 

timeArray[0]


Obviously for the low values you use CopyLow and ArrayMinimum.

 
Enigma71fx:

If I understand you properly, for the values you can use CopyHigh e.g. 1st variant of call:

 and then ArrayMaximum to find the highest High value among the copied elements:

 So that you know that the highest value is in

Then to get time of this bar:

 And then you have time of the bar in 


Obviously for the low values you use CopyLow and ArrayMinimum.

Thanks to you both,

That is what I was looking for. I also missed the code sample at the bottom of the CopyHigh page, which might be useful to me.

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- at each tick we output the High and Low values for the bar with index,
//--- equal of the tick second
   datetime t=TimeCurrent();
   int sec=t%60;
   printf("High[%d] = %G  Low[%d] = %G",
          sec,iHigh(Symbol(),0,sec),
          sec,iLow(Symbol(),0,sec));
  }


 

Reason: