Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Running a multi-instrument strategy on tick replay

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

    Running a multi-instrument strategy on tick replay

    Just wondering if there are any special considerations to be aware of. I've downloaded each day of CL 06-23 and MCL 06-23 from 03/01/23 through April 21st. The strategy runs on CL and places trades on MCL. It runs without error in real time when market's open but when connected to market replay connection it craters with an error about no market data being available to place the order.

    I've run the script before on tick replay with just the main chart instrument so I know the process generally works. Just wondering if there's anything special about multi-instrument scripts and tick replay

    #2
    Make sure you downloaded market replay data for both CL and MCL. Even though MCL is not shown on the chart (if you added it with AddDataSeries to place orders on that series), you still need to have the data available so that fills can be simulated.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Thanks Bruce. Yup, did that.

      Click image for larger version

Name:	Screenshot 2023-04-22 at 12.33.10 PM.png
Views:	197
Size:	898.0 KB
ID:	1247739

      Comment


        #4
        Ah never mind. Moved forward to another date and started there and it's working. Must have been something to do with the first start date of 3/1

        Comment


          #5
          Perhaps one of them doesn't have historical data (even though it has market replay data) or perhaps one of them has a rollover date configured incorrectly.
          Bruce DeVault
          QuantKey Trading Vendor Services
          NinjaTrader Ecosystem Vendor - QuantKey

          Comment


            #6
            Hmm... Do you mean to say one could benefit from also downloading the historical data in addition to the replay data then?

            Comment


              #7
              Well, for one thing, if your chart has let's say 5 days of data on it, when you start the replay, the historical data will be used to populate the chart before the moment the replay starts so your indicators can get set up and primed with the historical context. There are probably other reasons as well - I always get both.
              Bruce DeVault
              QuantKey Trading Vendor Services
              NinjaTrader Ecosystem Vendor - QuantKey

              Comment


                #8
                Right so then I had the market replay running along happily for about a week when it disabled itself. Ran it again. Blew up at the same place. There's a line in the log referring to a database issue:

                Click image for larger version  Name:	Screenshot 2023-04-22 at 4.20.58 PM.png Views:	0 Size:	75.3 KB ID:	1247767

                Looked back through the log and seems like this was happening quite a bit but it kept on going then suddenly it just sort of had enough and quit. In a way kinda reminds me of myself when I was younger actually.

                Click image for larger version  Name:	Screenshot 2023-04-22 at 4.29.11 PM.png Views:	0 Size:	917.1 KB ID:	1247769

                Script didn't seem to have any errors in it that might have prompted such extreme frustration on the part of the database. There was a short position. It was politely suggested that it was no longer welcome, so it took the hint and exited peacefully. No drama there. Inserting 2 screenshots to show full width details

                Click image for larger version  Name:	Screenshot 2023-04-22 at 4.34.33 PM.png Views:	0 Size:	134.9 KB ID:	1247770
                Click image for larger version  Name:	Screenshot 2023-04-22 at 4.34.54 PM.png Views:	0 Size:	13.5 KB ID:	1247771
                Attached Files
                Last edited by markdshark; 04-22-2023, 04:40 PM.

                Comment


                  #9
                  It would seem that your database is corrupted. Try using Tools -> Database to repair and reset, then restart.
                  Bruce DeVault
                  QuantKey Trading Vendor Services
                  NinjaTrader Ecosystem Vendor - QuantKey

                  Comment


                    #10
                    Hey that worked! I got a week or so past the previous crash and logs no longer show that error.

                    I have a new problem though (that's just how it goes )

                    Apparently an indicator has a problem with how many brushes it's using. I get the error: Brush series exceeds the maximum number (65535) of unique brushes. Indicators and brushes are still new to me so I'll wrap up for the night and attack again tomorrow. Interestingly in realtime this error never cropped up. Then again I've never been able to (or frankly had any reason to) leave the script running for a week or more.

                    Thought I'd share the progress. Thank you for the pointers Bruce.

                    Comment


                      #11
                      You should not be creating unique brushes each time in OnBarUpdate or OnRender or OnMarketData. You should create all of the brushes you might need upfront, during something like State.DataLoaded, freeze them, and then refer to the already instantiated brushes from then on.
                      Bruce DeVault
                      QuantKey Trading Vendor Services
                      NinjaTrader Ecosystem Vendor - QuantKey

                      Comment


                        #12
                        Hello markdshark,

                        Thanks for your posts.

                        QuantKey_Bruce is correct. Before using the Playback connection with Market Replay you should make sure that you have the Market Replay data you are accessing downloaded in the Historical Data window. It is also a good idea to download Historical data for the same instruments and timeframes.

                        Playback: https://ninjatrader.com/support/help...connection.htm
                        Downloading Market Replay data: https://ninjatrader.com/support/help...jaTraderserver

                        Further, instead of creating unique brushes each time you use them in OnBarUpdate(), OnRender(), and OnMarketData(), you could create a class-level Brush object, assign a value to it in something like State.DataLoaded, and call .Freeze() on the unique brush. That brush could then be used later in the script in OnBarUpdate(), OnRender(), or OnMarketData(). This will allow your script to use fewer resources when the script is running.

                        From the help guide: You may have up to 65535 unique Brush instances, therefore, using static predefined brushes (as in the section above) should be favored. Alternatively, in order to use fewer brushes, please try to cache your custom brushes until a new brush would actually need to be created.

                        See this help guide page for more information about working with brushes: https://ninjatrader.com/support/help...gcustombrushes
                        Last edited by NinjaTrader_BrandonH; 04-23-2023, 03:36 PM.
                        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Mountain_cast, 02-10-2025, 11:14 PM
                        3 responses
                        20 views
                        0 likes
                        Last Post beobast
                        by beobast
                         
                        Started by defa0009, 12-13-2024, 09:19 AM
                        21 responses
                        209 views
                        1 like
                        Last Post marcus2300  
                        Started by ttrader23, Today, 04:48 PM
                        0 responses
                        6 views
                        0 likes
                        Last Post ttrader23  
                        Started by wisdomspoon, Today, 03:50 PM
                        3 responses
                        15 views
                        0 likes
                        Last Post rockmanx00  
                        Started by Robotman, Today, 01:06 PM
                        2 responses
                        37 views
                        0 likes
                        Last Post Robotman  
                        Working...
                        X