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

Trading multiple instruments from within a single strategy

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

    Trading multiple instruments from within a single strategy

    Hi,

    I'd like to create a strategy that trades two instruments from a single strategy. Say I want to go long in AAA and also go short in BBB, either at the same time, or just one but not the other. After browsing other similar threads on the forum, I took a look at the MultiInstrumentStrategy sample but that sample doesn't appear to actually trade multiple symbols, it only references multiple instrument data series/bars.

    Also, the Ninjascript documentation for the various order methods don't show a way to specify which symbol to submit the order (unless I missed it).

    Is what I'm asking just not possible? If it is, can someone provide sample syntax on how to submit orders for a given symbol in a multi-instrument strategy?

    Thanks,
    Kerry

    #2
    Hello Kerry,

    Additional instruments can be added with the Add() method.

    Add(string instrumentName, PeriodType periodType, int period)

    Below is a publicly available link to the help guide on Add().


    As well as a few links on relevant items you may need for a multi-series script.



    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea. The last link in particular addresses my question: http://ninjatrader.com/support/helpG...nstruments.htm

      Thanks!

      Comment


        #4
        I want a slightly nuanced version of what this poster had in mind. I want to base the entire logic of the trade on the say "ES 06-20" (which I have written and it is working perfectly the way I wish). However because right now the margins can be excessive, I simply want to enter the trade on the MES 06-20 instead of the ES. I DO NOT want to base the logic of whether to trade or not on the MES, I simply want to trade the MES when the full-sized contract strategy fires a long or short. The issue I am having is that despite using the override which specifies the bars index, it still is firing entries on the ES instrument.

        Will I have to add code to check which bar is in progress? (Both the primary and the 2nd data series are the same time frame.

        Comment


          #5
          Hello EminiTrader,

          Thanks for your post.

          If you are using the advanced order method where you are providing the BarsInProgress to identify where the order should be applied then all you should need at the beginning of your code would be to have it return when the MES calls the OnBarUpdate(). This way MES is not calling your code that is intended to run only on ES

          For example, if MES is the first added data series and you are applying your script to an ES chart, then in OnBarUpdate() you would use:

          if (BarsInProgress != 0) return; // do not process unless chart bars (BarsInProgress 0, is calling OnBarUpdate).

          if (Your entry conditions based on ES)
          {
          EnterLong(1, 1, "MyMESEntry:"); // sends order to the first added data series MES.
          }


          Reference: https://ninjatrader.com/support/help...?enterlong.htm
          Paul H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by RookieTrader, Today, 07:41 AM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by kujista, Today, 05:44 AM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by elderan, Yesterday, 08:03 PM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by samish18, Yesterday, 08:57 AM
          8 responses
          25 views
          0 likes
          Last Post samish18  
          Started by DJ888, 04-16-2024, 06:09 PM
          3 responses
          10 views
          0 likes
          Last Post NinjaTrader_Erick  
          Working...
          X