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 Hwop38, 05-04-2026, 07:02 PM
          0 responses
          163 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Started by CaptainJack, 04-24-2026, 11:07 PM
          0 responses
          313 views
          0 likes
          Last Post CaptainJack  
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          245 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          350 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          179 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Working...
          X