![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jul 2010
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
|
Sorry for my bad English.
Try use CancelOrder() but command does not work! Code:
EntryAskOrder=EnterShortLimit(quantity,EnterPrice,"Open Short");
if (EntryAskOrder != null)
{
min=EntryAskOrder.LimitPrice+AskShift+Shift;
if (GetCurrentAsk() < min)
{
Print("Try cancel Order id="+EntryAskOrder.Token.ToString()+",State="+EntryAskOrder.OrderState.ToString());
CancelOrder(EntryAskOrder);
}
}
Code:
Bid=1068 Calc Price=1067 12.07.2010 13:14:00 Entered internal PlaceOrder() method at 12.07.2010 13:14:00: Action=Buy OrderType=Limit Quantity=1 LimitPrice=1067,00 StopPrice=0 SignalName='Open Long' FromEntrySignal='' Order Changed: id=ff8629b187be4257a1ccb0075225ffd0;State=PendingSubmit Order Changed: id=ff8629b187be4257a1ccb0075225ffd0;State=Accepted Order Changed: id=ff8629b187be4257a1ccb0075225ffd0;State=Working Try cancel Order id=ff8629b187be4257a1ccb0075225ffd0,State=Working Try cancel Order id=ff8629b187be4257a1ccb0075225ffd0,State=Working Try cancel Order id=ff8629b187be4257a1ccb0075225ffd0,State=Working Try cancel Order id=ff8629b187be4257a1ccb0075225ffd0,State=Working Try cancel Order id=ff8629b187be4257a1ccb0075225ffd0,State=Working |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,382
Thanks: 252
Thanked 967 times in 950 posts
|
Welcome to our forums here at NinjaTrader - could it be the order expires to quick before you get a chance to cancelOrder it? It would just last for one OnBarUpdate() per default, try for example submitting the original one with liveUntilCancelled set to true -
http://www.ninjatrader-support.com/H...LongLimit.html
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jul 2010
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
|
For Long order CancelOrder() work if I use "EnterLongLimit(0,true,quantity,EnterPrice,"Op en Long")" but
with short orders this don`t work. OrderState Changed to "Canceled" but event OnOrderUpdate() does not occur. |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,382
Thanks: 252
Thanked 967 times in 950 posts
|
Which NT version are you using as you run into this issue (Help > About).
Please just run your short order part and enable the TraceOrders feature in the Strategy's Initialize() to debug your order behaviors. http://www.ninjatrader.com/support/f...ead.php?t=3627
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Jul 2010
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
|
NT 6.5.1000.16, TraceOrders=true; Instrument=ES 09-10.
in Output Window I see message "Cancelled custom managed order" but function OnOrderUpdate() not run and order not cancel at NT orders tab. |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 89 times in 81 posts
|
Sauronix, could you please provide the code sample that you're using here that does not cancel the order? We'd like to test this out on our end and see if there is anything else that could be going on.
Austin
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Jul 2010
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
|
Enter order code:
Code:
if (devi>MinTradeDeviation && devi<MaxTradeDeviation && Position.MarketPosition==MarketPosition.Flat)
{
if (em>Close[0])
{
if (EntryBidOrder==null && EntryAskOrder==null)
{
firstExitTry=false;
EnterPrice=GetCurrentBid()-bidShift;
Print("Bid="+GetCurrentBid());
Print("Calc Price="+EnterPrice.ToString());
EntryBidOrder=EnterLongLimit(0,true,quantity,EnterPrice,"Open Long");
}
}
if (em<Close[0])
{
if (EntryBidOrder==null && EntryAskOrder==null)
{
firstExitTry=false;
EnterPrice=GetCurrentAsk()+AskShift;
Print("Ask="+GetCurrentAsk());
Print("Calc Price="+EnterPrice.ToString());
EntryAskOrder=EnterShortLimit(0,true,quantity,EnterPrice,"Open Short");}
}
}
}
Code:
if (EntryBidOrder != null)
{
max=EntryBidOrder.LimitPrice+BidShift+Shift; //Правильный вариант
if (GetCurrentBid() > max)
{
Print("Try cancel Order id="+EntryBidOrder.Token.ToString()+",State="+EntryBidOrder.OrderState.ToString());
CancelOrder(EntryBidOrder);
}
}
if (EntryAskOrder != null)
{
min=EntryAskOrder.LimitPrice-AskShift-Shift; //Правильный вариант
if (GetCurrentAsk() < min)
{
Print("Try cancel Order id="+EntryAskOrder.Token.ToString()+",State="+EntryAskOrder.OrderState.ToString());
CancelOrder(EntryAskOrder);
}
}
|
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,382
Thanks: 252
Thanked 967 times in 950 posts
|
Thanks Sauronix, could you please send us the complete script also with the OnOrderUpdate() section to support at ninjatrader dot com referencing this thread?
Also: have you tried the same script on our NT7 beta?
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Unmanaged + OCO + CancelOrder | cls71 | Version 7 Beta General Questions & Bug Reports | 2 | 05-06-2010 11:16 AM |
| Using CancelOrder with SampleATMStrategy | jthom | ATM Strategies (Discretionary Trading) | 1 | 03-11-2010 08:32 AM |
| CancelOrder() problem | boreland | Strategy Development | 1 | 12-28-2009 05:33 AM |
| How CancelOrder() work? | xewoox | Strategy Development | 6 | 02-18-2009 02:21 PM |
| CancelOrder() problem | John833 | Strategy Development | 41 | 10-31-2008 03:15 PM |