Download MetaTrader 5
To add comments, please log in or register
All articles are available from MetaTrader 5. Contribute your own one!
Rock-Trader.com
197
Rohit Sharma 2014.06.17 14:36 

Dear Traders & Coders,

I am creating a custom indicator with "Bollinger Bands %b" a Trade Should take Above "Bollinger Bands %b" Value 0.8 Level.

But I am little confused in coding part , Can any one confirm I did call this indicator in a right way ?

iCustom(Symbol(),0,"Bollinger Bands %b",BBPeriod,StdDeviation,0,i) > Bollinger_Min 

I am posting the full code of this indicator. Please Help any body.

//+-------------------------------------------------------------------+
//|                                            Bollinger Bands %b.mq4 |
//|                       Copyright © 2004, MetaQuotes Software Corp. |
//|                                         http://www.metaquotes.net |
//|                                     Modified by Alejandro Galindo |
//|                                                                   |
//|                                            You are free to use it |
//|                                                                   |
//|       If you want and if this work/modification is helpful to you |
//|              you can send me a PayPal donation to ag@elcactus.com |
//+-------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Yellow
//---- input parameters
extern int BBPeriod=20;
extern int StdDeviation=2;
//---- buffers
double BLGBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,BLGBuffer);
//---- name for DataWindow and indicator subwindow label
   short_name="BBpB("+BBPeriod+","+StdDeviation+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//----
   SetIndexDrawBegin(0,BBPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Momentum                                                         |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
//----
   if(Bars<=BBPeriod) return(0);
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=BBPeriod;i++) BLGBuffer[Bars-i]=0.0;
//----
   i=Bars-BBPeriod-1;
   if(counted_bars>=BBPeriod) i=Bars-counted_bars-1;
   while(i>=0)
     {
      BLGBuffer[i]=(Close[i]-iBands(NULL,0,BBPeriod,StdDeviation,0,0,MODE_HIGH,i))/(iBands(NULL,0,BBPeriod,StdDeviation,0,0,MODE_LOW,i)-iBands(NULL,0,BBPeriod,StdDeviation,0,0,MODE_HIGH,i));
      i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+
whroeder1
13641
whroeder1 2014.06.17 15:08  
Rock-Trader: Can any one confirm I did call this indicator in a right way ?
Looks right
Detailed explanation of iCustom - MQL4 forum
qjol
3243
qjol 2014.06.17 16:47  


if you would provide a detailed example what's your goal maybe someone can help you

i doubt you mean this:

BLGBuffer[i]=(Close[i]-iBands(NULL,0,BBPeriod,StdDeviation,0,0,MODE_HIGH,i))/
             (iBands(NULL,0,BBPeriod,StdDeviation,0,0,MODE_LOW,i)-iBands(NULL,0,BBPeriod,StdDeviation,0,0,MODE_HIGH,i));

or this:

BLGBuffer[i]=(Close[i]-(iBands(NULL,0,BBPeriod,StdDeviation,0,0,MODE_HIGH,i))/
             (iBands(NULL,0,BBPeriod,StdDeviation,0,0,MODE_LOW,i))-iBands(NULL,0,BBPeriod,StdDeviation,0,0,MODE_HIGH,i));

maybe this one ?

BLGBuffer[i]=(Close[i]-((iBands(NULL,0,BBPeriod,StdDeviation,0,0,MODE_HIGH,i))/
             (iBands(NULL,0,BBPeriod,StdDeviation,0,0,MODE_LOW,i))-iBands(NULL,0,BBPeriod,StdDeviation,0,0,MODE_HIGH,i)));


there are (if i'm not mistaken) 24 combinations and permutations possibilities

/
To add comments, please log in or register