Help: How to obtain yesterday Highest closed and yesterday Lowest closed price in MQL4?

To add comments, please log in or register
Jutareal
18
Jutareal  

Hi All,

I want to learn coding in MQL4 but cannot find a way to get Yesterday Highest CLOSED and Yesterday Lowest CLOSED price? I can get yesterday highest and Lowest price but not its closed price. Can anyone show me how to do it? Thanks in advance.

Icham Aidibe
11675
Icham Aidibe  
Jutareal:

Hi All,

I want to learn coding in MQL4 but cannot find a way to get Yesterday Highest CLOSED and Yesterday Lowest CLOSED price? I can get yesterday highest and Lowest price but not its closed price. Can anyone show me how to do it? Thanks in advance.


Do you mean the candle (which timeframe ?) which closed the lowest/highest yesterday  - OR - the highest/lowest price of yesterday once market closed or the close price of the candle in which occured yesterday's highest/lowest ? 

You're confuse.

Carl Schreiber
Moderator
8826
Carl Schreiber  
Jutareal:

Hi All,

I want to learn coding in MQL4 but cannot find a way to get Yesterday Highest CLOSED and Yesterday Lowest CLOSED price? I can get yesterday highest and Lowest price but not its closed price. Can anyone show me how to do it? Thanks in advance.

Maybe you should start reading in the editor's reference (F1) about Close[] and iClose().

It's a lot faster than waiting here for someone to answer.

Beside that you can be sure that practically all question you'll have the next week already have been asked and answered here: Search first by the lens top right on the pages!

Jutareal
18
Jutareal  
Icham Aidibe:

Do you mean the candle (which timeframe ?) which closed the lowest/highest yesterday  - OR - the highest/lowest price of yesterday once market closed or the close price of the candle in which occured yesterday's highest/lowest ? 

You're

Icham Aidibe:

Do you mean the candle (which timeframe ?) which closed the lowest/highest yesterday  - OR - the highest/lowest price of yesterday once market closed or the close price of the candle in which occured yesterday's highest/lowest ? 

You're confuse.

WOW Icham! I don't realize so many different values...

Actually what I want is the price at yesterday Highest candle (body) and yesterday Lowest candle (body) in H1 time frame. Please see the attached picture. Thanks.

Files:
Diagram.JPG 82 kb
Icham Aidibe
11675
Icham Aidibe  
Jutareal:

What you're looking for is yesterday open and close price :) - you want the highest & lowest from open&close price of 1h candles yesterday ?

nicholi shen
2392
nicholi shen  
Icham Aidibe:

What you're looking for is yesterday open and close price :)


According to his diagram he wants the highest close price in the working timeframe. 

   int start = iBarShift(_Symbol,_Period,iTime(_Symbol,PERIOD_D1,1));
   int end   = iBarShift(_Symbol,_Period,iTime(_Symbol,PERIOD_D1,1)+PeriodSeconds(PERIOD_D1)-1);
   double highest_close = Close[iHighest(_Symbol,_Period,MODE_CLOSE,start-end+1,end)];
Icham Aidibe
11675
Icham Aidibe  
void OpenCloseHighestLowestYesterday()
{
  datetime yesterday[];
  double open[], close[];
  CopyTime(_Symbol,PERIOD_D1,1,1,yesterday);
//
  CopyOpen(_Symbol,PERIOD_H1,yesterday[0],24,open);
  CopyClose(_Symbol,PERIOD_H1,yesterday[0],24,close);
//
  double Lowest = MathMin(open[ArrayMinimum(open,WHOLE_ARRAY,0)],close[ArrayMinimum(close,WHOLE_ARRAY,0)]);
  double Highest = MathMax(open[ArrayMaximum(open,WHOLE_ARRAY,0)],close[ArrayMaximum(close,WHOLE_ARRAY,0)]);
  printf("*** Lowest H1 candle open/close yesterday : %g ---- Highest H1 candle open/close yesterday : %g",Lowest,Highest);  
}

This function for MQL4, will print the highest open or close price of all H1 candle yesterday and the lowest open or close price all H1 candle yesterday.

EDIT : I've corrected the code to suits MQL4 (ArrayMax & ArrayMin works differently)

nicholishen:

According to his diagram he wants the highest close price in the working timeframe. 


Not sure what he's really looking for, but here's what I got from his request :/

Jutareal
18
Jutareal  
Icham Aidibe:

This function for MQL4, will print the highest open or close price of all H1 candle yesterday and the lowest open or close price all H1 candle yesterday.

EDIT : I've corrected the code to suits MQL4 (ArrayMax & ArrayMin works differently)


Not sure what he's really looking for, but here's what I got from his request :/

Thanks Icham. That is what I am looking for. I will try to see the results. Thanks again.
Icham Aidibe
11675
Icham Aidibe  
Jutareal:
Thanks Icham. That is what I am looking for. I will try to see the results. Thanks again.

You welcome.

luthersuerte
5
luthersuerte  
Icham Aidibe:

This function for MQL4, will print the highest open or close price of all H1 candle yesterday and the lowest open or close price all H1 candle yesterday.

EDIT : I've corrected the code to suits MQL4 (ArrayMax & ArrayMin works differently)


Not sure what he's really looking for, but here's what I got from his request :/

Hello! Icham Aidibe, Thank you for the code but Im trying to make it work in Metaeditor but it seems im having a problem compiling it. Error says "event handling function not found" at line no. 1.

To add comments, please log in or register