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

Backtesting strategy: Unmanaged Approach

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

    Backtesting strategy: Unmanaged Approach

    Hi,

    I have tried back testing my strategy but every time I try to run the back test, it comes back without any results. I am not sure what is causing this behavior? I am wondering if there are any errors in the strategy. Strategy seems to be working fine when I test it on simulation account.

    Thanks,

    #2
    Hello bjunaid,

    Thanks for your post.

    When something is not working as expected, please check the "Log" tab of the control center for any related error messages.

    If no error messages then please run the strategy SampleMACrossover in the strategy analyzer using the exact same start/end dates, bar type and size. If there are no results this would indicate that you do not have the data needed. You might try changing the start/end dates or create a chart of the instrument and observe if you have data for it.

    If the sampleMACrossover produces results and the results show trades from the beginning of your data to the end that the issue would be related to your strategy. Does your strategy have any check that it only will run on Real time data?

    If no checks for Real time data, then the next step would be to debug your strategy using print statements that sends their output to the New>Ninjascript output window. Typically you would print out the values of the conditions for placing the order(s) and this may lead you down the investigative path. Here is a link to our debugging tips: https://ninjatrader.com/support/help...script_cod.htm

    Note: That your strategy is working fine on real time data makes me suspect either the historical data or coding that specifies using Real time (or not using historical).
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks, I will take look.

      Comment


        #4
        Hi,

        My entries are based OnMarketData function. Could it be because of this function since it relies on real time data?

        Comment


          #5
          Hello bjunaid,

          Thanks for your reply.

          Correct, OnMarketData does not function on the static historical data in the Strategy analyzer.

          You could enable/use Tick Replay however the OnMarketData() method states: "If used with TickReplay, please keep in mind Tick Replay ONLY replays the Last market data event, and only stores the best inside bid/ask price at the time of the last trade event." Reference: https://ninjatrader.com/support/help...marketdata.htm Note that you would need tick data for the entire duration of the backtest period.

          I would suggest using PlayBack with market replay data to backtest your strategy. This will be a significantly slower backtest process but will provide all of the data you need to run your strategy.

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

          Comment


            #6
            Hi Paul,

            So I clicked the Tick Replay when using the Strategy Analyzer however I am getting a an error:

            2020-11-09 16:55:33:282|3|4|Strategy 'UVSTRLOW': Error on calling 'OnBarUpdate' method on bar 0: 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.

            Comment


              #7
              ***************Update

              I was able to figure out the error. It was related to Market Data. I had to put the method in the statement if(State = State.Realtime) in OnBarUpdate.

              Thanks,

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Tim-c, Today, 03:54 AM
              0 responses
              3 views
              0 likes
              Last Post Tim-c
              by Tim-c
               
              Started by FrancisMorro, Today, 03:24 AM
              0 responses
              2 views
              0 likes
              Last Post FrancisMorro  
              Started by Segwin, 05-07-2018, 02:15 PM
              10 responses
              1,771 views
              0 likes
              Last Post Leafcutter  
              Started by Rapine Heihei, 04-23-2024, 07:51 PM
              2 responses
              31 views
              0 likes
              Last Post Max238
              by Max238
               
              Started by Shansen, 08-30-2019, 10:18 PM
              24 responses
              945 views
              0 likes
              Last Post spwizard  
              Working...
              X