Чтобы определить, из какого списка выбран ордер, необходимо проанализировать его время закрытия. Если время закрытия ордера равно 0, то ордер является открытым или отложенным и взят из списка открытых ордеров терминала. Отличить открытый ордер от отложенного ордера можно по типу ордера. Если время закрытия ордера не равно 0, то ордер является...
//+----------------------------------------------------------------------------+//| Автор : Ким Игорь В. aka KimIV, http://www.kimiv.ru |//+----------------------------------------------------------------------------+//| Версия : 19.02.2008 |//| Описание : Возвращает суммарный профит в валюте депозита |//| закрытых с определённой даты позиций |//+----------------------------------------------------------------------------+//| Параметры: |//| sy - наименование инструмента ("" - любой символ, |//| NULL - текущий символ) |//| op - операция (-1 - любая позиция) |//| mn - MagicNumber (-1 - любой магик) |//| dt - Дата и время в секундах с 1970 года ( 0 - с начала истории) |//+----------------------------------------------------------------------------+double GetProfitFromDateInCurrency(string sy="", int op=-1, int mn=-1, datetime dt=0)
{
double p=0;
int i, k=OrdersHistoryTotal();
if (sy=="0") sy=Symbol();
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
if ((OrderSymbol()==sy || sy=="") && (op<0 || OrderType()==op)) {
if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
if (mn<0 || OrderMagicNumber()==mn) {
if (dt<OrderCloseTime()) {
p+=OrderProfit()+OrderCommission()+OrderSwap();
}
}
}
}
}
}
return(p);
}
// код Кима изменил на это и теперь от считает профит за сегодня и обнуляется в полночьdouble GetProfitFromDateInCurrency1(string sy="0", int op=-1, int mn=-1)
{
double p=0;
int i, k=OrdersHistoryTotal();
datetime dt=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE));
if (sy=="0") sy=Symbol();
for (i=0; i<k; i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
if ((OrderSymbol()==sy || sy=="") && (op<0 || OrderType()==op)) {
if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
if (mn<0 || OrderMagicNumber()==mn) {
if (dt<OrderCloseTime()) {
p+=OrderProfit()+OrderCommission()+OrderSwap();
}
}
}
}
}
}
return(p);
}
Hello. Please help me calculate the profit of closed trades yesterday, the day before yesterday, etc. I want to do Profit for today:. Profit for yesterday, profit for the day before yesterday
I copied the code/ for today's profit calculation.
or how to set profit today to postpone this value to yesterday's profit and then to the profit the day before that
Hello. Please help me calculate the profit of closed trades yesterday, the day before yesterday, etc. I want to do Profit for today:. Profit for yesterday, profit for the day before yesterday
To calculate today's profit, copy code/.
or how to make value from today's profit move lower to yesterday's profit, then to the day before yesterday's profit
Add one more parameter to the function description and change the check condition:
double GetProfitFromDateInCurrency(string sy="", int op=-1, int mn=-1, datetime dtstart, datetime dtstop)
....
if (OrderCloseTime()>=dtstart && dtstop<=OrderCloseTime()) {
It is possible to read an order ticket.
Is there a similar function
OrderGetTicket();for mql4?
Is there a similar function
for mql4?
There is, only not exactly the same. After selecting an order you have to define the order type and the ticket by other functions.
Good afternoon.
There is a function to open a grid of orders with lot incremented by i,
I need the grid (lots) to be built by lot, i.e. lot1 = 0.01, lot2 = 0.02, lot3 = lot2 + lot 1. ,
how should this be described in the fLots() function?
I want to check if there are any open positions in onInit, but for some reason I can't select them:
I get:
2019.05.01 00:11:32.177 breakeven (GBPUSD,H1) ticket(1) = 0
2019.05.01 00:11:32.177 breakeven (GBPUSD,H1) false
2019.05.01 00:11:32.177 breakeven (GBPUSD,H1) Position Total = 1
I want to check if there are any open positions in onInit, but for some reason I can't select them:
I get:
2019.05.01 00:11:32.177 breakeven (GBPUSD,H1) ticket(1) = 0
2019.05.01 00:11:32.177 breakeven (GBPUSD,H1) false
2019.05.01 00:11:32.177 breakeven (GBPUSD,H1) Position Total = 1
Right away it catches my eye:
I didn't look further because it should be like this in a reverse cycle:
Immediately that caught my eye:
I didn't look any further, because that's how it should be on the reverse cycle:
I prefer this notation
I prefer this entry
Well... I showed an understandable one for beginners ;)
Hello. Please help me calculate the profit of closed trades yesterday, the day before yesterday, etc. I want to do Profit for today:. Profit for yesterday, profit for the day before yesterday
I copied the code/ for today's profit calculation.
or how to set profit today to postpone this value to yesterday's profit and then to the profit the day before thatHello. Please help me calculate the profit of closed trades yesterday, the day before yesterday, etc. I want to do Profit for today:. Profit for yesterday, profit for the day before yesterday
To calculate today's profit, copy code/.
or how to make value from today's profit move lower to yesterday's profit, then to the day before yesterday's profitAdd one more parameter to the function description and change the check condition: