Welch Bollinger Bands® Width - MetaTrader 4 Script | Forex Indicator Download - MT4/MT5 Resources



maj1es2tic (Tim Welch)
The indicator takes the current width of the Bollinger Bands and compares it with the maximum and minimum width of the Bollinger Bands over N periods (WidthCalcPeriod).
If the calculated percentage is less than or equal to MinRangePercent, the histogram displays green. If the calculated percentage is 2 times MinRangePercent, the histogram displays yellow. If neither matches, the histogram displays red.
This is a great way to quickly see if a currency pair is range-bound or about to break out of range. If you set ShowWidthLine to true, it also displays a line with the actual width of the Bollinger Bands in PIPS. This should work with 4-digit and 5-digit brokers, and for all currency pairs.
Use iCustom to extract the value of an Expert Advisor or other custom indicator:
You should be able to extract any value from outside using the following code:
integer period = 0 ; // How far back do you want to look? 0 == current bar. 1 == previous column, etc. // Only one of these 3 values is greater than 0 at any given time. The value is 300. Double WelchBBWidth_Green = Custom ( void , 0 , "WelchBBWidth" , 20 , 0 , 2.0 , 20 , "x" , 100 , " x " , False , 0 , period ) ; Double WelchBBWidth_Yellow = Custom ( void , 0 , " WelchBBWidth" , 20 , 0 . period ); // This will give you the actual width of the Bollinger Bands PIP Double Welch BB Width = Custom ( void , 0 , "Welch BB Width" , 20 , 0 , 2.0 , 20 , "x" , 100 , "x" , False, 3 , periods); // These will give you the actual Bollinger Bands values. // These are the values that will be plotted on the main chart, so it is based on the price on the chart. Double WelchBBWidth_MiddleLine = Custom ( void , 0 , "Welch BB Width" , 20 , 0 , 2.0 , 20 , "x" , 100 , "x" , False , 4 , period); Double WelchBBWidth_UpperLine = Custom ( void , 0 , "Welch BB Width" , 20 , 0 , 2.0 , 20 , "x" , 100 , "x" , false, 5 , periods); double WelchBBWidth_LoweLine = custom ( void , 0 , "WelchBBWidth" , 20 , 0 , 2.0 , 20 , "x" , 100 , "x" , false, 6 , period);
You can add the following content to your Expert Advisor:
/* * int areWeRanging(int period=0) * * Returns 1 for GREEN (ranging) * Returns -1 for YELLOW (start/end of range) * Returns 0 otherwise (no range) */ integer we are ranging ( integer period = 0 ) { Double WelchBBWidth_Green = Custom ( void , 0 , "Welch BB Width" , 20 , 0 , 2.0 , 20 , "x" , 100 , "x" , False, 0 , period); Double WelchBBWidth_Yellow = Custom ( void , 0 , "Welch BB Width" , 20 , 0 , 2.0 , 20 , "x" , 100 , "x" , false , 1 , period); if ( WelchBBWidth_Green > 0 ) { return ( 1 ); } Else if (WelchBBWidth_Yellow > 0 ) { return (- 1 ); } return ( 0 ); } // Check if we are out of range. // This tells us that the last candle is still within a range, // But the current candle is now breaking out of that range. if (we are ranging ( 1 ) == 1 && ( we are ranging ( 0 ) == - 1 || we are ranging ( 0 ) == 0 ) ) { print ( "We have been range-bound, but now we have broken out of the range! If other indicators confirm the breakout, trade!" ); }
** Use any/all symbols at your own discretion and only place live trades after confirming other indicators. **

*Note: The dark gray vertical line and red arrow are added to show the correlation of the indicator with the Bollinger Bands on the chart, they will not be displayed on your chart.
Attachment download
📎 WelchBBWidth.mq4 (4.77 KB)
Source: MQL5 #10416
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •