under there is 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 confermatrand2 : Strategy
{
#region Variables
// Wizard generated variables
private IOrder entryOrder = null;
private IOrder stopOrder = null;
private IOrder targetOrder = null;
private int target = 20;
private int stop = 40;
// 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()
{
DisconnectDelaySeconds = 120;
//ConnectionLossHandling = ConnectionLossHandling.StopStrategy;
BarsRequired = 0;
TraceOrders = true;
SetProfitTarget("1", CalculationMode.Ticks, Target);
// SetStopLoss("1", CalculationMode.Ticks, Stop, false);
SetTrailStop("1", CalculationMode.Ticks, Stop, false);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if ( Condition set 1
&& entryOrder == null
)
{
entryOrder = EnterLong(1,"1");
}
if (Condition set 2
&& entryOrder == null)
{
entryOrder = EnterShort(1,"1");
}
}
}
/// <summary>
/// Called on each incoming order event
/// </summary>
protected override void OnOrderUpdate(IOrder order)
{
// Handle entry orders here. The entryOrder object allows us to identify that the order that is calling the OnOrderUpdate() method is the entry order.
if (entryOrder != null && entryOrder == order)
{
// Reset the entryOrder object to null if order was cancelled without any fill
if (order.OrderState == OrderState.Cancelled && order.Filled == 0)
{
entryOrder = null;
}
}
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int Target
{
get { return target; }
set { target = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int Stop
{
get { return stop; }
set { stop = Math.Max(1, value); }
}
#endregion
}
}
Comment