How to use Bollinger Bands in EA

 

Hi,

I'd like to use Bollinger Bands when the chart is in trading range in order to get buy/sell signal when a bar touch the lower/upper band. I want to detect if the chart is in trading range by comparing value of upper band or lower band bar after bar to know if its value is stable or not so I suppose I have to stock iBands results in an array or to use iBandsOnArray() function to stock these values in an array but I don't understand how to use this function..

Could anyone tell me how to do it ?

Thanks.

 
There are lots of examples in the code base.
 

Yeah I know, but all codes I found in the code base just verified if the bar touched the upper or lower band, but it didn't verify if the upper or lower band value was stable in order to know if the chart was in trading range.. it sends signals even if the bands are in a trend.

What I want to do is to stock each value of Bollinger Bands in an array in order to compare them, but if I declare an array in the function, it will be reinitialize each time the function will be called..

 
What do you mean by stable? Do you mean if they're the same or equal to the previous? The values are already in an array equal to the number of periods of the bb. To get this value, use the shift.
 
What do you mean by stable? Do you mean if they're the same or equal to the previous?

Yes, you solved my problem, I didn't understand the shift role when I used the iBands() function.

Thanks a lot !

 
Arkenis:

Yeah I know, but all codes I found in the code base just verified if the bar touched the upper or lower band, but it didn't verify if the upper or lower band value was stable in order to know if the chart was in trading range.. it sends signals even if the bands are in a trend.

What I want to do is to stock each value of Bollinger Bands in an array in order to compare them, but if I declare an array in the function, it will be reinitialize each time the function will be called..


please can u send me on email ewq_ewq@centrum.sk how would a code look like if i want to be alerted if a candle touches a bollinger band?? Please help,thx a lot... the best way would be if u send me the whole script... so u just incorporate that sound alarm into bollinger bands code... thx a lot