NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 12-24-2010, 06:35 AM   #1
jp_kettunen
Member
 
Join Date: Dec 2008
Location: Sipoo, Finland
Posts: 93
Thanks: 1
Thanked 0 times in 0 posts
Default IOrder.Error vs. IOrder.NativeError

Can't fully understand how to use IOrder.Error and IOrder.NativeError properties:

1) Error not mentioned in NT7 Help but is recognized by the NT7 editor / compiler and works in Sim mode.

2) Error="NoError" and NativeError="" when OK.

3) The following code seems to work, any limitations?

Code:
 
OnOrderUpdate (IOrder orderHandle)
{
if (orderHandle.Error != ErrorCode.NoError)
{
Print("Problem");
}
}
jp_kettunen is offline  
Reply With Quote
Old 12-26-2010, 09:32 AM   #2
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Thanks for your forum post.


A Native error is a text error that comes directly from the broker and never NinjaTrader generated. The iOrder.Error is an internal NinjaTrader error that is internally generated by NinjaTrader.

So I dont see any issue with your code. A change I might make is that I Print the Native Error text instead of just Problem. So that if an error was to occur you can see the reasoning for the error from the broker and even a broker error message that you can ask the broker what the error code indicates.

Let me know if I can be of further assistance.
NinjaTrader_Brett is offline  
Reply With Quote
Old 12-27-2010, 06:52 AM   #3
jp_kettunen
Member
 
Join Date: Dec 2008
Location: Sipoo, Finland
Posts: 93
Thanks: 1
Thanked 0 times in 0 posts
Default

Presuming then that the possible values of NativeError specified in NT7 IOrder help file actually apply to Error and that the possible values of NativeError are broker-dependent? If this is the case, the help is misleading (at least the Error property is missing). But thanks for explanation.
jp_kettunen is offline  
Reply With Quote
Old 12-27-2010, 07:00 AM   #4
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Jut realized, That we dont even show Error on the help guide therefor NativeError is the only one to use in this case.

As, the error property is for NinjaTrader internal use only.

Let me know if I can be of further assistance.
NinjaTrader_Brett is offline  
Reply With Quote
Old 12-27-2010, 07:19 AM   #5
jp_kettunen
Member
 
Join Date: Dec 2008
Location: Sipoo, Finland
Posts: 93
Thanks: 1
Thanked 0 times in 0 posts
Default

Hmmm. So this means that the possible values of NativeError are 'erroneous' (should be e.g. 'string containing the broker-generated error message'), right?

I am inspecting the OrderState, and can therefore identify reject, but not much more (automatically).
Last edited by jp_kettunen; 12-27-2010 at 07:22 AM.
jp_kettunen is offline  
Reply With Quote
Old 12-27-2010, 07:38 AM   #6
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

No these have been reversed for NinjaScript. The string containing the broker message is for display in NinjaTrader only. Use NativeError to get the error code, there is no access to this String error from the broker in NinjaScript I jumped the gun when I mentioned this. As when you analyze the log file the native error is the shown error from the broker. Since there is no need for this in a NinjaScript strategy it is not availiable.

Let me know if I can be of further assistance.
NinjaTrader_Brett is offline  
Reply With Quote
Old 12-27-2010, 08:16 AM   #7
jp_kettunen
Member
 
Join Date: Dec 2008
Location: Sipoo, Finland
Posts: 93
Thanks: 1
Thanked 0 times in 0 posts
Default

I am not yet sure whether I have understood this completely (sorry!). So I'll have to continue posing these questions.

1) You wrote earlier that "the error property is for NinjaTrader internal use only". Question: what is the risk involved in referring to order.Error in NT script, e.g. inside OnOrderUpdate()?

2) If I wanted to inspect NativeError programmatically, should I do it like this:

if (order.NativeError != "") { Print("Broker error: " + order.NativeError); },

or like this:

if (order.NativeError == "ErrorCode.Panic") { Print("Abandon ship"); }
jp_kettunen is offline  
Reply With Quote
Old 12-27-2010, 08:24 AM   #8
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

You would use:

if (order.NativeError == "ErrorCode.Panic") { Print("Abandon ship"); } , also using order.Error is unsupported suggest not using this.

Let me know if I can be of further assistance.
NinjaTrader_Brett is offline  
Reply With Quote
Old 12-27-2010, 09:01 AM   #9
jp_kettunen
Member
 
Join Date: Dec 2008
Location: Sipoo, Finland
Posts: 93
Thanks: 1
Thanked 0 times in 0 posts
Default

Ok, making progress... But one more crucial question: if "A Native error is a text error that comes directly from the broker and never NinjaTrader generated", as you wrote, then how come we can know in advance what it can be (e.g. "ErrorCode.Panic" instead of "ijifj32350")? Or do all brokers adhere to the same industry standard, described in the IOrder help file?
jp_kettunen is offline  
Reply With Quote
Old 12-27-2010, 09:13 AM   #10
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

This is only in terms of the logs sorry for the confusion. In terms of NinjaScript ignore this statement as you have no access to this. In NinjaScript the Order.NativeError is the standard error codes that you can check for with checking equality to the order types mentioned on the iOrder page. Therefor you will not have access to the error that comes direct from the broker as you are correct there would be no action you could take on these.

Let me know if I can be of further assistance.
NinjaTrader_Brett is offline  
Reply With Quote
Old 12-27-2010, 09:36 AM   #11
jp_kettunen
Member
 
Join Date: Dec 2008
Location: Sipoo, Finland
Posts: 93
Thanks: 1
Thanked 0 times in 0 posts
Default

thanks, trying to live with that!
jp_kettunen is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot Serialise IOrder LloydH Version 7 Beta General Questions & Bug Reports 5 04-08-2010 08:16 AM
Iorder array binwang2 General Programming 1 10-27-2009 12:52 PM
IOrder trend General Programming 3 02-18-2009 10:12 AM
Problem with IOrder fxRichard Automated Trading 8 02-14-2009 10:50 AM
Using IOrder in a Strategy clfield General Programming 7 12-01-2008 03:46 PM


All times are GMT -6. The time now is 08:07 PM.