Why does Metaquotes push MT5 instead of MT4? - page 3

 
Stanislav Korotky:

And which MT4Orders functions are used - asynchronous (OrderSendAsync, OrderCloseAsync) or not? This is probably the problem.

I haven't looked into it, just connected it, checked speed, compared it to original code on mql5, deleted original and left only library with mql4 code

 
Vitaly Muzichenko:

I did not understand it, just plugged it in, checked the speed, compared it to the original code on mql5, deleted the original and left only the library with mql4 code

I'm not asking about the details of the library, but how it has been used, to understand the problem. In general, I gave a tip.

 
Stanislav Korotky:

I wasn't asking about the insides of the library, I was asking about how it was used, to see what was causing the problem. Anyway, I gave you a tip.


The problem is not how to use the library.

The problem is that we do not have a complex position in MT4, we have orders. And the result of closing a dozen orders will be the same as shown above.

By the way, there is no such effect in the tester. And we do not have it on the demo. But we have it on the real account.

In this case, code migration from mql4 to mql5 and back "1 to 1" is impossible.

The work with orders on mql4 must be organized adequately to the possibilities of mql4.

There is no way to tell here:

Vitaly Muzichenko:

The only big drawback of MT4 ...

It's just that mql4 has some features and mql5 has other features. In this particular case mql5 has the advantage. But the problem can be solved normally with mql4.

 
Andrey F. Zelinsky:

The problem is not how to use the library.

The problem is that in MT4 there is no aggregate position, there are orders. And closing a dozen orders has the effect shown.

By the way, there is no such effect in the tester. And we do not have it on the demo. But we have it on the real account.

In this case, code migration from mql4 to mql5 and back "1 to 1" is impossible.

The work with orders on mql4 must be organized adequately to the possibilities of mql4.

There is no way to tell here:

It's just that mql4 has some features and mql5 has other features. In this particular case mql5 has the advantage. But this problem can be solved normally on mql4.

What can be accelerated in MT4?

 if(OT==OP_BUY) {
   error=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),slippage,Blue);
   if(!error) Print("Error ",GetLastError());
 }
 if(OT==OP_SELL) {
   error=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),slippage,Red);
   if(!error) Print("Error ",GetLastError());
 }
 
Andrey F. Zelinsky:

The problem is not how to use the library.

The problem is that in MT4 there is no aggregate position, there are orders. And closing a dozen orders has the effect shown.

It is only reasonable to compare MT4 with a hedging account of MT5 (in this case it is just such a trading system). And what does that have to do with the aggregate position? In MT5 there will be exactly the same pile of positions = equivalents of quad orders. Anyway, you're taking the conversation away from the problem again.

 
Vitaly Muzichenko:

What can be accelerated in MT4?

I suggested above to replace with XXXAsync functions. Not sure if it will help, but why not give it a try?

 
Stanislav Korotky:

I suggested above to replace with XXXAsync functions. Not sure if it will help, but why not give it a try?

It's probably a bit off. I have no problem in MT5 with this code, and using <MT4Orders>, everything closes instantly.

There is a problem in MT4, but there for obvious reasons and do not need <MT4Orders>, there is the simplest quadruple code. I have more than one hundred of them, I've got screenshots. Sometimes it slides in my favour, and quite often, if a close has started and the price has moved on. I don't know what it's related to, but it's probably due to the sequence of sending orders.

 

Forum on trading, automated trading systems and trading strategy testing

Why does Metaquotes slip MT5 instead of MT4?

Vitaly Muzichenko, 2017.09.23 20:50

What can be accelerated in MT4?

 if(OT==OP_BUY) {
   error=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),slippage,Blue);
   if(!error) Print("Error ",GetLastError());
 }
 if(OT==OP_SELL) {
   error=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),slippage,Red);
   if(!error) Print("Error ",GetLastError());
 }

At the very least:

  • Doing away with labels will speed up the code.
  • Price normalization is not always needed. Even if getting Ask or Bid price prints more decimal places, it does not mean that normalisation will give any positive result.

The normalisation of the price value is only necessary when mathematical operations are performed on it. When a value is added to or subtracted from the price.

 
Vitaly Muzichenko:

Probably a bit of a misunderstanding. I have no problem in MT5 with this code, and using <MT4Orders>, everything closes instantly.

There is a problem in MT4, but there for obvious reasons and does not need <MT4Orders>, there is the simplest quadruple code. I have more than one hundred of them, I've got screenshots. Sometimes it slides in my favour, and quite often, if a close has started and the price has moved on. I don't know what it's related to, but it's probably the order sending sequence.

Yes, it is my fault - I am dumb.

The variant of solution is as follows: instead of closing several orders, I place a counter total volume, and then call OrderCloseBy several times until mutual destruction.

 
Stanislav Korotky:

The solution is as follows: instead of closing several orders, put a counter total volume, and then call OrderCloseBy several times until mutual destruction.

This variant works, unfortunately, only for one symbol.


It's strange that nobody has added asynchronous Order-functions to the MT4 kodobase over the years.

Reason: