When testing the advisor on standard indicators included in MT4 delivery on currency pairs - no questions - everything works according to the trading algorithm.
When testing on metals, such as silver and gold, the orders are not opened, in the Strategy Tester Journal they write zero division.
I have the same input parameters, the history for this five-digit brokerage company (forex4yu) has been uploaded for the tested instruments.
What is the possible reason? I do not want to send my EA to a telepath. I wrote the Expert Advisor personally according to the version of the book.
When testing the advisor on standard indicators included in MT4 delivery on currency pairs - no issues - everything works according to the trading algorithm.
When testing on metals, such as silver and gold, the orders are not opened, in the Strategy Tester Journal they write zero division.
I have the same input parameters, the history for this five-digit brokerage company (forex4yu) has been uploaded for the tested instruments.
What is the possible reason? I do not want to send my EA to a telepath. I wrote the Expert Advisor personally according to the version of the book.
Whenever dividing by a variable, you must first check that it is not equal to zero.
When testing the advisor on standard indicators included in MT4 delivery on currency pairs - no issues - everything works according to the trading algorithm.
When testing on metals, such as silver and gold, the orders are not opened, in the Strategy Tester Journal they write zero division.
I have the same input parameters, the history for this five-digit brokerage company (forex4yu) has been uploaded for the tested instruments.
What is the possible reason? I do not want to send my EA to a telepath. I wrote the Expert Advisor personally according to the version of the book.
You should see the code. In general, you can (in Notepad++) automatically mark all places where a division sign occurs in the code and see if division by zero actually occurs in some case.
I'd love to see the code. And in general, you can (in Notepad++) automatically mark all places where division sign appears in the code and check if in some case division by zero actually occurs.
Yes, I'm already looking at the prints where the unpacking has reached, everything is fine there...
In the function of volume normalisation for metals there was this error (division by zero), now it is not present, there was another 131 - incorrect volume, although set obviously = 0,01 lot, I look in general...
For currencies, this volume normalization function works correctly.... Maybe there is a common for them (for metals and currencies)?
//--------------------------------------------------------------------// Lot_MM.mqh// //--------------------------------------------------------------- 1 --// Функция вычисления количества лотов.// Глобальные переменные:// double Lots_New - количество лотов для новых ордеров (вычисляется)// double Lots - желаемое количество лотов, заданное пользовател.// double MaksRisk - процент риска// Возвращаемые значения:// true - если средств хватает на минимальный лот// false - если средств не хватает на минимальный лот//--------------------------------------------------------------- 2 --bool Lot_MM() // Позовательская ф-ия
{
int time, ticket; // Наибольшее время открытия и номер ордераdouble orderLots; // Lots double orderProfit; // Profitdouble Price; // Цена открытия рыночного ордераdouble SL; // Значение StopLoss ордераdouble TP; // Значение TakeProfit ордераstring Symb =Symbol(); // Финансовый инструм.double One_Lot=MarketInfo(Symb,MODE_MARGINREQUIRED);//Размер свободных средств, необходимых для открытия 1 лотаdouble Min_Lot=MarketInfo(Symb,MODE_MINLOT);// Мин. размер. лотовdouble Max_Lot =MarketInfo(Symbol(),MODE_MAXLOT);
double Step =MarketInfo(Symb,MODE_LOTSTEP);//Шаг изменен размераdouble Free =AccountFreeMargin(); // Свободные средстваdouble LotVal =MarketInfo(Symbol(),MODE_TICKVALUE);//стоимость 1 пункта для 1 лота//--------------------------------------------------------------- 3 --if (Lots>0) // Лоты заданы явно..
{ // ..проверим этоdouble Money=Lots*One_Lot; // Стоимость открываемого ордера if(Money<=AccountFreeMargin()) // Средств хватает..
{
Lots_New=Lots; // ..принимаем заданное// else // Если не хватает..// Lots_New=MathFloor(Free/One_Lot/Step)*Step;// Расчёт лотов Print("Функция Lot_MM: Lots_New = ", Lots_New);
...
...
...
...
// ---------НОРМАЛИЗУЕМ НОВЫЕ РАСЧЕТНЫЕ ЛОТЫ И ОТКРЫВАЕМ ОЧЕРЕДНУЮ ПОЗИЦИЮ...
Lots_New = NormalizeLots(Lots_New);
return(true); // Выход из польз. ф-ии
}
//--------------------------------------------------------------- 6 --//+------------------------------------------------------------------+//| Нормализация лота |//+------------------------------------------------------------------+double NormalizeLots(double lot)
{
double lotStep = MarketInfo(Symbol(), MODE_LOTSTEP);
double lots = NormalizeDouble(lot / lotStep, 0) * lotStep;
lots = MathMax(lots, MarketInfo(Symbol(), MODE_MINLOT));
lots = MathMin(lots, MarketInfo(Symbol(), MODE_MAXLOT));
return (lots);
}
Add my lot checking function to your custom subroutines. And call it before each OrderSend(). Rounding in my dll is done by the laws of mathematics: If the rounded number ends in fractional part with number >=5, then rounded up. If <=4, then it's rounded down. As far as I understood programming languages have problems with this for some reason - I had to make my own dll-code. Basically, the code is very simple, but I searched the Internet quite a lot at my time, before I found the optimal solution. Do you need the source code of the dll?
// ============ ProverkaLota() =====================================================================// функция принимает нормализует лот ордера//-----------------------------------------------------double ProverkaLota(double LotOrdera,string SMB){
double SMB_MinLot=MarketInfo(SMB,MODE_MINLOT);
double SMB_MaxLot=MarketInfo(SMB,MODE_MAXLOT);
double SMB_LotStep=MarketInfo(SMB,MODE_LOTSTEP);
LotOrdera=OkruglenieDoSotykh(LotOrdera);// округляем до сотыхif(SMB_LotStep==0.1){// округляем до десятых
LotOrdera/=10;
LotOrdera=OkruglenieDoSotykh(LotOrdera);
LotOrdera*=10;// возвращаем дробную часть ордера на место
}
if(LotOrdera<SMB_MinLot){
LotOrdera=SMB_MinLot;
}
if(LotOrdera>SMB_MaxLot){
LotOrdera=SMB_MaxLot;
}
return(LotOrdera);
}
// =================================================================================================
https://www.mql5.com/ru/forum/101632 and here https://docs.mql4.com/ru/basis/variables/formal
Thank you
No, that's too much. What is more volatile from at least 20-50 pips
Guys, can you advise:
When testing the advisor on standard indicators included in MT4 delivery on currency pairs - no questions - everything works according to the trading algorithm.
When testing on metals, such as silver and gold, the orders are not opened, in the Strategy Tester Journal they write zero division.
I have the same input parameters, the history for this five-digit brokerage company (forex4yu) has been uploaded for the tested instruments.
What is the possible reason? I do not want to send my EA to a telepath. I wrote the Expert Advisor personally according to the version of the book.
Guys, can you advise:
When testing the advisor on standard indicators included in MT4 delivery on currency pairs - no issues - everything works according to the trading algorithm.
When testing on metals, such as silver and gold, the orders are not opened, in the Strategy Tester Journal they write zero division.
I have the same input parameters, the history for this five-digit brokerage company (forex4yu) has been uploaded for the tested instruments.
What is the possible reason? I do not want to send my EA to a telepath. I wrote the Expert Advisor personally according to the version of the book.
Guys, can you advise:
When testing the advisor on standard indicators included in MT4 delivery on currency pairs - no issues - everything works according to the trading algorithm.
When testing on metals, such as silver and gold, the orders are not opened, in the Strategy Tester Journal they write zero division.
I have the same input parameters, the history for this five-digit brokerage company (forex4yu) has been uploaded for the tested instruments.
What is the possible reason? I do not want to send my EA to a telepath. I wrote the Expert Advisor personally according to the version of the book.
You should see the code. In general, you can (in Notepad++) automatically mark all places where a division sign occurs in the code and see if division by zero actually occurs in some case.
I'd love to see the code. And in general, you can (in Notepad++) automatically mark all places where division sign appears in the code and check if in some case division by zero actually occurs.
Yes, I'm already looking at the prints where the unpacking has reached, everything is fine there...
In the function of volume normalisation for metals there was this error (division by zero), now it is not present, there was another 131 - incorrect volume, although set obviously = 0,01 lot, I look in general...
For currencies, this volume normalization function works correctly.... Maybe there is a common for them (for metals and currencies)?
I can't understand: it prints the top line, but the order doesn't open with error 131 - wrong volume, I've already set 0.1 and 0.01...
Whenever dividing by a variable, you must first check that it is not equal to zero.
Thanks, I'll keep that in mind in the future. It's just that this time I took a ready-made volume normalisation function.
No use so far... Writes the same error...
I opened a position for gold on my account in the tester with 10,000 and 0.01 and 0.1 lots - to no avail.
Perhaps someone had a similar issue? A tip, plz...
Add my lot checking function to your custom subroutines. And call it before each OrderSend(). Rounding in my dll is done by the laws of mathematics: If the rounded number ends in fractional part with number >=5, then rounded up. If <=4, then it's rounded down. As far as I understood programming languages have problems with this for some reason - I had to make my own dll-code. Basically, the code is very simple, but I searched the Internet quite a lot at my time, before I found the optimal solution. Do you need the source code of the dll?