Does anyone see anything wrong with this code snippet?

 
   EntrySignal = 0;

   if(isNewTechnicalAnalysisBar)
     {
      for(int i = 0; i < MAX_ENTRY_LOGICS; ++i)
        {
         EntrySignal += EntryLogic[i]();
        }

      EntrySignal = (EntrySignal >=  MinEntrySignals) ? 1 : (EntrySignal <= -MinEntrySignals) ? -1 : 0;
     }


I get the following error, I can't figure out what is going wrong:

invalid function pointer call in 'XXX' (683,25) 2020.01.02 04:00:00 Testing pass stopped due to a critical error in the EA

 
Enrique Enguix:


I get the following error, I can't figure out what is going wrong:

invalid function pointer call in 'XXX' (683,25) 2020.01.02 04:00:00 Testing pass stopped due to a critical error in the EA

EntrySignal += EntryLogic[i]();

what do the parentheses  do?

 
Lorentzos Roussos #:

what do the parentheses  do?

Hi Lorentzo, thanks for answering. This is the pointer call:


#define MAX_ENTRY_LOGICS 9

typedef int(*EntryLogicFunction)();

EntryLogicFunction EntryLogic[MAX_ENTRY_LOGICS];

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

void InitEntryLogicFunction(int iEntry, ENTRY_LOGIC logicType)
  {
   if((iEntry < 0) || (iEntry > (MAX_ENTRY_LOGICS - 1)))
      return;

   switch(logicType)
     {
      case ENTRY_LOGIC_A  :
         EntryLogic[iEntry] = EntryLogicA;
         break;
      case ENTRY_LOGIC_B  :
         EntryLogic[iEntry] = EntryLogicB;
         break;
      case ENTRY_LOGIC_C  :
         EntryLogic[iEntry] = EntryLogicC;
         break;
      case ENTRY_LOGIC_D  :
         EntryLogic[iEntry] = EntryLogicD;
         break;
      case ENTRY_LOGIC_E  :
         EntryLogic[iEntry] = EntryLogicE;
         break;
(.....)

 
Enrique Enguix #:

Hi Lorentzo, thanks for answering. This is the pointer call:


That is so cool !

okay i replicated it and i set an extra "slot" empty (not set) on purpose . 

  ArrayResize(checks,4,0);
  checks[0]=signal_check_a;
  checks[1]=signal_check_b;
  checks[2]=signal_check_a;
  
  int sum=0;
  for(int i=0;i<ArraySize(checks);i++){
  if(checks[i]!=NULL){sum+=checks[i]();}
  }

(4 , 3 set 1 empty) the exact same error popped up . It does not if i check for null but i guess you don't want that . It can point to where the error is though.

for(int i = 0; i < MAX_ENTRY_LOGICS; ++i)
{
if(EntryLogic[i]!=NULL){EntrySignal += EntryLogic[i]();}else{
Print("EntryLogic["+IntegerToString(i)+"] is not set");
}
}
 
Lorentzos Roussos # :

Eso es tan genial!

bien, lo repliqué y configuré una "ranura" adicional vacía (no configurada) a propósito. 

(4, 3 set 1 vacío) apareció exactamente el mismo error. No lo hace si verifico nulo, pero supongo que no quieres eso. Sin embargo, puede señalar dónde está el error.

Thanks for such a detailed answer. It doesn't exactly work for me but it's very useful as a starting point. I'm going to investigate a little more to see where the error is. Thank you very much again, you are a teacher for me

 
Lorentzos Roussos #:

That is so cool !

okay i replicated it and i set an extra "slot" empty (not set) on purpose . 

(4 , 3 set 1 empty) the exact same error popped up . It does not if i check for null but i guess you don't want that . It can point to where the error is though.

Finally I discovered the error thanks to your indications, I had not indexed the strategies correctly, so it stopped at 7, and did not reach 9 (MAX_ENTRY_LOGICS).

Although I went through the fragment again and again, I could not locate that small error. Thanks again. I really admire your knowledge.

 
Enrique Enguix #:

Finally I discovered the error thanks to your indications, I had not indexed the strategies correctly, so it stopped at 7, and did not reach 9 (MAX_ENTRY_LOGICS).

Although I went through the fragment again and again, I could not locate that small error. Thanks again. I really admire your knowledge.

Thank you . You can also export signals to excel as an alternative and use the genetic algorithm there (milleniums superior to the mt4 one and not as restricted as the mt5 one), with some limitations . (if i get what you are trying to do)

For instance when you try to evaluate a signal you need -in theory- to look at all the cases , but , with the trading context limitations of meta trader you cannot take all trades and you cannot optimize for profit potential . 

Its like excel is finding the woman and mt5 is flirting with a woman . You cannot keep flirting when she is not interested you may need to find a new one sometimes . (mt4 is drinking beers alone watching football)

 
Lorentzos Roussos #:

Thank you . You can also export signals to excel as an alternative and use the genetic algorithm there (milleniums superior to the mt4 one and not as restricted as the mt5 one), with some limitations . (if i get what you are trying to do)

For instance when you try to evaluate a signal you need -in theory- to look at all the cases , but , with the trading context limitations of meta trader you cannot take all trades and you cannot optimize for profit potential . 

Its like excel is finding the woman and mt5 is flirting with a woman . You cannot keep flirting when she is not interested you may need to find a new one sometimes . (mt4 is drinking beers alone watching football)

Haha, got it.  I like your point of view.  You have given me a good idea with this!
 
Enrique Enguix #:
Haha, got it.  I like your point of view.  You have given me a good idea with this!

xD xD . (in case you try it , Excel has a 2GB limit on CSVs)