1.5 SD on bollinger bands

 

Bollinger Bands don't seem to allow 1.5 standard deviations in the external variable setting.

If I use 1.5 in the iBands it doesn't work.

Is this just a setting in the Bollinger Band code because it is set to an integer maybe?


Do I need to create a Bolly band indicator and use iCustom to reference it?

 

hi, iBand() uses a integer. so you can't use a 1.5 deviation. but you don't have to create a new indicator. there is a bollingerband in the custom indicators originally shipped from metaquotes, you can call that trough iCustom(). i don't understand too why metaqotes made 2 different bollinger bands but thats life ;)

//z

 

I have the code to get the buffer values here:

double Boll_15SD_Upper=iCustom(NULL, 0, "Bands",20,0,1.5,1,0);
double Boll_15SD_Lower=iCustom(NULL, 0, "Bands",20,0,1.5,2,0);

The problem is that later in my code, I need to iterate through i. Is this possible with iCustom?


limit = Bars - counted_bars;
      for(i=0; i<=limit; i++) 
      {  
         if (
             (iClose(Symbol(),NULL,i+1) < iBands(Symbol(),NULL, 20, Sigma, 0, PRICE_CLOSE, MODE_UPPER, i+1)) &&
             (iClose(Symbol(),NULL,i) > iBands(Symbol(),NULL, 20, Sigma, 0, PRICE_CLOSE, MODE_UPPER, i) && iClose(Symbol(),NULL,i) < iBands(Symbol(),NULL, 20, 2, 0, PRICE_CLOSE, MODE_UPPER, i))
             )
         {
            ExtMapBuffer1[i] = Low[i] + nShift*Point;
         }
         if (
             (iClose(Symbol(),NULL,i+1) > iBands(Symbol(),NULL, 20, Sigma, 0, PRICE_CLOSE, MODE_LOWER, i+1)) &&
             (iClose(Symbol(),NULL,i) < iBands(Symbol(),NULL, 20, Sigma, 0, PRICE_CLOSE, MODE_LOWER, i) && iClose(Symbol(),NULL,i) > iBands(Symbol(),NULL, 20, 2, 0, PRICE_CLOSE, MODE_LOWER, i))
             ) 
         {
            ExtMapBuffer2[i] = High[i] - nShift*Point;
         }
        //this code below here does not work properly...
        if (
             (iClose(Symbol(),NULL,i+1) > iBands(Symbol(),NULL, 20, Sigma, 0, PRICE_CLOSE, MODE_LOWER, i+1)) &&
             (iClose(Symbol(),NULL,i) < Boll_15SD_Upper)
             ) 
         {
            ExtMapBuffer3[i] = High[i] - nShift*Point;
         }
         if (
             (iClose(Symbol(),NULL,i+1) < iBands(Symbol(),NULL, 20, Sigma, 0, PRICE_CLOSE, MODE_LOWER, i+1)) &&
             (iClose(Symbol(),NULL,i) > Boll_15SD_Lower)
             ) 
         {
            ExtMapBuffer3[i] = High[i] - nShift*Point;
         }
      }
 
SanMiguel 2010.07.29 00:35

Bollinger Bands don't seem to allow 1.5 standard deviations in the external variable setting.

If I use 1.5 in the iBands it doesn't work.

Is this just a setting in the Bollinger Band code because it is set to an integer maybe?

double iBands( string symbol, int timeframe, int period, int deviation, int bands_shift, int applied_price, int mode, int shift)


Either you have to use an int with iBands, or the custom indicator "Bands", or calculate the deviation yourself:
#define BB.Period 20
double MA = iMA(NULL,0, BB.Period, 0, MODE_SMA, PRICE_CLOSE, 0),
       uB = iBands(NULL,0,BB.Period,1,0,PRICE_CLOSE,MODE_UPPER,0),
       std= uB - MA,
       upper = MA + 1.5*std,
       lower = MA - 1.5*std,;
 
gdDeviation = 1.5;
giLength = 20;
ldStdDev = iStdDev(Symbol(), 0, giLength, 0, MODE_SMA, PRICE_TYPICAL, 0);
ldMA = iMA(Symbol(), 0, giLength, 0, MODE_SMA, PRICE_TYPICAL, 0);
ldUpperBB = ldMA+ldStdDev*gdDeviation;
ldLowerBB = ldMA-ldStdDev*gdDeviation;
You can also use iStdDev. Same result
 
Russell:
You can also use iStdDev. Same result


Hi guys

I'm new to MT4 language so still trying to get my head around it.

Russell, the details you put there - is that all you have to put in the 'compiler' I think its called - or do you need more detail than that?

Cheers

Seth

 
Russell: is not active anymore.
 

Thanks ubzen

Do you have any ideas on where I could get a tip on some basics to start. I've done several other languages but for some reason this one is just doing my head in.

If I could get the initial layout I should be able to work it out from there - hopefully :)

EG: if I just wanted to do something like..........

close > 20mov

20mov > 20mov 20 candles/days ago

draw an up arrow and buy at open with a fixed stop of say 1ATR and a profit target of 1ATR

Obviously its not that simple a system but if I can see the layout to get to there then hopefully I can nut it out, add in bollinger bands and any other indicators etc etc

Cheers

Seth

 
Try Here. Or Here.
 

Thanks ubzen - will do more reading - will have to see if I can find a basic example to make it easier to decipher.

Cheers......

Reason: