EA stop working. iCustom is no longer updated without error

 

Hello Community,

I have programmed an EA that is supposed to enter trades based on fractal breaks. I have programmed my own fractal indicator for this, as I want to adjust the period. The logic is quite simple: as soon as a high fractal is broken with a close above it, a long trade should be placed and the same applies to short.

For this I get the fractals from my 'Indicator' and save them in a separate struct variable (simplified code! Complete code in the appendix) every time a fractal is formed, highFractal/lowFractal is overwritten and the "trend line" is set to the new fractal. Every time a fractal is broken, highFractal/lowFractal is set to 0 and the "trend line" is deleted :

 input int Fr_period = 2 ;   // Fractal period

 struct SFractals {
     double    price;
     datetime time;
     bool      set;
};

SFractals highFractal;
SFractals lowFractal;

 string highFractal_Line = "High Fractal line" ;
 string lowFractal_line  = "Low Fractal line" ;

 double cBuffer_lowFactals[], cBuffer_highFractals[];

 int fractals_handle = iCustom ( _Symbol , PERIOD_CURRENT , "Stfn_Fractals_Beta" , Fr_period);

 void OnTick () {
    copyBufferFractals(Fr_period + 2 );
     if (cBuffer_highFractals[Fr_period + 1 ] != EMPTY_VALUE && cBuffer_highFractals[Fr_period + 1 ] > 0 )
        setHighFractal(cBuffer_highFractals[Fr_period + 1 ], iTime ( _Symbol , PERIOD_CURRENT , Fr_period + 1 ));
     if (cBuffer_lowFactals[Fr_period + 1 ] != EMPTY_VALUE && cBuffer_lowFactals[Fr_period + 1 ] > 0 )
        setLowFractal(cBuffer_lowFactals[Fr_period + 1 ], iTime ( _Symbol , PERIOD_CURRENT , Fr_period + 1 ));
}

 void copyBufferFractals( int _count) {
     CopyBuffer (fractals_handle, 0 , 0 , _count, cBuffer_lowFactals);
     CopyBuffer (fractals_handle, 1 , 0 , _count, cBuffer_highFractals);
}

 // Set HighFractal with data
 void setHighFractal( double _price, datetime _time) {
    highFractal.price = _price;
    highFractal.time  = _time;
    highFractal.set   = true ;
    drawTrendLine(highFractal_Line, highFractal.price, highFractal.time, clrAqua );
     // printTxt(__FUNCTION__, "New high fractal set with: " + DoubleToString(_price) + " on " + TimeToString(_time)); 
}

 // Set LowFractal with data
 void setLowFractal( double _price, datetime _time) {
    lowFractal.price = _price;
    lowFractal.time  = _time;
    lowFractal.set   = true ;
    drawTrendLine(lowFractal_line, lowFractal.price, lowFractal.time, clrOrange );
     // printTxt(__FUNCTION__, "New low fractal set with: " + DoubleToString(_price) + " on " + TimeToString(_time)); 
}

 void drawTrendLine( string _name, double x, datetime y, color _clr) {
     if ( ObjectCreate ( 0 , _name, OBJ_TREND , 0 , y - PeriodSeconds ( PERIOD_CURRENT ) * Fr_period, x, y + PeriodSeconds ( PERIOD_CURRENT ) * Fr_period, x)) {
         ObjectSetInteger ( 0 , _name, OBJPROP_COLOR , _clr);
    }
}


Now my problem:

After an undefined time (usually at night), the fractals are neither deleted if they are broken nor are they updated. In the tester, everything ran smoothly and the logic worked even with complex follow-up purchases. In the test run on a demo account, it usually ended after the day had changed. So I reduced the code to a minimum to find the error, but I can't find the error because there are no outputs in the journal tab that indicate an error.

I hope someone can tell me why these interruptions occur in the live/demo account. 

I hope I have shared all the necessary information and thank you in advance for your support.


Best regards

Stefan

 

here is a short video of the pronlem live. At the end I changed the timeframe and then it works fine: