This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community

Bollinger Bands Width Indicator


Back to topics list
avatar
Trader 2004.11.25 13:07 
There's only Bollinger Bands indicator in MetaTrader. Is there away to add the Bollinger Bands Width Indicator?

Thanks!
avatar
Trader 2004.11.25 15:36 
Do you have full description and formulas?
avatar
Trader 2004.11.25 16:17 
Surely I don't have any description or formulas, ---I'm disable in coding or formulas things. I just got a nice stratage which need the Bollinger Bands Width. It would be great if there's a place to download a code, then You help me understand how to add the code into Metatrader.
Here are some articals about BWI, I'm not sure if it is the description you mentioned:

http://www.bollingerbands.com/services/bb/

http://www.stockcharts.com/education/IndicatorAnalysis/indic_BBWidth.htm

Thanks!

avatar
Trader 2004.11.26 06:13 
Lenar, I just found a piece of material from website. I don't know if this is the right famula. But please help me reading it:

Name: Bollinger Band Width measured in ATR
Submitted by: eKam of TradeStationWorld
Version: 1.00
Credit: Based on TradeStation code and concepts by nickm001 and Kanuna
Purpose: Calculates 21-day Bollinger Band Width, measured in ATR
Formula: 2 * SQR((
(C0 - avgC21) * (C0 - avgC21) + (C1 - avgC21) * (C1 - avgC21) +
(C2 - avgC21) * (C2 - avgC21) + (C3 - avgC21) * (C3 - avgC21) +
(C4 - avgC21) * (C4 - avgC21) + (C5 - avgC21) * (C5 - avgC21) +
(C6 - avgC21) * (C6 - avgC21) + (C7 - avgC21) * (C7 - avgC21) +
(C8 - avgC21) * (C8 - avgC21) + (C9 - avgC21) * (C9 - avgC21) +
(C10 - avgC21) * (C10 - avgC21) + (C11 - avgC21) * (C11 - avgC21) +
(C12 - avgC21) * (C12 - avgC21) + (C13 - avgC21) * (C13 - avgC21) +
(C14 - avgC21) * (C14 - avgC21) + (C15 - avgC21) * (C15 - avgC21) +
(C16 - avgC21) * (C16 - avgC21) + (C17 - avgC21) * (C17 - avgC21) +
(C18 - avgC21) * (C18 - avgC21) + (C19 - avgC21) * (C19 - avgC21) +
(C20 - avgC21) * (C20 - avgC21)
) / 21)
/
(1.5 * (
C1 *( C1< L0) + L0 *( C1>= L0) - C1 *( C1> H0) - H0 *( C1<= H0) +
C2 *( C2< L1) + L1 *( C2>= L1) - C2 *( C2> H1) - H1 *( C2<= H1) +
C3 *( C3< L2) + L2 *( C3>= L2) - C3 *( C3> H2) - H2 *( C3<= H2) +
C4 *( C4< L3) + L3 *( C4>= L3) - C4 *( C4> H3) - H3 *( C4<= H3) +
C5 *( C5< L4) + L4 *( C5>= L4) - C5 *( C5> H4) - H4 *( C5<= H4) +
C6 *( C6< L5) + L5 *( C6>= L5) - C6 *( C6> H5) - H5 *( C6<= H5) +
C7 *( C7< L6) + L6 *( C7>= L6) - C7 *( C7> H6) - H6 *( C7<= H6) +
C8 *( C8< L7) + L7 *( C8>= L7) - C8 *( C8> H7) - H7 *( C8<= H7) +
C9 *( C9< L8) + L8 *( C9>= L8) - C9 *( C9> H8) - H8 *( C9<= H8) +
C10*(C10< L9) + L9 *(C10>= L9) - C10*(C10> H9) - H9 *(C10<= H9) +
C11*(C11< L10) + L10*(C11>=L10) - C11*(C11> H10) - H10*(C11<=H10) +
C12*(C12< L11) + L11*(C12>=L11) - C12*(C12> H11) - H11*(C12<=H11) +
C13*(C13< L12) + L12*(C13>=L12) - C13*(C13> H12) - H12*(C13<=H12) +
C14*(C14< L13) + L13*(C14>=L13) - C14*(C14> H13) - H13*(C14<=H13) +
C15*(C15< L14) + L14*(C15>=L14) - C15*(C15> H14) - H14*(C15<=H14) +
C16*(C16< L15) + L15*(C16>=L15) - C16*(C16> H15) - H15*(C16<=H15) +
C17*(C17< L16) + L16*(C17>=L16) - C17*(C17> H16) - H16*(C17<=H16) +
C18*(C18< L17) + L17*(C18>=L17) - C18*(C18> H17) - H17*(C18<=H17) +
C19*(C19< L18) + L18*(C19>=L18) - C19*(C19> H18) - H18*(C19<=H18) +
C20*(C20< L19) + L19*(C20>=L19) - C20*(C20> H19) - H19*(C20<=H19) +
C21*(C21< L20) + L20*(C21>=L20) - C21*(C21> H20) - H20*(C21<=H20)
)/21)
Formula in English: "Normalizes" the Bollinger Band Width by the Average True Range. This way, Bollinger Band squeezes (as well as wide expansions) can be more readily identified. Consolidation is indicated by values less than 1.0, while a large bandwidth alerts you of big moves. The formula implemented in PCF code is 2 * StandardDeviation (ClosePrice, 21) / (1.5 * AverageTrueRange (21)).
Back to topics list