Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1178

 
Aleksey Mavrin:

are we talking about the tester or online?

If online - look at the code, the move event is not routed properly. Panels by the way on the site only five different libraries, what do you mean?

And in the tester - it seems there is no way, and why.

After sending move commands to ALL panel objects, do ChartRedraw()
 
Aleksey Mavrin:

are we talking about the tester or online?

If online - look at the code, somewhere the move event is not routed normally. Panels by the way on the site only five different libraries, what do you mean?

And in the tester - it seems there is no way, and why.

We are talking about online. I really don't need it in the tester. I'm not sure about the libraries - I'm not an expert in programming. I just took a ready code of button from MQL5 Reference.

I've done it already but I have not got any errors, I cannot fix it yet. Apparently this is why button position is updated on the next tick. I don't understand how to make buttons move together with background.

Документация по MQL5: Основы языка / Функции / Функции обработки событий
Документация по MQL5: Основы языка / Функции / Функции обработки событий
  • www.mql5.com
В языке MQL5 предусмотрена обработка некоторых предопределенных событий. Функции для обработки этих событий должны быть определены в программе MQL5: имя функции, тип возвращаемого значения, состав параметров (если они есть) и их типы должны строго соответствовать описанию функции-обработчика события. Именно по типу возвращаемого значения и по...
 
Artyom Trishkin:
After sending move commands to ALL panel objects do ChartRedraw()
I tried it like this, but it didn't work.
   ObjectSetInteger(0, "Buy",            OBJPROP_XDISTANCE, x + 2);
   ObjectSetInteger(0, "Buy",            OBJPROP_YDISTANCE, y + 2);
   ChartRedraw();
  
   ObjectSetInteger(0, "Sell",           OBJPROP_XDISTANCE, x + 74);
   ObjectSetInteger(0, "Sell",           OBJPROP_YDISTANCE, y + 2);
   ChartRedraw();
 
Please help me to understand. I have code for a trading panel to open a pending Buy Stop order with subsequent trailing if the order does not trigger. The order is opened but it does not get modified. There are no errors in the journal and we haven't seen any attempts to modify the order. I tried to track through the log at what stage an error occurs using the function:
Print("Ордер Выбран!");

Just inserted it after each if condition.

As a result, I found out that function:

 for(int i=OrdersTotal()-1;i>=0;i--)
          if(aorder.SelectByIndex(i))  

Successfully selects the order to proceed, but ifPrint("Order Selected!"); isinserted after this code:

if(aorder.Symbol()==asymbol.Name() && aorder.Magic()==MagicNumber && Ask < aorder.PriceOp
en())

then an error occurs:

2020.06.17 01:38:24.136 2020.01.02 07:40:00 failed modify order #2 buy stop 0.1 EURUSD_i at 1.12086 sl: 1.12023 tp: 1.12275 -> 1.00000, sl: 1.00000 tp: 1.00000 [Invalid price]

2020.06.17 01:38:24.136 2020.01.02 07:40:00 CTrade::OrderSend: modify #2 at 1.00000 (sl: 1.00000 tp: 1.00000) [invalid price]

2020.06.17 01:38:24.136 2020.01.02 07:40:00 BUY STOP modification failed! Result Retcode: 10015, description of Retcode: invalid price

I use the same code in another EA for autotrading (the only difference is the absence of such a code):

ObjectGetInteger(0, "Buy Stop", OBJPROP_STATE) == true


) and I have no problems. The orders are opened and modified without any problems.

