![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Dec 2006
Location: Nelson, New Zealand
Posts: 371
Thanks: 1
Thanked 3 times in 3 posts
|
Scenario: I have an strategy that uses an instrument that comes from a secondary data feed. I have a friend that wants to use my strategy. They don't have the secondary data feed.
Question: If they don't have the feed or instrument active what will the NT strategy do? I didn't know if I needed to modify it to make the check optional or if it would just return zeros on the values. Cliff |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
Good question. Although I believe I know what will happen, I will need to double check with Dierk. He will likely reply later on late this evening.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Dec 2006
Location: Nelson, New Zealand
Posts: 371
Thanks: 1
Thanked 3 times in 3 posts
|
Thanks Ray
ok, I didn't want to remove it my system and erase my history if I didn't have to. Cliff |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
He needs to have a feed for the secondary instrument as well. No data -> no OnBarUpdate will be triggered.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Apr 2007
Location: , ,
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
|
In addition to this topic, how one can detect programmatically if a call to BaseStrategy.Add() was successful, and corresponding instrument will be available in OnBarUpdate at expected index through BarsArray/Opens/Closes etc properties?
Scenario: Initialize() { Add("Secondary feed instrument", Ticks, 50); Add("Primary feed instrument"); } OnBarUpdate() { BarsArray[1] // <-- what instrument it will refer to if there was no secondary feed? } Thanks! p.s. Testing whether BarsArray.Length increased after Add() causes run-time exception (cannot access BarsArray property in Initialize() method...).
Last edited by imisuno; 05-15-2007 at 08:27 AM.
|
|
|
|
|
|
#6 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
Hi,
1) If there was no instrument in BarsArray[1] then the strategy would throw an exception (seen in the Log tab) and terminate 2) Correct, you can not access BarsArray from the Initialize() method
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Apr 2007
Location: , ,
Posts: 6
Thanks: 0
Thanked 0 times in 0 posts
|
Ray, thank you very much.
Sorry, I have not described in details what I am trying to achieve. I need to know at runtime whether instrument was added successfully or not, i.e., which instrument BarsArray[1] would refer to, in the example below, "Secondary feed" or "Primary", so that my strategy will know which instruments it is using. Sure, I can add all primary instruments first and then detect that there are no secondary ones, and to disable all checks involved. Ok, I think this is acceptable. Thank you again. |
|
|
|
|
|
#8 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
You have to perform the check in OnBarUpdate().
Code:
if (BarsArray[1] != null)
Print(Instruments[1].FullName);
Ray
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Instrument Manager | Oli | Automated Trading | 2 | 02-26-2007 01:35 AM |
| How do I check for the instrument name? | NinjaTrader_Ray | General Programming | 0 | 02-07-2007 01:24 AM |
| Instrument Manager | Quicktrader10 | Miscellaneous Support | 2 | 01-17-2007 07:57 AM |
| Name Of Instrument | guym | Indicator Development | 2 | 11-27-2006 09:21 AM |
| IB trying to Add Instrument ER2 | Ripcat | Miscellaneous Support | 4 | 09-25-2005 01:51 PM |