• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 rahul202, Today, 09:53 AM
          0 responses
          6 views
          0 likes
          Last Post rahul202  
          Started by U0000999, Today, 09:45 AM
          0 responses
          6 views
          0 likes
          Last Post U0000999  
          Started by Newtrader101, Today, 08:01 AM
          0 responses
          6 views
          0 likes
          Last Post Newtrader101  
          Started by Johnny Santiago, 10-11-2019, 08:21 AM
          6 responses
          103 views
          0 likes
          Last Post 4x777
          by 4x777
           
          Started by pjsmith, Today, 02:42 AM
          2 responses
          16 views
          0 likes
          Last Post pjsmith
          by pjsmith
           
          Working...
          X