Download MetaTrader 5

Need help with this piece of code, should be simple.

To add comments, please log in or register
Marcos Silva
358
Marcos Silva  

Hello,

 

Thank you in advance for looking this up.

Im looking to get the the StdDev cross of the upper bollinger band on my ea like the picture bellow:

 

 

 

So far i wrote this code but i cant get the upper bollinger band(always return 0) value to compare the variables... Could anyone point me in the right direction?? Thank You 

 

extern int StdDevPeriod = 14;
extern int StdDevBolPeriod = 21;
extern double StdDevBolDeviation = 1.5;

double StdDevBuffer[],BandsStdDevBuffer[];

int init()
{  
   int StdDevCount = MathMax(StdDevPeriod,StdDevBolPeriod);
   ArrayResize(StdDevBuffer,StdDevCount*2);
   ArraySetAsSeries(StdDevBuffer,true);   
   ArrayResize(BandsStdDevBuffer,StdDevCount*2);
   ArraySetAsSeries(BandsStdDevBuffer,true);   
}

int StdDevSignal()
  {

   int StdDevCount = MathMax(StdDevPeriod,StdDevBolPeriod);   

   for(i=0; i<StdDevCount*2; i++)
     {
      StdDevBuffer[i]=iStdDev(NULL,0,StdDevPeriod,0,MODE_LWMA,PRICE_MEDIAN,i);
     }

   for(i=0; i<StdDevCount*2; i++)
     {
      BandsStdDevBuffer[i]=iBandsOnArray(StdDevBuffer,0,StdDevBolPeriod,StdDevBolDeviation,0,MODE_UPPER,i);             
      Print("StdDevBuffer for ",i," = " , StdDevBuffer[i]);
      Print("BandsStdDevBuffer for ",i," = " , BandsStdDevBuffer[i]);
     }

   Print("StdDevBuffer[0]  = ",StdDevBuffer[0] , "|| BandsStdDevBuffer[0] = " , BandsStdDevBuffer[0]);
   
   if(StdDevBuffer[0] > BandsStdDevBuffer[0]) return(1);
   else return(0);
  }

 

I also have this results from the terminal when running the code... 

 

 2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 17 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 17 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 16 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 16 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 15 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 15 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 14 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 14 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 13 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 13 = 0.001

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 12 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 12 = 0.001

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 11 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 11 = 0.0011

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 10 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 10 = 0.0011

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 9 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 9 = 0.0011

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 8 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 8 = 0.001

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 7 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 7 = 0.0009

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 6 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 6 = 0.0008

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 5 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 5 = 0.0007

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 4 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 4 = 0.0006

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 3 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 3 = 0.0005

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 2 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 2 = 0.0004

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 1 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 1 = 0.0004

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: BandsStdDevBuffer for 0 = 0

2015.06.24 17:18:13.959 2013.11.20 18:24  SESSIONS EURUSD,M30: StdDevBuffer for 0 = 0.0007


To add comments, please log in or register