You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
If you have any indicator that consists of 1 line in the chart window, and you want to add standard deviation bands to that line, like Bollinger bands. How do you do this:
let's say your buffer that plots your original indicator is named abc
so first you declare these:
extern int BandsPeriod=20;
extern int BandsShift=0;
extern double BandsDeviations=2.0;
1) you change
#property indicator_buffers 1 (1 becomes 3)
2)
SetIndexBuffer(0,abc);
SetIndexStyle(0,DRAW_LINE);
and add
SetIndexBuffer(1,UpperBuffer);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(2,LowerBuffer);
SetIndexStyle(2,DRAW_LINE);
SetIndexDrawBegin(0,BandsPeriod+BandsShift);
SetIndexDrawBegin(1,BandsPeriod+BandsShift);
3) you add the rest of the bollinger bands code into the initialization loop
int start()
{
int i,k,counted_bars=IndicatorCounted();
double deviation,sum,oldval,newres;
//----
if(Bars<=BandsPeriod) return(0);
//---- initial zero
if(counted_bars<1)
and so on....
4) but how the heck do you replace the buffer called MovingBuffer in the original bands.mq4 code by your new buffer from your indicator, called "abc"?
What's the best way to go about this?
Should I try to get my indicator code into the bands.mq4 code or the other way around?
I attached a well-known piece of code called bands.mq4 so you can see what I'm working with.
again, sorry for my coding-ignorance
Maybe someone knows of a 'adding stdev bands tutorial' ? That would be what I need right now. Thx