Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1035

 
Roman Sharanov:

I want to get acquainted with developing interfaces in MQL5 on EasyAndFastGUI

There are 10 parts (or what?) of "Graphical Interfaces" articles from 2015

I have a question, are they all consistent, or is there no point in reading the older ones?

If you want to understand it, read from the beginning. If you want to learn by trial and error, download the latest version and study the examples.
 

Hi all, I have a question about MQL5.
I have not found a good example of how to close an order correctly. I know how to close an order and use CTrade class, but is there a good ready solution?
The idea is not to send a close command but to have a function which returns true only after I've received "YES, POSITION IS FULLY CLOSED, Relax" reply from broker.)
I know about trade.ResultRetcode() and TRADE_RETCODE_DONE too, but I don't want to re-invent a wheel, has anyone have a ready solution?

 
Evgeny Dyuka:

Hi, I have a question about MQL5.
I have not found a good example of how to correctly close an order. I know how to close an order and use the CTrade class, but is there a good ready solution?
The idea is not to send a close command but to have a function which returns true only after I've received "YES, POSITION IS FULLY CLOSED, Relax" reply from broker.)
I know about trade.ResultRetcode() and TRADE_RETCODE_DONE too, but I don't want to re-invent a wheel, has anyone have a ready solution?

OrderClose from MT4Orders will return true with the same logic as in MT4 - when position will be closed.

 
fxsaber:

OrderClose from MT4Orders will return true with the same logic as in MT4 - when the position is closed.

I think, like last time MT5 adepts will appear and criticise your library, that would be OK... but not many people know how to use the order system of MT5 ))))

 
fxsaber:

The OrderClose from MT4Orders will return true with the same logic as in MT4 - when the position is closed.

Thank you, I was not aware of this library
 
Igor Makanu:

I think like last time MT5 adepts will show up to criticise your library, that would be OK... but not many people know how to use the order system of MT5 ))))

It's strange that there is no ready-made solution from mql5 developers. The order, deal and position are brain-destroying. Position is something that is open, but if it's already closed, what is it? What does HistoryOrdersTotal return if, logically, one order opens a position and the other closes it, i.e. two per position... in this case, the ticket of the opening order (sometimes, maybe, maybe) raises the position id, but then what is the ticket of the closing one????
 
Evgeny Dyuka:
It's strange that there is no ready-made solution available from mql5 developers. The order, deal and position are really tearing the brain apart. Position is something that is open, and if it's already closed, what is it? What does HistoryOrdersTotal return if, logically, one order opens a position and the other closes it, i.e. two per position... in this case, the ticket of the opening order (sometimes, maybe, maybe) raises the position id, but then what is the ticket of the closing one????
  • An order is an order you give to a server to do something. It may be executed, it may be partially executed (incompletely executed), and it may be rejected.
  • Transaction - The result of the execution of an order (your order to execute an action).
  • A position is the result of the execution of a trade to enter the market.
  • A closed position (this is when there is no position and it is useless to talk about it as something tangible - there is no position) - is the result of execution of a deal to exit the market.
  • An exit trade is obtained upon the execution of an order, i.e., your order to close the position.
  1. You send an order to the server to open a position to buy - the order with the ORDER_TYPE_BUY type
  2. If the order is accepted by the server and fully executed, a deal will be formed - an order to enter the market with the DEAL_ENTRY_IN type
  3. As a result, you have a position of the POSITION_TYPE_BUY type
  4. You send an order to the server to close the position to buy - an order of the ORDER_TYPE_SELL type with the same size as the position to be closed
  5. If the order is accepted by the server and fully executed, then a deal will be concluded - an exit trade of the DEAL_ENTRY_OUT type
  6. As a result, you do not have a position of the POSITION_TYPE_BUY type - it is completely closed, and its history can be viewed in the History journal of the client terminal - all orders and deals of this and other positions are located there
This in brief - for initial understanding. And further, you can find everything on the Forum and in the articles. If only you had the desire.
 
Evgeny Dyuka:
Strange that there is no ready-made solution from the mql5 developers.

There is.

Документация по MQL5: Стандартная библиотека / Торговые классы
Документация по MQL5: Стандартная библиотека / Торговые классы
  • www.mql5.com
Стандартная библиотека / Торговые классы - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Artyom Trishkin:
  • An order is an order you give to a server to do something. It may be executed, it may be partially executed (incompletely executed), and it may be rejected.
  • Transaction - The result of the execution of an order (your order to execute an action).
  • A position is the result of the execution of a trade to enter the market.
  • Closed position (this is when there is no position and it is useless to talk about it as something tangible - there is no position) - the result of execution of a deal to exit the market.
  • An exit trade is obtained upon the execution of an order, i.e., your order to close the position.
  1. You send an order to the server to open a position to buy - the order with the ORDER_TYPE_BUY type
  2. If the order is accepted by the server and fully executed, a deal will be formed - an order to enter the market with the DEAL_ENTRY_IN type
  3. As a result, you have a position of the POSITION_TYPE_BUY type
  4. You send an order to the server to close the position to buy - an order of the ORDER_TYPE_SELL type with the same size as the position to be closed
  5. If the order is accepted by the server and fully executed, then a deal will be concluded - an exit trade of the DEAL_ENTRY_OUT type
  6. As a result, you do not have a position of the POSITION_TYPE_BUY type - it is completely closed, and its history can be viewed in the History journal of the client terminal - all orders and deals of this and other positions are located there
This in brief - for initial understanding. And further, you can find everything on the Forum and in the articles. All you need is a strong will.
Thank you, I will dig in
 
Artyom Trishkin:
  • An order is an order you give to a server to do something. It may be executed, it may be partially executed (incompletely executed), and it may be rejected.
  • Transaction - The result of the execution of an order (your order to execute an action).
  • A position is the result of the execution of a trade to enter the market.
  • Closed position (this is when there is no position and it is useless to talk about it as something tangible - there is no position) - the result of execution of a deal to exit the market.
  • An exit trade is obtained upon the execution of an order, i.e., your order to close the position.
  1. You send an order to the server to open a position to buy - the order with the ORDER_TYPE_BUY type
  2. If the order is accepted by the server and fully executed, a deal will be formed - an order to enter the market with the DEAL_ENTRY_IN type
  3. As a result, you have a position of the POSITION_TYPE_BUY type
  4. You send an order to the server to close the position to buy - an order of the ORDER_TYPE_SELL type with the same size as the position to be closed
  5. If the order is accepted by the server and fully executed, then a deal will be concluded - an exit trade of the DEAL_ENTRY_OUT type
  6. As a result, you do not have a position of the POSITION_TYPE_BUY type - it is completely closed, and its history can be viewed in the History journal of the client terminal - all orders and deals of this and other positions are located there
This in brief - for initial understanding. And further, you can find everything on the forum, and in the articles. All you need is a strong will.
You write"A closed position (this is when there is no position and it is useless to talk about it as something perceptible - it does not exist) - the result of the execution of a deal to exit the market". It turns out that there is no such single entity in the history, but there is a set of events - order->trade (opening), order->trade (closing) and it all has no single name.
I just can't solve a trivial problem - I need to access this last entity (by tickit probably) and collect information about it - opening/closing time, volume, etc. Suppose that this something was opened by one order and closed by one order too. So, we should take the last two orders from HistoryOrderTotal and use them for some analysis? What if the ticket types are different...
How is such a reference to the history solved in practice?
Reason: