Read function value from class

To add comments, please log in or register
FiaMeta5admiral
963
FiaMeta5admiral  
How to read value of the function CheckPatternAllBullish() in class  CCandlePattern ?

I want to read it inside in void OnTick()

// Print(fican.CheckPatternAllBullish());

Error is  invalid pointer access in 'candlepatterns.mqh' (162,20)

Thanks!

//+------------------------------------------------------------------+

//| Include                                                          | //+------------------------------------------------------------------+ #include <Expert\Expert.mqh> #include <candlepatterns.mqh> ulong                    Expert_MagicNumber        =3434;        // bool                     Expert_EveryTick          =false;       // //+------------------------------------------------------------------+ //| Global expert object                                             | //+------------------------------------------------------------------+ CExpert ExtExpert; CCandlePattern fican; //+------------------------------------------------------------------+ //| Initialization function of the expert                            | //+------------------------------------------------------------------+ int OnInit(){    if(!ExtExpert.Init(Symbol(),Period(),Expert_EveryTick,Expert_MagicNumber)) {//--- failed       printf(__FUNCTION__+": error initializing expert");   ExtExpert.Deinit();   return(INIT_FAILED);  } //--- Creating signal    CExpertSignal *signal = new CExpertSignal;    if(signal==NULL){                printf(__FUNCTION__+": error creating signal"); ExtExpert.Deinit();   return(INIT_FAILED);  }    ExtExpert.InitSignal(signal);       CIndicators *indicators = new  CIndicators;    if(indicators==NULL){                printf(__FUNCTION__+": IND NIJE dignut signal"); ExtExpert.Deinit();   return(INIT_FAILED);  }    //ExtExpert.InitIndicators(indicators);       //--- Creating filter CMySignalEnvelopes    //CMySignalEnvelopes *filter0=new CMySignalEnvelopes;    CCandlePattern *filter0 = new CCandlePattern;          if(filter0==NULL){               printf(__FUNCTION__+": error creating filter0");  ExtExpert.Deinit();  return(INIT_FAILED); }    filter0.MAPeriod(22);         //--- Tuning of all necessary indicators    if(!ExtExpert.InitIndicators()){  printf(__FUNCTION__+": error initializing indicators"); ExtExpert.Deinit();  return(INIT_FAILED); }       if(!filter0.InitIndicators(indicators)){  printf(__FUNCTION__+": error initializing CC "); ExtExpert.Deinit();  return(INIT_FAILED); }    filter0.ValidationSettings();    filter0.InitSignal(signal);           signal.AddFilter(filter0);   //--- Set filter parameters       return(INIT_SUCCEEDED);   } //+------------------------------------------------------------------+ //| "Tick" event handler function                                    | //+------------------------------------------------------------------+ void OnTick(){    ExtExpert.OnTick(); // fican.InitIndicators(indicators);    fican.CheckPatternAllBullish();   // Print(fican.CheckPatternAllBullish());    Print("Read price "+ExtExpert.Low(0)+" O1 "+ExtExpert.Open(1)+" C1 "+ExtExpert.Close(1)+" O2 "+ExtExpert.Open(2));   }
Files:
nicholi shen
1869
nicholi shen  
#include <Expert\Expert.mqh>
#include <candlepatterns.mqh>


ulong                    Expert_MagicNumber        =3434;        // 
bool                     Expert_EveryTick          =false;       // 

//+------------------------------------------------------------------+
//| Global expert object                                             |
//+------------------------------------------------------------------+
CExpert ExtExpert;
CCandlePattern *fican;
//+------------------------------------------------------------------+
//| Initialization function of the expert                            |
//+------------------------------------------------------------------+
int OnInit(){
   if(!ExtExpert.Init(Symbol(),Period(),Expert_EveryTick,Expert_MagicNumber)) {//--- failed
      printf(__FUNCTION__+": error initializing expert");   ExtExpert.Deinit();   return(INIT_FAILED);  }
//--- Creating signal
   CExpertSignal *signal = new CExpertSignal;
   if(signal==NULL){                printf(__FUNCTION__+": error creating signal"); ExtExpert.Deinit();   return(INIT_FAILED);  }
   ExtExpert.InitSignal(signal);
   
   CIndicators *indicators = new  CIndicators;
   if(indicators==NULL){                printf(__FUNCTION__+": IND NIJE dignut signal"); ExtExpert.Deinit();   return(INIT_FAILED);  }
   //ExtExpert.InitIndicators(indicators);
   
   //--- Creating filter CMySignalEnvelopes
   //CMySignalEnvelopes *filter0=new CMySignalEnvelopes;
   CCandlePattern *filter0 = new CCandlePattern;      
   fican = filter0;
   if(filter0==NULL){               printf(__FUNCTION__+": error creating filter0");  ExtExpert.Deinit();  return(INIT_FAILED); }
   filter0.MAPeriod(22);
   
     //--- Tuning of all necessary indicators
   if(!ExtExpert.InitIndicators()){  printf(__FUNCTION__+": error initializing indicators"); ExtExpert.Deinit();  return(INIT_FAILED); }
   
   if(!filter0.InitIndicators(indicators)){  printf(__FUNCTION__+": error initializing CC "); ExtExpert.Deinit();  return(INIT_FAILED); }
   filter0.ValidationSettings();
   filter0.InitSignal(signal);
       
   signal.AddFilter(filter0);   //--- Set filter parameters
   
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| "Tick" event handler function                                    |
//+------------------------------------------------------------------+
void OnTick(){
   ExtExpert.OnTick();
// fican.InitIndicators(indicators);
   fican.CheckPatternAllBullish();
  // Print(fican.CheckPatternAllBullish());
   Print("Read price "+ExtExpert.Low(0)+" O1 "+ExtExpert.Open(1)+" C1 "+ExtExpert.Close(1)+" O2 "+ExtExpert.Open(2));
  }

Try this.

FiaMeta5admiral
963
FiaMeta5admiral  
nicholishen:

Try this.


You're genius!

Finally, the real answer

Now I can go on

Thank You very much!!

To add comments, please log in or register