NT8 - Multi Instrument Indicators - NinjaTrader Programming | futures io social day trading
futures io futures trading


NT8 - Multi Instrument Indicators
Updated: Views / Replies:1,727 / 13
Created: by wuileng Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

NT8 - Multi Instrument Indicators

  #1 (permalink)
Elite Member
Kuala Lumpur + Malaysia
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Interactive Brokers
Favorite Futures: ES
 
Posts: 26 since Aug 2012
Thanks: 13 given, 9 received

NT8 - Multi Instrument Indicators

Has anyone tried writing a multi instrument/spread indicator in NT8?

I was wondering if there was a way to add a secondary series which takes on the BarsPeriodType and BarsPeriod of the primary series without having to hardcode.

Used to be able to do this in NT7 using something like:

 
Code
Add("XYZ", BarsPeriods[0].Id, BarsPeriods[0].Value);
But in NT8, the following just gives me errors:

 
Code
AddDataSeries("XYZ", BarsPeriods[0].BarsPeriodType, BarsPeriods[0].Value);
Does anyone know of a better way?

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Market Wizard
Germany
 
Futures Experience: Intermediate
Platform: Other
Favorite Futures: ES, YM, 6E
 
Posts: 2,640 since Feb 2013
Thanks: 4,893 given, 6,422 received
Forum Reputation: Legendary


Your syntax is incorrect.

For the correct syntax see:
NinjaTrader 8

Reply With Quote
 
  #4 (permalink)
Elite Member
Kuala Lumpur + Malaysia
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Interactive Brokers
Favorite Futures: ES
 
Posts: 26 since Aug 2012
Thanks: 13 given, 9 received


choke35 View Post
Your syntax is incorrect.

For the correct syntax see:
NinjaTrader 8

Thanks for your response. I don't think the syntax is incorrect as I have already made the code-breaking adjustments required from NT7 to NT8 and it compiles fine.

The problem is that the primary bars have not been loaded yet by State.Configure (where you are supposed to add additional data series) so you can't really reference them by means of BarsPeriods[0].BarsPeriodType and BarsPeriods[0].Value. In NT7 I used to be able to do this within Initialize().

