stop orders not filled in strategy tester

 

Hi all, I'm testing an expert in strategy tester.

Stop orders are correctly placed from the expert, but for some reason are not filled when price level is triggered.

Parameters order are settled as follow, without slippage parameters or similar.

      request_3.action=TRADE_ACTION_PENDING; 
      request_3.type=ORDER_TYPE_SELL_STOP;  
      request_3.price=Entry_Price; 
      request_3.magic=1 ;                     
      request_3.symbol=_Symbol;               
      request_3.volume=Get_Size(0,Risk,Distanza_Short);            
      request_3.sl=Stop_Short;                 
      request_3.tp=Take_Profit_1_;  
      request_3.comment="Trigger 2";
      request_3.type_time=ORDER_TIME_DAY;

When price level is trggered, then the stop price cell become yellow as below, but the order is not filled. Could you indicate the reason? Thank you


 
  1. 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. Prices (open, SL, and TP) must be a multiple of ticksize. Using Point means code breaks on 4 digit brokers (if any still exists), exotics (e.g. USDZAR where spread is over 500 points), and metals. Compute what a logical PIP is and use that, not points.
                How to manage JPY pairs with parameters? - MQL4 programming forum (2017)
                Slippage defined in index points - Expert Advisors and Automated Trading - MQL5 programming forum (2018)

    4. 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)

  2. Your image shows 110.292-109.760=0.532. 53 PIPs minus the spread minus slippage; almost nothing, perhaps negative.

    The yellow indicates the market is less than 10 PIPs above your order price. The order has not yet opened.

  3. There is no need to create pending orders in code.

    1. The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)

      Don't worry about it unless you're scalping M1 or trading news.

    2. Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.

 

As you can see from this chart price goes well below the stop price, so it's not a bid/ask spread problem.

Other strange thing is that I'm using ORDER_TIME_DAY option, but at the end of the day the order is not deleted. 

Anyway, I will use market orders.

 
Alberto Tortella #:

As you can see from this chart price goes well below the stop price, so it's not a bid/ask spread problem.

Other strange thing is that I'm using ORDER_TIME_DAY option, but at the end of the day the order is not deleted. 

Anyway, I will use market orders.

Which MT5 version is this ? 

I cannot reproduce it .

If anything is wrong the tester wont accept the order , and , the ORDER TIME DAY kills the order after 24hrs 

 
Lorentzos Roussos #:

Which MT5 version is this ? 

I cannot reproduce it .

If anything is wrong the tester wont accept the order , and , the ORDER TIME DAY kills the order after 24hrs 

I'm using MT5, stop order is placed but is not filled and is not deleted at the end of the day.

 
Alberto Tortella #:

I'm using MT5, stop order is placed but is not filled and is not deleted at the end of the day.

Which version is it ?

All stop orders on all symbols on all times ?

 

5.00 Build 4755.

Attached the expert I'm using (see rows 374-398).

GetLastError() at order placing returns zero.

The error is with USDJPY, but I just tried with a CFD and it works well.

Files:
 
Alberto Tortella #:

5.00 Build 4755.

Attached the expert I'm using (see rows 374-398).

GetLastError() at order placing returns zero.

The error is with USDJPY, but I just tried with a CFD and it works well.

The earlier tests (not this yet) were on 4866 version