Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to run a single strategy for 10 instruments

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

    How to run a single strategy for 10 instruments

    Hi,
    How to run a single strategy for 10 instruments without adding 10 entries in control center

    #2
    Hello shankar.deshapande,

    Thanks for your notes.

    You would need to add all the additional data series to the strategy script by using the AddDataSeries() method.

    Then, you could submit entry and exit orders to the added secondary series in the script by using the Enter and Exit method overloads that let you specify the barsInProgressIndex you want to submit the orders to.

    The primary series the script is running on will have a barsInProgressIndex of 0. The first added series in the script will have a barsInProgressIndex of 1. The second added series in the script will have a barsInProgressIndex of 2, and so on.

    See the help guide documentation below for more information.

    AddDataSeries(): https://ninjatrader.com/support/help...dataseries.htm
    Managed Approach Order Methods: https://ninjatrader.com/support/help...d_approach.htm
    Working with Multi-Timeframe/Multi-Instrument NinjaScripts: https://ninjatrader.com/support/help...nstruments.htm

    Here is a reference sample from the help guide demonstrating submitting orders to an added series: https://ninjatrader.com/support/help...ipt_strate.htm
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      hi ,
      i attached script i added to run for multiple instruments . please check and help me.
      Attached Files

      Comment


        #4
        Hello shankar.deshapande,

        Thanks for your notes.

        You would not be able to use Set methods to submit stop loss or profit target orders to added series in the script. Exit methods must be used, such as ExitLongLimit() and ExitLongStopMarket() if you are submitting orders to secondary added series.

        In the script, the wrong syntax for EnterLong(), EnterShort(), ExitLong(), and ExitShort(). You must use the overload that allows you to specify the barsInProgressIndex that you want to submit each order to.

        For example, the syntax for EnterLong() would look like this: EnterLong(int barsInProgressIndex, int quantity, string signalName)

        If you want to submit the order to the primary series the script is running on, the method would look something like:

        EnterLong(0, 1, "PrimarySeriesEntry");

        If you want to submit the order to the first added series in the script, you would need to call EnterLong(1, 1, "FirstAddedSeriesEntry");

        To submit the entry to the second added series in the script, you would need to call EnterLong(2, 1, "SecondAddedSeriesEntry");, and so on. Note how the BarsInProgressIndex is set to the series you are submitting the order to.

        You would need to use the similar syntax for your Exit methods as well.

        Please review this help guide page in full to gain a good understanding of how to work with Multi-Timeframe/Multi-Instrument NinjaScripts: https://ninjatrader.com/support/help...nstruments.htm

        See this help guide page about Managed Approach Order Methods and their syntaxes: https://ninjatrader.com/support/help...ach.htm​
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          Hi ,
          How to do same for TM Strategies. As i have written many strategies with ATM

          Comment


            #6
            Hello shankar.deshapande,

            Thanks for your notes.

            Atm Strategy Methods would need to be used if you are wanting to code a NinjaScript strategy that uses Atm Strategy templates for protective orders.

            You could create a condition that checks the BarsInProgress of the added series you want to submit orders to and then call AtmStrategyCreate() to create and submit an entry order with an ATM Strategy template.

            For example, to submit the order to the first added series in the script you would create a condition that checks if BarsInProgress == 1 and then call your ATM logic within that condition.

            To see an example of using Atm Strategy Methods, see the SampleAtmStrategy strategy that comes default with NinjaTrader. To view the code, open a New > NinjaScript Editor window, open the Strategies folder, and double-click on the SampleAtmStrategy file.

            See the help guide documentation below for more information.

            Atm Strategy Methods: https://ninjatrader.com/support/help...gy_methods.htm
            Using Atm Strategies in NinjaScript: https://ninjatrader.com/support/help...strategies.htm
            BarsInProgress: https://ninjatrader.com/support/help...inprogress.htm
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Hi ,

              If i want to trade 100 stocks how can i trade?

              suppose i want to list all stocks which are at Ultimate oscilator value below 20 , How i can do this out of 100 stocks?

              Comment


                #8
                Hello shankar.deshapande,

                Thanks for your notes.

                You would need to add each individual instrument to the script using the AddDataSeries() method and then call your Entry order methods and submit the orders to each added secondary data series in the script.

                There is no way available to dynamically add instruments to a NinjaScript based on a certain condition. Each instrument must be hardcoded into the strategy using the AddDataSeries() method.

                From the AddDataSeries() help guide: Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner.

                AddDataSeries(): https://ninjatrader.com/support/help...ies.htm​
                Brandon H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by James650, 05-07-2024, 08:25 AM
                3 responses
                14 views
                0 likes
                Last Post NinjaTrader_ChristopherJ  
                Started by xepher101, 05-10-2024, 12:19 PM
                5 responses
                66 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by Vitamite, Yesterday, 12:48 PM
                3 responses
                18 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by aligator, Today, 02:17 PM
                0 responses
                17 views
                0 likes
                Last Post aligator  
                Started by lorem, 04-25-2024, 09:18 AM
                22 responses
                96 views
                0 likes
                Last Post lorem
                by lorem
                 
                Working...
                X