Better Bollinger Bands... - page 14

 

Hi,

I tried the better bollinger bands, but I'm finding it more difficult than the standard version. In other words, I like the standard way of viewing the deviation lines. Maybe with time, I'll get used to this new "better" way. Can someone please be so kind to check this code to make sure it's up to the latest MT4 Build. I downloaded this indi from this forum, so I'm highly appreciative of those doing the work to help us non-coders out.

Thanks so much-

jbozman

Files:
 
jbozman:
Hi,

I tried the better bollinger bands, but I'm finding it more difficult than the standard version. In other words, I like the standard way of viewing the deviation lines. Maybe with time, I'll get used to this new "better" way. Can someone please be so kind to check this code to make sure it's up to the latest MT4 Build. I downloaded this indi from this forum, so I'm highly appreciative of those doing the work to help us non-coders out.

Thanks so much-

jbozman

jbozman

all is OK with that indicator. It does not need any code changes

 
mladen:
jbozman all is OK with that indicator. It does not need any code changes

Thank you so much. It must be something on my end...working offline maybe?

I added the indicator with specific settings...200 BB dev 2, 15 min timeframe. When I switched to the 30 min chart to view the band, it disappeared. Even though I work offline with other indicators, they do not disappear when switching timeframes. So it must be something with working offline with this indicator, and not the code?

Thanks so much. You are very kind.

jbozman

 
jbozman:
Thank you so much. It must be something on my end...working offline maybe?

I added the indicator with specific settings...200 BB dev 2, 15 min timeframe. When I switched to the 30 min chart to view the band, it disappeared. Even though I work offline with other indicators, they do not disappear when switching timeframes. So it must be something with working offline with this indicator, and not the code?

Thanks so much. You are very kind.

jbozman

jbozman

With new metatrader 4 and offline chart, nothing can be taken for granted. If the indicator works OK on regular charts and causes some problems on offline charts than the problem is coming form the offline charts implementation or from the metatrader

 

Thank you for that information, mladen.

Here's another question, unrelated to the answer above, but related to bollinger bands.

Do they require a great deal of processing power? I use 3 bollinger bands on my charts, and was wondering if they demand more processor power than using say 3 moving averages.

I try to use as few indicators as possible, and have a few others on my chart, but they are "static" if you will...they are objects like previous day's high/low. I'm assuming these don't require processing power, right...only memory?

I'm just trying to streamline my charts as much as possible, and would like to use as few indicators as possible.

Thanks

 
jbozman:
Thank you for that information, mladen.

Here's another question, unrelated to the answer above, but related to bollinger bands.

Do they require a great deal of processing power? I use 3 bollinger bands on my charts, and was wondering if they demand more processor power than using say 3 moving averages.

I try to use as few indicators as possible, and have a few others on my chart, but they are "static" if you will...they are objects like previous day's high/low. I'm assuming these don't require processing power, right...only memory?

I'm just trying to streamline my charts as much as possible, and would like to use as few indicators as possible.

Thanks

jbozman

Bollinger bands is an extremely simple indicator to calculate : it should not cause any kind of slow dawn of the terminal

 

as an illustration : here is what Bollinger bands indicator looks like (as simple as it gets - not like the example that comes with metatrader - avoid using that one)

#property indicator_chart_window

#property indicator_buffers 3

#property indicator_color1 LimeGreen

#property indicator_color2 DimGray

#property indicator_color3 Orange

#property indicator_style2 STYLE_DOT

extern int BandsLength = 20;

extern double BandsDeviation = 2;

double MaBuffer[];

double UpperBand[];

double LowerBand[];

//

//

//

//

//

int init()

{

SetIndexBuffer(0,UpperBand);

SetIndexBuffer(1,MaBuffer);

SetIndexBuffer(2,LowerBand);

return(0);

}

int deinit() { return(0); }

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars < 0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

for (int i=limit;i>=0;i--)

{

double deviation = iStdDev(NULL,0,BandsLength,0,MODE_SMA,PRICE_CLOSE,i);

MaBuffer = iMA(NULL,0,BandsLength,0,MODE_SMA,PRICE_CLOSE,i);

UpperBand = MaBuffer+BandsDeviation*deviation;

LowerBand = MaBuffer-BandsDeviation*deviation;

}

return(0);

}

bollinger_bands.mq4

Files:
 
mladen:
as an illustration : here is what Bollinger bands indicator looks like (as simple as it gets - not like the example that comes with metatrader - avoid using that one)
#property indicator_chart_window

#property indicator_buffers 3

#property indicator_color1 LimeGreen

#property indicator_color2 DimGray

#property indicator_color3 Orange

#property indicator_style2 STYLE_DOT

extern int BandsLength = 20;

extern double BandsDeviation = 2;

double MaBuffer[];

double UpperBand[];

double LowerBand[];

//

//

//

//

//

int init()

{

SetIndexBuffer(0,UpperBand);

SetIndexBuffer(1,MaBuffer);

SetIndexBuffer(2,LowerBand);

return(0);

}

int deinit() { return(0); }

int start()

{

int counted_bars=IndicatorCounted();

if(counted_bars < 0) return(-1);

if(counted_bars>0) counted_bars--;

int limit = MathMin(Bars-counted_bars,Bars-1);

for (int i=limit;i>=0;i--)

{

double deviation = iStdDev(NULL,0,BandsLength,0,MODE_SMA,PRICE_CLOSE,i);

MaBuffer = iMA(NULL,0,BandsLength,0,MODE_SMA,PRICE_CLOSE,i);

UpperBand = MaBuffer+BandsDeviation*deviation;

LowerBand = MaBuffer-BandsDeviation*deviation;

}

return(0);

}
bollinger_bands.mq4

Many thanks. Could I ask for you to look at this MTF version. I only use MTF to keep things consistent across time frames.

It's attached. Can you tell me if the code is simple? It looks fairly simple...not many lines of code. But I'm not a coder.

jbozman

 
jbozman:
Many thanks. Could I ask for you to look at this MTF version. I only use MTF to keep things consistent across time frames.

It's attached. Can you tell me if the code is simple? It looks fairly simple...not many lines of code. But I'm not a coder.

jbozman

jbozman

All is OK with the way it calculates the bands. Two flaws : it can not calculate fractional bands width and in multi time frame mode it will go into a classical repainting (it does not update the sate of all the bars of the current chart belonging to the higher time frame)

 
mladen:
jbozman All is OK with the way it calculates the bands. Two flaws : it can not calculate fractional bands width and in multi time frame mode it will go into a classical repainting (it does not update the sate of all the bars of the current chart belonging to the higher time frame)

Great. So what is needed to fix it? Can you please fix it or provide one that overcomes those flaws?

I really like the MTF version as the bands remain the same across time frames.

Also, attached is an MTF Moving Average. Does this have the same inherent problem or is it okay? If it's problematic, is it too much to ask to help fix it too so these aren't issues?

I'm not trading yet, and developing my own method and need these as part of it. I'm thankful you pointed out the repainting issue.

Here's the MTF MA:

EDITED POST:

I get that you said the bands are calculated okay. Fractional isn't that important, but it would be really nice to have. I also understand that the lower TF doesn't match up with the higher TF on the MTF. Is there a way to overcome this? I'd like for it to update. I'm not knowledgeable enough to speak to the updating with the MTF and the higher TF. I just know I'd like to see the same representation across TFs.

Files:
Reason: