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.
It does not fit, there is no information for 10 years.
It's not the same for you either.
The t variable will change and you'll be aghtung.
It has to be memorised before you start closing the series
color ProfitColor;
datetime t;
// START //
//t=TimeCurrent();//разместить в блоке сигнала на закрытие серии ордеров
if(LastProfitCL(-1)<0) ProfitColor=Red;
if(LastProfitCL(-1)>0) ProfitColor=LimeGreen;
if(LastProfitCL(-1)==0)ProfitColor=DarkGray;
ObjectCreate("Last Profit", OBJ_LABEL, 0, 0, 0);
ObjectSet("Last Profit", OBJPROP_CORNER, 1);
ObjectSet("Last Profit", OBJPROP_XDISTANCE, 5);
ObjectSet("Last Profit", OBJPROP_YDISTANCE, 15);
ObjectSetText("Last Profit",StringConcatenate("Last Profit: ",DoubleToStr(LastProfitCL(-1),2)),10,"Arial",ProfitColor);
// END START //
//+----------------------------------------------------------------------------+
//| Возвращает суммарный профит в валюте депозита серии закрытых ордеров |
//+----------------------------------------------------------------------------+
double LastProfitCL(int op=-1){ //"op" позиция (-1 любая позиция)
double LastProfit=0;
for(i=OrdersHistoryTotal()-1;i>=0;i--)
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) && (OrderType()==OP_BUY || OrderType()==OP_SELL) && OrderSymbol()==Symbol() && OrderMagicNumber()==magic) {
if (OrderType()!= op || OrderSymbol()!= Symbol() || OrderMagicNumber()!= magic) continue;
if (op<0 || OrderType()==op)
{
if(OrderCloseTime()>=t)LastProfit+=OrderProfit()+OrderCommission()+OrderSwap();
}
}
return(LastProfit);
}
It's not the same for you either.
The t variable will change and you'll be aghast.
It has to be memorized before the series closes.
Have you tried it?
It's memorized before closing, at the moment the signal to close.
It is not suitable, there is no information for 10 years.
Current profit, , all history.
By the way, it can be set to any date and time.
Try
return(LastProfit);Comment( LastProfitCL(-1, 0) );
//+----------------------------------------------------------------------------+
//| Возвращает суммарный профит в валюте депозита серии закрытых ордеров |
//+----------------------------------------------------------------------------+
double LastProfitCL(int op=-1, datetime t=0){ //"op" позиция (-1 любая позиция)
double LastProfit=0;
for(int i=OrdersHistoryTotal()-1;i>=0;i--) {
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) {
if((op<0||OrderType()==op) && OrderSymbol()==Symbol() && OrderMagicNumber()==magic){
if(t<=OrderCloseTime()) {
t=OrderCloseTime();
LastProfit+=OrderProfit()+OrderCommission()+OrderSwap();
}}}}
}
Profit remembers every new one, but then something counts unknown. In screen #3 it should be 4, not 190
Have you tried it?
It remembers before it closes, at the moment the closing signal is received
That, too, 190
Profit remembers every new one, but then something counts unknown. In screen #3 it should be 4, not 190
Here's the code, it works fine for me, but maybe because the series is closed correctly
So also 190
Where is the command to close orders located?
Did you write the variable t in there?
Where is the command to close orders located?
Have you written the variable t in there?
t=TimeCurrent();//place in the signal block for closing a series of ordersIt's all there of course.
t=OrderCloseTime();
if(OrderCloseTime()>=t)LastProfit+=OrderProfit()+OrderCommission()+OrderSwap();
It's all there, of course.
t=OrderCloseTime();
if(OrderCloseTime()>=t)LastProfit+=OrderProfit()+OrderCommission()+OrderSwap();
No, this line is removed. This is already a profit calculation, it won't work that way.
Where the command to close in the code - there, but not such a line
Read above.