• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 8:50am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 8:50am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Metatrader Application Window Width 1 reply

Bollinger Band Day Trading System 8 replies

ema bollinger band alerts 1 reply

Bollinger band difference indicator... 2 replies

Bollinger band settings? 1 reply

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
Tags: Bollinger Band Width for Metatrader
Cancel

Bollinger Band Width for Metatrader

  • Post #1
  • Quote
  • First Post: Jan 23, 2007 9:31am Jan 23, 2007 9:31am
  •  Kamikaze1
  • | Joined Jul 2006 | Status: Member | 4 Posts
Who of you has the Bollinger Band With Indicator for me?
I tried to program it myself, but i 'm no programmer.
For those of you who want to make this indicator, the formula is:

(Upper Bolband - Lower Bolband) / Middle Bolband

If you want to share it, i would greatly appreciate it.

Thanks in advance
  • Post #2
  • Quote
  • Jan 23, 2007 4:50pm Jan 23, 2007 4:50pm
  •  tesla
  • | Joined Oct 2006 | Status: Friendly Neighborhood Programmer | 533 Posts
I think the formula you're looking for is UpperBand - LowerBand. I'm more than happy to help those who help themselves. Post what you've got so far and I'll help you with the code.
 
 
  • Post #3
  • Quote
  • Jan 23, 2007 5:31pm Jan 23, 2007 5:31pm
  •  Kamikaze1
  • | Joined Jul 2006 | Status: Member | 4 Posts
In his book Bollinger on bollinger bands, John Bollinger used the formula i typed in above, so i dont know if we are talking over the same thing here.

About the programming. I copied some text from a formula that looks simular to the bollinger band width. It's the formula for the %b in his book. It only has no simple moving average in it and thats immediately a big problem for me to overcome. All i have is this:

#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);
}
//+------------------------------------------------------------------+

This is the formula of the %b. To adapt this formula to the new situation i changed the 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));

to :

(iBands(NULL,0,BBPeriod,StdDeviation,0,0,MODE_HIGH,i)-iBands(NULL,0,BBPeriod,StdDeviation,0,0,MODE_LOW,i)) / "simple moving average ??"

I just don't know what to type in for the 20 period sma. I once saw it standing as mov(C,20,S), but that one gives errors.

Is there a good tutorial for Metatrader 4 programming?

This is all i could come up with sofar. As you can see i am a real newbie to this. Hope you will help me.
 
 
  • Post #4
  • Quote
  • Jan 23, 2007 5:55pm Jan 23, 2007 5:55pm
  •  tesla
  • | Joined Oct 2006 | Status: Friendly Neighborhood Programmer | 533 Posts
Try this. If the calculation is different from what you're expecting I'm sure we can work it out.

PHP Code
 #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;
    
    
SetIndexStyle(0,DRAW_LINE);
    
SetIndexBuffer(0,BLGBuffer);

    
short_name="BBpB("+BBPeriod+","+StdDeviation+")";
    
IndicatorShortName(short_name);
    
SetIndexLabel(0,short_name);

    return(
0);
}


int start() {

    
// Figure out how many bars need to be calculated
    // If one or more bars have already been calculated, recalculate
    // last complete bar.
    // This is done incase the indicator was busy and a tick was skipped.
    
int iBarsToCalc = Bars - IndicatorCounted() - 1;
    if (
iBarsToCalc < Bars - 1)    iBarsToCalc--;
    
    
// Iterate over all the bars, from oldest to newest
    
for (int i=iBarsToCalc;i>=0;i--) {
    
        
// Get values for upper and lower bars
        
double dUpperBand = iBands(NULL,0,BBPeriod,StdDeviation,0,PRICE_CLOSE,MODE_UPPER,i);
        
double dLowerBand = iBands(NULL,0,BBPeriod,StdDeviation,0,PRICE_CLOSE,MODE_LOWER,i);
        
        
// Calculate the difference and place it in the buffer.        
        
BLGBuffer[i] = dUpperBand - dLowerBand;
    }

    
// All done.    
    
return(0);
} 
 
 
  • Post #5
  • Quote
  • Last Post: Jan 23, 2007 8:30pm Jan 23, 2007 8:30pm
  •  Kamikaze1
  • | Joined Jul 2006 | Status: Member | 4 Posts
I think this is the one. Thank you Tesla
 
 
  • Platform Tech
  • /
  • Bollinger Band Width for Metatrader
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023