Issue reading data from custom indicator

 

Hi all,

Hoping someone can assist with my issue.

I have a custom indicator which I created with 7 buffers:

int start()
  {
   int counted_bars=IndicatorCounted();
   int limit=Bars-IndicatorCounted();
   int k;
   if(counted_bars<1)
      for(k=0; k<limit-1; k++)
      k=Bars-counted_bars-1;
      while(k>=0)
         {
         //---log calculations
         Pair1_log[k]=MathLog(iClose(Pair1,PERIOD_CURRENT,iBarShift(Pair1,PERIOD_CURRENT,Time[k],false)))-MathLog(iClose(Pair1,PERIOD_CURRENT,iBarShift(Pair1,PERIOD_CURRENT,Time[k+1],false)));
         Pair2_log[k]=MathLog(iClose(Pair2,PERIOD_CURRENT,iBarShift(Pair2,PERIOD_CURRENT,Time[k],false)))-MathLog(iClose(Pair2,PERIOD_CURRENT,iBarShift(Pair2,PERIOD_CURRENT,Time[k+1],false)));
         logspread[k] = Pair2_log[k]-Pair1_log[k];
         k--;
         }
      k=Bars-counted_bars-1;
      while(k>=0)
         {
         //---MA calculations
         logspreadma[k] = iMAOnArray(logspread,0,MAperiod,0,MAmethod,k);
         logspreadfastma[k] = iMAOnArray(logspread,0,MAFastperiod,0,MAFastmethod,k);  
         k--;
         }
      k=Bars-counted_bars-1;
      while(k>=0)
         {
         logspreadmastdup[k] = logspreadma[k] + iStdDevOnArray(logspreadma,0,MAperiod,0,MAmethod,k)*Devperiod; 
         logspreadmastddn[k] = logspreadma[k] - iStdDevOnArray(logspreadma,0,MAperiod,0,MAmethod,k)*Devperiod; 
         k--;
         }
//---
   return(0);

However when i call buffers 'logspreadfastma', 'logspreadmastdup' and 'logspreadmastddn' in an EA for the previous 2 candles using:

double indi(int buff,int bar_)
  {
   return iCustom(NULL,PERIOD_CURRENT,indicator_name,Pair1,Pair2,MAperiod,MAmethod,Devperiod,MAFastperiod,MAFastmethod, buff,bar_);
  }
         if(indi(6,1) > indi(4,1) && indi(6,2) < indi(4,2))
       
         if(indi(6,1) < indi(5,1) && indi(6,2) > indi(5,2))
       

I have checked all of the buffers to ensure i'm calling the correct buffers but still no joy

Any ideas why the crossings i'm expecting from the above aren't in line?

Thank you in advance

Step on New Rails: Custom Indicators in MQL5
Step on New Rails: Custom Indicators in MQL5
  • www.mql5.com
Finally we've got an opportunity to try the new trade terminal - MetaTrader 5 . No doubt, it is noteworthy and has many new features as compared to its predecessor. The important advantages of this platform among others are: Essentially modified language allowing now to use the object-oriented programming, still allowing to use the rich...
 
SJCFX:

Hi all,

Hoping someone can assist with my issue.

I have a custom indicator which I created with 7 buffers:

However when i call buffers 'logspreadfastma', 'logspreadmastdup' and 'logspreadmastddn' in an EA for the previous 2 candles using:

I have checked all of the buffers to ensure i'm calling the correct buffers but still no joy

Any ideas why the crossings i'm expecting from the above aren't in line?

Thank you in advance

No one can offer any advice?

 
SJCFX:

No one can offer any advice?

Please share an image from the indicator inputs tab.

 
Reza nasimi:

Please share an image from the indicator inputs tab.

Please see above inputs

 
SJCFX:

Please see above inputs

Have you show us all inputs ?

 
remcous:

Have you show us all inputs ?

the only 2 not shown are 'Pair 1' and 'Pair 2'

 
SJCFX:

the only 2 not shown are 'Pair 1' and 'Pair 2'

screenshot of all inputs

 
SJCFX:

screenshot of all inputs

ok thank !

you forget some inputs :

iCustom(NULL,PERIOD_CURRENT,indicator_name,"",Pair1,Pair2,"",MAperiod,MAmethod,Devperiod,"",MAFastperiod,MAFastmethod, buff,bar_);


don't forget  the comment like ======= MA slow settings ========== count for 1 param

 
remcous:

ok thank !

you forget some inputs :


don't forget  the comment like ======= MA slow settings ========== count for 1 param

how embarrassing, absolutely right. thank you! 

 
SJCFX:

how embarrassing, absolutely right. thank you! 

you're welcome :-)
Reason: