#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.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// Enter the description of your strategy here
/// </summary>
[Description("Enter the description of your strategy here")]
public class The10dayNHNL : Strategy
{
#region Variables
// Wizard generated variables
private double enter = 0.800; // Default setting for Enter
private double exit = 0.75; // Default setting for Exit
private int nHNLsma = 10; // Default setting for Exit
private DataSeries nHNLSeries;
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
Add ("NYSE_NEW_HIGHS", PeriodType.Day, 1);
Add ("NYSE_NEW_LOWS", PeriodType.Day, 1);
nHNLSeries = new DataSeries(this);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
double NH1 = BarsArray[1][0];
double NL1 = BarsArray[2][0];
double NHNLavg = (NH1/(NH1 + NL1));
double NHNLsma = SMA(NHNLavg, NHNLsma)[0];
// Condition set 1
if (NHNLsma >= Enter);
{
EnterLong(DefaultQuantity, "");
}
// Condition set 2
if (nHNLSeries[0] <= Exit)
{
ExitLong("", "");
}
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public double Enter
{
get { return enter; }
set { enter = Math.Max(0.5, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int NHNLsma
{
get { return nHNLsma; }
set { nHNLsma = Math.Max(5, value); }
}
[Description("")]
[GridCategory("Parameters")]
public double Exit
{
get { return exit; }
set { exit = Math.Max(0.5, value); }
}
#endregion
}
}
Comment