--------START CODE --------
#region Using declarations
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
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>
/// Gives brighter green when going up for sure, gives brighter red when going down the tube
/// </summary>
[Description("Gives brighter green when going up for sure, gives brighter red when going down the tube")]
public class MoreDepthBars : Indicator
{
#region Variables
// Wizard generated variables
private int myInput0 = 1; // Default setting for MyInput0
// 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()
{
double barClosePrice = Close[0];
double barOpenPrice = Open[0];
double barHighPrice = High[0];
double barLowPrice = Low[0];
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
CalculateOnBarClose = true;
Overlay = false;
PriceTypeSupported = false;
}
/// <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.
if (Open[0] < Close[0])
{BarColor = Color.Green;}
if (Open[0] < Close[0] && Close[0] > High[0])
{BarColor = Color.Lime;}
if (Open[0] > Close[0])
{BarColor = Color.Maroon;}
if (Open[0] > Close[0] && Close[0] < Low[0])
{BarColor = Color.Red;}
if (Open[0] == Close[0])
{BarColor = Color.White;}
Plot0.Set(Close[0]);
}
#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 Plot0
{
get { return Values[0]; }
}
[Description("")]
[Category("Parameters")]
public int MyInput0
{
get { return myInput0; }
set { myInput0 = 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 MoreDepthBars[] cacheMoreDepthBars = null;
private static MoreDepthBars checkMoreDepthBars = new MoreDepthBars();
/// <summary>
/// Gives brighter green when going up for sure, gives brighter red when going down the tube
/// </summary>
/// <returns></returns>
public MoreDepthBars MoreDepthBars(int myInput0)
{
return MoreDepthBars(Input, myInput0);
}
/// <summary>
/// Gives brighter green when going up for sure, gives brighter red when going down the tube
/// </summary>
/// <returns></returns>
public MoreDepthBars MoreDepthBars(Data.IDataSeries input, int myInput0)
{
checkMoreDepthBars.MyInput0 = myInput0;
myInput0 = checkMoreDepthBars.MyInput0;
if (cacheMoreDepthBars != null)
for (int idx = 0; idx < cacheMoreDepthBars.Length; idx++)
if (cacheMoreDepthBars[idx].MyInput0 == myInput0 && cacheMoreDepthBars[idx].EqualsInput(input))
return cacheMoreDepthBars[idx];
MoreDepthBars indicator = new MoreDepthBars();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
indicator.Input = input;
indicator.MyInput0 = myInput0;
indicator.SetUp();
MoreDepthBars[] tmp = new MoreDepthBars[cacheMoreDepthBars == null ? 1 : cacheMoreDepthBars.Length + 1];
if (cacheMoreDepthBars != null)
cacheMoreDepthBars.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cacheMoreDepthBars = 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>
/// Gives brighter green when going up for sure, gives brighter red when going down the tube
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.MoreDepthBars MoreDepthBars(int myInput0)
{
return _indicator.MoreDepthBars(Input, myInput0);
}
/// <summary>
/// Gives brighter green when going up for sure, gives brighter red when going down the tube
/// </summary>
/// <returns></returns>
public Indicator.MoreDepthBars MoreDepthBars(Data.IDataSeries input, int myInput0)
{
return _indicator.MoreDepthBars(input, myInput0);
}
}
}
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
/// <summary>
/// Gives brighter green when going up for sure, gives brighter red when going down the tube
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.MoreDepthBars MoreDepthBars(int myInput0)
{
return _indicator.MoreDepthBars(Input, myInput0);
}
/// <summary>
/// Gives brighter green when going up for sure, gives brighter red when going down the tube
/// </summary>
/// <returns></returns>
public Indicator.MoreDepthBars MoreDepthBars(Data.IDataSeries input, int myInput0)
{
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.MoreDepthBars(input, myInput0);
}
}
}
#endregion
--------END CODE --------
Comment