Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Price level order execution

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

    Price level order execution

    Hello guys,

    I developed a strategy that is using an indicator that is also developed by myself.

    Now trying to Backtest the strategy on StrategyAnalyzer is giving me some strange behaviour. I wanted precise execution and I enabled "TickReplay".
    My TakeProfit should be executed on 134.75 - but it is not. Actually it is executed on the close of the next bar after the TakeProfit price level is exceeded.
    I also added some logs to the Output to observe the exact calculation results and values of Open, Close and my Indicator values:

    Click image for larger version

Name:	image.png
Views:	153
Size:	132.4 KB
ID:	1329795

    My Indicator is working on Calculate.OnBarClose but I think that this is no argument for the strange behaviour.

    I also tried to change different calculation modes on my strategy - Calculate.OnBarClose and Calculate.OnEachTick but this was not making a difference.

    Click image for larger version

Name:	image.png
Views:	127
Size:	154.8 KB
ID:	1329796

    Click image for larger version

Name:	image.png
Views:	122
Size:	171.1 KB
ID:	1329797

    Any ideas to help?

    Thank you in advance

    #2
    Actually, running the strategy with Calculate.OnEachTick is leading to executing the Entry and StopLoss immediately one after another for all trades.
    Click image for larger version

Name:	image.png
Views:	131
Size:	101.1 KB
ID:	1329799

    Comment


      #3
      Hello nrgful,

      TickReplay is a concept that helps scripts process tick by tick historically and is not intended for more accurate fills so using that won't make a difference. If your strategy and indicator use OnBarClose processing then you don't need to use tick replay. You can change the order fill resolution to a more granular series to have more granular fills in a backtest.

      Comment


        #4
        NinjaTrader_Jesse Thank you for your support.

        I have several questions in mind. The first one is :
        1. By saying "You can change the order fill resolution to a more granular series to have more granular fills in a backtest." you mean that I need to import DataSeries ? Is that right?

        2. If I need to backtest a strategy for a longer period of time (for example, 6 months) on a futures instrument (for example FGBL). But all we know that the futures instruments have an expiration date by 3 months. Is it possible to backtest on futures instruments for more than 3 months? Because, if I choose FGBL MAR25 I can do reliable test back to 6th of December 2024 (because this is
        the starting date on the FGBL MAR25 contract). And I cannot use the same contract for test on dates that are older than 6th of December 2024.

        How can I backtest a strategy on futures instruments on longer periods of time (longer than the live period of time of the contract). The issue is that before the contract became active the volume and data on it will not be reliable. And after it expires, it will not be reliable again. There is a time gap of 3 months to use a contract for backtesting and before and after that - it is not reliable.

        Best wishes.
        Last edited by nrgful; 01-10-2025, 07:02 AM.

        Comment


          #5
          Hello nrgful,

          When doing the backtest the order fill resolution is one of the options that you can configure in the backtest settings. That is not something you need to change in your strategies code.

          To test for longer periods you don't need to do anything, the platform by default has merge backadjusted data. https://ninjatrader.com/support/help...rge_policy.htm

          Comment


            #6
            Thank you NinjaTrader_Jesse

            But from your reply above, I cannot understand how I can set the proper Merge settings for the purposes of StrategyAnalyzer Backtest.

            I read this guide: https://ninjatrader.com/support/help...rge_policy.htm

            But how exactly I can set the settings for the Backtesting of a strategy ?

            Thank you in advance

            Comment


              #7
              Hello nrgful,

              The merge policy applies platform wide and is already set by default to merge contracts so nothing needs to be changed.

              Comment


                #8
                NinjaTrader_Jesse But what is the exact merge policy mathematically? Isn't it changing the actual values of the price? Eventually, this may lead to wrong results!

                Comment


                  #9
                  Hello nrgful,

                  I wouldn't be able to comment on how the internal logic may work as that is not available but you can see some diagrams on how that changes the data in the page I linked. The offset is described as the following:


                  Selecting this option, the 03-15 data will be merged with the 06-15 data on the date of rollover (March 12th, 2015) and an Offset value will be used to connect the previous 03-15 contract price point with the first 06-15 contract point.

                  If you believe in some way that is affecting your data or results you can also disable that feature and just trade individual contracts.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by NullPointStrategies, Today, 05:17 AM
                  0 responses
                  43 views
                  0 likes
                  Last Post NullPointStrategies  
                  Started by argusthome, 03-08-2026, 10:06 AM
                  0 responses
                  124 views
                  0 likes
                  Last Post argusthome  
                  Started by NabilKhattabi, 03-06-2026, 11:18 AM
                  0 responses
                  65 views
                  0 likes
                  Last Post NabilKhattabi  
                  Started by Deep42, 03-06-2026, 12:28 AM
                  0 responses
                  42 views
                  0 likes
                  Last Post Deep42
                  by Deep42
                   
                  Started by TheRealMorford, 03-05-2026, 06:15 PM
                  0 responses
                  46 views
                  0 likes
                  Last Post TheRealMorford  
                  Working...
                  X