NexusFi: Find Your Edge


Home Menu

 



Categories Help    






 
BBand2 with color double stddev band V1 5 *
This bband has 2 stddev value so that it can color the outer band and it highlights the band if price touch the band and it also do the alert if touch.


Category NinjaTrader 6.5 Indicators 
 
Suggest other entries I might like
Details: BBand2 with color double stddev band V1
Category: NinjaTrader 6.5 Indicators 


March 12th, 2010
Size: 6.42 KB
Downloaded: 843 times

Keywords: alert bollinger cory bband
Comments/ratings
5 * 445NDO March 12th, 2010 08:42 PM
Thanks Again !!

Check this code out :- Similar like yours :-

#region Using declarations
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using System.Xml.Serialization;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// Keltner Channel. The Keltner Channel is a similar indicator to Bollinger Bands. Here the midline is a standard moving average with the upper and lower bands offset by the SMA of the difference between the high and low of the previous bars. The offset multiplier as well as the SMA period is configurable.
/// </summary>
[Description("The Keltner Channel is a similar indicator to Bollinger Bands. Here the midline is a standard moving average with the upper and lower bands offset by the SMA of the difference between the high and low of the previous bars. The offset multiplier as well as the SMA period is configurable.")]
public class BLineKeltnerChannel : Indicator
{
#region Variables

private int period = 9;
private double offsetMultiplier = 1.5;
private double offsetMultiplier2 = 3.0;
private DataSeries diff;
private DataSeries diffSecond;

private int opacityBands = 2;
private int opacityTouch = 3;

private Color colorBands = Color.Gray;
private Color colorTouchUpper = Color.Tomato;
private Color colorTouchLower = Color.LawnGreen;
#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.Empty, "Upper"));
Add(new Plot(Color.Empty, "Lower"));
Add(new Plot(Color.Empty, "UpperSecond"));
Add(new Plot(Color.Empty, "LowerSecond"));
diff = new DataSeries(this);
diffSecond = new DataSeries(this);
Overlay = true;
PriceTypeSupported = true;
PriceType = PriceType.Close;
PaintPriceMarkers = false;
}
/// <summary>
/// Called on each bar update event (incoming tick).
/// </summary>
protected override void OnBarUpdate()
{
diff.Set(High[0] - Low[0]);
diffSecond.Set(High[0] - Low[0]);
double middle = SMA(Input, Period)[0];
double offset = SMA(diff, Period)[0] * offsetMultiplier;
double middleSecond = SMA(Input, Period)[0];
double offsetSecond = SMA(diffSecond, Period)[0] * offsetMultiplier2;
double upper = middle + offset;
double lower = middle - offset;
double upperSecond = middleSecond + offsetSecond;
double lowerSecond = middleSecond - offsetSecond;
Upper.Set(upper);
Lower.Set(lower);
UpperSecond.Set(upperSecond);
LowerSecond.Set(lowerSecond);

if (!Bars.FirstBarOfSession)
{
DrawRegion("Fill1" + CurrentBar, 1, 0, Upper, UpperSecond, Color.Empty, colorBands, opacityBands);
DrawRegion("Fill2" + CurrentBar, 1, 0, Lower, LowerSecond, Color.Empty, colorBands, opacityBands);
}

if (High[0] >= upper)
DrawRegion("KeltnerHigh" + CurrentBar, 1, 0, Upper, UpperSecond, Color.Empty, colorTouchUpper, opacityTouch);
else
if (Low[0] <= lower)
DrawRegion("KeltnerLow" + CurrentBar, 1, 0, Lower, LowerSecond, Color.Empty, colorTouchLower, opacityTouch);

}
#region Properties
/// <summary>
/// </summary>
[Description("Numbers of bars used for calculations")]
[Category("Parameters")]
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public int Period
{
get { return period; }
set { period = Math.Max(1, value); }
}
/// <summary>
/// </summary>
[Description("Transperancy of Bands 1 - 10")]
[Category("Parameters")]
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public int OpacityBands
{
get { return opacityBands; }
set { opacityBands = Math.Min(10, value); }
}
/// <summary>
/// </summary>
[Description("Transperancy of Band Touches 1 - 10")]
[Category("Parameters")]
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public int OpacityTouch
{
get { return opacityTouch; }
set { opacityTouch = Math.Min(10, value); }
}
/// <summary>
/// </summary>
[Description("How much to expand the upper and lower band from the normal offset")]
[Category("Parameters")]
[Gui.Design.DisplayNameAttribute("Offset multiplier")]
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public double OffsetMultiplier
{
get { return offsetMultiplier; }
set { offsetMultiplier = Math.Max(0.01, value); }
}
[Description("How much to expand the second upper and lower band from the normal offset")]
[Category("Parameters")]
[Gui.Design.DisplayNameAttribute("Offset multiplier Two")]
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public double OffsetMultiplier2
{
get { return offsetMultiplier2; }
set { offsetMultiplier2 = Math.Max(0.01, value); }
}
[Description("Color of Keltner Bands")]
[Category("Parameters")]
[Gui.Design.DisplayNameAttribute("Band Color")]
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public Color ColorBands
{
get { return colorBands; }
set { colorBands = value; }
}
[Description("Color of Upper Touch of Bands")]
[Category("Parameters")]
[Gui.Design.DisplayNameAttribute("Band Touch Upper Color")]
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public Color ColorTouchUpper
{
get { return colorTouchUpper; }
set { colorTouchUpper = value; }
}
[Description("Color of Lower Touch of Bands")]
[Category("Parameters")]
[Gui.Design.DisplayNameAttribute("Band Touch Lower Color")]
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public Color ColorTouchLower
{
get { return colorTouchLower; }
set { colorTouchLower = value; }
}

