Mihlali Linge Dlulane:
I am having an issue trying to count closed trades , i just can seem to get it done .
It just doesnt count the closed trades correctly
I am having an issue trying to count closed trades , i just can seem to get it done .
It just doesnt count the closed trades correctly
You need to check deals, not orders.
You should search before wasting your time on something you don't master, such code is available on this site.
Forum on trading, automated trading systems and testing trading strategies
I don't understand how to distinguish between position and order.
Fernando Carreiro, 2023.06.18 18:48
A simple way to view it ...
- Order — the request (current and history)
- Deal — the action (history)
- Position — the result (current)
Read the following article ...
Orders, Positions and Deals in MetaTrader 5
MetaQuotes, 2011.02.01 16:13
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.
Alain Verleyen #:
You need to check deals, not orders.
You should search before wasting your time on something you don't master, such code is available on this site.
Ive changed it from checking deals not orders and it still doesnt seem to work
int ClosedOdersCount = 0; datetime TimeNow = TimeCurrent(); datetime TimeBefore = TimeCurrent() - 860000; long OrderType ; HistorySelect(TimeBefore,TimeNow); if(HistoryDealsTotal() > 0){ for(int i=HistoryDealsTotal()-1; i>=0 ;i--){ ulong ticket = HistoryDealGetTicket(i); if (ticket>0) { if ( HistoryDealGetTicket(ticket) ){ Print("ticket: ", ticket); HistoryDealGetInteger(ticket, DEAL_ORDER,OrderType); Print("i = ", i, ", ticket = ", ticket, ", OrderType = ", OrderType ); ClosedOdersCount ++; } } } Print("Today's closed trades count: ", ClosedOdersCount); }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
It just doesnt count the closed trades correctly