Download MetaTrader 5

How to find the time when previous day high and low were made

To add comments, please log in or register
Interested in Signals activity? Come and track!
DeanDeV
330
DeanDeV 2016.06.28 18:21 

Hey guys,

I need some help please. I am trying to look for the time when the previous day high and low was formed. Below are my equations; they do give the correct prices, however they do not return the correct integers of the candles that formed the high/ low. Please help! 

high=iHighest(NULL,0,MODE_HIGH,iBarShift(NULL,0,Time[0]-((Time[0]%86400)+86400),1)); 
low=iLowest(NULL,0,MODE_LOW,iBarShift(NULL,0,Time[0]-((Time[0]%86400)+86400),1));
timei=Time[low];
timeii=Time[high];

Thank you!  

whroeder1
14544
whroeder1 2016.06.29 01:39  
  1. Time[0]-((Time[0]%86400)+86400)
    This assumes that there are no gaps in the chart, like there are over the weekend. Don't assume.
  2. iHighest(NULL,0,MODE_HIGH,x,1)
    This returns the highest bar from [x-1 .. 1] That is not from [yesterday .. today)
  3. Write self documenting code.
    #define HR2400 86400
    datetime today     = Time[0] - Time[0] % HR2400;
    int      iYestLast = iBarShift(NULL,0, today) - 1;
    datetime yesterday = Time[iYestLast] - Time[iYestLast]  % HR2400;
    int      iYestBeg  = iBarShift(NULL,0, yesterday);
    int      len       = iYestBeg - iYestLast + 1;
    
    high=iHighest(NULL,0,MODE_HIGH, len, iYestLast); 
     low=iLowest( NULL,0,MODE_LOW,  len, iYestLast); 
    timei=Time[low];
    timeii=Time[high];

DeanDeV
330
DeanDeV 2016.06.29 04:02  
WHRoeder:
  1. This assumes that there are no gaps in the chart, like there are over the weekend. Don't assume.
  2. This returns the highest bar from [x-1 .. 1] That is not from [yesterday .. today)
  3. Write self documenting code.
Thank you good sir. Will give this a try.
To add comments, please log in or register