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.

    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.

        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.

              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.

                  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

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by argusthome, 03-08-2026, 10:06 AM
                      0 responses
                      71 views
                      0 likes
                      Last Post argusthome  
                      Started by NabilKhattabi, 03-06-2026, 11:18 AM
                      0 responses
                      43 views
                      0 likes
                      Last Post NabilKhattabi  
                      Started by Deep42, 03-06-2026, 12:28 AM
                      0 responses
                      25 views
                      0 likes
                      Last Post Deep42
                      by Deep42
                       
                      Started by TheRealMorford, 03-05-2026, 06:15 PM
                      0 responses
                      28 views
                      0 likes
                      Last Post TheRealMorford  
                      Started by Mindset, 02-28-2026, 06:16 AM
                      0 responses
                      56 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Working...
                      X