Yedelkin: 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?
You may, thank you. Can you tell me if it is possible to select the last deal on a position without going through the deals and comparing times or their tickets?
tor4en: Do you know if it is possible to select the last deal of a position without going through the deals and comparing times or ticks?
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,
//--- запросим историр ю сделок в указанном интервалеHistorySelect(from_date,to_date);
//--- общее количество в списке сделокint deals=HistoryDealsTotal();
//--- теперь обработаем каждую сделкуfor(int i=0;i<deals;i++)
{
deal_ticket=HistoryDealGetTicket(i);
...
}
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.
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
chipo: I have connected two EAs for some kind of synergy effect, the simpler ones seem to connect, but this one does not compile, although I have done everything correctly as with the previous one. This 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
Such messages appear, for example, when one function is declared inside another. See if there's anything like this in the code:
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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:
func_1() { void func_2()... }