Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Analyzer - why does the trading signal not pass at the close of the bar ?

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

    Strategy Analyzer - why does the trading signal not pass at the close of the bar ?

    Hello!
    Why does the trading signal not pass at the close of the bar when testing ?
    Attached Files

    #2
    This is when testing via LineBreak.

    Comment


      #3
      Hello,

      Thanks for your post.

      Is this in reference to an alert that you have configured to submit an order, or a NinjaScript Strategy, or something else?

      I look forward to your reply.
      Marco G.NinjaTrader Customer Service

      Comment


        #4
        This is my strategy. The indicator when crossing the line "0" generates a buy signal, when crossing below "0" to sell. But as you can see on the chart, the deal closes only at the beginning of the next bar. How can I make the deal close in tests at the end of the bar on which the signal formed.
        This is exactly what happens when testing on a demo account.

        Comment


          #5
          Hello jonrussia,

          Thank you for your reply.

          There are several methods your strategy can use to calculate when running on live data on a chart or on Market Replay data. You can choose to run the strategy On Bar Close, which is what appears is occurring here, On Price Change, or On Each Tick. On Bar Close means that your logic will be evaluated only once per bar, when it closes. Any orders generated by a signal will be entered on the bar following the signal bar in this case. On Price Change and On Each Tick allow for intrabar entry.

          Also, you should expect that a strategy running real-time (live brokerage account, live market simulation, Market Replay etc...) will produce different results than the performance results generated during a backtest using historical data on a chart or in the Strategy Analyzer. This difference may be more easily seen on certain Bars types (e.g. Point and Figure) than others due to their inherent nature in bar formation.

          During a backtest you can select conservative or liberal fill algorithms which will produce different results. Fills are determined based on 4 data points, OHLC of a bar since that is the only information that is known during a backtest and there will be no intra-bar data. This means actions cannot happen intra-bar, fills cannot happen intra-bar. All prices and actions come from and occur when the bar closes as this is all the information that is known.

          Because of this, OnBarUpdate will only update 'On bar close' in the Strategy Analyzer or on Historical data as it does not have the intra-bar information necessary for 'On price change' or 'On each tick'.

          Also, here is a link to the differences on real-time vs backtest (historical).


          Adding intra-bar granularity can help with this.

          Intra-bar granularity adds a second data series such as a 1 tick series so that the strategy has finer granularity in the historical data in between the OHLC of the primary series. This allows for more accurate trades by supplying the correct price at the correct time for the order to fill with.

          In NinjaTrader 8, there have been two new enhancements so that programmers do not have to manually add this secondary series and code the script to for high accuracy fills (Order Fill Resolution) and for intra-bar actions (TickReplay).

          Here is a link to our forums that goes into depth on using Order Fill Resolution and Tick Replay to ensure your backtests are as close to real time results as possible:

          Citizens of the NinjaTrader Community, A common question we hear from clients is 'why are results from backtest different from real-time or from market replay?'. Live orders are filled on an exchange with a trading partner on an agreed upon price based on market dynamics. Backtest orders are not using these market dynamics.


          High Fill Order Resolution and TickReplay cannot be used together. If it is necessary to have both, it is still possible to add intra-bar granularity to a script in the code itself for order fill accuracy and use TickReplay to update indicators with Calculate set to OnPriceChange or OnEachTick historically.

          Please let us know if we may be of further assistance to you.
          Kate W.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Shansen, 08-30-2019, 10:18 PM
          24 responses
          938 views
          0 likes
          Last Post spwizard  
          Started by Max238, Today, 01:28 AM
          0 responses
          3 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by rocketman7, Today, 01:00 AM
          0 responses
          2 views
          0 likes
          Last Post rocketman7  
          Started by wzgy0920, 04-20-2024, 06:09 PM
          2 responses
          27 views
          0 likes
          Last Post wzgy0920  
          Started by wzgy0920, 02-22-2024, 01:11 AM
          5 responses
          32 views
          0 likes
          Last Post wzgy0920  
          Working...
          X