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

DataSeries when using Market Replay

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

    DataSeries when using Market Replay

    I have a strategy that uses the following data series:
    • The primary: it is a custom Renko that uses bar size and threshold values. The threshold value establish where the next Renko is drawn in relationship to the previous Renko.
    • DataSeries 1: same primary instrument, 1 tick BID
    • DataSeries 2: same primary instrument, 1 tick ASK
    • DataSeries 3: same primary instrument, 1 tick LAST
    The last three data series are used to do order fills in a granular manner.

    I have been able to test successfully my strategy using the following techniques:
    • Invoking the strategy through a chart
      • Changing the dates of the primary data series. I have use custom range and days
    • Invoking the strategy through Strategy Analyzer and running it in backtest and optimization mode
    Now I am trying to test using Market Replay and having issues as soon as the strategy reaches a simple command priceAtOrderSubmittion = Closes[2][0]. If I change it to priceAtOrderSubmittion = Closes[0][0], the strategy runs successfully.

    Question:
    • When running Market Replay and looking into the Historical Data window, I noticed that Market Replay data does not mention ASK, BID and LAST data as Historical info. I know that Market Replay stores level I and level II data. How can I access the BID, ASK, and LAST information when running Market Replay. Is there an event to handle Market Replay logic?

    #2
    Hello GARZONJ,

    You won't see any details surrounding ask/bid for market replay data only the dates which you have data for. You also don't have to do anything special to the code, it would be called the same as it would be in realtime or historical.

    Did you record this data or download it? I see that using the downloaded data on my end I am able to produce prints for secondary series like you mentioned:

    Code:
     if (State == State.Configure)
    {
        AddDataSeries("ES 03-20", BarsPeriodType.Tick, 1, MarketDataType.Last);
        AddDataSeries("ES 03-20", BarsPeriodType.Tick, 1, MarketDataType.Bid);
    }
    
    protected override void OnBarUpdate()
    {
        Print(BarsInProgress + " " + Time[0]);
    }
    0 12/27/2019 1:13:37 AM
    1 12/27/2019 1:13:37 AM
    2 12/27/2019 1:13:37 AM

    Can you provide a sample of how you are adding data in code and how you are printing the values?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I am downloading the Market Replay data.

      I am able to replicate the error when I use 6 for BrickSize and 3 for the threshold of the primary data series using my custom Renko bar type . In the TestingMarketReplay strategy I get the error when I enable line 73 which establishes another data series using my custom Renko bar type; this leads me to believe that the issue in the custom Renko bar type.

      I am including the the TestingMarketReplay strategy.

      Is there a way to send you guys the Renko bar type through another media which is more private than a forum?

      Also, keep in mind that the issue that I am encountering ONLY occurs when I use Playback Connection; either Market Replay or Historical. If I use my normal connection (the one through Phillip Capital) and invoke the strategy through the chart or the Strategy Analyzer (Backtesting or Optimization), I never get this error.

      Full Error Message: Strategy 'TestingMarketReplay': Error on calling 'OnBarUpdate' method on bar 116: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

      Attached Files

      Comment


        #4
        Hello GARZONJ,

        Thanks for the added details.

        I get the error when I enable line 73 which establishes another data series using my custom Renko bar type; this leads me to believe that the issue in the custom Renko bar type.
        Before we continue further, did you copy the Renko bars type which comes with NinjaTrader and create yours from that? It would be very helpful to know if the standard renko also fails here or not. If you can reproduce this using the standard bars type you wont need to send anything additional we just would need the parameters to test so I can see the problem as well.


        Is there a way to send you guys the Renko bar type through another media which is more private than a forum?
        Yes you can email our platform support [at] ninjatrader.com address, however before doing that I do suggest to test the standard renko and see if that reproduces the problem. If the standard renko does not produce a problem it may be more beneficial to try and make modifications to a duplciate of that script to see if the error comes back or not with your modifications. That at least will set a baseline of where the problem starts and what code should be excluded when looking for problems.

        Full Error Message: Strategy 'TestingMarketReplay': Error on calling 'OnBarUpdate' method on bar 116: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
        I don't necessarily see what would be throwing this error by just looking at the code however you are using some BarsAgo with various series here and not checking that all series have at least one bar. This may be solved by modifying your first condition to be the following:

        Code:
        if (BarsInProgress == 1 || BarsInProgress == 4 || CurrentBars[0] < BarsRequiredToTrade || CurrentBars[1] < BarsRequiredToTrade || CurrentBars[2] < BarsRequiredToTrade || CurrentBars[3] < BarsRequiredToTrade || CurrentBars[4] < BarsRequiredToTrade)
                return;
        For the series you are using in OnBarUpdate you would want to make sure that it has at least one bar before being used. For example in BarsInProgress == 2 you are using Times[3], if Times[3] doesn't have a bar when BIP 2 processes you would get this error.


        I look forward to being of further assistance.


        JesseNinjaTrader Customer Service

        Comment


          #5
          Jesse,

          You guys know your stuff. I just needed to add CurrentBars[x] < BarsRequieredToTrade statement for every data series and that solve the issue.

          I did this after I started using NT Renko's bar type and still getting the same issue. Then I went back to the post and added the statement.

          Thank you again for that tiny insight with did all the difference.

          Issue solved. Always add CurrentBars[x] < BarsRequieredToTrade for every data series. The issue will only come out when using the Playback Connection.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by algospoke, Yesterday, 06:40 PM
          2 responses
          24 views
          0 likes
          Last Post algospoke  
          Started by ghoul, Today, 06:02 PM
          3 responses
          15 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          46 views
          0 likes
          Last Post jeronymite  
          Started by Barry Milan, Yesterday, 10:35 PM
          7 responses
          23 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by AttiM, 02-14-2024, 05:20 PM
          10 responses
          181 views
          0 likes
          Last Post jeronymite  
          Working...
          X