The great and terrible MT4 forever (or how to strategise a transition) - page 25

 
Igor Makanu:

in the PM has abandoned the server

This server (or rather the broker's software) has spam protection. They plan to update it by next week and then the slowdown will go away.

 
fxsaber:

I'll have to have a look at this server. It would be good to check out the crutch suggested here, for whom it seems important.

I'd hate to come back to this topic after a while. It would be better to point out bugs, if there are any.

There is no option in MT4-style yet?

Just run the script opening 100 positions on different servers?

 
Andrey Khatimlianskii:

No option in MT4-style yet?

Hasn't started yet. Most likely, the user will not change anything in the code. The additional functionality will be activated through a macro.

Just run the script opening 100 positions on different servers?

Yes, on different servers, but only a different script. If no doubling occurs during one minute of running it, it has passed the check successfully. Otherwise - failure.

Библиотеки: TradesID
Библиотеки: TradesID
  • 2021.03.29
  • www.mql5.com
Статьи и техническая библиотека по автоматическому трейдингу: Библиотеки: TradesID
 
fxsaber:

Hasn't started yet. Most likely, the user will not change anything in the code. The extra functionality will be activated via a macro.

Got it.

Библиотеки: MT4Orders
Библиотеки: MT4Orders
  • 2021.02.09
  • www.mql5.com
MT4Orders: Автор: fxsaber...
 

It was.

Forum on trading, automated trading systems and trading strategy testing

The great and terrible MT4 forever (or how to build a smart migration strategy)

fxsaber, 2021.05.11 09:05

Without waiting for a position - results immediately.

#include <fxsaber\TradesID\ByPass.mqh>
#include <MT4Orders.mqh>

#define  Ask SymbolInfoDouble(_Symbol, SYMBOL_ASK)

void OnStart()
{
  BYPASS ByPass;
  
  MT4ORDERS::OrderSend_MaxPause = 0; // Запрет на ожидание позиции после OrderSend
  
  while (OrdersTotal() < 30)
    if (ByPass.Is())
      ByPass += OrderSend(_Symbol, OP_BUY, 0.1, Ask, 0, 0, 0);      
    
  Print(OrdersTotal());
}

It did.

#define  MT4ORDERS_BYPASS_MAXTIME 1000000 // Максимальное время (в мкс.) на ожидание синхронизации торгового окружения
#include <MT4Orders.mqh> // https://www.mql5.com/ru/code/16006

#define  Ask SymbolInfoDouble(_Symbol, SYMBOL_ASK)

void OnStart()
{
  MT4ORDERS::OrderSend_MaxPause = 0; // Запрет на ожидание позиции после OrderSend
  
  while (OrdersTotal() < 30)
    OrderSend(_Symbol, OP_BUY, 0.1, Ask, 0, 0, 0);      
    
  Print(OrdersTotal());
}


Now no different to the MT4 variant, including reliability.

Any examples that are so hard to write in MT5 have become easily implementable, as they should be.

 

Forum on trading, automated trading systems and trading strategy testing

The great and terrible MT4 forever (or how to build your migration strategy)

Igor Makanu, 2021.05.10 10:28

it seems to work:

#include <Trade\Trade.mqh>
void OnStart()
{
   CTrade Trade;
   while(PositionsTotal() < 10)
   {
      if(OrdersTotal() > 0) continue;
      if(!Trade.Buy(0.01)) continue;
      if(OrdersTotal() == 0 && PositionsTotal() >= 10) return;
   }
}

but very slow, and the solution is so-so.

What will happen if after the order to open the 10th position is placed, at the next iteration of the

while(PositionsTotal() < 10)

PositionTotal has not had time to update (=9), and the order has already managed to go into history and OrdersTotal()==0.

In that case, will there be another Trade.Buy()?

Theoretically, it may happen several times in a row?

Or have I missed something?

 
mktr8591:

What happens, if after the order to open the 10th position is placed, at the next iteration of the

PositionTotal has not had time to update (=9), and the order has already managed to go to history and OrdersTotal()==0.

In that case, will there be another Trade.Buy()?

Theoretically, it may happen several times in a row?

Or am I missing something?

it's his high-frequency interests, the rest have enough timeouts and no problem with a second go

I'm sure that's how it's built in MT4, wait-and-see
 
mktr8591:

What happens, if after the order to open the 10th position is placed, at the next iteration of the

PositionTotal has not had time to update (=9), and the order has already managed to go to history and OrdersTotal()==0.

In that case, will there be another Trade.Buy()?

Of course, it will be. The reasoning in the code is exactly the same.

Theoretically, it may repeat several successive iterations?

If Buy is true, then there is almost zero probability that the next iteration will have OrdersTotal() == 0. I.e., opening 12 positions is impossible in practice.


This is a very primitive case. A double iteration often looks like this:

  1. Limit OrdersTotal = 1, PositionsTotal = 0.
  2. Limiters are executed. OrdersTotal = 0, PositionsTotal = 0.
  3. Positions are opened. OrdersTotal = 0, PositionsTotal = 1.

On the second step, the Expert Advisor sees that there is nothing and sets a Limit. As a result, we have two open positions.

The second point is the MT5 overshoot. And now the crutch bypasses it.

 

Thank you.

About that:

fxsaber:

The doubling is not a difficulty of MT5, but an architectural bug, when the Total()-functions shows false positives.

You can say it's a bug, or you can present it differently :-)

PositionsTotal() is not the number of open positions, but the size of the open positions table. The table of positions - is in fact a cache, as the cache of the history of deals, only it is updated not on request, but automatically, but not instantly, and with a small delay. Because of this, it may not contain already opened positions, or contain already closed ones.

The same thing with OrdersTotal().

If we explain the help in this way, there will be fewer questions, complaints and misunderstandings.

And in the article "Orders, Positions and Trades in MetaTrader 5," you can pay attention to this (now it's ambiguous - "The result of the PositionsTotal() function does not depend on whether the position cache is full - it always returns the actual number of open positions in the base terminal for all symbols").


P.S. But then a legitimate question arises - why not make a system function/flag to determine the synchronisation status of the tables of live orders, positions, trades and executed orders, so as not to create crutches?
 
mktr8591:

P.S. But then a legitimate question arises - why not make a system fi/flag to determine the synchronisation status of the tables of live orders, positions, trades and executed orders, so as not to create crutches?

Most likely, there is no such flag inside.