And in this example the calculation is only for one symbol CalcHistorySlip( const string Symb) Well this can be solved by calling the function for each symbol.
Maybe you have an equivalent for MT5 that matches MT4Orders? If not, I will leave it as it is or will not include it in the big report at all. As it is not clear how it can help. I am now outputting the sum of volumes. For single-symbol Expert Advisors, the result of sorting by the sum of volumes and TurnOver from MT4Orders is the same. I.e. there is a replacement for TurnOver . But for multisymbol will be different. Because the sum of lots of different symbols are not equivalent in monetary terms. TurnOver would be better.
And comparison of sorting by volume with the variant for MT5 (code in the link above) does not match at all.
Plus it is necessary to check the symbol type, because for non-forex brokers it is necessary to calculate the cost of a tick from the base currency to the currency of the account (for forex - the cost of a tick is immediately reported in the currency of the account).
Plus you need to check the symbol type, because for non-forex you need to calculate the tick value from the base currency to the account currency (for forex - the tick value is reported immediately in the account currency).
I copied this from Report.mqh. It also goes like this.
// Different values for profitable and losing trades are not taken into accountstaticdouble GetTickValue()
{
staticdouble TickValue[];
constint Pos = REPORT::GetSymbolPos(OrderSymbol());
constint Size = ::ArraySize(TickValue);
if (Pos >= Size)
TickValue[::ArrayResize(TickValue, Pos + 1) - 1] = 0; // https://www.mql5.com/ru/forum/170952/page142#comment_13691776// const double TmpPips = NormalizeDouble(OrderClosePrice() - OrderOpenPrice(), 8); // https://www.mql5.com/ru/forum/170952/page128#comment_10696343constdouble TmpPips = OrderClosePrice() - OrderOpenPrice();
constdouble Lots = OrderLots();
if (TmpPips && Lots/* && OrderProfit()*/) // Profit can be zero - OrderType() > OP_SELL
TickValue[Pos] = ::MathAbs(OrderProfit() / (TmpPips * Lots));
return(TickValue[Pos]);
}
Report works for trading history with symbols that have not been in the Market Watch for a long time. And it has no idea whether it is Forex or something else. However, the information in the history is often enough to calculate the trade turnover.
ZY It follows from the sources that if the opening and closing prices do not coincide, the calculation follows this formula.
Trading turnover - how much money you grind. The commission is calculated from it in normal brokers.
If, for example, individual conditions are required, the first thing they will ask about is the size of the trading turnover.
I have reproduced what is done in Report and wrote about it in the first post. Sorting by them coincides with sorting by just volumes. The problem with the calculation variant without Mt4Orders. The function https://www.mql5.com/ru/forum/98421/page2#comment_2908365 gives quite different results.
One of the results of this function: -149,96. The sign - you can remove fabs() And for the same calculation via Report: 13,839,230.40.
Maybe you have an equivalent for MT5 matching MT4Orders?
If not, then the easiest solution is to see if a trade made via MT5 functions can be viewed in history via MT4Orders. To use this
мистер o O очень хорошо знает что такое DEAL Потому что Ку. Количество пунктов - средневзвешенное по объему количество пунктов каждой из сделок. может о О вполне и подойдет предложенный Вами вариант
lotSize = (int)SymbolInfoDouble(OrderSymbol(),SYMBOL_TRADE_CONTRACT_SIZE); // not available in mat mode, but is available in MT5
Get lotSize for Virtual in mat mode from OrderProfit()=(OrderClosePrice()-OrderOpenPrice())) * OrderLots() * lotSize
if(OrderProfit()!=0){lotSize=OrderProfit()/((OrderClosePrice()-OrderOpenPrice())*OrderLots());}
else{lotSize=lotSize;}// find or ignore a rare case by the same character
Total for Virtual
double CalcMt4TurnOver(){
double lotSize=100000, Turn_Over=0;
for (int i = 0; i < OrdersHistoryTotal(); i++){
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) ){
if(OrderType()<2){
if(OrderProfit()!=0){lotSize=OrderProfit()/((OrderClosePrice()-OrderOpenPrice())*OrderLots());}////else{lotSize=lotSize;}//find or neglect a rare case by the same symbol
//lotSize=_TickValue/_TickSize;// - alternative - you need to get it from Virtual
Turn_Over += (OrderOpenPrice() + OrderClosePrice())*OrderLots()*lotSize;
}}}
return Turn_Over;
}
For MT5: (this is what I wanted to get initially and it turned out to be much easier than in that example).
double CalcMt5TurnOver(){
double lotSize, Turn_Over=0;
for (int i = 0; i < ::HistoryDealsTotal(); i++){
constulong ticket = ::HistoryDealGetTicket(i);
if (((HistoryDealGetInteger(ticket,DEAL_TYPE) < 2))){
lotSize = (int)SymbolInfoDouble(HistoryDealGetString(ticket,DEAL_SYMBOL),SYMBOL_TRADE_CONTRACT_SIZE);
Turn_Over += HistoryDealGetDouble(ticket,DEAL_PRICE) * HistoryDealGetDouble(ticket,DEAL_VOLUME) * lotSize;
}
}
return Turn_Over;
}
The results are exactly the same.
But I'm not sure if I should use SYMBOL_TRADE_CONTRACT_SIZE instead of lotSize=SYMBOL_TRADE_TICK_VALUE / SYMBOL_TRADE_TICK_SIZE; Or is the result the same in theory? In practice with a simple one character example, yes.
It's easily done, but just why?
At the end of Report.mqh there is such an entry.
To move/delete a column you need to change only this sequence in the source accordingly.
You have TurnOver calculation in your report.
I am trying to do the same, but without MT4Ordes.
As an example I found your post https://www.mql5.com/ru/forum/98421/page2#comment_2908365
One of the results: -149,96. The sign - you can remove fabs()
And for the same calculation via Report: 13,839,230.40.
And in this example the calculation is only for one symbol CalcHistorySlip( const string Symb) Well this can be solved by calling the function for each symbol.
Maybe you have an equivalent for MT5 that matches MT4Orders? If not, I will leave it as it is or will not include it in the big report at all. As it is not clear how it can help. I am now outputting the sum of volumes. For single-symbol Expert Advisors, the result of sorting by the sum of volumes and TurnOver from MT4Orders is the same. I.e. there is a replacement for TurnOver . But for multisymbol will be different. Because the sum of lots of different symbols are not equivalent in monetary terms. TurnOver would be better.
And comparison of sorting by volume with the variant for MT5 (code in the link above) does not match at all.
Maybe you have an equivalent for MT5 that matches MT4Orders?
Is that what you mean?
If not, I will leave it as it is or not include it in the big report at all. As it is not clear how it can help.
Trading turnover - how much money you grind. Normal brokers calculate commission from it.
If, for example, individual conditions are required, the first thing they will ask about is the size of the trading turnover.
Is that what you're talking about?
Trading turnover - how much money you grind. The commission is calculated from it in normal brokers.
If, for example, individual conditions are required, the first thing they will ask about is the size of the trading turnover.
I think it should be like that:
OrderLots() * TickValue * fabs(OrderOpenPrice() - OrderClosePrice())Plus it is necessary to check the symbol type, because for non-forex brokers it is necessary to calculate the cost of a tick from the base currency to the currency of the account (for forex - the cost of a tick is immediately reported in the currency of the account).
It seems like it should be:
Plus you need to check the symbol type, because for non-forex you need to calculate the tick value from the base currency to the account currency (for forex - the tick value is reported immediately in the account currency).
I copied this from Report.mqh. It also goes like this.
Report works for trading history with symbols that have not been in the Market Watch for a long time. And it has no idea whether it is Forex or something else. However, the information in the history is often enough to calculate the trade turnover.
ZY It follows from the sources that if the opening and closing prices do not coincide, the calculation follows this formula.
(OrderOpenPrice() + OrderClosePrice()) * MathAbs(OrderProfit() / ((OrderClosePrice() - OrderOpenPrice()))Is that what you're talking about?
Trading turnover - how much money you grind. The commission is calculated from it in normal brokers.
If, for example, individual conditions are required, the first thing they will ask about is the size of the trading turnover.
I have reproduced what is done in Report and wrote about it in the first post. Sorting by them coincides with sorting by just volumes.
The problem with the calculation variant without Mt4Orders.
The function https://www.mql5.com/ru/forum/98421/page2#comment_2908365 gives quite different results.
One of the results of this function: -149,96. The sign - you can remove fabs()
And for the same calculation via Report: 13,839,230.40.
Maybe you have an equivalent for MT5 matching MT4Orders?
If not, then the easiest solution is to see if a trade made via MT5 functions can be viewed in history via MT4Orders. To use this
If not, then the easiest solution is whether a trade made via MT5 functions can then be viewed in history via MT4Orders.
So that's exactly how Report.mqh works! Or am I completely misunderstanding the questions today.
Turn_Over += (OrderOpenPrice() + OrderClosePrice()) * MathAbs(OrderProfit() / ((OrderClosePrice() - OrderOpenPrice()));It can be simplified by substituting:
OrderProfit()=(OrderClosePrice()-OrderOpenPrice()) * OrderLots() * lotSize
Substitute
Delete (OrderClosePrice()-OrderOpenPrice()))
Let's find the size of 1 lot/contract:
Get lotSize for Virtual in mat mode from OrderProfit()=(OrderClosePrice()-OrderOpenPrice())) * OrderLots() * lotSize
Total for Virtual
For MT5: (this is what I wanted to get initially and it turned out to be much easier than in that example).
The results are exactly the same.
But I'm not sure if I should use SYMBOL_TRADE_CONTRACT_SIZE instead of lotSize=SYMBOL_TRADE_TICK_VALUE / SYMBOL_TRADE_TICK_SIZE;
Or is the result the same in theory? In practice with a simple one character example, yes.
Total for Virtual
I.e. we got what we originally wrote.
I'm not sure if you should use SYMBOL_TRADE_CONTRACT_SIZE instead of lotSize=SYMBOL_TRADE_TICK_VALUE / SYMBOL_TRADE_TICK_SIZE;
Or is the result the same in theory? In practice with a simple example with a single symbol, yes.
The symbol may not be in the Market Watch.