Simple candle stick pattern EA issue

 

I'm working on developing a pattern based entry using this class: https://www.mql5.com/en/code/291

The code for my EA is simple:

#include <CandlePatterns.mqh>

CCandlePattern m_candle;

int OnInit()
{
   m_candle.ValidationSettings();
   m_candle.InitIndicators();
   m_candle.MAPeriod(20);
   return(INIT_SUCCEEDED);
}

void OnTick()
{
   if(m_candle.CheckCandlestickPattern(CANDLE_PATTERN_BULLISH_ENGULFING) == true)
   Print("Bullish");
}

However the result I get in the strategy tester is: invalid pointer access in 'CandlePatterns.mqh' (62,64)

I'm sure I'm missing something here but I cant figure out what, I'm studying up on C++ but my background in coding comes from Basic >.<


Any bit of help is greatly appreciated.


MQL5 Wizard - Candlestick Patterns Class
MQL5 Wizard - Candlestick Patterns Class
  • www.mql5.com
The class can be used for creation of trade signal classes with reversal candlestick patterns.
 

hi Tnil i got the same error did you find the way fixing this no pointer issue?


thanks

 
  1. Your code
       m_candle.InitIndicators();
    Requires a CIndicators to work.
    bool CCandlePattern::InitIndicators(CIndicators *indicators)

  2. if(m_candle.CheckCandlestickPattern(CANDLE_PATTERN_BULLISH_ENGULFING) == true)

    You should be able to read your code out loud and have it make sense. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled where as Long_Entry sounds like a trigger price or a ticket number and “if long entry” is an incomplete sentence.