Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Hello, I am trying to develop a system based on bollinger bands indicator, but I need the upper band is calculated with maximum candle, the lower band with minimal candle and center with SMA.
I have written the following code, but I see that the result is not correct, I still figuring everything with the closing price of the candle
what is wrong ???
any help will be appreciated
thx
public class bollingerfelipenuevo : Indicator
{
#region Variables
private double numStdDev = 2;
private int period =14;
#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.Orange, "Upper band"));
Add(new Plot(Color.Orange, "Middle band"));
Add(new Plot(Color.Orange, "Lower band"));
Overlay = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
double smaValue = SMA(Period)[0];
double smaHIGH = SMA(High,Period)[0];
double smaLOW = SMA(Low,Period)[0];
double stdDevValue = StdDev(Period)[0];
Upper.Set(smaHIGH + NumStdDev * stdDevValue);
Middle.Set(smaValue);
Lower.Set(smaLOW - NumStdDev * stdDevValue);
}
#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 Lower
{
get { return Values[2]; }
}
/// Get the middle value.
/// <summary>
[Browsable(false)]
[XmlIgnore()]
public DataSeries Middle
{
get { return Values[1]; }
}
/// </summary>
/// Get the upper value.
/// <summary>
[Browsable(false)]
[XmlIgnore()]
public DataSeries Upper
{
get { return Values[0]; }
}
/// </summary>
[Description("Number of standard deviations")]
[GridCategory("Parameters")]
[Gui.Design.DisplayNameAttribute("# of std. dev.")]
public double NumStdDev
{
get { return numStdDev; }
set { numStdDev = Math.Max(0, value); }
}
/// <summary>
[Description("Numbers of bars used for calculations")]
[GridCategory("Parameters")]
public int Period
{
get { return period; }
set { period = Math.Max(1, value); }
}
/// </summary>
#endregion
}
}
Can you help answer these questions from other members on NexusFi?
Hello fat tails thanks for your interest in my question
I need the following:
the upper band is calculated by the maximum of the candle
the middle band is calculated by the closing price
the lower band is calculated by the low Candle
Because it is not correct ???
because I work with Visual Chart, and visual indicator that brings bollinger bands these options you can configure the way you like, and are implemented, and the result is not the same
If the result is not the same, please post a chart produced with Visual Chart and another one made with NinjaTrader and explain the difference. I cannot help without the relevant information.
Maybe, you are not yet allowed to post screenshots, as you have less than 5 posts. Just be patient.