// 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
No announcement yet.
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.
Any further examples of code using a second input series would be appreciated.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 Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
567 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
330 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
548 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
548 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment