NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 06-21-2011, 01:48 PM   #1
AntiMatter
Member
 
Join Date: Dec 2010
Posts: 66
Thanks: 6
Thanked 0 times in 0 posts
Default Multi-Instrument Multi-Entry Strategy: Getting EntryOrder Info

I have a strategy which is Multi-Instrument. Furthermore, it pyramids, so I can have multiple unclosed entries on each instrument.

I would like to get info (entry price etc) on each separate trade E.g. Trade 1,2,3 each for instruments 1,2 and 3 (so 9 trades in total).

The problem I have is that Positions[3].AvgPrice is the average of my 3 entries. I would like info for each separate entry.

Is there an easy way to achieve this? Otherwise, what would you suggest?
AntiMatter is offline  
Reply With Quote
Old 06-21-2011, 02:20 PM   #2
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

AntiMatter,

To expose information specific to one order, you need to structure your orders as IOrder, and can then expose specific execution details using OnExecution()
http://www.ninjatrader.com/support/h...nexecution.htm

This IExecution page provides you with the types of details you can expose about an execution and an example.
http://www.ninjatrader.com/support/h...iexecution.htm
NinjaTrader_RyanM is offline  
Reply With Quote
Old 06-22-2011, 08:57 AM   #3
AntiMatter
Member
 
Join Date: Dec 2010
Posts: 66
Thanks: 6
Thanked 0 times in 0 posts
Default

Thanks Ryan,

Just to be clear, should I be having a different IOrder object for each trade, each instrument, or will a single object be fine?

e.g. is one instance of this sufficient:
private IOrder entryOrder = null;


or do I need many IOrder objects e.g.:
private IOrder entryOrder1 = null;
private IOrder entryOrder2 = null;
private IOrder entryOrder3 = null;
etc....
AntiMatter is offline  
Reply With Quote
Old 06-22-2011, 09:06 AM   #4
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

A separate IOrder object for each unique order is what you should go for. Since you mention multiinstrument in your first post, you likely will need more than one. It depends what order methods you have exactly, but each distinct Enter() or Exit() statement can have its own IOrder object associated with it.
NinjaTrader_RyanM is offline  
Reply With Quote
Old 06-22-2011, 09:29 AM   #5
AntiMatter
Member
 
Join Date: Dec 2010
Posts: 66
Thanks: 6
Thanked 0 times in 0 posts
Default

OK, thanks.... I'm pushing my c# knowledge beyond the limits now ;-)

I'm unsure how many IOrder objects I am going to need. I'm going to have to use some sort of 2-dimensional data structure (e.g. list of lists) and create the objects on-the-fly as I need them. Is this going to be possible?


e.g. I guess I could do something like this..... e.g. create a list of IOrder objects:

private List<IOrder> entryOrders = new List<IOrder>();

protected override void Initialize(){
...
foreach(string ticker in tickerList){
Add(ticker, PeriodType.Minute, 1);
entryOrders.Add(new IOrder(ticker));
...



However, that last statement doesnt't work.
Can I create a list of IOrder objects?
Can I create them on-the-fly within my OnBarUpdate()?
AntiMatter is offline  
Reply With Quote
Old 06-22-2011, 09:41 AM   #6
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

This may be possible, but general C# like this is outside our scope of support. It may be best to start with a simple strategy using one or two IOrders, so you can be familiar with all the structure required for proper management.

For populating items to a list consider using OnStartup() instead of Initialize()
http://www.ninjatrader.com/support/h.../onstartup.htm
Last edited by NinjaTrader_RyanM; 06-22-2011 at 10:27 AM.
NinjaTrader_RyanM 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
Multi-Instrument Multi Strategy runtime Oil_Trader Automated Trading 1 08-19-2010 11:42 AM
Multi-Instrument Multi-Time frame strategy Shansen Strategy Development 1 12-28-2009 06:09 AM
Questions regarding multi-day, multi instrument capability bridenour Strategy Development 39 01-24-2009 07:08 PM
Multi-instrument Strategy - Order Entry problem yot1120 Strategy Development 15 03-23-2008 06:40 PM
Use of Order Entry APIs in multi-instrument environment lclifner General Programming 2 10-11-2007 05:58 PM


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