Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Market Replay Inconsistent trades

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

    Market Replay Inconsistent trades

    Hello all,

    This is my first post so please excuse me if I don't describe this well. I am new to Ninja Trader and C# so have been climbing a very steep learning curve.

    I have been trying to test a fairly basic strategy in using Market Replay. I found that at any replay speed ( even x1 ) the orders are sometimes being executed at prices that in no way match the tick data.

    I have tried replay data from two sources, Ninja and MarketReplay.net.

    Having found a serious incident of mismatch I tested the SampleMACrossOver strategy and this fails at about the same point in the data.

    Backtest gives correct results but with all trades at least one bar late is of no practical use in testing profitability.

    Could anyone help me to correct this as I cannot test my strategy if trades are being placed sometimes over 9 ticks away from the actual price boundaries?

    Sorry images did not attach, trying again.

    I have not only tried two different data sources.
    I have tried on two different machines, one 32 bit and one 64 bit.
    I have tried assigning just one processor core also as that appeared to be an issue described in one thread.
    I am running on version 7.0.1000.25

    Thank you in advance...
    Attached Files
    Last edited by ManicMonk; 09-09-2014, 06:29 AM.

    #2
    Hello ManicMonk,

    Thank you for your post.

    What instrument are you using?

    What dates are you running the replay on?

    What time frame are you running the charts on? Daily, Minute, tick, etc.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hello NinjaTrader_Cal.

      I am on ES 09-14 on 610 tick chart and the images provided are from the first of August 2014.
      I am trading on UTC+0 timezone.

      However this behaviour appears on many dates at many times

      Comment


        #4
        Hello ManicMonk,

        Thank you for your info.

        Could you please send me your strategy, so I can test this on my end with the Market Replay?
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Thank you NinjaTrader_Cal for your prompt reply.

          This happens with Ninja's default sample strategy SampleMACrossOver, as shown in one of the earlier attached images.

          Just test it on ES 09-14, 610 Tick, 1st August 2014 (@ about 13:32 UTC+0 I believe).You will see a Buy at 1915.50 where the respective Low of that bar is at 1923.25

          All test data is clean, deleted, reloaded, repaired, second source tried, etc.

          Again, thank you for your help.

          protected override void Initialize()
          {
          SMA(Fast).Plots[0].Pen.Color = Color.Orange;
          SMA(Slow).Plots[0].Pen.Color = Color.Green;

          Add(SMA(Fast));
          Add(SMA(Slow));

          CalculateOnBarClose = true;
          }

          /// <summary>
          /// Called on each bar update event (incoming tick).
          /// </summary>
          protected override void OnBarUpdate()
          {
          if (CrossAbove(SMA(Fast), SMA(Slow), 1))
          EnterLong();
          else if (CrossBelow(SMA(Fast), SMA(Slow), 1))
          EnterShort();
          }
          Last edited by ManicMonk; 09-09-2014, 08:17 AM.

          Comment


            #6
            ManicMonk,

            I ran the same test and got the same results. So I checked the tick ask data from the 8/1 replay data and found there is an issue with the ask tick data (you can view this on a chart if you load 1 tick with the price based on last to see what I mean). In other words the low of the ask price was right at where the order filled.

            I was able to confirm that the current data does not have this issue and I will forward a note to our IT department to take a look at the market replay data for this day.

            If you run the script through yesterdays data this should not be an issue.

            Please let me know if I may be of further assistance for you.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Hello NinjaTrader_Cal

              Yes indeed, the Market Replay data is clearly bad at that point. However that was just an extreme example of what is happening in my testing all over the place.

              However, I am still left confused. I understand that my confusion may stem from a basic lack of understanding on how the trading system works. If so, please excuse my ignorance.

              When simulating on a Last price chart, should the Last price range be used to evaluate the maximum/minimum fill price, In other words, right now I am getting some fills in mid-air, not on the bar at all. Is this correct? Using the extreme values of the bid/ask spread to simulate fills seems a bit crazy as those prices would often not be realized on a last chart.

              Also I saw a link elsewhere in this forum to a description of the Simulator algorythm. The link was dead. Is this information available elsewhere?

              Comment


                #8
                ManicMonk,

                The last price is not a matter of the fills.

                Buy orders will get filled at the Ask price and Sell orders will get filled at the Bid price.

                If you are seeing these orders get filled out of bar, then you need to check the Bid/Ask data for that same time and see where those prices were.

                I'm not about the algorithm being available but are you talking about how the Sim101 fills orders?
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  Yes NinjaTrader_Cal,

                  I would like the Sim101 fill rules for filling orders.

                  Thank you.

                  Comment


                    #10
                    ManicMonk, this would be a proprietary engine to simulate the fills - all info we would have is documented here online about it - https://www.ninjatrader.com/support/...simulation.htm
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      So don't you guys at NT feel there should be a configurable option to fill on last instead of bid/ask? Shouldn't be hard to implement.

                      Comment


                        #12
                        Hello User13,

                        Thank you for your post.

                        The Last Price would either be Bid or Ask, can you provide a scenario where you would only need the last price (not knowing if it is bid or ask) to fill the order?

                        Comment


                          #13
                          Originally posted by NinjaTrader_PatrickH View Post
                          The Last Price would either be Bid or Ask
                          Not necessarily the most recent Bid or Ask - some Bids or Asks never become Last - to my understanding that's what the issue is about. So when you simulate fills on Bids or Asks you can get fills on prices that never traded.

                          Comment


                            #14
                            All trades occur at either the ask or bid price. There may be situations where you are filled in between the bid or the ask if there is a large spread between these values, however the last price has nothing to do with the price orders are filled in a live environment and as such our simulator does not consider last price when simulating fills. The issue you are seeing is not related to the simulator logic used in market replay.

                            The issue you face is a noted limitation where our last price may become out of sync with the bid/ask when using replay that we have taken steps to resolve in the next major release of NinjaTrader 8. Our replay data will be stored in a single file which will prevent these situations where the last price recorded is out of sync with the bid/ask price.
                            MatthewNinjaTrader Product Management

                            Comment


                              #15
                              Originally posted by NinjaTrader_Matthew View Post
                              the last price has nothing to do with the price orders are filled in a live environment and as such our simulator does not consider last price when simulating fills.
                              In live environment when order is filled at bid or ask that price becomes last. This issue, as I see it, is about sim assuming that every bid or ask price becomes last, what is not true. Therefore sim sometimes fills orders at bids or asks which never became last in live environment - no single fill happened at that bid or ask price before it changed. Sim fills at bid or ask without taking this into account.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by judysamnt7, 03-13-2023, 09:11 AM
                              4 responses
                              59 views
                              0 likes
                              Last Post DynamicTest  
                              Started by ScottWalsh, Today, 06:52 PM
                              4 responses
                              36 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by olisav57, Today, 07:39 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post olisav57  
                              Started by trilliantrader, Today, 03:01 PM
                              2 responses
                              21 views
                              0 likes
                              Last Post helpwanted  
                              Started by cre8able, Today, 07:24 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post cre8able  
                              Working...
                              X