Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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

    Comment


      #3
      Hello,

      Thanks for that output.

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

      -Brett

      Comment


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

        Comment


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

          -Brett

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by yertle, Today, 08:38 AM
          6 responses
          24 views
          0 likes
          Last Post ryjoga
          by ryjoga
           
          Started by algospoke, Yesterday, 06:40 PM
          2 responses
          24 views
          0 likes
          Last Post algospoke  
          Started by ghoul, Today, 06:02 PM
          3 responses
          15 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          46 views
          0 likes
          Last Post jeronymite  
          Started by Barry Milan, Yesterday, 10:35 PM
          7 responses
          23 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X