/// <summary>
/// </summary>
[Browsable(false)]
[XmlIgnore()]
public DataSeries Upper
{
get { return Values[0]; }
}

/// <summary>
/// </summary>
[Browsable(false)]
[XmlIgnore()]
public DataSeries Lower
{
get { return Values[1]; }
}
[Browsable(false)]
[XmlIgnore()]
public DataSeries UpperSecond
{
get { return Values[2]; }
}

/// <summary>
/// </summary>
[Browsable(false)]
[XmlIgnore()]
public DataSeries LowerSecond
{
get { return Values[3]; }
}
#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 BLineKeltnerChannel[] cacheBLineKeltnerChannel = null;
private static BLineKeltnerChannel checkBLineKeltnerChannel = new BLineKeltnerChannel();
/// <summary>
/// The Keltner Channel is a similar indicator to Bollinger Bands. Here the midline is a standard moving average with the upper and lower bands offset by the SMA of the difference between the high and low of the previous bars. The offset multiplier as well as the SMA period is configurable.
/// </summary>
/// <returns></returns>
public BLineKeltnerChannel BLineKeltnerChannel(Color colorBands, Color colorTouchLower, Color colorTouchUpper, double offsetMultiplier, double offsetMultiplier2, int opacityBands, int opacityTouch, int period)
{
return BLineKeltnerChannel(Input, colorBands, colorTouchLower, colorTouchUpper, offsetMultiplier, offsetMultiplier2, opacityBands, opacityTouch, period);
}
/// <summary>
/// The Keltner Channel is a similar indicator to Bollinger Bands. Here the midline is a standard moving average with the upper and lower bands offset by the SMA of the difference between the high and low of the previous bars. The offset multiplier as well as the SMA period is configurable.
/// </summary>
/// <returns></returns>
public BLineKeltnerChannel BLineKeltnerChannel(Data.IDataSeries input, Color colorBands, Color colorTouchLower, Color colorTouchUpper, double offsetMultiplier, double offsetMultiplier2, int opacityBands, int opacityTouch, int period)
{
checkBLineKeltnerChannel.ColorBands = colorBands;
colorBands = checkBLineKeltnerChannel.ColorBands;
checkBLineKeltnerChannel.ColorTouchLower = colorTouchLower;
colorTouchLower = checkBLineKeltnerChannel.ColorTouchLower;
checkBLineKeltnerChannel.ColorTouchUpper = colorTouchUpper;
colorTouchUpper = checkBLineKeltnerChannel.ColorTouchUpper;
checkBLineKeltnerChannel.OffsetMultiplier = offsetMultiplier;
offsetMultiplier = checkBLineKeltnerChannel.OffsetMultiplier;
checkBLineKeltnerChannel.OffsetMultiplier2 = offsetMultiplier2;
offsetMultiplier2 = checkBLineKeltnerChannel.OffsetMultiplier2;
checkBLineKeltnerChannel.OpacityBands = opacityBands;
opacityBands = checkBLineKeltnerChannel.OpacityBands;
checkBLineKeltnerChannel.OpacityTouch = opacityTouch;
opacityTouch = checkBLineKeltnerChannel.OpacityTouch;
checkBLineKeltnerChannel.Period = period;
period = checkBLineKeltnerChannel.Period;
if (cacheBLineKeltnerChannel != null)
for (int idx = 0; idx < cacheBLineKeltnerChannel.Length; idx++)
if (cacheBLineKeltnerChannel[idx].ColorBands == colorBands && cacheBLineKeltnerChannel[idx].ColorTouchLower == colorTouchLower && cacheBLineKeltnerChannel[idx].ColorTouchUpper == colorTouchUpper && Math.Abs(cacheBLineKeltnerChannel[idx].OffsetMultiplier - offsetMultiplier) <= double.Epsilon && Math.Abs(cacheBLineKeltnerChannel[idx].OffsetMultiplier2 - offsetMultiplier2) <= double.Epsilon && cacheBLineKeltnerChannel[idx].OpacityBands == opacityBands && cacheBLineKeltnerChannel[idx].OpacityTouch == opacityTouch && cacheBLineKeltnerChannel[idx].Period == period && cacheBLineKeltnerChannel[idx].EqualsInput(input))
return cacheBLineKeltnerChannel[idx];
BLineKeltnerChannel indicator = new BLineKeltnerChannel();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
indicator.Input = input;
indicator.ColorBands = colorBands;
indicator.ColorTouchLower = colorTouchLower;
indicator.ColorTouchUpper = colorTouchUpper;
indicator.OffsetMultiplier = offsetMultiplier;
indicator.OffsetMultiplier2 = offsetMultiplier2;
indicator.OpacityBands = opacityBands;
indicator.OpacityTouch = opacityTouch;
indicator.Period = period;
indicator.SetUp();
BLineKeltnerChannel[] tmp = new BLineKeltnerChannel[cacheBLineKeltnerChannel == null ? 1 : cacheBLineKeltnerChannel.Length + 1];
if (cacheBLineKeltnerChannel != null)
cacheBLineKeltnerChannel.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cacheBLineKeltnerChannel = 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>
/// The Keltner Channel is a similar indicator to Bollinger Bands. Here the midline is a standard moving average with the upper and lower bands offset by the SMA of the difference between the high and low of the previous bars. The offset multiplier as well as the SMA period is configurable.
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.BLineKeltnerChannel BLineKeltnerChannel(Color colorBands, Color colorTouchLower, Color colorTouchUpper, double offsetMultiplier, double offsetMultiplier2, int opacityBands, int opacityTouch, int period)
{
return _indicator.BLineKeltnerChannel(Input, colorBands, colorTouchLower, colorTouchUpper, offsetMultiplier, offsetMultiplier2, opacityBands, opacityTouch, period);
}
/// <summary>
/// The Keltner Channel is a similar indicator to Bollinger Bands. Here the midline is a standard moving average with the upper and lower bands offset by the SMA of the difference between the high and low of the previous bars. The offset multiplier as well as the SMA period is configurable.
/// </summary>
/// <returns></returns>
public Indicator.BLineKeltnerChannel BLineKeltnerChannel(Data.IDataSeries input, Color colorBands, Color colorTouchLower, Color colorTouchUpper, double offsetMultiplier, double offsetMultiplier2, int opacityBands, int opacityTouch, int period)
{
return _indicator.BLineKeltnerChannel(input, colorBands, colorTouchLower, colorTouchUpper, offsetMultiplier, offsetMultiplier2, opacityBands, opacityTouch, period);
}
}
}
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
/// <summary>
/// The Keltner Channel is a similar indicator to Bollinger Bands. Here the midline is a standard moving average with the upper and lower bands offset by the SMA of the difference between the high and low of the previous bars. The offset multiplier as well as the SMA period is configurable.
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.BLineKeltnerChannel BLineKeltnerChannel(Color colorBands, Color colorTouchLower, Color colorTouchUpper, double offsetMultiplier, double offsetMultiplier2, int opacityBands, int opacityTouch, int period)
{
return _indicator.BLineKeltnerChannel(Input, colorBands, colorTouchLower, colorTouchUpper, offsetMultiplier, offsetMultiplier2, opacityBands, opacityTouch, period);
}
/// <summary>
/// The Keltner Channel is a similar indicator to Bollinger Bands. Here the midline is a standard moving average with the upper and lower bands offset by the SMA of the difference between the high and low of the previous bars. The offset multiplier as well as the SMA period is configurable.
/// </summary>
/// <returns></returns>
public Indicator.BLineKeltnerChannel BLineKeltnerChannel(Data.IDataSeries input, Color colorBands, Color colorTouchLower, Color colorTouchUpper, double offsetMultiplier, double offsetMultiplier2, int opacityBands, int opacityTouch, int period)
{
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.BLineKeltnerChannel(input, colorBands, colorTouchLower, colorTouchUpper, offsetMultiplier, offsetMultiplier2, opacityBands, opacityTouch, period);
}
}
}
#endregion
5 * Poocher March 14th, 2010 10:42 PM
Thanks Cory!

These are way better than what's-his-faces bands.
5 * qewcool April 21st, 2010 09:22 PM
Thanks.
5 * oneguy May 16th, 2010 03:48 PM
thanks
5 * oneguy May 16th, 2010 03:48 PM
thanks
5 * kareem40 June 11th, 2010 03:17 PM
Very useful in Trading range market. Thank you
5 * mirhrd June 15th, 2010 02:18 PM
Thank you. Very helpful for me.
5 * dsraider July 24th, 2010 07:36 PM
Thanks for this, cory. I actually now enjoy watching the BBs.
5 * Abde February 29th, 2012 12:45 PM
Wow Cory. Thanks for this very useful indicator.

 
Sort by

 




© 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