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

 
fxsaber:

MT4 and MT5 terms are the same.

For so many years everyone has known about the backwater, coming to... Sleep. Because it's VERY complicated. A lot of the features of the trading API that have been brought up on the forum, the developers are not aware of, or have not commented on.


No one is criticizing MT5. I've shown you by examples some problems that occur while solving the basic tasks.

Why are they the same? You still have not answered my question.

Forum on trading, automated trading systems and testing of trading strategies

The Great and Horrible MT4 Forever (or How to Effectively Determine a Migration Strategy)

Alexey Viktorov, 2021.05.09 09:15

... And if I connect to my account from another computer and place a couple of orders ... what will MQL4 open?

No one is criticising MT5. I showed some problems in solving elementary problems with examples.

You just need to correctly process the result of OrderSend() function and you can't get away from the simplicity of mql4. You have your own goal, to catch microseconds, not to trade... One DT has problems and you pass these problems off as MT bugs. Show the position reversal on the MQ account and then the developers will pay attention to it. I ran your code on the Robo demo and couldn't see any backtracking.

Some of your bug reports are really worthy of respect, but some... sorry, such nonsense, I'm speechless.

That's all... Happy Victory Day. Peace. Labor. May.

 
Alexey Viktorov:

Why are they the same? You still haven't answered the question.

Once again, the conditions are the same for MT4/5. You need to have 100 open positions in an empty account at the end of the script execution. It is allowed to close some positions in any terminal during the script runtime. This "intervention" is necessary only to avoid dumb decisions.

for (int i = 0; i < 100; i += OrderSend(Request, Result))
  ;

The result of the OrderSend() function must be processed correctly, but you can't get away from the simplicity of mql4. You have your own goal, to catch microseconds, not to trade... One dtz has problems and you pass these problems off as MT bugs. Show the position reversal on the MQ account and then the developers will pay attention to it. I ran your code on the Robo demo and couldn't see any backtracking.

Some of your bug reports are really worthy of respect, but some... sorry, such nonsense, it lacks decent words.

Just because you don't notice problems doesn't mean there aren't any. The MQ demo is a disgusting place, in terms of debugging. There is an execution type where OrderSend returns true for market orders only when a position is opened. In reality, there is nothing like that on the ECN accounts. true - market order is accepted. What happens next is important to monitor. Only kitchen DCs use a different (as in MQ-Demo) execution scheme.

That's all... Happy Victory Day. Peace. Labor. May.

Likewise.

 
fxsaber:

I need to write a script on an MT5 that opens 100 positions on an empty account.


On MT4 solved it this way.

void OnStart()
{
  while (OrdersTotal() < 100)
    OrderSend(_Symbol, OP_BUY, 0.1, Ask, 0, 0, 0);
    
  Print(OrdersTotal());
}

Who has a solution on MT5?

I received the shortest code I have ever written on MT5:

MqlTradeRequest BuyRequest = {0};
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
   static bool run = false;
   if(run) return;
   BuyRequest.action = TRADE_ACTION_DEAL;
   BuyRequest.type = ORDER_TYPE_BUY;
   BuyRequest.symbol = _Symbol;
   BuyRequest.volume = 0.1;
   BuyRequest.price = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
   BuyRequest.type_filling = GetFilling();
   MqlTradeResult result;
   run = OrderSend(BuyRequest, result);
}
//+------------------------------------------------------------------+
//| Trade function                                                   |
//+------------------------------------------------------------------+
void OnTrade()
{
   MqlTradeResult result;
   while(PositionsTotal() < 10 &&
         SymbolInfoDouble(_Symbol, SYMBOL_ASK, BuyRequest.price) &&
         OrderSend(BuyRequest, result))
   {}
}
//+------------------------------------------------------------------+
ENUM_ORDER_TYPE_FILLING GetFilling(const uint Type = ORDER_FILLING_FOK)
{
   const ENUM_SYMBOL_TRADE_EXECUTION ExeMode = (ENUM_SYMBOL_TRADE_EXECUTION)::SymbolInfoInteger(_Symbol, SYMBOL_TRADE_EXEMODE);
   const int FillingMode = (int)::SymbolInfoInteger(_Symbol, SYMBOL_FILLING_MODE);

   return((FillingMode == 0 || (Type >= ORDER_FILLING_RETURN) || ((FillingMode & (Type + 1)) != Type + 1)) ?
          (((ExeMode == SYMBOL_TRADE_EXECUTION_EXCHANGE) || (ExeMode == SYMBOL_TRADE_EXECUTION_INSTANT)) ?
           ORDER_FILLING_RETURN : ((FillingMode == SYMBOL_FILLING_IOC) ? ORDER_FILLING_IOC : ORDER_FILLING_FOK)) :
          (ENUM_ORDER_TYPE_FILLING)Type);
}
//+------------------------------------------------------------------+

withoutGetFilling() - does not work on crypto (((

But even with this code 11 positions opened:


 
Igor Makanu:

the shortest code I could write on MT5:

I could do SB for brevity.

But even in this code I got 11 positions open:

Because the logic in the code is this.

 
fxsaber:

You can use SB for brevity

Because the logic in the code is this.

the problem is not solved with PositionsTotal() even like this:

void OnTrade()
{
   if(PositionsTotal() >= 10) return;
   MqlTradeResult result;
   BuyRequest.price = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
   OrderSend(BuyRequest, result);
}

opens when there are 10 positions, when there are even 13

the only way to solve it is to memorize the ticket order from MqlTradeResult result and wait for the appearance of an open position; then the specified number of positions will be opened

 
Igor Makanu:

PositionsTotal() is not solved even this way:

it opens when there are 10 positions, when there are even 13

there is no much choice, but to remember the ticket order from MqlTradeResult result and wait for the appearance of an open position. Then the specified number of positions will be opened for sure

So just wait!!! Because mql4 is waiting, and you don't resent it. And in MQL5 you have decided that you can just send a request and assume that it has to be executed............

 
Igor Makanu:

PositionsTotal() is not solved even this way:

it opens when there are 10 positions, when there are even 13

There is not much choice, but to remember the ticket order from MqlTradeResult result and wait for the appearance of an open position. Then the specified number of positions will be opened for sure.

Please note that this is not a script/service but an EA. But even with an EA it would take a lot of effort to solve such a simple two-line task.

 
Alexey Viktorov:

So wait!!! After all, mql4 waits and you don't resent it. And in MQL5 you have decided that you can just send a request and assume that it has to be executed............

Several people have stated here that there are no difficulties. However, they haven't provided a solution.

 
fxsaber:

Several people have expressed here that there are no difficulties. However, they have not provided a solution.

I won't provide one either, for the simplest reason. I don't want to teach ...coders (not you), but if necessary I will solve the problem without thinking too much. And all for the same reason for a long time now codes have been appearing in CodeBase exclusively from Tumblr. All the others are silent...

 
Alexey Viktorov:

I won't provide either, for the simplest reason. I don't want to teach ...coders (it doesn't concern you), but if necessary I will solve the problem without thinking too much. And all for the same reason for a long time codes have come to CodeBase exclusively from Tumblr. All the rest are silent...

Talking with your tongue is not like talking with a sack. You should teach me. Me, please.

There's a problem, and it's not just at this broker.
And the problem is not in waiting for the execution of a specific order (that is another issue), but in the fact that when the order is executed, it temporarily disappears from all the lists (open, closed, trades, positions).

We could use another crutch, of course. But we want to find a human solution. And that is what fxsaber is working on publicly, listening to barking of well-wishers passing by.