Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Strategy Analyzer with Bid/Ask Prices

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

    Using Strategy Analyzer with Bid/Ask Prices

    I have been using market-replay to backtest my strategy since my strategy buys at the bid and sells at the ask. My understanding is that market-replay is the most accurate way to have these orders filled for testing purposes. First, is that correct? That backtesting will not fill my BID/ASK orders as accurately as market-replay.

    Second, don't I face the same situation with the Strategy Analyzer? I'm presuming that SA does not have the ability to use market-replay data - please tell me if I am wrong. So, I have not been using SA figuring it is not much use to me because of the importance of my strategy using bid and ask prices. Do I understand this correctly?

    #2
    Hi scottreynolds,

    Yes, market replay is a simulated real time feed, so does not have some of the typical discrepancies you would see backtesting compared to running a strategy real time.

    The strategy analyzer is the backtesting feature in NinjaTrader. It's only used on historical data. It's not connected to market replay which is a separate connection you initiate through File > Connect > Market replay.

    Market Replay works if you have downloaded or recorded market replay data.

    Please click here for detailed instructions on downloading and recording market replay data
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      My understanding is that back-testing only looks at bar close while market-replay processes each incoming tick, thereby making market replay more accurate. What does the Strategy Analyzer use? Does it use bar close or tick data? Does it have the option to use either one?

      Comment


        #4
        Hi Scott, the Strategy Analyzer backtesting using the OHLCV series data on bar close only per default, for simulating intrabar fills you could add a finer series though to your strategy -

        You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by

        Comment


          #5
          I looked at the example that you reference. In the example, the strategy works off a 5 min chart. In the Initialize event, it adds a 1 minute time series:

          Code:
          Add(PeriodType.Minute, 1);
          but I'm not sure exactly how this helps Strategy Analyzer?

          In my case, my strategy uses a 400 tick chart. I have been using market-replay with limit orders - buy at the bid, sell at the ask, for my backtesting. I don't want Strategy Analyzer backtesting to just use OHLCV series on bar close - I want it to process ticks.

          Am I to add a secondary time series in the Initialize event so that SA has the granularity to process my limit orders? What secondary time series would I add?

          Comment


            #6
            To have granularity in the strategy analyzer, add a secondary series that's smaller than the primary. You can add down to 1-tick level if you like, but the more bars processed will increase the duration of the backtest. Adding a series doesn't automatically add intrabar granularity. You can submit orders to a specific series using the advanced overload available with all order methods.

            EnterLong(int barsInProgressIndex, int quantity, string signalName)
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Thanks, the clarification is helping a lot. You say:

              Originally posted by NinjaTrader_RyanM View Post
              Adding a series doesn't automatically add intrabar granularity.
              Can you expand on this? If it doesn't add intrabar granularity, what does it add?

              I think you see what I am trying to do. Is adding a secondary 1-tick series the best way to approach my getting tick level data to best simulate fills at bid and ask prices using Strategy Analyzer?

              Comment


                #8
                scottreynolds,

                I am responding on behalf of Ryan.

                When adding a second data series for the purpose of adding intrabar granularity you must add a data series that has a shorter period than the main data series.

                For more information, please see the following link.



                To get tick level data you can add a secondary tick data series. However, it sounds like you want to enter on tick based data, and as such you can use a BarsInProgress index for the order method.

                If you add a second tick-based data series, its BarsInProgress is set to 1, so something like :

                EnterLong(1, quantity, signalName);

                Would work to enter on tick based updates. Please find some more information below.

                EnterLong() : http://www.ninjatrader.com/support/h...?enterlong.htm

                BarsInProgress : http://www.ninjatrader.com/support/h...inprogress.htm
                Last edited by NinjaTrader_AdamP; 11-16-2011, 08:13 AM.
                Adam P.NinjaTrader Customer Service

                Comment


                  #9
                  clarifying intrabar granularity

                  just to clarify from the below post...

                  if I'm running a daily strategy (ie: entries on daily bars) / primary data series is daily, and I add tick bid and ask data in the init. routine, and I enter trades from the daily bar closes (ie: barsInProgress == 0), will my stops and profit targets be using the tick data to work out which hits first,
                  ie; I want to make sure that the tick data is being used to capture the actual price movement during each day, so if I have small profit targets and stop losses (eg: 0.2 ATR) I get accurate results of what would have happened during trading live

                  I want to make sure I don't have to enter the order a different way (for example, explicitly referencing the tick data series), eg: EnterLong(barsInProgressIndex, ...)

                  thanks

                  Comment


                    #10
                    Hi PolarBear, just adding granularity in would not be enough - you would need explicitly submit the orders to the added series via the advanced overloads in the entry / exit order methods.

                    Especially if you're using the Set methods for stops / targets - those would not by submitted to the added, finer series.

                    Enhancing those aspects for more convenience is on our feature list in product management for the next major platform update - added your request in here as well.

                    Comment


                      #11
                      thanks for the reply.

                      Looking through the methods, I only see the dataseries referenced in the order entry functions eg: EnterShort().
                      I can't see anywhere to reference the dataseries in the setProfitTarget or stop loss methods.

                      Can you confirm I just need to reference in the order entry and this will then use the fine granularity.

                      eg:
                      EnterShort(MAIN_INDEX_BID, myLots, TradeName);


                      thanks again

                      Comment


                        #12
                        This would only help for the entries, it would not take care of submitting to the finer series for the exits done via the Set methods. Those will always work on the primary series. To backtest this setup with more accuracy, remove the Set's and replace by the more advanced Exit() calls, for example the limit order target would be done by ExitLongLimit / ExitShortLimit then > those you could point towards a specific bars index to process against.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        649 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        370 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        109 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        574 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        576 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X