Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Bollinger BandWidth Percent for NinjaTrader
meralim
about 14 years ago
NinjaTrader

Rating:
5 / 5 (Votes 1)
Tags:
bands, ninjatrader

Bollinger Percent (%), like Bollinger Bandwidth, is based on the Bollinger Bands indicator, which was developed by John Bollinger. The Bollinger Bands indicator was developed to measure a stock’s volatility. Furthermore, both Bollinger Bandwidth and Bollinger Percent are used in technical analysis for the same purpose of volatility evaluation.

Similar Indicators / Formulas

Bill Williams Market Facilitation Index
Submitted by kaiji over 14 years ago

Indicator / Formula

Copy & Paste Friendly
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion
 
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
    /// <summary>
    /// Enter the description of your new custom indicator here
    /// </summary>
    [Description("Enter the description of your new custom indicator here")]
    public class BollingerBandWidthPercent : Indicator
    {
        #region Variables
        // Wizard generated variables
            private int period = 14; // Default setting for Period
            private double stdDev = 2; // Default setting for StdDev
        // User defined variables (add any user defined variables below)
        #endregion
 
        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        protected override void Initialize()
        {
            Add(new Plot(Color.FromKnownColor(KnownColor.Lime), PlotStyle.Line, "BBWidthPercent"));
            CalculateOnBarClose = true;
            Overlay             = false;
            PriceTypeSupported  = true;
        }
 
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            double upperValue= Bollinger(stdDev,period).Upper[0];
            double lowerValue= Bollinger(stdDev,period).Lower[0];
            double middleValue= Bollinger(stdDev,period).Middle[0];
            double bbwp= ((upperValue/lowerValue)-1)*100;
            BBWidthPercent.Set(bbwp);
        }
 
        #region Properties
        [Browsable(false)]  // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
        [XmlIgnore()]       // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
        public DataSeries BBWidthPercent
        {
            get { return Values[0]; }
        }
 
        [Description("")]
        [Category("Parameters")]
        public int Period
        {
            get { return period; }
            set { period = Math.Max(1, value); }
        }
 
        [Description("")]
        [Category("Parameters")]
        public double StdDev
        {
            get { return stdDev; }
            set { stdDev = Math.Max(1, value); }
        }
        #endregion
    }
}
 
#region NinjaScript generated code. Neither change nor remove.
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
    public partial class Indicator : IndicatorBase
    {
        private BollingerBandWidthPercent[] cacheBollingerBandWidthPercent = null;
 
        private static BollingerBandWidthPercent checkBollingerBandWidthPercent = new BollingerBandWidthPercent();
 
        /// <summary>
        /// Enter the description of your new custom indicator here
        /// </summary>
        /// <returns></returns>
        public BollingerBandWidthPercent BollingerBandWidthPercent(int period, double stdDev)
        {
            return BollingerBandWidthPercent(Input, period, stdDev);
        }
 
        /// <summary>
        /// Enter the description of your new custom indicator here
        /// </summary>
        /// <returns></returns>
        public BollingerBandWidthPercent BollingerBandWidthPercent(Data.IDataSeries input, int period, double stdDev)
        {
            checkBollingerBandWidthPercent.Period = period;
            period = checkBollingerBandWidthPercent.Period;
            checkBollingerBandWidthPercent.StdDev = stdDev;
            stdDev = checkBollingerBandWidthPercent.StdDev;
 
            if (cacheBollingerBandWidthPercent != null)
                for (int idx = 0; idx < cacheBollingerBandWidthPercent.Length; idx++)
                    if (cacheBollingerBandWidthPercent[idx].Period == period && Math.Abs(cacheBollingerBandWidthPercent[idx].StdDev - stdDev) <= double.Epsilon && cacheBollingerBandWidthPercent[idx].EqualsInput(input))
                        return cacheBollingerBandWidthPercent[idx];
 
            BollingerBandWidthPercent indicator = new BollingerBandWidthPercent();
            indicator.BarsRequired = BarsRequired;
            indicator.CalculateOnBarClose = CalculateOnBarClose;
            indicator.Input = input;
            indicator.Period = period;
            indicator.StdDev = stdDev;
            indicator.SetUp();
 
            BollingerBandWidthPercent[] tmp = new BollingerBandWidthPercent[cacheBollingerBandWidthPercent == null ? 1 : cacheBollingerBandWidthPercent.Length + 1];
            if (cacheBollingerBandWidthPercent != null)
                cacheBollingerBandWidthPercent.CopyTo(tmp, 0);
            tmp[tmp.Length - 1] = indicator;
            cacheBollingerBandWidthPercent = tmp;
            Indicators.Add(indicator);
 
            return indicator;
        }
 
    }
}
 
// This namespace holds all market analyzer column definitions and is required. Do not change it.
namespace NinjaTrader.MarketAnalyzer
{
    public partial class Column : ColumnBase
    {
        /// <summary>
        /// Enter the description of your new custom indicator here
        /// </summary>
        /// <returns></returns>
        [Gui.Design.WizardCondition("Indicator")]
        public Indicator.BollingerBandWidthPercent BollingerBandWidthPercent(int period, double stdDev)
        {
            return _indicator.BollingerBandWidthPercent(Input, period, stdDev);
        }
 
        /// <summary>
        /// Enter the description of your new custom indicator here
        /// </summary>
        /// <returns></returns>
        public Indicator.BollingerBandWidthPercent BollingerBandWidthPercent(Data.IDataSeries input, int period, double stdDev)
        {
            return _indicator.BollingerBandWidthPercent(input, period, stdDev);
        }
 
    }
}
 
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
    public partial class Strategy : StrategyBase
    {
        /// <summary>
        /// Enter the description of your new custom indicator here
        /// </summary>
        /// <returns></returns>
        [Gui.Design.WizardCondition("Indicator")]
        public Indicator.BollingerBandWidthPercent BollingerBandWidthPercent(int period, double stdDev)
        {
            return _indicator.BollingerBandWidthPercent(Input, period, stdDev);
        }
 
        /// <summary>
        /// Enter the description of your new custom indicator here
        /// </summary>
        /// <returns></returns>
        public Indicator.BollingerBandWidthPercent BollingerBandWidthPercent(Data.IDataSeries input, int period, double stdDev)
        {
            if (InInitialize && input == null)
                throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
 
            return _indicator.BollingerBandWidthPercent(input, period, stdDev);
        }
 
    }
}
#endregion

4 comments

1. anandnst

NO FORMULA… Admin kindly check

2. administrator

Formula is for ninjatrader

3. kv_maligi

Hi,

Have look at this http://www.swingtradingfordummies.com/freestuff.htm

Can one develop this for amibroker?

THis code is for ninjatrader. Unfortumately, there are no data vendors in india for testing this.

Thanks
viswanath

4. santa

hello admin

how to paste this formula in ninjatrader 7
pls help me…

Leave Comment

Please login here to leave a comment.

Back