How to check if Bollinger Bands had Crossed

 

Hi Guys,

I'm working on a EA and I need to check if the Bollinger Bands has crossed in the last X Candle of the specified timeframe...

How can I do it ?

Should I have to implement a loop where "for X times" calculates the bands and check if the value crossed?

Thanks to support !

 
Bollinger Bands will never cross. What do you mean?
 

which line of Bollinger Bands, and cross what line ?

 

I'm sorry, the question is wrong...

I mean in iStockastic...

 
Dario T.:

I'm sorry, the question is wrong...

I mean in iStockastic...


double currentMain=iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,0);
double prevMain=iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_MAIN,1);

double currentSignal=iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,0);
double prevSignal=iStochastic(NULL,0,5,3,3,MODE_SMA,0,MODE_SIGNAL,1);

   if( currentMain<currentSignal && prevMain>prevSignal )
     {
      if(totalSells()>0)CloseSell();
      if(totalBuys()==0)Buy(lots);
     }
   if( currentMain>currentSignal && prevMain<prevSignal )
     {
      if(totalBuys()>0)CloseBuy();
      if(totalSells()==0)Sell(lots);
     }

}

here is your code,

 

You are the Man Bro ! ;-)