Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtests and Optimization on Tick by Tick

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

    Backtests and Optimization on Tick by Tick

    Hi,


    I try to do tick by tick backtests over a long period. For this, I created a symbol, imported ticks (Ask, Bid, Last), I also imported minute bars.

    when i launch a backtest on a 1 minute chart, i see that only Open,Close, High, Low values are used. It's ok with tick replay, but not with backtests on a long period.

    I also added dataseries on ticks in the strategy as secondary data, same result.

    The only way to perform is to use Tick primary data series, so tick charts.

    Is there another way ? I'd like tu use 1mn chart, like in automated live trading. Difficult to verify my strategy on tick chart.

    Thanks for your anwers.

    #2
    Welcome to the forums fredericlebre!

    In my opinion, the quickest way to create a strategy that backtests with each tick is to design a strategy that operates on a single tick data series. You can add additional data series to the script and reference those added data series, and you can have that additional data drive indicators as well. This can all be done with the Strategy Builder, but limits you to enabling the strategy on a single tick data series.

    You could also consider adding a single tick data series as the secondary series and to use that to drive your logic, and to make sure that orders are submitted to the single tick data series so the orders are filled with intrabar granularity. If you want to consider an approach that does not require Calculate.OnEachTick, or Calculate.OnPriceChange, I recommend this approach.

    Multi time Frame and Instruments - https://ninjatrader.com/support/help...nstruments.htm

    Backtesting with intrabar granularity - https://ninjatrader.com/support/help...ipt_strate.htm

    Tick Replay allows for historical OnEachTick and OnPriceChange updates with OnBarUpdate and also for historical OnMarketData events for Last ticks, but does not affect how orders fill. You can add your single tick data series to the script and have the orders submitted to the single tick data series to have them filled with intrabar granularity, however. I would recommend this approach if you do want to use Calculate.OnEachTick or OnPriceChange.

    Using Tick Replay - https://ninjatrader.com/support/help...ick_replay.htm

    Developing for Tick Replay - https://ninjatrader.com/support/help...ick_replay.htm

    We look forward to assisting.

    Comment


      #3
      Originally posted by NinjaTrader_Jim View Post
      Welcome to the forums fredericlebre!

      In my opinion, the quickest way to create a strategy that backtests with each tick is to design a strategy that operates on a single tick data series. You can add additional data series to the script and reference those added data series, and you can have that additional data drive indicators as well. This can all be done with the Strategy Builder, but limits you to enabling the strategy on a single tick data series.

      You could also consider adding a single tick data series as the secondary series and to use that to drive your logic, and to make sure that orders are submitted to the single tick data series so the orders are filled with intrabar granularity. If you want to consider an approach that does not require Calculate.OnEachTick, or Calculate.OnPriceChange, I recommend this approach.

      Multi time Frame and Instruments - https://ninjatrader.com/support/help...nstruments.htm

      Backtesting with intrabar granularity - https://ninjatrader.com/support/help...ipt_strate.htm

      Tick Replay allows for historical OnEachTick and OnPriceChange updates with OnBarUpdate and also for historical OnMarketData events for Last ticks, but does not affect how orders fill. You can add your single tick data series to the script and have the orders submitted to the single tick data series to have them filled with intrabar granularity, however. I would recommend this approach if you do want to use Calculate.OnEachTick or OnPriceChange.

      Using Tick Replay - https://ninjatrader.com/support/help...ick_replay.htm

      Developing for Tick Replay - https://ninjatrader.com/support/help...ick_replay.htm

      We look forward to assisting.


      thanks for your answer.

      So, you confirm that if i realy want real tick by tick backtest i'll have to put the strategy on a Tick chart ?
      i tried to add tick data series as secondary serie, using 1mn primary dataserie on a 1mn chart and it does not work.

      Comment


        #4
        very sorry for my poor english

        Comment


          #5
          Hello fredericlebre,

          Thanks for your reply.

          So, you confirm that if i realy want real tick by tick backtest i'll have to put the strategy on a Tick chart ?
          i tried to add tick data series as secondary serie, using 1mn primary dataserie on a 1mn chart and it does not work.
          No, I am providing three different avenues where you can process on each tick. Please see my demonstration below for adding a single tick data series and observing the prints from the single tick data series. The Multi Time Frame and Instruments documentation is an important read for working with multi time frame scripts, so please be sure to follow that guide for a complete understanding on this topic.

          Demo - https://drive.google.com/file/d/1IFy...w?usp=drivesdk

          Code used:

          Code:
          protected override void OnStateChange()
          {
              if (State == State.SetDefaults)
              {
                  Description                                    = @"Enter the description for your new custom Strategy here.";
                  Name                                        = "MyCustomStrategy3";
                  Calculate                                    = Calculate.OnBarClose;
              }
              else if (State == State.Configure)
              {
                  AddDataSeries(Data.BarsPeriodType.Tick, 1); // BarsInProgress 1
              }
          }
          
          protected override void OnBarUpdate()
          {
              if (BarsInProgress == 1)
              {
                  Print(String.Format("Bar index for single tick data series: {0} Time[0]: {1} Close[0]: {2}", CurrentBar, Time[0], Close[0]));
              }
          }
          We look forward to assisting.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          53 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          130 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          70 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          44 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          49 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X