Errors, bugs, questions - page 2829

 
New in-house functions.
int OrderExist( const string symbol, ENUM_ORDER_TYPE type, ulong magic, ulong &tickets[] );

int PositionExist( const string symbol, ENUM_POSITION_TYPE type, ulong magic, ulong &tickets[] );
 

Greetings. Can you advise or give me a link to where to go?

VPS WinServer 2012 R2, MT4 runs, at some point unloads, have to run again.

Where to look, etc. ....

Many thanks in advance.

 

Forum on trading, automated trading systems and trading strategies testing

Peculiarities of mql5, tips and tricks

fxsaber, 2020.08.20 18:52

The following code on theRannForex-Server demo account can immediately reproduce this situation by running this EA.

// Воспроизведение ситуации наличия позиции и отложенного ордера с одинаковыми тикетами.

#define  Ask SymbolInfoDouble(_Symbol, SYMBOL_ASK)

MqlTradeResult Result = {0};
MqlTradeRequest Request = {0};

int OnInit()
{

        Request.action = TRADE_ACTION_PENDING;
        Request.symbol = _Symbol;
        Request.volume = 100;
        Request.price = Ask;
        Request.type = ORDER_TYPE_BUY_LIMIT;
        
        return(!OrderSend(Request, Result)); // Выставили лимитник по текущей цене.
}

#define  TOSTRING(A) #A + " = " + DoubleToString(A, _Digits)

void OnTradeTransaction( const MqlTradeTransaction&, const MqlTradeRequest&, const MqlTradeResult& )
{
  if (OrderSelect(Result.order) && (OrderGetInteger(ORDER_STATE) == ORDER_STATE_PARTIAL)) // Если наш лимитник исполнился частично
  {
    if (Ask - OrderGetDouble(ORDER_PRICE_OPEN) < 100 * _Point)                            // и находится близко от текущей цены
    {
        Request.action = TRADE_ACTION_MODIFY;
        Request.order = Result.order;
        Request.price = Ask - 1000 * _Point;

      // тогда передвигаем его подальше.
      if (OrderSend(Request, Result)) // Если синхронный OrderSend выполнился успешно, то торговое окружение должно соответствовать.
      {
        // Проверка соответствия торгового окружения.
        if (OrderSelect(Request.order) &&                                                                // Если получилось взять данные нашего ордера
            NormalizeDouble(OrderGetDouble(ORDER_PRICE_OPEN) - Request.price, _Digits))                  // и цена ордера не равна цене успешного OrderSend
          Alert("Bug:" + TOSTRING(OrderGetDouble(ORDER_PRICE_OPEN)) + " != " + TOSTRING(Request.price)); // сообщаем о баге MT5.
      }
    }
    else
      ExpertRemove();
  }     
}


By the way, the script shows (not always the first time) a bug in execution of synchronous OrderSend.

Alert: Bug:OrderGetDouble(ORDER_PRICE_OPEN) = 0.89837 != Request.price = 0.88837

After the OrderSend has been executed for a few tens/hundreds of milliseconds, the order price is old, and not the one which was successfully placed by OrderSend.

 

send a search - couldn't find it myself

how to achieve uniqueness of rows with multiple fields in a table in SQLite?

ZS: if someone can give an example - thanks in advance!

 

Whose idea was it to move the Forum tab to the top of the header list?

Bad idea, don't tell who.

 
Code highlighting in base not working for more than a week, switching attachments also an error
 
Igor Makanu:

send a search - couldn't find it myself

how to achieve uniqueness of rows with multiple fields in a table in SQLite?

ZS: if someone can give an example - thanks in advance!

Create a unique key for multiple fields (the rows with existing data must match the uniqueness being created, otherwise an error will occur).

ALTER TABLE `t1` ADD UNIQUE (
`id` ,
`name` ,
`account`
);
 
Andrey Khatimlianskii:

Create a unique key across multiple fields (with the rows with existing data must match the uniqueness being created, otherwise an error will occur).

OK, I'll try that, but I'll probably have to read a SQL book, not enough knowledge

Thank you!

 
Andrey Dik:

Whose idea was it to move the Forum tab to the top of the header list?

Bad idea, don't tell who.

I agree.

 
Andrey Dik:

Whose idea was it to move the Forum tab to the top of the header list?

Bad idea, don't tell who.

What's the problem? Reflexes?)

And "Forum" is still clicked more often than "Documentation" - at least on the site...

Reason: