Why StopLoss hit was triggered, yet the price never touched that limit ?

 

Dear Members

I am running a strategy in Tester and come across a situation where the stop loss hit was triggered and yet the price never reached that price level. The attached screen shot will explain it better.

Any clues why this is happening?

WhySLHit

 
Anil Varma: where the stop loss hit was triggered and yet the price never reached that price level.

It did.

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)

 

Forum on trading, automated trading systems and testing trading strategies

MT4 Backtesting Problem, Buys and Sells not within bar range

Fernando Carreiro, 2023.01.02 19:09

It is called "spread"! There is a Ask price and a Bid price. Charts only shows the bars/candles based on Bid 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.

 
William Roeder #:

It did.

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)

Thanks @William Roeder / @Fernando Carreiro

This is useful information, I was unaware of. I will try to implement these suggestion.

 
First thought is that spread is responsible here – the charts are displayed by bid price, and sell trade is closed by Ask price so ask price is marked as close price but still the chart show bid price (which might be a few pips lower – depend on what the spread was).
 
Marzena Maria Szmit #:
First thought is that spread is responsible here – the charts are displayed by bid price, and sell trade is closed by Ask price so ask price is marked as close price but still the chart show bid price (which might be a few pips lower – depend on what the spread was).

Thanks a lot @Marzena Maria Szmit

Yeh seems to be the cause. I will have to find some time and explore it in detail.

 

Hello, I have the same problem, spread is nice explanation some times but is it possible that the same situation occur any day at midnight?

Here some example from a EURGBP backtest of October 2023, if I keep some position overnight it take stop loss at 00.00 (sound odd to me that each day at midnight thespread became so uge to take the SL), what do you think about it?


I am using CTrade class.


Regards

Valerio

 
Valerio Riggi #: but is it possible that the same situation occur any day at midnight?

What midnight? Your local time, mine, your broker's time, FX end of day?
     How To Ask Questions The Smart Way. (2004)
          Be precise and informative about your problem

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)

Reason: