Announcement

Collapse
No announcement yet.

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.

    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?

        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.

            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.

                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


                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by NullPointStrategies, Yesterday, 05:17 AM
                    0 responses
                    62 views
                    0 likes
                    Last Post NullPointStrategies  
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    134 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    75 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    45 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    50 views
                    0 likes
                    Last Post TheRealMorford  
                    Working...
                    X