Questions from Beginners MQL5 MT5 MetaTrader 5 - page 381

 
Vladimir Pastushak:
So in fact the second option is better?
Yes. In the second variant, you first check if the function worked correctly, and if everything is OK, you start working with the variable where the result of the function has been placed.
 
Karputov Vladimir:
About voting principles and signal weights: MQL5 Wizard: New version.
This is just what you need, thank you.
 

Good afternoon, MQL5 specialists. Could you please advise how to open and close a standard order in the 5th one? //I just moved from the 4 series.

Can I do it without external libraries?

I can't find anything in the documentation about closing.

I understand there are two ways to open an order, but how would that affect testing?

 
new-rena:

Good afternoon, MQL5 specialists. Please advise how to open and close a standard order in the 5. //I just moved from the 4 series.

Can I do it without external libraries?

I can't find anything in the documentation about closing.

I understand there are two ways to open an order, but how would that affect testing?

//--- В шапке файла подключаем класс CTrade - класс 
//--- для упрощенного доступа к торговым функциям
#include <Trade\Trade.mqh>
//--- объявляем переменную
CTrade            m_trade;

//--- открываем, закрываем...
//--- используя методы класса CTrade...
CTrade. And of course at each step we have to check what was returned by the method.
 
Karputov Vladimir:
CTrade. And of course at each step we have to check what the method has returned.

Wow what a chip) Thank you!

So opening an order asynchronously is another story and not part of CTrade?

 
new-rena:
Wow what a chip) Thank you!
Welcome to the A!
 
Karputov Vladimir:
Welcome to the Five!

aha. if i open an order asynchronously, will that be tested? and it looks like CTrade is only for synchronous operation? // if you're going to write on the 5-point, then you should use something which is not in the 4-point)

// unsuccessfully scratched out the multicurrency indicator..., wasted half a day

 
new-rena:

aha. if i open an order asynchronously, will this be tested? and it looks like CTrade is only for synchronous operation?

// with a bit of difficulty scratched out a multi-currency indicator...

Here, for asynchronous sending SetAsyncMode. And more articles on the word "asynchronous"
Документация по MQL5: Стандартная библиотека / Торговые классы / CTrade / SetAsyncMode
Документация по MQL5: Стандартная библиотека / Торговые классы / CTrade / SetAsyncMode
  • www.mql5.com
Стандартная библиотека / Торговые классы / CTrade / SetAsyncMode - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
new-rena:

Good afternoon, MQL5 specialists. Could you please advise how to open and close a standard order in the 5th one? //I just moved from the 4 series.

Can I do it without external libraries?

I can't find anything in documentation about closing.

As far as I understand, the order can be opened in two ways, but how would that affect testing?

If we do not have any external libraries, there is PositionClose.

Also, we can open a position with the same volume in the opposite direction and it will result in a close.

 
Vitalie Postolache:

If not external - there is PositionClose

You can also open a position with the same volume in the opposite direction, which will result in a close.

I thought the code would be five pages long). thanks!
Reason: