MT5 backtest bug - close a sell price on gap cause to open a buy position

 

my EA opens a short position and when reach to a certain profit level it tries to close it. but in this case the tp point is where there is a gap. in real life there shouldn't be a trade at that level. but more strangely asking to close a sell position lead to open a buy position. 


I wonder with these kinds of bug how backtest is reliable and what steps as an EA developer I can take to mitigate these kind of problem.


btw I appreciate if anyone could guide me how to report this issue or report it himself to MetaQuote.


 

There is no issue.

You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit and open at the Ask.

  1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

  2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close to a specific Bid price, add the average spread.
              MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

  3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
    Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY shows average spread = 26 points, but average maximum spread = 134 (your broker will be similar).

 
William Roeder #:

There is no issue.

You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit and open at the Ask.

  1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

  2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close to a specific Bid price, add the average spread.
              MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

  3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
    Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY shows average spread = 26 points, but average maximum spread = 134 (your broker will be similar).

thanks for your answer. but still it's buggy. enabling ask line cause the debugger to break and grayed out.tried it many times but I can't confirm it's spread that cause this since each time I enable the ask line it break the debugger windows


 
mh_amri:

my EA opens a short position and when reach to a certain profit level it tries to close it. but in this case the tp point is where there is a gap. in real life there shouldn't be a trade at that level. but more strangely asking to close a sell position lead to open a buy position. 


I wonder with these kinds of bug how backtest is reliable and what steps as an EA developer I can take to mitigate these kind of problem.


btw I appreciate if anyone could guide me how to report this issue or report it himself to MetaQuote.


You need to give code and details how to reproduce it if you think there is a bug. All the rest if just babbling and waste of time.

For now there is nothing to report.