Anyone know why?
Thanks
Code:
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// Prints the following insicators to the output window:- High, low, MACD, BolengerBands, 50EMA, 200EMA
/// </summary>
[Description("Prints the following insicators to the output window:- High, low, MACD, BolengerBands, 50EMA, 200EMA")]
public class IndicatorPrinter : 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()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
Overlay = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
//double bolHigh, bolMid, bolLow = Bolenger (2,29) ;
double bolHigh = Bollinger(2,29).Upper[0];
double bolMid = Bollinger(2,29).Middle [0];
double bolLow = Bollinger(2,29).Lower [0];
//double macd, macdAvg, macdDiff = (6,13,9) ;
double macd = MACD(6,13,9) [0];
double macdAvg = MACD(6,13,9).Avg [0];
double macdDiff = MACD(6,13,9).Diff [0];
//double ema200 = EMA(200)/ double ema50 = EMA(50);
double ema200 = EMA(200)[0];
double ema50 = EMA(50)[0];
//Prints the indicators above to the output window ;
Print("" + Time[0] + " " + High[0] + " " + Low[0] + " " + bolHigh.ToString("N2") + " " + bolMid.ToString("N2") + " " + bolLow.ToString("N2") + " " + macd.ToString("N3") + " " + macdAvg.ToString("N3") + " " + macdDiff.ToString("N3") + " " + ema50.ToString("N2") + " " + ema200.ToString("N2"));
//
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Plot0.Set(High[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("")]
[GridCategory("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 IndicatorPrinter[] cacheIndicatorPrinter = null;
private static IndicatorPrinter checkIndicatorPrinter = new IndicatorPrinter();
/// <summary>
/// Prints the following insicators to the output window:- High, low, MACD, BolengerBands, 50EMA, 200EMA
/// </summary>
/// <returns></returns>
public IndicatorPrinter IndicatorPrinter(int myInput0)
{
return IndicatorPrinter(Input, myInput0);
}
/// <summary>
/// Prints the following insicators to the output window:- High, low, MACD, BolengerBands, 50EMA, 200EMA
/// </summary>
/// <returns></returns>
public IndicatorPrinter IndicatorPrinter(Data.IDataSeries input, int myInput0)
{
if (cacheIndicatorPrinter != null)
for (int idx = 0; idx < cacheIndicatorPrinter.Length; idx++)
if (cacheIndicatorPrinter[idx].MyInput0 == myInput0 && cacheIndicatorPrinter[idx].EqualsInput(input))
return cacheIndicatorPrinter[idx];
lock (checkIndicatorPrinter)
{
checkIndicatorPrinter.MyInput0 = myInput0;
myInput0 = checkIndicatorPrinter.MyInput0;
if (cacheIndicatorPrinter != null)
for (int idx = 0; idx < cacheIndicatorPrinter.Length; idx++)
if (cacheIndicatorPrinter[idx].MyInput0 == myInput0 && cacheIndicatorPrinter[idx].EqualsInput(input))
return cacheIndicatorPrinter[idx];
IndicatorPrinter indicator = new IndicatorPrinter();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
indicator.Input = input;
indicator.MyInput0 = myInput0;
Indicators.Add(indicator);
indicator.SetUp();
IndicatorPrinter[] tmp = new IndicatorPrinter[cacheIndicatorPrinter == null ? 1 : cacheIndicatorPrinter.Length + 1];
if (cacheIndicatorPrinter != null)
cacheIndicatorPrinter.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cacheIndicatorPrinter = tmp;
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>
/// Prints the following insicators to the output window:- High, low, MACD, BolengerBands, 50EMA, 200EMA
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.IndicatorPrinter IndicatorPrinter(int myInput0)
{
return _indicator.IndicatorPrinter(Input, myInput0);
}
/// <summary>
/// Prints the following insicators to the output window:- High, low, MACD, BolengerBands, 50EMA, 200EMA
/// </summary>
/// <returns></returns>
public Indicator.IndicatorPrinter IndicatorPrinter(Data.IDataSeries input, int myInput0)
{
return _indicator.IndicatorPrinter(input, myInput0);
}
}
}
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
/// <summary>
/// Prints the following insicators to the output window:- High, low, MACD, BolengerBands, 50EMA, 200EMA
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.IndicatorPrinter IndicatorPrinter(int myInput0)
{
return _indicator.IndicatorPrinter(Input, myInput0);
}
/// <summary>
/// Prints the following insicators to the output window:- High, low, MACD, BolengerBands, 50EMA, 200EMA
/// </summary>
/// <returns></returns>
public Indicator.IndicatorPrinter IndicatorPrinter(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.IndicatorPrinter(input, myInput0);
}
}
}
#endregion
Comment