|
vitoria
Posts: 2 since Sep 2013
Thanks Given: 0
Thanks Received: 0
|
Hi again,
after using my programed strategy, the order didnt cancel when it was not filled. What am i missing? Thanx in advance.
My compiled strategy:
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using .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 GasBajadaCancel21 : Strategy
{
#region Variables
// Wizard generated variables
private int ordenes = 1; // Default setting for Ordenes
private int stop = 20; // Default setting for Stop
// User defined variables (add any user defined variables below)
private IOrder myOrder1;
#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("", CalculationMode.Ticks, 60);
SetTrailStop("", CalculationMode.Ticks, 20, false);
CalculateOnBarClose = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnMarketData(MarketDataEventArgs e)
{
// Condition set 1
if (ToTime(DateTime.Now) >= ToTime ( 16, 29, 57) && ToTime(DateTime.Now) <= ToTime ( 16, 29, 58))
{
myOrder1 = EnterShortStopLimit( 1, GetCurrentBid() - 31 * TickSize, GetCurrentBid() - 21 * TickSize, "corto");
DrawTextFixed("My text (fixed)" + CurrentBar, "Bajada", TextPosition.TopLeft);
}
// Condition set 2
if ((ToTime(DateTime.Now) >= ToTime ( 16, 29, 59)) && (GetCurrentBid() < myOrder1.LimitPrice) && (myOrder1.OrderState != OrderState.Filled))
{
CancelOrder(myOrder1);
}
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int Ordenes
{
get { return ordenes; }
set { ordenes = Math.Max(1, value); }
}
[Description("")]
[GridCategory("Parameters")]
public int Stop
{
get { return stop; }
set { stop = Math.Max(1, value); }
}
#endregion
}
}
|