For an indicator which I'd like to have work on both a daily and minute bar strategy, it's quite annoying having to hard code two separate versions (even more needed if you use different minute bars and you'd like both minute data series the same).

Reply With Quote
 
  #5 (permalink)
Market Wizard
Germany
 
Futures Experience: Intermediate
Platform: Other
Favorite Futures: ES, YM, 6E
 
Posts: 2,640 since Feb 2013
Thanks: 4,893 given, 6,422 received
Forum Reputation: Legendary


wuileng View Post
Thanks for your response. I don't think the syntax is incorrect as I have already made the code-breaking adjustments required from NT7 to NT8 and it compiles fine.

The problem is that the primary bars have not been loaded yet by State.Configure (where you are supposed to add additional data series) so you can't really reference them by means of BarsPeriods[0].BarsPeriodType and BarsPeriods[0].Value. In NT7 I used to be able to do this within Initialize().

For an indicator which I'd like to have work on both a daily and minute bar strategy, it's quite annoying having to hard code two separate versions (even more needed if you use different minute bars and you'd like both minute data series the same).

No hardcoding needed; think you didn't get different syntax options right ...

Esp for spreads try (within State.Configure)

AddDataSeries(secondInstrument, BarsPeriod.BarsPeriodType, barValue, Data.MarketDataType.Last);

where barValue is
barValue = Math.Max(1, base.BarsPeriod.Value);

Reply With Quote
 
  #6 (permalink)
Elite Member
Kuala Lumpur + Malaysia
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Interactive Brokers
Favorite Futures: ES
 
Posts: 26 since Aug 2012
Thanks: 13 given, 9 received


choke35 View Post
No hardcoding needed; think you didn't get different syntax options right ...

Esp for spreads try (within State.Configure)

AddDataSeries(secondInstrument, BarsPeriod.BarsPeriodType, barValue, Data.MarketDataType.Last);

where barValue is
barValue = Math.Max(1, base.BarsPeriod.Value);

Thanks again for your help.

I just tried your syntax, and am getting the same error I was getting using my syntax:


Quoting 
Indicator 'MyIndicator': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.

When I do not reference anything to do with BarsPeriod or BarsPeriods though (and hardcode), it works fine. Have you tried it on the latest version of the beta?

Reply With Quote
 
  #7 (permalink)
Market Wizard
Germany
 
Futures Experience: Intermediate
Platform: Other
Favorite Futures: ES, YM, 6E
 
Posts: 2,640 since Feb 2013
Thanks: 4,893 given, 6,422 received
Forum Reputation: Legendary


wuileng View Post
Thanks again for your help.

I just tried your syntax, and am getting the same error I was getting using my syntax:



When I do not reference anything to do with BarsPeriod or BarsPeriods though (and hardcode), it works fine. Have you tried it on the latest version of the beta?

I use exactly the above snippet for spreads in the latest NT8 version.
Please post your State.Configure.

Reply With Quote
 
  #8 (permalink)
Elite Member
Kuala Lumpur + Malaysia
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Interactive Brokers
Favorite Futures: ES
 
Posts: 26 since Aug 2012
Thanks: 13 given, 9 received


choke35 View Post
I use exactly the above snippet for spreads in the latest NT8 version.
Please post your State.Configure.

 
Code
else if (State == State.Configure)
{
	int barValue = Math.Max(1, base.BarsPeriod.Value);
	AddDataSeries(RefInstrument, base.BarsPeriod.BarsPeriodType, barValue, Data.MarketDataType.Last);
	//AddDataSeries(RefInstrument, BarsPeriods[0].BarsPeriodType, BarsPeriods[0].Value);
	//AddDataSeries(RefInstrument, BarsPeriodType.Minute, 5);
	
	Calculate			= Calculate.OnBarClose;
	IsOverlay			= false;
	DrawOnPricePanel    = true;
	DisplayInDataBox    = true;
	IsAutoScale			= true;
}
The commented lines are what I use normally (the first one doesn't work for me though which is why I'm having this problem). RefInstrument is defined earlier in State.SetDefaults too.

One last thing if you don't mind, perhaps you could try my syntax out as well? I'm starting to think this is a problem specific to my system, so perhaps I'll try installing on another machine over the weekend before I waste any more of your time.

Thanks again!

Reply With Quote
 
  #9 (permalink)
Market Wizard
Germany
 
Futures Experience: Intermediate
Platform: Other
Favorite Futures: ES, YM, 6E
 
Posts: 2,640 since Feb 2013
Thanks: 4,893 given, 6,422 received
Forum Reputation: Legendary


wuileng View Post
 
Code
else if (State == State.Configure)
{
	int barValue = Math.Max(1, base.BarsPeriod.Value);
	AddDataSeries(RefInstrument, base.BarsPeriod.BarsPeriodType, barValue, Data.MarketDataType.Last);
	//AddDataSeries(RefInstrument, BarsPeriods[0].BarsPeriodType, BarsPeriods[0].Value);
	//AddDataSeries(RefInstrument, BarsPeriodType.Minute, 5);
	
	Calculate			= Calculate.OnBarClose;
	IsOverlay			= false;
	DrawOnPricePanel    = true;
	DisplayInDataBox    = true;
	IsAutoScale			= true;
}
The commented lines are what I use normally (the first one doesn't work for me though which is why I'm having this problem). RefInstrument is defined earlier in State.SetDefaults too.

One last thing if you don't mind, perhaps you could try my syntax out as well? I'm starting to think this is a problem specific to my system, so perhaps I'll try installing on another machine over the weekend before I waste any more of your time.

Thanks again!

The [0] line is evidently faulty. Line 1 and 3 are "supposed to work" ... strange.
Just to make sure that the error isn't caused by your RefInstrument the snippet I use for setting the second instrument of my spreads from Properties:

[Description("Second instrument")]
[NinjaScriptProperty]
[Display(Name="2nd Instrument", Order=1, GroupName="Parameters")]
public string secondInstrument
{
get { return secondInstrument; }
set { secondInstrument= value; }
}

Reply With Quote
 
  #10 (permalink)
Elite Member
Kuala Lumpur + Malaysia
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Interactive Brokers
Favorite Futures: ES
 
Posts: 26 since Aug 2012
Thanks: 13 given, 9 received



choke35 View Post
The [0] line is evidently faulty. Line 1 and 3 are "supposed to work" ... strange.
Just to make sure that the error isn't caused by your RefInstrument the snippet I use for setting the second instrument of my spreads from Properties:

[Description("Second instrument")]
[NinjaScriptProperty]
[Display(Name="2nd Instrument", Order=1, GroupName="Parameters")]
public string secondInstrument
{
get { return secondInstrument; }
set { secondInstrument= value; }
}

Okay, I just tried several things out. All three lines work when applying the indicator to a chart.

However, when calling the indicator from a strategy, only the third (the hardcode) works. Sorry for not being specific earlier that I was trying to get it to work in the context of a strategy.

Reply With Quote

Reply



futures io > > > > > NT8 - Multi Instrument Indicators

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi Instrument / Portfolio Strategy Backtesting Problem wuileng NinjaTrader 2 July 4th, 2015 03:04 PM
Multi Instrument Time Delay Redmoon22 NinjaTrader Programming 3 June 2nd, 2015 02:58 PM
Multi-instrument code strategy Astrogirl NinjaTrader 1 April 14th, 2014 03:47 PM
Multi-instrument strategy jnorris NinjaTrader Programming 14 February 4th, 2014 03:02 AM
Help with a Multi-Instrument Indicator ECI Ed NinjaTrader Programming 12 July 31st, 2013 10:22 AM


All times are GMT -4. The time now is 08:38 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-10 in 0.15 seconds with 19 queries on phoenix via your IP 54.83.122.227