Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to set spreads to backtest

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

    How to set spreads to backtest

    Hello guys,

    i have one issue, i have my strategy script and i do backtest in FOREX. I need to set some fix spread to my backtest, is it possible ?

    #2
    fLife, what order types do you use? You could for example set something fixed in via the Slippage property.

    BertrandNinjaTrader Customer Service

    Comment


      #3
      I thought that, it can be slippage, i use market and limit orders. Let me know if understand properly.
      If i set slippage 2, Is it gonna behave like spread ? So i will got spread going "in" and going "out" of position ?

      I have set half pips, so if i wanna simulate spread 5, have i set slippage 10 ? am i correct ?

      thanks for reply !

      Comment


        #4
        fLife, yes you are correct in understanding - slippage would allow to apply an offset to each execution seen via a market order. Since limit orders could not have slippage, you will either get your price specified or won't get filled.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Thank you a lot, now its clear, but again ...for sure ..if i set half pips, so if i wanna simulate spread 5, have i set slippage 10 ? Thank you !

          Comment


            #6
            Hello, i set slippage to 50 (i have set forex to half pips) and after that, with the same script, i set slippage to 10. As u can see in screenshots, there are really similiar entry prices and exit prices. How is it possible ?
            Attached Files
            Last edited by fLife; 09-04-2014, 07:47 AM.

            Comment


              #7
              fLife, for the entry bar, what bar high would you have? Slippage could not take the execution outside of the bar, so there's a cap.
              BertrandNinjaTrader Customer Service

              Comment


                #8
                So if i will trade on 1h bars and more ...there is biggest change to hit slippage in one bar ? So i am limited of bar height ?

                Comment


                  #9
                  Correct as far as the slippage goes. If you have bid / ask data you could create for example a MultiSeries script as well to execute on those series and thus include the spread.

                  Another option would be adding in a commission 'penalty' for the script to simulate the spread.
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Is there a posibility to do executions outside of bar, in backtest ? Because in real time trading it has happend. I am trying as accurately as possible to be close to results between backtest and real time trading. The option of adding more commisions its good idea, but it doesnt reflect entry prices and exit prices like spread, as you know. Thank you a lot !

                    And second question, after you advice, may i write script with simulated spreads ? Do you have any useful link ? Thank you!

                    Comment


                      #11
                      We would not have really documented this unsupported area, but there would be the possibility to work with a customized filltype that would determine how you want your fills to come back, for example consider this simple snippet for market order fills -

                      if (order.OrderType == OrderType.Market)
                      {
                      if (order.OrderAction == Cbi.OrderAction.Buy || order.OrderAction == Cbi.OrderAction.BuyToCover) // set fill price
                      FillPrice = (NextOpen + SlippagePoints);
                      else
                      FillPrice = (NextOpen - SlippagePoints);
                      }

                      Here we then just say use the next open price +- my entered slippage per execution - this is contrast to the default type limiting that to the Min Max of that price vs the bar high / low.

                      Here would be an example for getting started sending orders to another internal added series - http://www.ninjatrader.com/support/f...ead.php?t=6652

                      This would not need to be another timeframe, but could also be a bid / ask price series (MarketDataType).

                      Attached Files
                      BertrandNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Belfortbucks, Today, 09:29 PM
                      0 responses
                      3 views
                      0 likes
                      Last Post Belfortbucks  
                      Started by zstheorist, Today, 07:52 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post zstheorist  
                      Started by pmachiraju, 11-01-2023, 04:46 AM
                      8 responses
                      150 views
                      0 likes
                      Last Post rehmans
                      by rehmans
                       
                      Started by mattbsea, Today, 05:44 PM
                      0 responses
                      6 views
                      0 likes
                      Last Post mattbsea  
                      Started by RideMe, 04-07-2024, 04:54 PM
                      6 responses
                      33 views
                      0 likes
                      Last Post RideMe
                      by RideMe
                       
                      Working...
                      X