![]() |
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
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Member
Join Date: Dec 2010
Posts: 66
Thanks: 6
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Dec 2010
Posts: 66
Thanks: 6
Thanked 0 times in 0 posts
|
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.... |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Dec 2010
Posts: 66
Thanks: 6
Thanked 0 times in 0 posts
|
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()? |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
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
Ryan M
NinjaTrader Customer Service
Last edited by NinjaTrader_RyanM; 06-22-2011 at 10:27 AM.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |