NinjaTrader Support Forum  
X

Attention!

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


Go Back   NinjaTrader Support Forum > Suggestions and Feedback > Suggestions And Feedback

Suggestions And Feedback New feature suggestions and feedback.

Reply
 
Thread Tools Display Modes
Old 06-07-2009, 12:37 AM   #1
Obi
Member
 
Join Date: Mar 2007
Location: , ,
Posts: 55
Thanks: 0
Thanked 0 times in 0 posts
Default API Part 1 - Order methods consistency

Hello,

One of an interface success (usability, etc.) is or should be its consistency. This is as much for Graphical User "Interface" or Application Programming "Interface".

Every plane flies, has wings, engine (1 or more), tail and landing gear. The cockpit of a Cessna 172 (small 4-seater) has the same basic instruments as a Boeing 767 and a space shuttle.
Why? Because they all perform the same basic functionality: fly!
The difference comes in extras: engine, size, capabilty (weight, take off speed, landing speed, etc.).

Problem 1.
------------
The order methods in NT6.5 however are by their interface, divided in two groups:
- those that return "void" (SetSopLoss(), SetTarget() ) and
- those that return "IOrder" (Enter...(), EXit..() )

"SetStopLoss()" works great, does all the orders management under the hood:
- Finds its related Open Orders (Entry and StopLoss)
- Does all the required cancellation and placing of new orders.

Until one wants to implement one of the "OnOrder/Position Update()" method, then there is nothing. No information available to the programmer about the orders created and managed by the "SetStopLoss()" method!

In the case of using the "OnOrder/Position Update()" methods, one has to dramatically change his/her code and replace the "SetStopLoss()" method with the "supposed to be equivalent" "ExitLong/ShortStop()" method!!!

In other words, if I want to take off on a Boeing 767 instead of a Cessna 172, the yoke/stick (equivalent of driving wheel) is suddenly on the roof or hidden to the pilot. Even Discovery/Columbia/Endeavour all have the yoke/stick at the expected place of a fixed-wing aircraft.

Problem 2. (related to use of "ExitLong/ShortStop()"
----------------------------------------------------
When implementing the "OnOrder...", "OnPosition..." methods, one has to check the "Token" (ID) of the orders. Meaning that every generated order has an ID, which is great.

However, when one wants to set a StopLoss to an existing open order, one has to store, manage and remember something called an 'fromEntrySignal' (A string Created by the programmer).

"ExitLongStop(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double stopPrice, string signalName, string fromEntrySignal)"

Although this might appear to be harmless, it makes the program more error-prone.
One of OO good practice is re-usability. Why no re-use the Token or ID already generated and is guaranteed to be unique?

Suggestions:
--------------
If ALL order handling methods used the IOrder class, there would be one place and one place only to set and/or retrieve orders info: IOrder.

This will make the API easier to use, consistent and introduce re-usability, which will increase maintainability of our code (and yours in some extent) and productivity of the API users (us).

Direct Benefit for you: Less support (on related items)!
Direct benefit to us: Plenty.

Cheers,
Obi
Obi is offline  
Reply With Quote
Old 06-08-2009, 07:32 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Obi,

The Set() methods are generally for people who don't want to mess around with advanced order handling. It is designed for use with quick use rather than complex use. If you have needs for more advanced handling you should be using IOrders right off the bat.
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-09-2009, 07:08 AM   #3
Obi
Member
 
Join Date: Mar 2007
Location: , ,
Posts: 55
Thanks: 0
Thanked 0 times in 0 posts
Exclamation

Hello,

That's what I was told and so I did. But here is the problem:

In my code, I do the following:
Global Vars
-----------
private string _entrySignalName = null;
private string _stopSignalName = null;

...

// Set the signal Entry Order Signal Name
_entrySignalName = "SELL " + _orderQuantity.ToString() + " @ " + entryPrice.ToString();
// Send a Market Order
_entryOrder = EnterShort( _PrimaryBars, _orderQuantity, _entrySignalName );

...

// Set the Stop Order signal name
_stopSignalName = "Trailing_Stop";

// Now set the Trailing stop
_stopOrder = ExitLongStop( _PrimaryBars, true, _stopOrder.Quantity, stopPrice, _stopSignalName, _entrySignalName );

Nothing wrong so far, untill I realised that my Trailing Stops were not being executed. A trace through the program reveals the following:

When created, this is what the "_entryOrder" has as properties:

Action : SellShort
AvgFillPrice : 98.26
Filled : 1
FromEntrySignal : ""
Instrument : {$USDJPY Default}
LimitPrice : 0.0
LiveUntilCancelled : false
Name : "SELL 1 @ 98.27"
Oco : ""
...

Clearly the property 'FromEntrySignal' which should equal my 'entrySignalName' is not, instead, the 'Name' property has the 'entrySignalName' value !!!!

So, my "ExitLongStop()" calls are not tied to any "Entry Order"!!!

How do I solve this unexplained 'feature'?

Cheers,
Obi
Obi is offline  
Reply With Quote
Old 06-09-2009, 07:28 AM   #4
Obi
Member
 
Join Date: Mar 2007
Location: , ,
Posts: 55
Thanks: 0
Thanked 0 times in 0 posts
Default

Also, although, the "SetStop/Target/Trail" methods are intended for 'simple' users, they can still set the IOrder properties, so that, if a 'not-so' simple users would like to access these properties, they have the ability to.

That doesn't change anything for the other users, but adds accessibility and features for the second group of users.

The "SetStop/Target/Trail" methods are already internally manipulating/generating/populating the IOrder object anyway, you just have to make it visible to the second group of users and this is transparent to the former group!

What I am saying is that the API should cater for simplicity (Which you are doing), but too much simplicity can become cumbersome and counter-productive.
You will make NinjaTrader a much better and sought after platform by allowing those with development/mathematical background to harness the power of NT in combination with pure OOP and a higher progr. language.

Cheers,
Obi
Obi is offline  
Reply With Quote
Old 06-09-2009, 07:32 AM   #5
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Obi,

There are many implications and as such Set() do not provide IOrders.
NinjaTrader_Josh 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
The Source Code behind Order Methods brima Strategy Development 2 07-29-2008 04:47 PM
Chart time consistency cherriman Charting 1 04-18-2008 11:36 AM
A particular part of my strategy bigdaddo Strategy Development 12 11-21-2007 03:46 PM
Using StopLimit Order Methods tquinn Strategy Development 1 01-14-2007 03:18 AM
Q: Where did the help file for NinjaTrader API go? (Has API support been discontinued?) Larsen General Programming 4 12-08-2006 05:23 PM


All times are GMT -6. The time now is 05:46 PM.