For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Different results with MT4 for the same data

  • Hi,
    I exported the history data from my MT4 application and used them as data input for backtader.

    My test strategy is trivial: Buy/Sell when two MAs cross over. The same simple algorithm is implemented in backtrader and MT4 and applied to the same data.

    The results which I get using MT4 and backtrader are not same: sometimes the buy/sell operation is executed in the same time on both platforms but sometimes not (more often).

    Does anybody have similar experience? What could be the reason?


  • administrators

    A real (as real as possible) diagnostic could be attempted if at least a couple of data samples and buy/sell operations were provided. And furthermore if you use Market or Limit orders for example.

    A code sample would be even more helpful.

    In any other case one can only make an educated guess.

    The educated guess assumes you use Market orders and that MT4 lets you buy the close of the bar you are evaluating. Be it the case, that is unrealistic, because a bar which you see is already closed, and giving you the close of the bar is giving you a price which is no longer available (it may become available later in a yet-to-be-delivered bar)

    It can be a good approximation. Such a behavior can be enabled with cheat-on-close in the backtrader broker. All assuming the educated guess is not educated and not a guess.

  • Thanks @backtrader ! I will provide the code samples and history data as soon as I find a time.

Log in to reply