(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)
PShift = PShift+PShiftdiff;
PShift2 = PShift +PShiftdiff;
Use static or globally declared variables.
static double highest,lowest,range;
//---check for new bar
static int k,bar,prevBar;
//---get minimum and maximum
k = i;
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?
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%.