How to check if the middle line of bollinger is stable?

 

How to check if the middle line in Bollinger indicator is some what straight or stable?

See the following red circle in the image:  

image

Kindly, let me know.

 
jafferwilson:

How to check if the middle line in Bollinger indicator is some what straight or stable?

See the following red circle in the image:  

Kindly, let me know.

Linear regression slope. The easier method would be using the MA of channel width, a shrinking channel = less volatile market.
 
Perhaps something like:
bool isBBFlat(int iBar=1, int percentage=10, int smoothing=10){
   double ma1 = bands(iBar, MODE_MAIN),
          ma2 = bands(iBar+smoothing, MODE_MAIN),
          ma3 = bands(iBar+smoothing*2, MODE_MAIN);
   double slope1 = (ma1 - ma2) / smoothing,
          slope2 = (ma2 - ma3) / smoothing;
   return MathAbs(slope1) < MathAbs(slope2) * percentage/100.0;
}
double bands(int iBar, int mode){
   return iBandsMQL4( // MT4: iBands
                     _Symbol, PERIOD_CURRENT,
                     BB_Length,
                     BB_Deviations,
                     0, // Shift
                     PRICE_CLOSE,
                     mode, iBar);
}
 
Emma Schwatson:
Linear regression slope. The easier method would be using the MA of channel width, a shrinking channel = less volatile market.

Can you please share an example that would be helpful?

 
whroeder1:
Perhaps something like:

Not getting the desired output on the graph .. can you please show me what graph you have got on your side?

 
Look at this. Set up a flat FlatK. The red dots show the flat parts.
Files:
 
Dmitry Fedoseev:
Look at this. Set up a flat FlatK. The red dots show the flat parts.

Not getting the right output as require. See the following figure the output what your program gives and what was expected. Please let me know.

figure required and got

The blue region is what the program is giving, while the yellow region is what expected. Kindly, let me know what should be done, please.

 
jafferwilson:

Not getting the right output as require. See the following figure the output what your program gives and what was expected. Please let me know.

The blue region is what the program is giving, while the yellow region is what expected. Kindly, let me know what should be done, please.

You show the segment by means of which the flat is detected. As flat is detected, so it is immediately displayed with red dots. It is possible to draw red dots where you are showing, but it will be practically impossible to use it.

In order to draw some conclusion, it is necessary to analyze the preceding data. Therefore, everything happens with a delay.

What you are dreaming of is impossible.

 
jafferwilson:

How to check if the middle line in Bollinger indicator is some what straight or stable?

See the following red circle in the image:  

Kindly, let me know.

Try this.

Files:
BB-Flat.mq5  9 kb
Reason: