Download MetaTrader 5

EA Saving Dates of HIgh/Low of Reversal condition of oversold and overbought conditions to predict next oversold area What am i missing?.

To add comments, please log in or register
Having troubles understanding the code? Articles can help you!
Hector Martinez Jr
Hector Martinez Jr 2016.06.29 11:55 

(MQL4)I am trying to code a function that can remember the date of a low or high given a specific condition until that condition is generated again and determines a new high.

The problem im having is that if i make a simple Highest or Lowest Function it uses periods and as a new day comes and the highest or lowest point is outside the Period Range  the Highest and Lowest is not longer the Highest and Lowest value of the Trend.  

i tried subtracting the new periods to cancel them by using iBarshift of the relevant lowest but does not work, what am i missing. 

double PShift = 3;

double PShift2 = 4;

double PShiftdiff = PShift2 - PShift;

   double Lowest = iLow(NULL,PERIOD_D1,(iLowest(NULL,PERIOD_D1,MODE_LOW,PShift,1)));

   double Highest = iHigh(NULL,PERIOD_D1,(iHighest(NULL,PERIOD_D1,MODE_HIGH,PShift,1))); //i want this high to be remember regardless of the amount of periods chosen to find the highest value in this case the highest value of a reversal and the lowest  

    // so it can remember  oversold reversal high/low then overbought high/low so it can use this data to predict next oversold reversal. 

   double HTime = iTime(NULL,PERIOD_D1, Highest);

   double BarshiftH = iBarShift(NULL,PERIOD_D1, HTime);  

if(Slope<1.5 && Slope>-1.5) { if(mid >rsimid) { if(Open[0]<mid+stdev2a) { if(iHigh(NULL,PERIOD_D1,PShift2)>Highest) { PShift = PShift+PShiftdiff; PShift2 = PShift +PShiftdiff; } } } 

Ernst Van Der Merwe
Ernst Van Der Merwe 2016.06.29 16:53  

Use static or globally declared variables.

   double min,max;
   static double highest,lowest,range;
//---check for new bar
   static int k,bar,prevBar;
//---get minimum and maximum
      k = i;
Hector Martinez Jr
Hector Martinez Jr 2016.07.06 11:53  

Thanks Appreciate your feedback, i was able to code what i needed, was focused on trying to restrict time when it was as simple as simply using the begining and end of each event/condition to obtain the data i needed using static variables.  Simplest things always get me.  


Since i finished a good portion of my code i ran the EA through the tester but got results with a 58% modeling quality using a 4h TF on 1 years worth of data.  any idea on how reliable these results may be? 

Ernst Van Der Merwe
Ernst Van Der Merwe 2016.07.06 12:27  

The modelling quality depends on which lower timeframe the tester is using. In this case probably not lower than M15 (will indicate when testing starts).

Since the range is calculated on the previous bars, results should be quite accurate. That said, I wouldn't trust the tester algorithm 100%.

To add comments, please log in or register