How to change spread during backtesting ?

 

Hi. All

I spent nearly 8 hours to find out how to change spread during backtesting and optimization.

I googled everywhere even thinking of using paid software on the net. Please don't do that.

MT4 has a built in feature so you can change spread during backtesting or optimization.

Just sharing this just in case someone want to do the same things.

Kind regards.


 
Young Ho Seo:

Hi. All

I spent nearly 8 hours to find out how to change spread during backtesting and optimization.

I googled everywhere even thinking of using paid software on the net. Please don't do that.

MT4 has a built in feature so you can change spread during backtesting or optimization.

Just sharing this just in case someone want to do the same things.

Kind regards.


Of course.
 

What I would really like to know is:

  • Does changing the spread significantly affect optimisation / backtest results?
  • If so, how does it do this?
  • How much is the affect?
  • Do results vary depending on the instrument being backtested / optimised?
  • Some examples would greatly help to illustrate any answer to my questions!

 

Hi Mathew

  • Does changing the spread significantly affect optimisation / backtest results?  --- Yes
  • If so, how does it do this?  --- high spread give less profit to you (but more for brokers)
  • How much is the affect?   --- it is affected in a way that "your profit - spread". So they can affect as big as spread
  • Do results vary depending on the instrument being backtested / optimised? --- Yes,
  • Some examples would greatly help to illustrate any answer to my questions! --- Here.

  • It is little bit interesting why the system got more profit with spread = 50 than spread = 2. So this is not exactly the classic example of high spread = small profit scenario. One of the reason behind this is that I built this system in high spread environment like around 5 pips (50 points).

    But even this system does not make much profit if spread = 100 points (10 pips). It will probably lose money if spread = 200 points (20 pips) I guess. No trick to bend this physical law (high spread = less profit for us). Teach me if you have one. :)

    Regards.



     
    I'm looking for this option on MT5, does anyone knows ?
     
    Jerkha13:
    I'm looking for this option on MT5, does anyone knows ?

    It's a GIF, click on it.
     

     

    set spread

    then in strategy tester , it doesn't change 

    spread didn't change


    How do you change the spread within the Strategy Tester? 

    Working with build 2485

     
    torytory:

    then in strategy tester , it doesn't change 


    How do you change the spread within the Strategy Tester? 

    Working with build 2485

    is there a forum thread with ALL known bugs and issues with MT5 product? 

     

    I found a work-around solution for this using both methods TesterDeposit() and TesterWithdrawal().

    Let's say the average spread on USDJPY is 0.006 (6 points) and as per the backtesting terminal it shows 0.01. Since the difference is 4 points, you can use TesterDeposit() to simulate a rebate for the account by that amount.

    The other way around, if the backtesting terminal shows spread less than the real spread by your broker, you can simply deduct the difference using TesterWithdrawal().

    The below code will demostrate further.


    double Ask = NormalizeDouble(SymbolInfoDouble(Symbol(), SYMBOL_ASK), _Digits);
    double Bid = NormalizeDouble(SymbolInfoDouble(Symbol(), SYMBOL_BID), _Digits);      
    double terminalSpread = ((Ask - Bid) * 100000) / Ask;         //Get the current spread in USD form
    double rebate = terminalSpread - 6.85;                        // 6.85 is my broker total cost (spread + commission) in USD.
    if(rebate > 0){TesterDeposit(rebate); rebates += rebate;}else if(rebate < 0){TesterWithdrawal(MathAbs(rebate)); rebates -= rebate;} //If rebate > 0 then credit the difference, if rebate < 0 then deduct the difference.
    


    Good luck!

    Reason: