Buy Limit Pending order is not triggered

 

Hi,

today I stumbled on a problem with pending orders. Please see the following EA doing the following steps:

  • trading the currency pair USDCHF
  • as soon as the market is open two buy limit pendig orders will be placed: at 1.06800 and 1.06500
#include <Trade/Trade.mqh>
bool OrderOpened;
bool IsMarketOpen(const string symbol) {
  datetime from, to;
  datetime serverTime = TimeTradeServer();
  MqlDateTime dt;
  TimeToStruct(serverTime,dt);
  const ENUM_DAY_OF_WEEK day_of_week = (ENUM_DAY_OF_WEEK) dt.day_of_week;
  const int time = (int) MathMod(serverTime,PeriodSeconds(PERIOD_D1));
  int session = 0;
  while (SymbolInfoSessionTrade (symbol, day_of_week, session, from, to)) {
    if(time >=from && time <= to ) {
      return true;
    }
    session++;
  }
  return false;
}
int OnInit() {
   OrderOpened = false;
   return INIT_SUCCEEDED;
}
void OnTick() {
   if (OrderOpened) return;
   if (!IsMarketOpen("USDCHF")) return;
   CTrade trade;
   trade.OrderOpen("USDCHF",ORDER_TYPE_BUY_LIMIT,0.1,0.0,1.06800,0.0,0.0);
   trade.OrderOpen("USDCHF",ORDER_TYPE_BUY_LIMIT,0.1,0.0,1.06500,0.0,0.0);
   OrderOpened = true;
}

I tested this EA in the strategy tester from 2010.04.09 to 2010.04.13, TimeFrame H1, Delay 2ms, Every Tick based on real ticks, Deposit 10000 USD, Leverage 1:30.

The price starts from 1.07180/1.07220; as soon as the market is open the two pending orders will be placed as expected:



  During the further progress the ask price drops below the trigger price of the first order (ticket 2) and the order will be triggered as expected:



Later the ask price drops below the trigger price of the second order (ticket 3). But this order remains and will not be triggered!



Definitively the ask price is lower than the trigger price of order 3.

Admittedly the price data of the currency pair USDCHF are old and possibly of low quality; and there is a big jump of the date and time: from 2010.04.09 20:59 to 2010.04.11 21:00.

But nevertheless the order should be triggered. What do you think?

I'm using MQLbuild 3390.


Matthias


 
It can happen that the visual representation of the tester lacks a bit as it is optimized for speed.
 
Carl Schreiber #:
It can happen that the visual representation of the tester lacks a bit as it is optimized for speed.

Thanks for your answer. But I definitively can exclude any visual issues/problems here. There may exist a problem with the abrupt date and time change of the price ticks? Or the spread?

I do not know

Matthias

 
Dr Matthias Hammelsbeck #:

Thanks for your answer. But I definitively can exclude any visual issues/problems here. There may exist a problem with the abrupt date and time change of the price ticks? Or the spread?

I do not know

Matthias

OK, I'm not sure that might be it, but what is the slippage you're setting for the pending order? If there't a gap in the price and it falls way below the value or your max slippage tolerated, I'm not sure the system will trigger it. On the other hand I think that ECN brokers kind of ignore the slippage? But I'm not sure about this - I just read it somewhere. Post the solution if you figure it out, it's an interesting case.

 

Problem Solved!

I'm so stupid! Please excuse! The market simply is closed between 2010.04.11 21:00:00 and 2010.04.12 00:05:00

Matthias (I want to make myself very small) 

Reason: