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

Unable to Backtest Custom Strategy

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

    Unable to Backtest Custom Strategy

    Hi NT,

    I am having some trouble backtesting a custom strategy. This strategy runs on live data in my sim account, but will not run in strategy analyzer.

    A little about the strategy:
    • My entries are made in OnMarketData() -- I am using EnterLongLimit
    • My stops/targets are made in OnExecutionUpdate() -- I am using ExitLongStopMarket and ExitLongLimit. isLiveUntilCancelled is set to true
    • I am using tick fill resolution
    • My connection/historical data are both OK
    After attempting to run in strategy analyzer, the output only produces these two line... It produces nothing in the log.
    9/30/2020 5:00:00 PM CancelAllOrders: BarsInProgress=0
    9/30/2020 5:00:00 PM CancelAllOrders: BarsInProgress=1

    I realize this is vague, so please let me know what else I can provide to help narrow the problem down.

    I'm hoping the answer is obvious to those more seasoned than me (you can probably tell I'm not a programmer ) Thanks in advance!

    #2
    Hello collic653, thanks for your post and welcome to the NinjaTrader forum.

    It seems you are not getting the proper tick data for the backtest. Who are you using for a data provider currently? Can you pull up a 1 tick chart of the time period you are trying to test? What happens when you test the SampleMACrossover on the same set of data?

    I look forward to hearing from you.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi Chris,

      I am using Kinetick. I am able to populate a tick chart and I can also successfully run SampleMACrossover for the same time period on tick data. This is leading me to believe it is something to do with the strategy itself

      Comment


        #4
        Hello collic653, thanks for your reply.

        If you can enable the strategy on a chart and you see historical trades, then it should work in the strategy analyzer. Kinetick limits the amount of tick data you can pull during market hours to 8 days back. Can you run the strategy some time over this period and test what happens?
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Hi Chris,

          Unfortunately still no luck. I am only attempting to run this from 10/1 - 10/1

          Comment


            #6
            Hello collic653, thanks for your reply.

            I could test your strategy on my PC if you would like. Please Export it then email it to "platformsupport at ninjatrader.com" and reference ATTN ChrisL 2772066 in the body of the email.

            I look forward to hearing from you.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              I just sent it along, appreciate your help!

              Comment


                #8
                Hello, thanks for sending me that.

                The OnMarketData method must be designed for Tick Replay in order to work in a backtest. Also, GetCurrentBid() and GetCurrentAsk() are real time only methods. For a practical example of getting bid and ask data see the BuySellVolume indicator.

                Please let me know if you have any questions on this material.
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Chris,

                  I had a chance to digest the tick replay material and I think I am set there. I was able to get the script to run after commenting out all of the conditions containing GetCurrentBid()/GetCurrentAsk() and GetCurrentBidVolume()/GetCurrentAskVolume().

                  I understand how to access a historical bid/ask series, but I am also looking for historical bid volume/ask volume. I understand that this is not available per the link below, but I am wondering if there is any workaround? My goal is to take a snapshot of the quoted imbalance to use as one of my entry conditions.

                  Comment


                    #10
                    Hello collic653, thanks for your reply.

                    To get a tick by tick feed of volume data you can add two extra 1 tick data series of MarketDataType bid and ask. This would be needed if your data provider does not support Tick Replay. See this chart to check your data provider:



                    If your data provider does support Tick Replay, you can use the technique described in the BuySellVolume indicator to get the best bid/ask price at the time of the trade. See the OnMarketData method of the BuySellVolume indicator.

                    Kind regards,
                    -ChrisL


                    Chris L.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Kaledus, Today, 01:29 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post Kaledus
                    by Kaledus
                     
                    Started by PaulMohn, Today, 12:36 PM
                    1 response
                    16 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by yertle, Yesterday, 08:38 AM
                    8 responses
                    37 views
                    0 likes
                    Last Post ryjoga
                    by ryjoga
                     
                    Started by rdtdale, Today, 01:02 PM
                    1 response
                    6 views
                    0 likes
                    Last Post NinjaTrader_LuisH  
                    Started by alifarahani, Today, 09:40 AM
                    3 responses
                    19 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X