Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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:
But in NT8, the following just gives me errors:
Does anyone know of a better way?
Can you help answer these questions from other members on NexusFi?
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).
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?
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.
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; }
}
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.