Here's the code:
#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 deleteme : Strategy
{
#region Variables
// Wizard generated variables
private double target = 8; // Default setting for Target
private double stop = 8; // Default setting for Stop
private int qty1 = 4; // Default setting for Qty1
private int qty2 = 1; // Default setting for Qty2
// 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()
{
SetProfitTarget("order1", CalculationMode.Ticks, Target);
SetStopLoss("order2", CalculationMode.Ticks, Stop, false);
SetStopLoss("order1", CalculationMode.Ticks, Stop, false);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (Close[0] > Close[1])
{
EnterLong(Qty1, "order1");
EnterLong(Qty2, "order2");
}
// Condition set 2
if (Close[0] < Close[1])
{
EnterShort(Qty1, "order1");
EnterShort(Qty2, "order2");
}
}
#region Properties
[Description("")]
[Category("Parameters")]
public double Target
{
get { return target; }
set { target = Math.Max(1, value); }
}
[Description("")]
[Category("Parameters")]
public double Stop
{
get { return stop; }
set { stop = Math.Max(1, value); }
}
[Description("")]
[Category("Parameters")]
public int Qty1
{
get { return qty1; }
set { qty1 = Math.Max(0, value); }
}
[Description("")]
[Category("Parameters")]
public int Qty2
{
get { return qty2; }
set { qty2 = Math.Max(0, value); }
}
#endregion
}
}

Comment