Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bid Ask Spread cost simulation using Slippage Parameter

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

    Bid Ask Spread cost simulation using Slippage Parameter

    I have run some tests of using the "slippage parameter" to simulate B/A spread costs and am perplexed by the results.

    I expected that the average fill price when the "slippage parameter" is set to 1.0 ought to be 1.0 pips higher than the average fill price when the "slippage parameter" is set to 0.0 for a Buy order, and 1.0 pip lower for a Sell order.

    It appears that this is only the case for a fraction of the orders. Please see attached screenshot of my spread sheet comparing the average fill price for three back tests which were identical apart from having "slippage parameter" set to 0.0, 0.5 and 1.0 respectively. Corresponding, I assume, to a B/A spread of 0, 1 and 2 pips respectively.

    Surely every single order should be filled with the appropriate "slippage" - otherwise the mean slippage experienced will be lower than that expected from a consistent B/A spread 0, 1 or 2 pips respectively.

    Questions:
    i. How does NT select which orders get the slippage applied to them?

    ii. How can I make NT apply the "slippage parameter" to every order?

    iii. Could somebody please explain what is going on or what is wrong with my assumption that the "slippage parameter" should be applied to every trade. i.e. Why is NT handling slippage the wa it is?

    Thanks,
    Matthew.
    Attached Files

    #2
    Matthew, which order types did you use? For example for limit orders there's no slippage needed as if the simulation engine / backtest fill algorithm would report them as likely filled, they are filled and you 'get' the price specified.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,

      Thanks for the quick response. I used market orders, gtc. On a seperate issue I would like to find out how I can find out the best bid and ask inside my programs (I know it is not available in backtests, but I think the close is substituted in that case?) so that I can work out what to set the limit values to. I will ask about that later and seperately though, because I want to understand this current issue first.

      Please find attached another screenshot of a spreadsheet to further illustrate my issue.

      The data is from the Trades tab of the analyser output. Columns E and F are the entry and exit prices from the run with slippage set to 0.0. Column G is the profit calculated as (exit-entry)*quantity.

      Column H is what I expected the entry price to have been in the simulation with slippage set to 1.0. It is the entry price + 1.0. Column I is likewise, exit - 1.0. I.e. I am applying a hefty spread of 2 pips to every transaction.

      Column J is the profit I expect given the spread.

      Columns K and L are the actual entry and exit prices output from NT with slippage set to 1.0. I do not understand why they are not equal to columns H and I.

      Column M is the profit that NT calculates with slippage set to 1.0. It is clearly much higher than we would expect had a spread of 2 pips applied to each transaction.

      Do you know why columns K and L are not equal to columns H and I? That is my question.

      Thanks,
      Matthew.
      Attached Files

      Comment


        #4
        Please try to simplify this further - I just checked with a simple strategy going long on session begin via a market order and exit with a limit order target at 100$.

        Slippage would here be applied to the market order fill in historical backtesting, as the limit exit would not get slippage.

        With the slippage input set for example to 1 = 1 tick and I have an 'without slippage' entry reporting at 1170, I would then get a 'with slippage entry' at 1171.25, resulting also in a different placed profit target exit order of course.

        Were you expected this to see separately in the in the trades list like the commission for example? This will not be the case.

        Thanks
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Could you post the code that did this? Just to be sure that I am looking at exactly the same thing you are looking at.

          Thanks,
          Matthew.

          Comment


            #6
            Perhaps I could phrase things differently.

            In the image of the spreadsheet that I posted at 16:01 today, column K is not equal to column H and column L is not equal to column I.

            Should those columns be equal? I think they should be, because that is the only definition of slippage that I know of (i.e. the fill prices should be worse by the amount of slippage that is being applied). If they should not be equal, then can someone please explain why not.

            Thanks,
            Matthew.

            Comment


              #7
              Matthew, lets not complicate things here. Slippage is applied to stop orders and market orders. You will never get slippage on limit orders because they're filled at the price they're submitted at.

              The way NinjaTrader applies slippage is simple. It takes the price at which the order would be filled at and then either adds/subtracts the slippage in ticks.

              Please take a look at the attached screen shots of a one day (3/29/10) backtest of ES 06-10 5 Min with SampleMACrossover with no slippage applied and 1 tick slippage applied.

              The last trade is closed by an "Exit on Close" so it appears slippage is not applied to "exit on close" orders.
              Attached Files
              Last edited by NinjaTrader_Austin; 03-30-2010, 03:09 PM.
              AustinNinjaTrader Customer Service

              Comment


                #8
                Thanks Austin,

                The orders in my example were all market orders - so should slippage apply to all of the orders?

                Should the columns I refer to be equal?


                Thanks,
                Matthew.

                Comment


                  #9
                  Matthew, yes, if those are all market orders then they should all have slippage applied. Where did you get the spreadsheet from? If I'm reading it right, the columns should be equal.
                  AustinNinjaTrader Customer Service

                  Comment


                    #10
                    Please find attached images of the raw data from NT. Hopefully the file names are obvious, name ending in 0 is with slippage =0, 1 is with slippage = 1.

                    Things I find perplexing:

                    i) Column D of "execution0" (price) is only different for a few rows from "execution1", not all of them.

                    ii) Columns G, H, M and N of "trades0" are only different for a few rows from "trades1".

                    iii) Column I of "orders0" is only different to "orders1" for a few rows.

                    Should we expect these columns to be different between "slippage 0" and "slippage 1" at all rows?

                    Thanks,
                    Matthew.
                    Attached Files

                    Comment


                      #11
                      trades1 file.
                      Attached Files

                      Comment


                        #12
                        Hi Matthew, I agree it's strange you do not see slippage applied then to all trades / executions - do you see the same issue with for example using SampleMACrossOver on another instrument or even instrument type, so for example the ES June 1 min chart?

                        Which connection and data are you using while testing this?
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          I am using the barchart.com connection (not a free one, it's one I am paying for).

                          I will try out the ES MACrossOver with and without slippage later and get back to you on that.

                          Did you see my other post? It might be a related issue

                          Comment


                            #14
                            Thanks, please report back your findings - for the other issue with Immediate Fills enforced, I can get filled on extremly high lot sizes instantly as I was testing with BarChart. Have you tried the free Gain / Forex.com connection as well to compare?
                            BertrandNinjaTrader Customer Service

                            Comment


                              #15
                              The gain demo does fill limit orders immediately regardless of the size, but it does not allow the limit price to be above the ask. Those orders are rejected.

                              What is the gain demo data? I think it is bid only or something like that? I guess the question is, why does my BarChart.com take ages to fill limit orders but my gain demo fills them instantly (as soon as touched)?

                              Thanks,
                              Matthew.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Brevo, Today, 01:45 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post Brevo
                              by Brevo
                               
                              Started by aussugardefender, Today, 01:07 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post aussugardefender  
                              Started by pvincent, 06-23-2022, 12:53 PM
                              14 responses
                              238 views
                              0 likes
                              Last Post Nyman
                              by Nyman
                               
                              Started by TraderG23, 12-08-2023, 07:56 AM
                              9 responses
                              384 views
                              1 like
                              Last Post Gavini
                              by Gavini
                               
                              Started by oviejo, Today, 12:28 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post oviejo
                              by oviejo
                               
                              Working...
                              X