Here is the code itself:

     double Ask          = NormalizeDouble(PriceInformation_High_Buy[HighestCandle_High_Buy].high, _Digits) + indent; // максимум самой высокой свечи плюс отступ
     double sl_buy       = NormalizeDouble(PriceInformation_Low_Buy[LowestCandle_Low_Buy].low, _Digits) - indent;     // минимум самой низкой свечи минус отступ  
     double tp_buy       = Ask + ((Ask - sl_buy) * Профит_фактор);                                                    // количество стопов лоссов 
     
     if  (OrdersTotal()==0 && PositionsTotal()==0 &&                                         // проверка на наличие открытых позиций и ордеров
     ObjectGetInteger(0, "Buy Stop", OBJPROP_STATE) == true)                                 // проверка состояния кнопки
                                                                                             
     {
        atrade.BuyStop(Lots, Ask, _Symbol, sl_buy, tp_buy, ORDER_TIME_GTC, 0, "My comment"); // посылаем ордер Buy Stop
        ObjectSetInteger(0, "Buy Stop", OBJPROP_STATE, false);                               // отжимаем кнопку
     }

     else

     ObjectSetInteger(0, "Buy Stop", OBJPROP_STATE, false);                                  // отжимаем кнопку
       
//---Трейлинг Buy Stop---------------------------------------------------------------------------------------------------------------------------//     
      
        for(int i=OrdersTotal()-1;i>=0;i--)
          if(aorder.SelectByIndex(i))                                                                      // выбираем ордер 
       
            if(aorder.Symbol()==asymbol.Name() && aorder.Magic()==MagicNumber && Ask < aorder.PriceOpen()) // проверяем символ, мэджик номер, цену
               
              {
                 if(aorder.OrderType()==ORDER_TYPE_BUY_STOP)
                 Print("Ордер Выбран!"); 
                 if(aorder.PriceCurrent()<aorder.PriceOpen())
                 
                    {
                     if(atrade.OrderModify(aorder.Ticket(),
                        asymbol.NormalizePrice(Ask),
                        asymbol.NormalizePrice(sl_buy),
                        asymbol.NormalizePrice(tp_buy),
                        aorder.TypeTime(),
                        aorder.TimeExpiration()))
                        Print("Модификация BUY STOP прошла успешно! Тикет ордера = ",atrade.ResultOrder());
                     else
                        Print("Модификация BUY STOP прошла с ошибкой! Result Retcode: ",atrade.ResultRetcode(),
                              ", description of Retcode: ",atrade.ResultRetcodeDescription());
                    }
              }

Please tell me what is my mistake?

 
Mikhail:

It's about online. I really don't need it in the tester. I can't answer the question about the libraries, I'm a total dummy in programming. I just took a ready code of button from MQL5 Reference.

I've done it already but I have not got any errors, I cannot fix it yet. Apparently this is why button position is updated on the next tick. I do not understand how to make buttons move along with background.

And how did you determine that it is on the next tick and not on that one?)

 
Mikhail:
Please help to understand. Have code for trading panel to open pending Buy Stop order with subsequent trailing if order fails. The order is opened but there is no modification of the order. No errors are shown in the journal and we don't have any attempts to modify the order either. I tried to trace through the log at what stage an error occurs using the function:

Just inserted it after each if condition.

As a result, I found out that the function:

Successfully selects the order to proceed, but ifPrint("Order Selected!"); isinserted after this code:

then an error occurs:

2020.06.17 01:38:24.136 2020.01.02 07:40:00 failed modify order #2 buy stop 0.1 EURUSD_i at 1.12086 sl: 1.12023 tp: 1.12275 -> 1.00000, sl: 1.00000 tp: 1.00000 [Invalid price]

2020.06.17 01:38:24.136 2020.01.02 07:40:00 CTrade::OrderSend: modify #2 at 1.00000 (sl: 1.00000 tp: 1.00000) [invalid price]

2020.06.17 01:38:24.136 2020.01.02 07:40:00 BUY STOP modification failed! Result Retcode: 10015, description of Retcode: invalid price

I use the same code in another EA for autotrading (the only difference is the absence of such a code):


) and I have no problems. The orders are opened and modified without any problems.

Here is the code itself:

Can you please tell me what is my mistake?

Obviously, Normalize does not work properly. Unprint asymbol.Digits() asymbol.TickSize(),. Point() check .

 

