NexusFi: Find Your Edge


Home Menu

 





modifying bollinger bands


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one r68cervera with 7 posts (0 thanks)
    2. looks_two Fat Tails with 2 posts (1 thanks)
    3. looks_3 cory with 1 posts (1 thanks)
    4. looks_4 Jack22 with 1 posts (1 thanks)
    1. trending_up 3,427 views
    2. thumb_up 3 thanks given
    3. group 4 followers
    1. forum 11 posts
    2. attach_file 4 attachments




 
Search this Thread

modifying bollinger bands

  #1 (permalink)
r68cervera
spain
 
Posts: 7 since Jun 2010
Thanks Given: 3
Thanks Received: 0

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
}
}

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Exit Strategy
NinjaTrader
ZombieSqueeze
Platforms and Indicators
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Diary of a simple price action trader
26 thanks
Just another trading journal: PA, Wyckoff & Trends
21 thanks
My NQ Trading Journal
19 thanks
Tao te Trade: way of the WLD
14 thanks
HumbleTraders next chapter
9 thanks
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


Please post a chart with the indicator applied and explain what is not correct and why it is not correct.

There are different solutions possible.

For example you can calculate the standard deviation from the closes, highs or lows.

All depends on what you try to achieve or which system you try to imitate.

Reply With Quote
  #4 (permalink)
r68cervera
spain
 
Posts: 7 since Jun 2010
Thanks Given: 3
Thanks Received: 0

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

Reply With Quote
  #5 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


r68cervera View Post
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.

Reply With Quote
Thanked by:
  #6 (permalink)
r68cervera
spain
 
Posts: 7 since Jun 2010
Thanks Given: 3
Thanks Received: 0

ok fat
I will try to upload a graphic of the two platforms so you can see the difference
Thanks for your interest

Reply With Quote
  #7 (permalink)
r68cervera
spain
 
Posts: 7 since Jun 2010
Thanks Given: 3
Thanks Received: 0

I will upload the first graphic visual chart

Attached Thumbnails
Click image for larger version

Name:	visualchart.png
Views:	183
Size:	126.8 KB
ID:	173159  
Reply With Quote
  #8 (permalink)
r68cervera
spain
 
Posts: 7 since Jun 2010
Thanks Given: 3
Thanks Received: 0

ninja trader

Attached Thumbnails
Click image for larger version

Name:	ninja.png
Views:	126
Size:	94.6 KB
ID:	173160  
Reply With Quote
  #9 (permalink)
r68cervera
spain
 
Posts: 7 since Jun 2010
Thanks Given: 3
Thanks Received: 0

ninja trader date 26/01/2015 time 9:50

upper band 10676.4 blue line
middle.band 10625.9 green line
low.band 10575.1 red line


visual chart date 26/01/2015 time 9:50

upper band 10677.6 blue line
middle band 10626 green line
low band 10576 red line


in visual chart, let me set automatically close , high, low, open, in ninja I have only close

Reply With Quote
  #10 (permalink)
 
cory's Avatar
 cory 
virginia
 
Experience: Intermediate
Platform: ninja
Trading: NQ
Posts: 6,098 since Jun 2009
Thanks Given: 877
Thanks Received: 8,090



r68cervera View Post


in visual chart, let me set automatically close , high, low, open, in ninja I have only close

you select O,H,C thru indicator setting

Attached Thumbnails
Click image for larger version

Name:	2015-01-28_0803.png
Views:	144
Size:	94.2 KB
ID:	173166  
Reply With Quote
Thanked by:




Last Updated on January 28, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts