private string orderId = string.Empty;
private IOrder entryOrder = null;
private IOrder stopOrder = null;
// 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()
{
CalculateOnBarClose = false;
Unmanaged = true;
TraceOrders = true;
}
protected override void OnBarUpdate()
{
if ( Position.MarketPosition == MarketPosition.Flat )
{
entryOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Stop, 2,0, longPrice, "Enter", "EnterLong");
entryOrder = SubmitOrder(0, OrderAction.SellShort, OrderType.Stop, 2,0, shortPrice, "Enter", "EnterShort");
}
}
//not being used at this moment
protected override void OnOrderUpdate(IOrder order)
{
if (entryOrder != null && entryOrder == order)
{
if (order.OrderState == OrderState.Filled)
// entryOrder = null;
Print(order.ToString());
}
}
// this test is to create a profit target for the short order
protected override void OnExecution(IExecution execution)
{
if(Position.MarketPosition == MarketPosition.Short)
{
Print("we are short");
stopOrder = SubmitOrder(0, OrderAction.BuyToCover, OrderType.Limit,1,Position.AvgPrice -3*TickSize,0, "Enter", "EnterLong");
}
}
Comment