English

 54 strutch 2016.04.01 00:30 #   . Hi GumRai, thank you so much for your help! :) When I wrote it in here I've done that (stupid) declaration but I've declared the array in the EA like this:(between external variables declaration and init function) ```double   DIF_MA[2]; double   WPR[]; ```I've got the EA working well with this while loop (calling the indicator with iCustom):```// Code to find crosses at bar number index      index=0;      ArrayIndex = 0;      while(ArrayIndex <= 5)      {                DIF_MA[0] = iCustom(NULL,0,"Signal - WPR (Smooth)",Periodo,Periodo_Smooth,2,index);          DIF_MA[1] = iCustom(NULL,0,"Signal - WPR (Smooth)",Periodo,Periodo_Smooth,2,index+1);          if( (DIF_MA[0]>0 && DIF_MA[1]<=0) || (DIF_MA[0]<0 && DIF_MA[1]>=0) )      // if cross found          {             CrossAt[ArrayIndex] = index;             ArrayIndex++;          }          index++;      }``` And my intention was to "insert" the indicator in the EA.Because the indicator is only to smooth the WPR indicator with a certain period.My idea was to create an array called WPR[] with that for cycle and than use it with the iMAOnArray in the while cycle instead of calling the custom indicator. ```// Code to find crosses at bar number index index=0; ArrayIndex = 0; ArrayResize(WPR,Periodo+1); ArraySetAsSeries(WPR,true);      for (int g=0; g<=Periodo; g++) {    WPR[g] = iWPR(NULL,0,Periodo,g); }      while(ArrayIndex <= 5) {          DIF_MA[0] = (iMAOnArray(WPR,Periodo,Periodo_Smooth,0,MODE_SMA,index) +50);    DIF_MA[1] = (iMAOnArray(WPR,Periodo,Periodo_Smooth,0,MODE_SMA,index+1) +50);   if( (DIF_MA[0]>0 && DIF_MA[1]<=0) || (DIF_MA[0]<0 && DIF_MA[1]>=0) )      // if cross found    {     CrossAt[ArrayIndex] = index;     ArrayIndex++;    }    index++; }```  I really don't understand why does it give me an endless loop this way and it does not with iCustom ! :( .
 13126 WHRoeder 2016.04.01 02:20 #   strutch: I really don't understand why does it give me an endless loop this way and it does not with iCustom ! :(WPR contains Periodo valuesWhen index is zero`DIF_MA[1] = (iMAOnArray(WPR,Periodo,Periodo_Smooth,0,MODE_SMA,index+1) +50);`iMA requires Periodo_Smooth values. [index+1 ... index+1+Periodo_Smooth-1]`while(ArrayIndex <= 5)`ArrayIndex is only increased if a cross is foundDif_MA[1] is always bogus, no cross is found, infinite loop.
 54 strutch 2016.04.02 02:58 #   .Finally I understood my problem!!! I was so focused on the while cycle that I has not looking to the for cycle.. ;)Hours looking for the obviously... ... It's hard to be newbie... LOL.. I need to know WPR_Smooth value in past values and I was doing it as I was only working with the current time..Now, with a bigger WPR Array and with iMAOnArray counting all that array (zero value) it is finally working.No need to have a signal indicator anymore!  :).```     index=0;      ArrayIndex = 0; // Code to find crosses at bar number index      ArrayResize(WPR,(Bars-Periodo));      ArraySetAsSeries(WPR,true);           for (int g=0; g<=(Bars-Periodo); g++)      {          WPR[g] = iWPR(NULL,0,Periodo,g);      }           while(ArrayIndex <= 5)      {                DIF_MA[0] = (iMAOnArray(WPR,0,Periodo_Suav,0,MODE_SMA,index)+50);          DIF_MA[1] = (iMAOnArray(WPR,0,Periodo_Suav,0,MODE_SMA,index+1)+50);          if( (DIF_MA[0]>0 && DIF_MA[1]<=0) || (DIF_MA[0]<0 && DIF_MA[1]>=0) )      // if cross found          {             CrossAt[ArrayIndex] = index;             ArrayIndex++;          }          index++;      }```Once again.. Thank you so much for your patience to help me! :).