Positions closing around midnight on MetaQuotes Demo Server – SL triggered without visible price movement

 

Hi everyone,

I'm new to MT5 and currently testing some strategies using a demo account on the MetaQuotes-Demo server. I’ve noticed a strange recurring issue and wanted to ask if anyone else has experienced the same.

Every day, around 23:00 to 00:00 server time, several of my positions are closed automatically, supposedly by Stop Loss. However, when I check the price chart, the market price never actually reaches the SL level.

For example:

  • Trade #52816689863 (entry)

  • Trade #52817785786 (exit – SL hit)

  • Instrument: GBPNZD

  • SL: 2.23753

Looking at the chart (see attached screenshot), it's clear the price doesn’t touch 2.23753 — not even with spread taken into account — yet the position is closed by SL just before midnight. This has happened multiple times with different trades and symbols, always near the same time.

My questions are:

  1. Is this a known behavior of the MetaQuotes demo server?

  2. Could this be related to spread spikes, swap charging, rollover, or simulated liquidity gaps at end of day?

  3. Should I avoid using this demo server for backtesting or strategy evaluation during night hours?

Any guidance or insight from more experienced users would be greatly appreciated.

Thanks in advance!

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Account Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
To obtain information about the current account there are several functions: AccountInfoInteger() , AccountInfoDouble() and AccountInfoString() ...
 
As far as I know - there is bid price and there is ask price (and the charts show bid prices only).

Forum on trading, automated trading systems and testing trading strategies

How to use OrderTotal value as a variable

William Roeder, 2023.07.07 13:38

  1.   ticket = OrderSend (Symbol() , OP_SELL , 0.5 , Bid , 0 , Bid + 100*Point , Bid - 250*Point , "venda" , 0, 0 , Red ); //ordersend

    Why did you post your MT4 question in the MT5 EA section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
    Next time, post in the correct place. The moderators will likely move this thread there soon.

  2. You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by 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 at 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, average maximum spread = 134.
      My EURCHF shows average spread = 18 points, average maximum spread = 106.
      (your broker will be similar).
                Is it reasonable to have such a huge spreads (20 PIP spreads) in EURCHF? - General - MQL5 programming forum (2022)

  3. You check for the count to be zero and then open an order. Only then will your loop be run. The newly opened order will always be in loss (the spread).

----------------

You can see ask price on the chart (just to be sure that it is related to bid/ask prices for example):
MT5 - right mouse click on the chart - Proterties - Show ask price line

 
@Luis Pimentel #I'm new to MT5 and currently testing some strategies using a demo account on the MetaQuotes-Demo server. I’ve noticed a strange recurring issue and wanted to ask if anyone else has experienced the same. Every day, around 23:00 to 00:00 server time, several of my positions are closed automatically, supposedly by Stop Loss. However, when I check the price chart, the market price never actually reaches the SL level ...

During the end of the day, spreads widen drastically during swaps calculations. This usually means that the Ask price will increase and can knock out your stop-loss on "sell" positions if they are too tight.

Forum on trading, automated trading systems and testing trading strategies

error : automatic closing of sell position in loss instead of profit

Fernando Carreiro, 2025.01.15 04:44

It's called "spread"!

There is a Ask price and a Bid price. Charts only shows the bars/candles based on Bid (or Last) prices.

  • A "buy" position opens at the Ask price and closes at the Bid price.
  • A "sell" position opens at the Bid price and closes at the Ask price.
Enable the Ask price line on your chart so that you can track the current value visually.
 
undertood. thank you!