EA Code Errors making me go loopy

 

HI all, 


Would be very grateful if anyone could figure out why my code is, throwing off the following errors:

'}' - unexpected end of program 426 2

'{' - unbalanced parentheses 59 1


My Code is attached.


Thanks v much!

Files:
Horizon_V1.mq5  16 kb
 
Pete H:

HI all, 


Would be very grateful if anyone could figure out why my code is, throwing off the following errors:

'}' - unexpected end of program 426 2

'{' - unbalanced parentheses 59 1


My Code is attached.


Thanks v much!

Please provide code that compiles if possible.

This is a very simple error, and the description is very explicit: you are missing parentheses or brackets somewhere. The line and column is provided.
 
Pete H:

HI all, 


Would be very grateful if anyone could figure out why my code is, throwing off the following errors:

'}' - unexpected end of program 426 2

'{' - unbalanced parentheses 59 1


My Code is attached.


Thanks v much!

As written this: '{' - unbalanced parentheses 59 1 has no closing ]

So save your EA under a different name and  start from inner { - } pairs to delete them this way you can easily find where is the } missing. (The last else)

 
//+------------------------------------------------------------------+
//| Custom Indicator                                                 |
//+------------------------------------------------------------------+
double CiKAMA(…){
    ⋮
    for (i = count; i < rates_total; i++){
        ⋮
        if (i == count){…}
        else{
            ⋮
            if (tr > ad){…}
            else if (tr < ad){
                kama[i] = kama[i - 1] + slow_sc * (close[i] - kama[i - 1]);
            <<<<<<< End of else if?
         <<<<<<< End of else?
      <<<<<<< End of for?
} <<<<<<<<< End of CiKAMA
   
int start(){…}
void OnTick(…){
  1. Pete H: '}' - unexpected end of program 426 2
    Obvious
  2. A Custom indicator can't have an OnTick.
  3. You can have the old event handlers or the new. Not both.
  4. You should stop using the old event handlers (init, start, deinit) and IndicatorCounted() and start using new event handlers (OnInit, OnTick/OnCalculate, OnDeinit).
              Event Handling Functions - MQL4 Reference
              How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016)

  5.      sma = iMA(NULL, 0, g_smaPeriod, 0, MODE_SMA, PRICE_CLOSE, 1);
          kama = iCustom(NULL, 0, "KAMA", g_kamaFastPeriod, g_kamaSlowPeriod, g_kamaSignalPeriod, g_kamaFastMult, g_kamaSlowMult, g_kamaSignalMult, 0, 1);
    
    MT4 code. Stop using ChatGPT.
              Help needed to debug and fix an AI EA - Trading Systems - MQL5 programming forum #2 (2023)