Download MetaTrader 5

Highest High and Lowest Low for the Day

To add comments, please log in or register
Do you often publish source codes? Find out how to do that correctly!
DeanDeV
330
DeanDeV 2015.06.13 17:44 

Hey guys,

 I am in need of assistance please. What I would like to do is every time price creates a new high or low for the day I want to be able to save the price and the time somehow (perhaps in the global scope) to use it as a reference point? Would anyone know how to do this? 

PomeGranate
564
PomeGranate 2015.06.13 18:15  

Hi Dean,

your algorithm should look like this for the highs:

  • store the current highest high (at beginning of day, high of first bar)
  • compare high of new candle with current highest high (https://docs.mql4.com/series/ihigh)
  • if it is higher, memorize price and datetime, store new value for current highest high
  • and so on until end of day


Hope this was of help. Have a nice Weekend!

Paul B
175
Paul B 2015.06.13 19:01  

Use:

iHigh(NULL, PERIOD_D1, 0);

 and 

iLow(NULL, PERIOD_D1, 0);

 

Store them to variables and compare the current to the stored to update / record what you want .

DeanDeV
330
DeanDeV 2015.06.14 08:07  
Paul_B:

Use:

 and 

 

Store them to variables and compare the current to the stored to update / record what you want .

Thank you for your reply. I did some digging and got this:

int High=iHighest(Symbol(),Period(),MODE_HIGH,WindowFirstVisibleBar()-1,1); 

 And modified it to get the high price:

 double DailyHigh=High[iHighest(Symbol(),Period(),MODE_HIGH,WindowFirstVisibleBar()-1,1)];

 Then used this to store the time:

datetime DailyHighTime=Time[High]; 

 However, how do I compare the current high price and time to those and store them? 

PomeGranate
564
PomeGranate 2015.06.14 12:31  
DeanDeV:

 However, how do I compare the current high price and time to those and store them? 

I see your request was meant for daily charts, at first misunderstood you wanted to analyze smaller timeframes for every single day. Try this for comparation & update:

if (High[0]>DailyHigh)
  {
   DailyHigh=High[0];
   DailyHighTime=Time[0];
  }
To add comments, please log in or register