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

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

    Backtesting

    Are there instructions on how to use the back testing function?

    #2
    Hello vonyoldel,

    Thank you for your post.

    For NinjaTrader 8. Please download historical data for the instrument and dates you want to backtest.

    To download historical data first make sure NinjaTrader is connected and historical data is available from your data provider.

    1. In the Control Center, go to Tools > Import > Historical Data > Expand the Download menu

    2. Select an instrument for data to be downloaded. (Tip: You may also select an instrument list)

    3. Select the desired Start and End date range

    4. Select the desired Intervals and Data Types

    5. Press the "Download" button to begin the download


    A message in the bottom right of the Historical Data Window will appear and display the status of the download.


    To cancel a historical data request close the Historical Data Window window.


    To run a Backtest of a strategy:
    1. Open a Strategy Analyzer window under New > Strategy Analyzer. Select the Backtest type of "Standard"
    2. Select the strategy you would like to backtest
    3. Select the instrument and Data Series you would like to backtest
    4. Set the strategy and backtest parameters (See the "Understanding backtest properties" section below for property definitions)
    5. Select the "Run" button to start the backtest



    Here is a video tutorial that covers how to backtest a strategy using the Strategy Analyzer: NinjaTrader 8 - Backtesting Strategies

    Here is the Backtest a Strategy Help Guide to assist you further.

    Backtest a Strategy

    Here is the Discrepancies: Real-Time vs Backtest Help Guide article, which will detail the differences in fills when using Market Replay, Live, Simulated feeds and Backtests to assist you further.


    Please do not hesitate to contact us for any other NinjaTrader inquiries you may have.



    Shawn B.NinjaTrader Customer Service

    Comment


      #3
      Hello,
      I followed the steps here for downloading historical data since Jan 1, 2019. The connection for My Ninjatrader Continuum was active. When clicking download, it lit up for one or two seconds and said loading data in the bottom right of the window. There was no indication after that. After waiting some minutes, I attempted to run backtesting with the data, also following the steps above and there were no results. I tried then to download only data for this month and backtest. I also got no results. What am I missing?

      Comment


        #4
        Originally posted by NinjaTrader_ShawnB View Post
        Hello vonyoldel,

        Thank you for your post.

        For NinjaTrader 8. Please download historical data for the instrument and dates you want to backtest.

        To download historical data first make sure NinjaTrader is connected and historical data is available from your data provider.

        1. In the Control Center, go to Tools > Import > Historical Data > Expand the Download menu

        2. Select an instrument for data to be downloaded. (Tip: You may also select an instrument list)

        3. Select the desired Start and End date range

        4. Select the desired Intervals and Data Types

        5. Press the "Download" button to begin the download


        A message in the bottom right of the Historical Data Window will appear and display the status of the download.


        To cancel a historical data request close the Historical Data Window window.


        To run a Backtest of a strategy:
        1. Open a Strategy Analyzer window under New > Strategy Analyzer. Select the Backtest type of "Standard"
        2. Select the strategy you would like to backtest
        3. Select the instrument and Data Series you would like to backtest
        4. Set the strategy and backtest parameters (See the "Understanding backtest properties" section below for property definitions)
        5. Select the "Run" button to start the backtest



        Here is a video tutorial that covers how to backtest a strategy using the Strategy Analyzer: NinjaTrader 8 - Backtesting Strategies

        Here is the Backtest a Strategy Help Guide to assist you further.

        Backtest a Strategy

        Here is the Discrepancies: Real-Time vs Backtest Help Guide article, which will detail the differences in fills when using Market Replay, Live, Simulated feeds and Backtests to assist you further.


        Please do not hesitate to contact us for any other NinjaTrader inquiries you may have.


        Hi,

        I am trying to build a simple EMA crossover strategy. Long at the Close of EOD Bar after Fast EMA crosses above the Slow EMA. However backtest results show that the entry is not being taken at the close. I have tried all the workarounds I know of to get the backtest to go Long/Short at the close of the bar.

        I also do not see the option "STANDARD" as mentioned in your quoted reply for backtest option.

        I have a simulation license, could this be any concern.

        Thanks
        Shrenik

        Comment


          #5
          Hello ronaldgreene828,

          Thanks for your post.

          Originally posted by ronaldgreene828 View Post
          Hello,
          I followed the steps here for downloading historical data since Jan 1, 2019. The connection for My Ninjatrader Continuum was active. When clicking download, it lit up for one or two seconds and said loading data in the bottom right of the window. There was no indication after that. After waiting some minutes, I attempted to run backtesting with the data, also following the steps above and there were no results. I tried then to download only data for this month and backtest. I also got no results. What am I missing?
          Please run the NinjaTrader provided strategy "SampleMAcrossover" that is provided with your platform in the strategy analyzer. This strategy is "Always in" meaning that once it starts trading it is always in a trade and is a good way to see that you do or do not have the historical data. Please choose ES 09-19 1 minute bars as a starting point and if it shows trades then test with whatever bars you were wanting to use and whatever instrument you have data for. Once you have some results showing on the summary screen, it is always a good idea to change the "display" to show the chart with the trades shown on it and then examine the trades in detail to see that they match your expected entry/exit criteria.
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Hello ShrenikGolchha,

            Thanks for your reply.

            Originally posted by ShrenikGolchha View Post

            Hi,

            I am trying to build a simple EMA crossover strategy. Long at the Close of EOD Bar after Fast EMA crosses above the Slow EMA. However backtest results show that the entry is not being taken at the close. I have tried all the workarounds I know of to get the backtest to go Long/Short at the close of the bar.

            I also do not see the option "STANDARD" as mentioned in your quoted reply for backtest option.

            I have a simulation license, could this be any concern.

            Thanks
            Shrenik
            The simulation license key does not impact the strategy analyzer so you have full functionality of the analyzer. "The Standard" that NinjaTrader_Shawn refers to is the "BackTest type" which is the first selection at the top of the strategy analyzer "settings".

            Are you using daily bars for your Strategy?

            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Hi Paul,

              The first selection at the top of the strategy analyzer "settings", That is exactly where I do not see the "Standard" option.

              Yes I am using Daily bars for my strategy.

              Comment


                #8
                Hello ShrenikGolchha,

                Thanks for your reply.

                The screenshot that shows "standard' is from our help guide and the picture provided needs to be updated, so my apologies for that confusion and we will get it updated, but that is the line where you would select the backtest type, so if you show "Backtest" then you are in the right place for a standard backtest (standard as compared to optimization).

                With historical data, a strategy can only calculate at the end of the bar (end of the day). If the strategy logic is to place an order, the order would not be filled until the next day. Is this what you are seeing?

                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Paul,

                  Thanks for the clarification about backtest. It helps clear the confusion.

                  Regarding back testing, what you mentioned is right. I am able to see entry on the next bar but at the close price of previous bar. Can we not get the entry on the same bar at close?

                  Also I am trying this ( Simple EMA Crossover Strategy) since a long time now and just not able to reach anywhere. The longs/shorts and their respective exits are just haywire.

                  I have attached screenshots for your reference.

                  Thanks

                  Comment


                    #10
                    Hello ShrenikGolchha,

                    Thanks for your post.

                    If your code is running once, at the end of the daily bar, then you would never be filled at the end of the same bar. To accomplish your entry goal, you would need to have the strategy run before the end of the session. A suggestion, if you can only use the strategy builder, is to use a smaller time frame (intraday bars) and then use a time filter to perform the analysis and entry action prior to the end of the day. You can find an example of a time filter in the strategy builder help guide in the section, "How to create time filters" here: https://ninjatrader.com/support/help...on_builder.htm

                    In your screenshots I see that you have both and entry and exit condition occurring at the same time. Entry methods will automatically close any existing position in the opposite direction (it will show as "Close position" on the chart. You may also be in violation of the "Internal Order Handling Rules that Reduce Unwanted Positions" which could cause orders to be ignored. I would advise to review the "Log" tab of the control center when you run the strategy as it may provide such a warning. Please see the help guide here for further details: https://ninjatrader.com/support/helpGuides/nt8/en-us/?managed_approach.htm
                    Paul H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by kujista, Today, 06:23 AM
                    5 responses
                    15 views
                    0 likes
                    Last Post kujista
                    by kujista
                     
                    Started by f.saeidi, Today, 10:19 AM
                    0 responses
                    2 views
                    0 likes
                    Last Post f.saeidi  
                    Started by traderqz, Yesterday, 09:06 AM
                    2 responses
                    16 views
                    0 likes
                    Last Post traderqz  
                    Started by traderqz, Today, 12:06 AM
                    3 responses
                    6 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by RideMe, 04-07-2024, 04:54 PM
                    5 responses
                    28 views
                    0 likes
                    Last Post NinjaTrader_BrandonH  
                    Working...
                    X