View Full Version : entry order id
Kentoes
07-08-2010, 08:20 PM
I'm using GetAtmStrategyEntryOrderStatus and I get the error "GetAtmStrategyEntryOrderStatus() method error: orderID 'd15es85 etc' does not exist.
This is after I do
if (OrderId.Length > 0) // Check for a pending entry order
So I guess I need to understand how the entry order id changes through the order and execution process.
Before I do AtmStrategyCreate, I do OrderId = GetAtmStrategyUniqueId() .
Apparently this value changes somehow, somewhere that I don't know about.
NinjaTrader_Bertrand
07-09-2010, 03:57 AM
Kentoes, do you also reset the id's to empty if the order is filled, cancelled or rejected so reaches a terminal state?
Kentoes
07-09-2010, 09:01 AM
Kentoes, do you also reset the id's to empty if the order is filled, cancelled or rejected so reaches a terminal state?No. How and when should this be done?
If the id doesn't exist, how can GetAtmStrategyEntryOrderStatus be used to check to see if the order is filled, canceled or rejected?
NinjaTrader_Bertrand
07-09-2010, 09:06 AM
Please have a look at the SampleAtmStrategy we install per default - the needed sample code for the resets for order and stratey Id's would be shown there, the Id submitted to GetAtmEntryOrderStatus will need to exist and be valid.
Kentoes
07-09-2010, 09:43 AM
Followed the sample code and still getting the error "GetAtmStrategyEntryOrderStatus() method error: orderID 'd15es85 etc' does not exist.
First trade executes. Nothing after that.
protected override void OnBarUpdate()
{
if (Historical)
return;
LongStopTrigger = MAX(High, Lookback)[0] + 1*TickSize;
ShortStopTrigger = MIN(Low, Lookback)[0] - 1*TickSize;
if (LongStopTrigger-Close[0]>Close[0]-ShortStopTrigger && OrderId.Length == 0 && AtmStrategyId.Length == 0 ) //go short
{
AtmStrategyId = GetAtmStrategyUniqueId();
OrderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(Action.Sell, OrderType.Stop, 0,ShortStopTrigger, TimeInForce.Day, AtmStrategyId, "Standard", OrderId);
LastStop = ShortStopTrigger;
}
else if (LongStopTrigger-Close[0]<Close[0]-ShortStopTrigger && OrderId.Length == 0 && AtmStrategyId.Length == 0 )// go long
{
AtmStrategyId = GetAtmStrategyUniqueId();
OrderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(Action.Buy, OrderType.Stop, 0,LongStopTrigger, TimeInForce.Day, AtmStrategyId, "Standard", OrderId);
LastStop = LongStopTrigger;
}
// Check for a pending entry order
if (OrderId.Length > 0)
{
string[] status = GetAtmStrategyEntryOrderStatus(OrderId);
// If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
if (status.GetLength(0) > 0)
{
// If the order state is terminal, reset the order id value
if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
OrderId = string.Empty;
}
} // If the strategy has terminated reset the strategy id
else if (AtmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(AtmStrategyId) == Cbi.MarketPosition.Flat)
AtmStrategyId = string.Empty;
}
NinjaTrader_Bertrand
07-09-2010, 10:25 AM
The code looks ok to me at a glance, can you please try running the default SampleAtmStrategy with a fresh setup template called AtmStrategyTemplate? Would this work without the error?
Are there any other strategy related errors (related to order price you submit the stop at etc) in the logs before the strategy template for the exits would be called?
Kentoes
07-09-2010, 11:44 AM
SampleAtmStrategy runs fine with no errors.
No other errors showing. After the first trade, just the orderID does not exist repeated over and over referencing the same ID number.
NinjaTrader_Bertrand
07-09-2010, 11:46 AM
Have you tried your strategy also with a freshly created ATM template in case the one you were trying to use was corrupted for example?
Can you please send me your full code used and trace / logs from today via Help > Mail to Support to my Attn so I can look into?
Thanks
Kentoes
07-09-2010, 01:01 PM
Thanks. New ATM template gives same results. Files sent.
NinjaTrader_Josh
07-09-2010, 02:42 PM
Kentoes,
I didn't see anything come into our system in terms of your files. Did you receive a ticket # for when you sent in the files?
Kentoes
07-09-2010, 03:42 PM
Got an email from Kyle Nottingham requesting a link to this post. Sent.
NinjaTrader_Josh
07-09-2010, 04:08 PM
Kentoes,
You will want to add some Print() throughout your code and isolate out which line exactly is running into the OrderID messages. I suggest putting Print() lines in front of anywhere you have OrderID used so you can see where your code is reaching each time the message gets printed.
Kentoes
07-19-2010, 01:31 PM
You will want to add some Print() throughout your code and isolate out which line exactly is running into the OrderID messages. I suggest putting Print() lines in front of anywhere you have OrderID used so you can see where your code is reaching each time the message gets printed. Done that. The answer is that the line of code is string[] status = GetAtmStrategyEntryOrderStatus(OrderId);Which still doesn't explain what's going on, in fact this is telling me the same thing as my first post in this thread. Again, how does the order id change, such that when it is attempted to be accessed, that particular value doesn't exist?
NinjaTrader_RyanM
07-19-2010, 03:35 PM
Hello Kentoes,
The issue here seems to be the order of parameters specified in your AtmStrategyCreate method. Below you have in two different places:
AtmStrategyCreate(Action.Sell, OrderType.Stop, 0,ShortStopTrigger, TimeInForce.Day, AtmStrategyId, "Standard", OrderId);
AtmStrategyCreate(Action.Buy, OrderType.Stop, 0,LongStopTrigger, TimeInForce.Day, AtmStrategyId, "Standard", OrderId);
Swap the red text with blue text and it should now work properly for you. Sell Example:
AtmStrategyCreate(Action.Sell, OrderType.Stop, 0,ShortStopTrigger, TimeInForce.Day, OrderId, "Standard", AtmStrategyId);