How do I calculate a profit on one currency pair in my EA?
For example, I have seven buy orders open on euros at different prices. How do I calculate a profit on euros without affecting other orders on other pairs? ????
Example,
// ------------------------------------------------в цикле перебираем все ордера по инструменту и накапливаем общий профит---------------------------------double Sum_Profit;
int orderType;
for (int orderIndex = (OrdersTotal() - 1); orderIndex >= 0; orderIndex--)
{
if (!OrderSelect(orderIndex, SELECT_BY_POS))
{
continue;
}
if ((OrderSymbol() != Symbol()))
{
continue;
}
orderType = OrderType();
if ((orderType != OP_BUY) && (orderType != OP_SELL))
{
continue;
}
// запоминаем характеристики ордера
orderProfit = OrderProfit() + OrderSwap(); // Profit
// накапливаем общий профиит
Sum_Profit=Sum_Profit+orderProfit // В цикле по всем ордерам валютной пары считаем общий профитreturn (0);
}
// Вывод текущего состояния на экранComment("Общий профит по инструменту = ", Sum_Profit);
Can you please tell me if at weekends, when there are no ticks and the Start function is not running, is it possible to redraw objects on the chart, for example by mouse click? Tired of restarting the terminal and removing/inserting the Expert Advisor:)
Fam: Can you please tell me if at weekends, when there are no ticks and the Start function is not running, is it possible to redraw objects on the chart somehow, e.g. by mouse click? Tired of restarting the terminal and removing/inserting the Expert Advisor :)
Do
init()
{
start();
}
start()
{
while(true)
{
if (IsStopped()) break;
// ваш имеющийся код
}
}
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.
How do I calculate a profit on one currency pair in my EA?
For example, I have seven buy orders open on euros at different prices. How do I calculate a profit on euros without affecting other orders on other pairs? ????
Example,
Example,
Thanks.... But Sum_Profit is still 0 ............
either in global variables
double Sum_Profit;or in a function
static double Sum_Profit;Tell me if you can write variables in MQL4 in Russian ???? And what are the consequences ???????
Available at
VOLDEMAR:
1. Скажите можно ли в MQL4 переменные писать русским языком ????
2. and what the consequences might be ???????
1. Already answered...
2. Problems with selling your Creations to the English-speaking public. :-)))
Can you please tell me if at weekends, when there are no ticks and the Start function is not running, is it possible to redraw objects on the chart somehow, e.g. by mouse click? Tired of restarting the terminal and removing/inserting the Expert Advisor :)
Do
init() { start(); } start() { while(true) { if (IsStopped()) break; // ваш имеющийся код } }Do