• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting Spread When Backtesting

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

    Setting Spread When Backtesting

    Is there a way to set the spread when backtesting through Market Replay? I have been searching for a while now, but I have not found any workable solutions.

    Just to illustrate with an example, I have been running my strategy repeatedly on EURUSD through the same period of time. The first position it enters has an Ask price of 1.06679 and a Bid price of 1.06678. This is a spread of 0.1

    I plan to use Forex.com as my broker. Their website states that the typical spread for EURUSD is 1.3 pips (https://www.forex.com/en-us/why-us/w...bility/pricing).

    This means that to accurately backtest EURUSD for my purposes, the example above would need an Ask price of 1.066855 and a Bid price of 1.066715 (roughly, since it wouldn't actually have that many decimal points).

    Is there any way for me to set that spread of 1.3 pips?

    In searching these forums, I did see it suggested that you can use slippage to simulate spread. However, I am not having any success with it. Perhaps I am doing something wrong. No matter what I enter for slippage, the Ask and Bid prices remain the same as when I had a slippage of 0. I even tried putting in ridiculously high slippage like 100 to no effect. I have also ensured that “enforce immediate fills” is not enabled.

    Any help would be appreciated, thanks!

    #2
    Hello geofftambler,

    Thank you for your note.

    Slippage is going to apply to market orders, and assuming your strategy gets in and out with market orders, adding a slippage value would be a way to discount returns. However, as of now, NinjaTrader restricts fills to within a current bar. For example if you had a stop which was triggered at 50:50, which was also the low of a 15 minute bar, NinjaTrader would not fill this order outside the bar, thus slippage would be ignored. No slippage would be applied if you were submitted a order to a secondary tick series, another limitation of the current backtesting logic.

    I will add your vote to SFT 1137 which would remove this restriction of fills to within the current bar.

    A solution for you might be to create your own performance metric, which you could have total net profit adjusted, for example creating MyTotalNetProfit =TotalNetProfit-1.3*Trades*2.

    I do not have a sample of how this could be done but you could open the NinjaScript Editor and see in the Performance Metric Folder>SampleCumProfit.

    You should also see the following two links,

    https://ninjatrader.com/support/help...ce_metrics.htm
    https://ninjatrader.com/support/help...ric_values.htm

    If you do not have programming experience I can follow up with a list of third parties that would be interested in programming this for you.

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Hi AlanP,

      Please put me down for SFT 1137 as well.

      Thanks!

      Comment


        #4
        Hello wadams,

        Will do, thanks!

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by PeterGolz, 01-17-2020, 10:42 AM
        11 responses
        72 views
        0 likes
        Last Post reubenlasky  
        Started by utilizator, Today, 11:36 AM
        0 responses
        4 views
        0 likes
        Last Post utilizator  
        Started by EnveousColnago, Today, 07:24 AM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Started by tornadoatc, Today, 10:31 AM
        0 responses
        3 views
        0 likes
        Last Post tornadoatc  
        Started by EnveousColnago, Yesterday, 05:43 PM
        5 responses
        30 views
        0 likes
        Last Post EnveousColnago  
        Working...
        X