NexusFi: Find Your Edge


Home Menu

 





Help compiling "cancel an order not filled"


Discussion in NinjaTrader

Updated
    1. trending_up 1,180 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

Help compiling "cancel an order not filled"

  #1 (permalink)
ikerbar
vitoria
 
Posts: 2 since Sep 2013
Thanks Given: 0
Thanks Received: 0

Good morning,
I have a problem, i dont know how to compile (write the exact word) in order to cancel my not filled order. The words in red give me compiling errors. Can someone give me an answer or any advice? Thx

My compilation for a short order:

{
if (ToTime(DateTime.Now) >= ToTime ( 10, 29, 57) && ToTime(DateTime.Now) <= ToTime ( 10, 29, 58))
{
EnterShortStopLimit( 1, GetCurrentBid() - 11 * TickSize, GetCurrentBid() - 5 * TickSize, "corto")
}
// Condition set 2 "if the price currentbid jump my limitprice and the order has not been filled, cancel the order"
if (ToTime(DateTime.Now) >= ToTime ( 10, 29, 59) && GetCurrentBid() < ShortStopLimit.LimitPrice && OrderStatus = not Working)
{
CancelOrder(ShortStopLimit);
}
}

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
About a successful futures trader who didnt know anythin …
Psychology and Money Management
REcommedations for programming help
Sierra Chart
What broker to use for trading palladium futures
Commodities
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #3 (permalink)
kandlekid
College Point, NY (Queens)
 
Posts: 63 since Nov 2009
Thanks Given: 5
Thanks Received: 20


I think you want to use the iOrder object. See the NT 7 manual. Here's what you could do ...

private IOrder iOrder = null;

...

iOrder = EnterShortStopLimit( ... );

if ( (ToTime(DateTime.Now) >= ToTime ( 10, 29, 59) ) && ( GetCurrentBid() < iOrder.LimitPrice ) && ( iOrder.OrderState == OrderState.Working ) )
{
CancelOrder( iOrder );
}
...

Reply With Quote
  #4 (permalink)
ikerbar
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 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 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
}
}

Reply With Quote




Last Updated on October 10, 2013


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts