Not setting a spread on a backtest.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #89482 quote
    Shitforbrains
    Participant
    Average

    Hi,

     

    Sorry if this is a stupid question, but what would the difference be if I backtest a system with a 1 pip spread and 25 pip stop-loss vs. just setting a 26 pip stop-loss?

    Regards,

    #89488 quote
    GraHal
    Participant
    Master

    1/2 / half / 0.5  a pip? 🙂

    You could try it in less than 5 mins?

    Let us know?

    I’ll try it when I next have my Platform open. I just closed all 4 Platforms as everything was getting jumpy due to RAM Hogging!

    #89531 quote
    Shitforbrains
    Participant
    Average

    Yep there’s a difference. 🙂 Have a look at these pics. And also the code:

    DefParam FlatBefore = 090000
    
    DefParam FlatAfter = 130000
    
    Defparam cumulateorders=false
    
    
    xClose = (Open+High+Low+Close)/4
    
    
    if(barindex>2) then
    xOpen = (xOpen[1] + xClose[1])/2
    endif
    
    c1 = xClose>xOpen AND xClose[1]<xOpen[1]
    c2 = xClose<xOpen AND xClose[1]>xOpen[1]
    
    if c1 AND Not LongOnMarket then
    BUY 1 SHARE AT MARKET
    EXITSHORT AT MARKET
    endif
    
    if c2 AND Not ShortOnMarket then
    SELLSHORT 1 SHARE AT MARKET
    SELL AT MARKET
    Endif
    
    
    SET STOP $LOSS 95
    
    SET TARGET $PROFIT 85

    The first pic shows a backtest with 1 pip spread on the DAX. Stop loss 95, limit 85. The second pic shows the same system but with stop loss 96 and limit 84. I always get better results when I don’t define the spread. Any idea how there can be a difference between these two?

    Skärmavbild-2019-01-24-kl.-09.08.48.png Skärmavbild-2019-01-24-kl.-09.08.48.png Skärmavbild-2019-01-24-kl.-09.09.29.png Skärmavbild-2019-01-24-kl.-09.09.29.png
    #89539 quote
    jebus89
    Participant
    Master

    Spread = cost.

    You need to pay for every trade(in and out) that you make.
    If you code it “into the stop loss” then ur not seeing that cost on every trade that does not hit stop loss.

    lets say you take a trade and it hits target. if you have your “spread” coded into your stop loss then that trade would be free, when in fact in real life that trade would have cost u the spread for in and out.

    Shitforbrains thanked this post
    #89552 quote
    GraHal
    Participant
    Master

    The second pic shows the same system but with stop loss 96 and limit 84.

    Are you saying you had no spread entered in the box in the above example?

    If yes to above , then isn’t above equivalent to a spread of 2 (whereas you had spread = 1 when Stop loss 95, limit 85).

    Coffee has not woken my brain yet my suggestion above may be wrong?

    #89559 quote
    Shitforbrains
    Participant
    Average

    Spread = cost.

    You need to pay for every trade(in and out) that you make.

    If you code it “into the stop loss” then ur not seeing that cost on every trade that does not hit stop loss.

    lets say you take a trade and it hits target. if you have your “spread” coded into your stop loss then that trade would be free, when in fact in real life that trade would have cost u the spread for in and out.

    Okey, great answer. So I could basically go through each and every trade that doesn’t hit stop or limit to calculate how much the spread cost would be for those specific trades.

    #89561 quote
    jebus89
    Participant
    Master

    Easiest way if ur unable to add spread/cost into your backtest then you can basicly just take your amount of trades (correct me if im wrong here anyone) and mulitply them with the average spread, then multiply that with 2.

    100 trades * 1 pip (average spread) = 100 pips * 2 (1 for entry and 1 for exit) => 200 pips cost for doing 100 trades

    Note that for example IG have different average spread depending on the time of the day.

    Guessing this method is not the most accurate one because the spread does ultimately change your target and stop loss, depending on how youve coded ur system.

    if ur using PRT just put the spread in.

    #89562 quote
    Shitforbrains
    Participant
    Average

    The second pic shows the same system but with stop loss 96 and limit 84.

    Are you saying you had no spread entered in the box in the above example?

    If yes to above , then isn’t above equivalent to a spread of 2 (whereas you had spread = 1 when Stop loss 95, limit 85).

    Coffee has not woken my brain yet my suggestion above may be wrong?

    Hmm, but both system would stop out at the same level if I run the backtests like this right? The one that has 86 pip stop loss would stop out on the same price as with 85 pip stop loss with spread included.

    #89573 quote
    jebus89
    Participant
    Master

    You need to pay for entry as well as exit. if your stopping urself out 1 pip less, or taking a profit target 1 pip less, then thats just 1 pip. You would need 2. But this is affecting your backtest because your now moving your stop loss and target to try to calculate the spread, when you could actually just add the spread into backtest.. Also if you have trades that do not hit stop or target (but exit via an actual exit or trailing stop loss) then ur calculations are off again.

     

    just add the spread and accept the hardship hehe

     

    Example: lets say your “range” is profit target – stop loss = 50 pips. if you now start to remove pips to calculate for the spread ur new range would be 46, that might be a very big change in your system depending on ur pip pr trade on avg. (because ur removing 2 pips from the target, but also from your stop loss, leaving u with a much smaller range than your system normally would have if you just add the spread in the backtest.

    #89575 quote
    GraHal
    Participant
    Master

    100 trades * 1 pip (average spread) = 100 pips * 2 (1 for entry and 1 for exit) => 200 pips cost for doing 100 trades

    Unless my coffee STILL hasn’t worked through 🙂 if the spread = 1 then that is all you pay re spread costs?

    Ask – Bid = 1 so you buy at the Ask and sell at the Bid, cost 1 pip?

    #89633 quote
    Shitforbrains
    Participant
    Average

    All in all I think it’s best not to mess around with the spread considering there will be a lot of trades closed without hitting stops or limits.
    Thank you guys for the answers. 🙂

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.

Not setting a spread on a backtest.


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 10 replies,
has 3 voices, and was last updated by Shitforbrains
7 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/23/2019
Status: Active
Attachments: 2 files
Logo Logo
Loading...