Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi Instrument issues

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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:
    //  Add(SecondInstrument, BarsPeriods[0].Id, BarsPeriods[0].Value);
    //  Add(SecondInstrument, PeriodType.Range, Size, MarketDataType.Last);
    //  Add(PeriodType.Range,13);  //This seems to work consistently
    Any further examples of code using a second input series would be appreciated.

    #2
    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

    Comment


      #3
      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


        #4
        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


          #5
          Thanks Adam. I found my mistake. I had forgotten "Value_" in front of Size.
          Code:
          public int Value_Size
                  {
                      get { return size; }
                      set { size = value; }
                  }
          Thanks for your help.

          Comment


            #6
            Tdschultz,

            I am happy you have resolved your issue.

            Please don't hesitate to contact us should you require additional assistance.
            Adam P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by sjsj2732, Yesterday, 04:31 AM
            0 responses
            31 views
            0 likes
            Last Post sjsj2732  
            Started by NullPointStrategies, 03-13-2026, 05:17 AM
            0 responses
            286 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            283 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            133 views
            1 like
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            91 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Working...
            X