Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-instrument logic

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

    Multi-instrument logic

    Hello everyone,

    Could you please help me with the following problem - I need to record tick data of two instruments for post-procesing. I`m using the following code:

    Code:
            protected override void Initialize()
            {
                    Add("$EURUSD", PeriodType.Minute, 1);
            }
    
            protected override void OnBarUpdate()
            {
    			if (BarsInProgress == 0)
    			{
    				Close1 = Close[0];
    			}
    			if (BarsInProgress == 1)
    			{
    				Close2 = Close[0];
    			}
    
                            string cl12= Time[0] + ";" + Close1 + ";" + Close2 + Environment.NewLine;
    			File.AppendAllText(path, cl12);
    			
            }
    But it don`t works as expected - it writes Close prices for only second instrument. What is my mistake?

    #2
    Hello,

    Thanks for the note.

    This code should work, please note that Close1 will only change once BarsInProgress == 0 is true which is an OnBarUpdate call of the primary series.

    What primary series are you running on?

    Finally, what exact output are you getting?

    -Brett
    BrettNinjaTrader Product Management

    Comment


      #3
      Hello,

      Thanks for that output.

      What exactly is wrong? I see both outputs and they look good to me.

      -Brett
      BrettNinjaTrader Product Management

      Comment


        #4
        Hmm... Now it works fine. Thanks.

        Comment


          #5
          Sounds good. Have a good one and happy programming !

          -Brett
          BrettNinjaTrader Product Management

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          605 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          351 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          105 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          560 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          561 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X