Questions from Beginners MQL5 MT5 MetaTrader 5 - page 100
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
int index // номер сделки
);
What is a transaction number?
How do I select the last trade? Index 0?
I have an account with an open position and a history of trades. I want to select the last trade:
#include <Trade\DealInfo.mqh>
CDealInfo deal;
for(int n=20;n>=0;n--)
{
deal.SelectByIndex(n);
Print("Тикет сделки=",deal.Ticket()," n=",n);
}
All ticks 0...
int index // номер сделки
);
What is a transaction number?
See description of HistoryDealGetTicket() function. There is also an example of how to work with the list of deals.
I have tried to suggest an answer to your question "What is a transaction number? Can we assume that you have dealt with this question?
1. Unfortunately, I try not to use the Standard Library, so I cannot correctly suggest how to work with the SelectByIndex() method. I can only note that the CDealInfo class itself is positioned as a class for working with transaction properties, i.e. the issues of getting the list of transactions seem to be left out.
2. As you know, the SelectByIndex() method simply uses the HistoryDealGetTicket() function. From the description of thisfunction it follows that before accessing to the deal it is necessary to obtain the list of all deals . In particular,
About a year ago, I asked on the forum, whether it is possible to consider that the last deal in the list always has an index of HistoryDealsTotal()-1, but I didn't receive an answer (or did not notice, which is unlikely). Using the method of scientific proof, I have not found a refutation of this thesis. So, logically, each new deal, information about which is received in the base terminal, should simply increase the list of deals by one and, respectively, indexes in the list of deals would be assigned to each new deal in ascending order. How it is in reality - do not know.
3. I also suggest to read the articleOrders, Positions and Trades in MetaTrader 5 and (haven't read it myself) - How to use the Standard Library trade classes when writing an Expert Advisor.
That's all :)
Experts, help, please. I built two EAs for, so to speak, synergistic effect, the simpler ones seem to connect, but this one doesn't compile, although I've done everything correctly as with the previous one. Here is what it gives out
'Supervisor' - function can be declared only in the global scope 20_200_pips_MQL5_v1.mq5 360 18
'Perceptron' - function can be declared only in the global scope 20_200_pips_MQL5_v1.mq5 418 8
'basicTradingSystem' - function can be declared only in the global scope 20_200_pips_MQL5_v1.mq5 434 6
The function can only be declared in the global scope
I'm really confused where is the global scope
'Supervisor' - function can be declared only in the global scope 20_200_pips_MQL5_v1.mq5 360 18
'Perceptron' - function can be declared only in the global scope 20_200_pips_MQL5_v1.mq5 418 8
'basicTradingSystem' - function can be declared only in the global scope 20_200_pips_MQL5_v1.mq5 434 6
The function can only be declared in the global scope
I'm really confused where is the global scope
Such messages appear, for example, when one function is declared inside another. See if there's anything like this in the code: