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

Running script on multiple instruments

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

    Running script on multiple instruments

    So I wrote a script to backtest historical data and it only works one instrument at a time according to what instrument my chart window is set to. I want to be able to run the script on one instrument then next instrument when the previous expires without having to switch the contract in the chart window.

    In essence I want to be able to run the script independelty from what the chart shows. Or for that matter, to be able to switch the instrument in the chart programmatically

    What function could I use to achieve this? Would it be the AddDataSeries()?


    #2
    Hello Orden33,
    Thanks for your post and welcome to the NinjaTrader forum.

    You are on the right track. You can use AddDataSeries() and the concepts in the "Multi-Time Frame and Instrument" section of the help guide. I suggest reading through the following help guide page to become familiar with the concepts there.



    Additionally, there are Multi-Instrument and Multi-Time Frame sample strategies you can view and modify in the NinjaScript Editor.

    Let me know if you have any questions.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      JoshG,
      Thanks a lot for your response, it was right what I was looking for.

      I´m now wondering if there is a way a script can change the data series drawn on the chart and that way allow the x axis on the chart to scroll past where the BarsArray[0] ends.

      Comment


        #4
        Orden33,

        Are you wanting to combine multiple data series' into a single data series?

        Are you simply trying to view a continuous contract?

        How many days are you loading on your chart and what time period?

        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Hi JoshG, thanks for your reply,

          I´m trying to run a script across 5 years of ES data on 2min bars starting from ES 03-14 then ES 06-14 then ES 09-14 an so on.

          I´ve only added the oldest series (ES 03-14) on to the chart and I´m trying to see if there´s a way to use code to unload that series by its rollover date then load the next contract to continue viewing the script´s progress on the chart throughout the entire 5 years of data. I guess that´s what a "continuous contract" might be.

          Comment


            #6
            Orden33,

            I would suggest doing this by testing the front month of the historical data set you want to look at. If you have your Merge Policy set to "Merge back adjusted" NinjaTrader will automatically merge the historical data from each contract as far back as you set the date for your historical data request(assuming that you have access to the historical data that far back).

            You can set the Global Merge policy from your Control Center>>Tools>>Options>>Market Data>>Global merge policy



            Josh G.NinjaTrader Customer Service

            Comment


              #7
              JoshG,

              By "testing the front month" I believe you mean that my script should start testing from the last (the newest) bar on the newest contract (ES 12-18) then run the logic backwards in time, and that by setting the right merge policy the platform will automatically allow the script to run backwards across all of the contracts.
              If I understood correctly then I´m in a bind because my script works forward in time starting from the oldest bar so it can work forward, this way I could leave it on in realtime and have it open operations automatically.

              My objective was to run the script across historical data at max speed first (which I have already have but had to do each contract at a time) .

              Your advice to add all of the data series within the script seems to be the way to go but I would like to see the chart match the the series the script is processing

              Thanks a lot for your help and suggestions

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by WHICKED, Today, 12:56 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by cre8able, Today, 01:16 PM
              0 responses
              1 view
              0 likes
              Last Post cre8able  
              Started by chbruno, 04-24-2024, 04:10 PM
              2 responses
              47 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by WHICKED, Today, 12:45 PM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by samish18, Today, 01:01 PM
              0 responses
              5 views
              0 likes
              Last Post samish18  
              Working...
              X