![]() |
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Dec 2008
Location: Sipoo, Finland
Posts: 93
Thanks: 1
Thanked 0 times in 0 posts
|
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");
}
}
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
|
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.
Brett
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Dec 2008
Location: Sipoo, Finland
Posts: 93
Thanks: 1
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
|
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.
Brett
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Dec 2008
Location: Sipoo, Finland
Posts: 93
Thanks: 1
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
|
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.
Brett
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Member
Join Date: Dec 2008
Location: Sipoo, Finland
Posts: 93
Thanks: 1
Thanked 0 times in 0 posts
|
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"); } |
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
|
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.
Brett
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Member
Join Date: Dec 2008
Location: Sipoo, Finland
Posts: 93
Thanks: 1
Thanked 0 times in 0 posts
|
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?
|
|
|
|
|
|
#10 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,499
Thanks: 109
Thanked 291 times in 280 posts
|
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.
Brett
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Member
Join Date: Dec 2008
Location: Sipoo, Finland
Posts: 93
Thanks: 1
Thanked 0 times in 0 posts
|
thanks, trying to live with that!
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |