Hi! Can you please prescribe how to open an order in an EA, so that when the conditions to open an order once open the order, the next time it will open only when forming the opposite conditions?
1. How do you determine the profit/loss of the last trade?
2. In the tester, are the results shown including the spread, or do I need to subtract the spread from each trade?
1. I am showing you an example of code organization in my owl:
int time = 0; // время (разместить в глобальных переменных (до старта) - факт работы только с последним закрытым ордером//---Поиск последнего отработавшего ордера для открытия очередной позиции ---for (orderIndex = (OrdersHistoryTotal() - 1); orderIndex >= 0; orderIndex--)
{
if (!OrderSelect(orderIndex, SELECT_BY_POS, MODE_HISTORY))
{
Print("Ошибка при доступе к исторической базе (",GetLastError(),")");
continue;
}
if ((OrderSymbol() != Symbol()) || (OrderMagicNumber() != MagicNumber))
{
continue;
}
//-------------------------Принимаем в расчет только ордер, закрытый недавно-----------------------if(time<OrderCloseTime()) //(сравниваем его с хранящимся в пероеменной time)
{
time=OrderCloseTime(); //если время закрытия ордера больше - ложим его в переменнуюint lastType = OrderType();
double lastLots = OrderLots();
double lastProfit = OrderProfit() + OrderSwap();
// Print ("lastProfit = ", NormalizeDouble(lastProfit, 1));// Анализ только что закрывшегося ордераif (lastProfit >= 0.0)
{
//---Ордер закрылся с прибылью - сюда действия при выполнении этого условия
}
else
{
// Ордер закрылся с убытком - сюда действия при выполнении этого условия (дальше фигурные скобочки сами расставите).
.....
.....
.....
2. With the spread taken into account, click on the Symbol label in the Strategy Tester window at the top right and read the contents of the drop-down window.
Hi! Can you please prescribe how to open an order in an EA, so that when the conditions to open an order once open the order, the next time it will open only when the opposite conditions are formed?
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.
they can switch currencies, timeframes or left bars so programmatically.
Thanks, where can I read how it works?
Thank you, where can I read how it works?
This is Alexei joking. The MT4 help is all there.
But I answered about using it from the code. and you can't do it without API.
yes, the description and purpose of the window is there.
But I answered about the use from the code. and you can't do it without API.
Hi! Can you please prescribe how to open an order in an EA, so that when the conditions to open an order once open the order, the next time it will open only when forming the opposite conditions?
1. How do you determine the profit/loss of the last trade?
2. In the tester, are the results shown including the spread, or do I need to subtract the spread from each trade?
1. I am showing you an example of code organization in my owl:
2. With the spread taken into account, click on the Symbol label in the Strategy Tester window at the top right and read the contents of the drop-down window.
How do you find out the highest and lowest price between 5 and 8am today?
Hi! Can you please prescribe how to open an order in an EA, so that when the conditions to open an order once open the order, the next time it will open only when the opposite conditions are formed?