Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-instrument strategy on tick base

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

    Multi-instrument strategy on tick base

    Hi!

    I'm trying to create pair-trading strategy, that fills orders in different instruments in different times - exactly only on bar close. I'm using 150 tick data. BUt it is clear, that for different instruments needed different time to fill 150 ticks.

    But then I run strategy in real time data, it fills orders in the same time - one on bar-closed instrument, but another - during opened bar.

    Question. How to set up real-time strategy, that fills orders in two different instruments only on bar close of each instrument. First order must be placed for the first instrument on this instrument's bar close. For the second instrument it must wait for the bar close, and only in that time send order.

    Thanks

    #2
    makhmout, you could check with FirstTickOfBar and only send the order if that evaluates to 'true' for each BarsInProgress - that would give you access to the closing tick event of each series. As NT is event driven, the closing tick equals the open tick of the new bar formed.

    Comment


      #3
      Thank you, Bertrand!

      One more question.

      Can strategy access to external file, for example for sharing data between two different strategies?

      Comment


        #4
        Per default the NinjaScript strategies run would not cross communicate, but we have had users successfully using txt files to exchange info as needed - http://www.ninjatrader.com/support/f...ead.php?t=3477

        For more complex setups, look into the StreamReader / StreamWriter classes provided with C#, as they would offer more performance.

        Comment


          #5
          Hi, Bertrand!

          During my backtests I have found one strange thing.
          My strategy uses two instruments to calculate some trigger and sends orders only in this instruments.
          Instruments defined manually by option fields during statring SA.
          Runnung Strategy Analizer sometimes I forgot to choose instrument, so it starts to backtest on all instruments on default instrument list. Strange, that it shows absolutely different results for the different instruments, although it doesn't use this instruments in calculation.
          I don't understand.

          Thanks!

          Comment


            #6
            makhmout, could it be you would have a default instrument to use hard-coded into the script somewhere that is overridden with the user input then? So it would be used if you forgot to enter any custom one?

            Comment


              #7
              Bertrand, I'm using "1" and "2" indexes to set first and second instruments. As I know, default instrument uses "0' index. Everywhere in code I hardly use '1" and "2" indexes only.

              Comment


                #8
                Ok, but for those 2 indices - is there any placeholder / default value coded into your script that would be used if forget to enter any input?

                NT would definintely change the primary instrunent then in backtest if you chose to backtest the default list.

                To see what instruments are used in your setup, you could simply print Instrument.FullName on each OnBarUpdate() - http://www.ninjatrader.com/support/h...t_fullname.htm

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                646 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                367 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                107 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                569 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                573 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X