Need help with bands / buffers ??

 

Hi,

Could anyone please help me to understand the use of buffers. I need to create two upper bands and two lower bands around a simple MA. I used ienvelopes, but the deviation is in percent. I need to use a point value.

Here is a sample;

double BotBand1 = NormalizeDouble(iEnvelopes(NULL,0,FastMAPeriod,MODE_SMA,0,PRICE_MEDIAN,BotBand1,MODE_LOWER,1),5);
double TopBand1 = NormalizeDouble(iEnvelopes(NULL,0,FastMAPeriod,MODE_SMA,0,PRICE_MEDIAN,TopBand1,MODE_UPPER,1),5);

double TopBand2 = NormalizeDouble(iEnvelopes(NULL,0,FastMAPeriod,MODE_SMA,0,PRICE_MEDIAN,TopBand2,MODE_UPPER,1),5);
double BotBand2 = NormalizeDouble(iEnvelopes(NULL,0,FastMAPeriod,MODE_SMA,0,PRICE_MEDIAN,BotBand2,MODE_LOWER,1),5);


When I backtest my system, and open chart window, Only one set of bands are visible.

Is there a way of creating a similar set of bands using buffers[]. Does anyone have a relevant code sample for use in ea.

Many thanks for any help.

Chris.

 

hi, you have the same variable name for your result and you deviation of the envelopes.

double BotBand1 = NormalizeDouble(iEnvelopes(NULL,0,FastMAPeriod,MODE_SMA,0,PRICE_MEDIAN,BotBand1,MODE_LOWER,1),5);
double TopBand1 = NormalizeDouble(iEnvelopes(NULL,0,FastMAPeriod,MODE_SMA,0,PRICE_MEDIAN,TopBand1,MODE_UPPER,1),5);

double TopBand2 = NormalizeDouble(iEnvelopes(NULL,0,FastMAPeriod,MODE_SMA,0,PRICE_MEDIAN,TopBand2,MODE_UPPER,1),5);
double BotBand2 = NormalizeDouble(iEnvelopes(NULL,0,FastMAPeriod,MODE_SMA,0,PRICE_MEDIAN,BotBand2,MODE_LOWER,1),5);

.

.

.use other names for setting the deviation and your code looks good. i am surprised that it will compile without errors, but thats mql4.

 

Sorry, That was a typo. I didn't copy and paste that code from my ea. It was supposed to be this;

double BotBand1 = NormalizeDouble(iEnvelopes(NULL,0,FastMAPeriod,MODE_SMA,0,PRICE_MEDIAN,Bot1,MODE_LOWER,1),5);
double TopBand1 = NormalizeDouble(iEnvelopes(NULL,0,FastMAPeriod,MODE_SMA,0,PRICE_MEDIAN,Top1,MODE_UPPER,1),5);

double TopBand2 = NormalizeDouble(iEnvelopes(NULL,0,FastMAPeriod,MODE_SMA,0,PRICE_MEDIAN,Top2,MODE_UPPER,1),5);
double BotBand2 = NormalizeDouble(iEnvelopes(NULL,0,FastMAPeriod,MODE_SMA,0,PRICE_MEDIAN,Bot2,MODE_LOWER,1),5);

I am still only seeing one set of upper and one set of lower bands in the chart window. (When I click 'Open chart' in the tester).

Any ideas on how to create these bands with point deviation instead of percent???

Do I need to create my own custom function using buffer arrays around an MA ? Any advice?

Many thanks,

Chris.

 
That code isn't placing anything on a chart. If you are wriiting an EA not an indicator, you must add indicators to the chart to see them. If you are writing an indicator did you adjust the buffer count?
init() {
        IndicatorBuffers(4)
 

i prefer programs from freerobot2010.com. I have no problems with download programs. I’m very glad. There are more new free robot on this website and other useful files. I advice to visit it .

 
Nik_:

i prefer programs from freerobot2010.com. I have no problems with download programs. I’m very glad. There are more new free robot on this website and other useful files. I advice to visit it .


The above link is R__a  L__ka, Please delete it along with my post.
Reason: