Discussion of article "Orders, Positions, and Deals in MetaTrader 5"

 

New article Orders, Positions, and Deals in MetaTrader 5 is published:

Creating a robust trading robot cannot be done without an understanding of the mechanisms of the MetaTrader 5 trading system. The client terminal receives the information about the positions, orders, and deals from the trading server. To handle this data properly using the MQL5, it's necessary to have a good understanding of the interaction between the MQL5-program and the client terminal.

Author: MetaQuotes

 

Very Helpful 

Thank you  

 

How to select history orders/ deals/ position by incremental indexing.

Such as:

    for(uint i = uint(HistoryDealsTotal()-1); i >= 0; i--)
    {
    if(deal.SelectByIndex(i) == true)
    {
    //--my data
    }
    }

Is it possible? 

 

Thanks for your interesting article 

 

Forum on trading, automated trading systems and testing trading strategies

Discussion of article "Orders, Positions, and Deals in MetaTrader 5"

Tanvir Ahmed, 2017.10.21 16:52

    for(uint i = uint(HistoryDealsTotal()-1); i >= 0; i--)
    {
    if(deal.SelectByIndex(i) == true)
    {
    //--my data
    }
    }

Infinite loop!

 
MetaQuotes Software Corp.:

New article Orders, Positions, and Deals in MetaTrader 5 is published:

Author: MetaQuotes


very helpful!!!!!!!thanks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1

 

Thanks for such an informative article. @MetaQuotes

Query: How can I collectively loop through both : open orders and open positions in a single for() loop (in a similar way how we loop all orders in MQL4 and then check if an order is already executed or a pending order) ?

 
Rahul Dhangar :

Thanks for such an informative article. @MetaQuotes

Query: How can I collectively loop through both : open orders and open positions in a single for() loop (in a similar way how we loop all orders in MQL4 and then check if an order is already executed or a pending order) ?

To calculate POSITIONS and PENDING ORDERS you must use two independent cycles. One cycle enumerates POSITIONS, and the second cycle enumerates PENDED ORDERS. Example: Calculate Positions and Pendong Orders

How to start with MQL5
How to start with MQL5
  • 2020.12.19
  • www.mql5.com
This thread discusses MQL5 code examples. There will be examples of how to get data from indicators, how to program advisors...
 

Hi, folks!

It would be helpful that @MetaQuotes upgrade this article with Trade Classes (CAccountInfo, CSymbolInfo, COrderInfo, CHistoryOrderInfo, CPositionInfo, CDealInfoCTrade, CTerminalInfo). Develop EA under Object-Oriented paradigm could modify (and simplify) this operations of synchronize cache and to get data over symbols, orders, positions, deals, trades, etc.

Am I right?

Documentation on MQL5: Standard Library / Trade Classes / CAccountInfo
Documentation on MQL5: Standard Library / Trade Classes / CAccountInfo
  • www.mql5.com
CAccountInfo - Trade Classes - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

if you please how to calculate order commision with profit to be like this

" Profit += profit + swap + commision "