First day using NT and first time trying the NT script by its wizard.Successfully compiled. Could it be a good start?
Now I've a problem : How can I plot the horizontal lines both from 930 high and low to 1330 then from 1330 high and low to next day 930. Any help will be much appreciated.
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
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>
/// Breakout of high and low
/// </summary>
[Description("Breakout of high and low")]
public class Breakout : Indicator
{
#region Variables
// Wizard generated variables
// 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, " Hi"));
Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, " Lo"));
CalculateOnBarClose = true;
Overlay = true;
PriceTypeSupported = 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.
Hi.Set(High[0]);
Lo.Set(Low[0]);
if (ToTime(Time[0]) == 093000 || ToTime(Time[0]) == 133000)
{
double myHigh = High[0];
double myLow = Low[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 Hi
{
get { return Values[0]; }
}
[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 Lo
{
get { return Values[1]; }
}
#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 Breakout[] cacheBreakout = null;
private static Breakout checkBreakout = new Breakout();
/// <summary>
/// Breakout of high and low
/// </summary>
/// <returns></returns>
public Breakout Breakout()
{
return Breakout(Input);
}
/// <summary>
/// Breakout of high and low
/// </summary>
/// <returns></returns>
public Breakout Breakout(Data.IDataSeries input)
{
if (cacheBreakout != null)
for (int idx = 0; idx < cacheBreakout.Length; idx++)
if (cacheBreakout[idx].EqualsInput(input))
return cacheBreakout[idx];
Breakout indicator = new Breakout();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
indicator.Input = input;
indicator.SetUp();
Breakout[] tmp = new Breakout[cacheBreakout == null ? 1 : cacheBreakout.Length + 1];
if (cacheBreakout != null)
cacheBreakout.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cacheBreakout = 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>
/// Breakout of high and low
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.Breakout Breakout()
{
return _indicator.Breakout(Input);
}
/// <summary>
/// Breakout of high and low
/// </summary>
/// <returns></returns>
public Indicator.Breakout Breakout(Data.IDataSeries input)
{
return _indicator.Breakout(input);
}
}
}
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
/// <summary>
/// Breakout of high and low
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.Breakout Breakout()
{
return _indicator.Breakout(Input);
}
/// <summary>
/// Breakout of high and low
/// </summary>
/// <returns></returns>
public Indicator.Breakout Breakout(Data.IDataSeries input)
{
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.Breakout(input);
}
}
}
#endregion
Comment