// Add(SecondInstrument, BarsPeriods[0].Id, BarsPeriods[0].Value); // Add(SecondInstrument, PeriodType.Range, Size, MarketDataType.Last); // Add(PeriodType.Range,13); //This seems to work consistently
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Multi Instrument issues
Collapse
X
-
Multi Instrument issues
I am attempting to use the Add() feature to compare a custom indicator applied to two different instruments. I have followed the scripts provided for adding second instruments but my code sometimes works, sometimes does not, and I can't find a common denominator. If I add another timeframe (or Range size) and do not deviate from the master instrument input series, then the indicator works without any problems. But once I change instruments on the second series, the code becomes unstable. Below are the three attempts I've used to Add.
Code:Tags: None
-
Tdschulz,
Please be sure that you are separating the OnBarUpdate() calls using BarsInProgress.
BarsInProgress : http://www.ninjatrader.com/support/h...inprogress.htm
Multi Instrument Strategies : http://www.ninjatrader.com/support/h...nstruments.htm
Please let me know if I may assist further.Adam P.NinjaTrader Customer Service
-
The structure of my code is below. Something with calling the second instrument is the issue because calling another size range chart of the same instrument is no problem. I only run into issues when trying to use the SecondInstrument method of Add(). I've tried a few variations of Adding the second instrument including hard coding into the code and still it sometimes works and other times doesn't. The stranger part is that sometimes I load the indicator, it does not come up with anything, I change the data series from "load days" to "load bars" and then it works. Sometimes it's the opposite though.
I'm starting to feel crazy....
Code:private double Indicator1() { return ("this area is a combination of custom indicators all using BarArray[0]") } private double Indicator2() { return ("Combination of custom indicators using BarArray[1]") } #endregion /// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Add(SecondInstrument, PeriodType.Range, Size, MarketDataType.Last); CalculateOnBarClose = false; Overlay = true; PriceTypeSupported = true; DrawOnPricePanel = true; PaintPriceMarkers = false; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if (CurrentBarArray[0] > 0 && CurrentBarArray[1] > 0 ) { if (BarsInProgress == 0) { if ((Indicator1 > X) && (Indicator2 > X)) { BackColor = Color.MediumSeaGreen; }
Last edited by Tdschulz; 01-09-2012, 09:36 AM.
Comment
-
Tdschulz,
Are you passing the BarsArray[0] to the Indicator1 and Indicator2 methods?
Also, I should have noticed before, this line : Add(SecondInstrument, BarsPeriods[0].Id, BarsPeriods[0].Value);
You cannot access BarsPeriods in the initialize method.
This : Add(SecondInstrument, PeriodType.Range, Size, MarketDataType.Last);
Should work fine as long as SecondInstrument is defined.
I look forward to helping you resolve your issue.Adam P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by bmartz, Today, 09:30 AM
|
2 responses
11 views
0 likes
|
Last Post
by bltdavid
Today, 11:24 AM
|
||
Started by f.saeidi, Today, 11:02 AM
|
1 response
3 views
0 likes
|
Last Post Today, 11:08 AM | ||
Started by geotrades1, Today, 10:02 AM
|
4 responses
12 views
0 likes
|
Last Post
by geotrades1
Today, 11:08 AM
|
||
Started by rajendrasubedi2023, Today, 09:50 AM
|
3 responses
16 views
0 likes
|
Last Post Today, 10:57 AM | ||
Started by lorem, Today, 09:18 AM
|
2 responses
11 views
0 likes
|
Last Post Today, 10:55 AM |
Comment