Good day to all. Faced this problem when accessing EA to DLL:

Cannot load 'C:\....\shablon.dll' [487]

The error 487 seems to meanERROR_INVALID_ADDRESS but the path to the library is correct. Actually, I already put this dll in all folders, does not help.

What can it be? I will be grateful to you for help.


P.S. At first this dll was for 32 bit and worked in mt4*86. I recompiled it for 64 bit, now i put it on mt5*64 and have such problems.



 
Aleksey Mavrin:

How do you know what's on the next tick and not on that one?)

Until the new tick arrives, there is no movement of the buttons. That's what I can see with my eyes. As soon as the price changes, the buttons move.

Today, though, even on the new tick, the buttons have stopped redrawing, although I haven't changed anything. Only the background is moving.
 
Aleksey Mavrin:

Apparently Normalize doesn't work properly. rounds up to one. Unprint asymbol.Digits() asymbol.TickSize(),. Point() check .

When I make a query like this:

Print("Symbol ", _Symbol, " Digits ", _Digits, " Point ", Point());

I get this result:

2020.06.17 13:49:53.270 2020.01.02 06:50:00 Symbol EURUSD_i Digits 5 Point 1e-05

When I make a request like this:

Print("Symbol ",aorder.Symbol(), " Digits ", asymbol.Digits(), " Point ", asymbol.TickSize());

I get this result:

2020.06.17 13:51:58.787 2020.01.02 06:45:00 Symbol EURUSD_i Digits 0 Point 0.0

At the same time I want to note that if I don't insert Print function, I don't get any error at all, the order doesn't even try to modify itself. It is as if CTrade does not see my order.

Checking for symbol and magic number doesn't work:

Print("Symbol ", asymbol.Name(), " Magic ", aorder.Magic(), " Ticket ", aorder.Ticket()); 

Result:

2020.06.17 14:37:38.147 2020.01.02 06:50:00 Symbol Magic 0 Ticket 2

Magic number should be 12345, the symbol is euro dollar.

Why can't I get symbol and medgic?

If you change the string:

aorder.Symbol()==asymbol.Name()

is changed to

aorder.Symbol()==_Symbol

and remove validation by magic number, then we have problems with prices

2020.06.17 01:38:24.136 2020.01.02 07:40:00 failed modify order #2 buy stop 0.1 EURUSD_i at 1.12086 sl: 1.12023 tp: 1.12275 -> 1.00000, sl: 1.00000 tp: 1.00000 [Invalid price]

2020.06.17 01:38:24.136 2020.01.02 07:40:00 CTrade::OrderSend: modify #2 at 1.00000 (sl: 1.00000 tp: 1.00000) [invalid price]

2020.06.17 01:38:24.136 2020.01.02 07:40:00 BUY STOP modification failed! Result Retcode: 10015, description of Retcode: invalid price

I've already racked my brains, while this same code works fine in another Expert Advisor.

What am I doing wrong?

Документация по MQL5: Общие функции / Print
Документация по MQL5: Общие функции / Print
  • www.mql5.com
Данные типа double выводятся с точностью до 16 десятичных цифр после точки, при этом данные могут выводиться либо в традиционном либо в научном формате – в зависимости от того, как запись будет наиболее компактна. Данные типа float выводятся с 5 десятичными цифрами после точки. Для вывода вещественных чисел с другой точностью либо в явно...
 
dozolov:

Good day to all. Faced this problem when accessing EA to DLL:

Cannot load 'C:\....\shablon.dll' [487]

The error 487 seems to meanERROR_INVALID_ADDRESS but the path to the library is correct. Actually, I already put this dll in all folders, does not help.

What can it be? I will be grateful to you for help.


P.S. At first this dll was for 32 bit and worked in mt4*86. I recompiled it for 64 bit and now I put it on mt5*64 and have such problems.



ERROR_INVALID_ADDRESS is not about path. You are passing the wrong arguments.