Asesores Expertos: CCI_MA. EA a base de una aplicación particular de CCI y MA

 

CCI_MA. EA a base de una aplicación particular de CCI y MA:

Un buen algoritmo de trabajo del EA a base de CCI y su MA. Buenos resultados en el Probador de Estrategias. Se necesita la ayuda con la optimización, pruebas, y tal vez con la depuración del código.

Autor: Andrey

 
Keith Watford:

Are you using OnCalculate()?

You should try to avoid the old variables such as IndicatorCounted(). Use prev_calculated instead.

Your problem is possibly due to the chart being updated after you change timeframes.

When prev_calculated ==0, you should use ArrayInitialize() to set all index to EMPTY_VALUE.

Yes I use the OnCalculate() function.

Thank you for the tip with the   ArrayInitialize() , i think that was the main problem. 

Not the code (in the OnCalculate) looks like this:

if(prev_calculated == 0)                           //changing TF f.e.
   {
       ArrayInitialize(RsiLevelBuffer,EMPTY_VALUE);
       ArrayInitialize(BBCon1UpBuffer,EMPTY_VALUE);
       ArrayInitialize(BBCon1DownBuffer,EMPTY_VALUE);
   }
   if(rates_total != prev_calculated)
   {
      int limit = rates_total - prev_calculated;            // Do not check repeated bars
   
      //For drawing Indicators 
      for(int i = limit; i >= 1; i--)                       // Iterate bars from past to present
      {
         if(i > Bars -2) continue;                          // If not enough data...
         
         if(BBCondition_1(i)) { continue; }
         if(BBCondition_2(i)) { continue; }
         if(BBCondition_3(i)) { continue; }
         
         RsiCondition(i);  
       }
    }

Would oyu solve it differently? Or how do you do it?

Have  a nice day, and thank you :)