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

Historical Tick Backtest has incorrect entry and exit

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

    Historical Tick Backtest has incorrect entry and exit

    I have read this post https://ninjatrader.com/support/foru...mance?t=102504

    and I still am a little confused about how the historical tick data works.

    I have turned on Tick Replay in the options and on the Data Series for the chart. This is an OnPriceChange strategy.

    I have also added the 1 tick series to the code,
    Code:
    AddDataSeries("NQ 06-21", Data.BarsPeriodType.Tick, 1, Data.MarketDataType.Last);
    The backtest entries are incorrect. This first picture below shows lines where the strategy would enter a long and short in realtime. It also exits at a defined profit point OR when it TOUCHES the 14 SMA (white line)

    Realtime functionality

    This second picture below is a cap of historical bars with the backtest trade lines and entries. It appears that it can only process an entry and exit on the top or bottom of a bar (Like it's working in OnBarClose mode???). I have Red lines on where it WOULD enter if it was in realtime. I don't have it pictured, but an exit at the 14 SMA is also only ever on the top or bottom of the bar.

    Click image for larger version

Name:	hist.jpg
Views:	134
Size:	66.2 KB
ID:	1148581

    Have I done something wrong? Does a strategy need to be custom-tailored to accommodate historical tick data?
    Or is it even possible for historical tick to function outside of the top and bottom of bars (I'm assuming Open and Close)?

    Once again, this strategy works perfectly fine in realtime, exactly how I would want it to. Thank you in advance.

    #2
    Hello Plzwork123,

    Do you have output from prints and TraceOrders to show when the condition is evaluating as true, and when the order is being submitted?


    Please include the output from prints and traceorders with your reply.

    Are the orders being submitted to the BarsInProgress index of the added 1 tick series?
    EnterLong(int barsInProgressIndex, int quantity, string signalName)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      So i have entered the barsInProgressIndex on Enter and Exit, and the entry prices are correct now. But for some reason, if the 14 SMA is crossed its setting the exit price to the Open of the bar it crossed on.

      Comment


        #4
        Hello Plzwork123,

        If you are using the BarsInProgress index of the single tick data series when submitting orders, the single tick data series will be used to simulate order fills.

        Please also note that if you add a single tick data series, OnBarUpdate will also process on that single tick data series. You can use BarsInProgress checks to limit which data series your logic gets processed on.

        I have attached a modification of the SampleMACrossover strategy that submits orders to a single tick data series and uses a BarsInProgress check to ensure logic is only processed on the primary data series. It uses Calculate.OnPriceChange, and you may test it with Tick Replay enabled to see how the orders will fill following this process.

        We look forward to assisting.

        Attached Files
        JimNinjaTrader Customer Service

        Comment


          #5
          I think it works now. I missed an Enter/ExitLong and hadn't put barsInProgressIndex in the parameters. After doing that the strategy seems to be working as intended on the backtest. Thanks a lot for the help!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by inanazsocial, Today, 01:15 AM
          0 responses
          2 views
          0 likes
          Last Post inanazsocial  
          Started by trilliantrader, 04-18-2024, 08:16 AM
          5 responses
          22 views
          0 likes
          Last Post trilliantrader  
          Started by Davidtowleii, Today, 12:15 AM
          0 responses
          3 views
          0 likes
          Last Post Davidtowleii  
          Started by guillembm, Yesterday, 11:25 AM
          2 responses
          9 views
          0 likes
          Last Post guillembm  
          Started by junkone, 04-21-2024, 07:17 AM
          9 responses
          71 views
          0 likes
          Last Post jeronymite  
          Working...
          X