Highest High and Lowest Low for the Day

Back to topics list To post a new topic, please log in or register
avatar
120
DeanDeV 2015.06.13 19: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? 

avatar
54
PomeGranate 2015.06.13 20: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!

avatar
76
Paul_B 2015.06.13 21: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 .

avatar
120
DeanDeV 2015.06.14 10: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? 

 

 

 

avatar
54
PomeGranate 2015.06.14 14: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];
  }


Back to topics list  

To add comments, please log in or register