Announcement

Collapse
No announcement yet.

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 nailui, Today, 07:26 AM
              1 response
              24 views
              0 likes
              Last Post NinjaTrader_Spencer  
              Started by chartchartchart, Today, 08:08 AM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_Emily  
              Started by andreslazor7, Today, 08:08 AM
              2 responses
              13 views
              0 likes
              Last Post andreslazor7  
              Started by FatCanary, Today, 08:09 AM
              2 responses
              7 views
              0 likes
              Last Post FatCanary  
              Started by vantojo, 01-12-2021, 02:13 PM
              15 responses
              196 views
              0 likes
              Last Post FatCanary  
              Working...
              X