[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 323

 
Vinin писал(а) >>

That's why you make mistakes on purpose.

And on purpose, it's funny... I'd love to see that mistake, but I can't find it.

 
Daiver2 >> :

I run some functions as a test script to see if there are any compilation errors and which ones to check if they work or not in the terminal. I took today the Pre-calculation function of bars in the window:

Naturally the message *Not enough bars* comes out, but on a new tick I understand this message will appear again indefinitely.

Now I add a variable and write in an if statement, and also in the future block of errors handlers Bloc_Error, I put in an operator switch and result it:

The question is what I've done wrong in the switch statement, why isn't the message *Expert is not working* displayed, and why does the EA really stop working?????
//+------------------------------------------------------------------+      
    switch()//?????????????? почему в switch не передаёте параметр 
      {
      case 3:          // Неверные параметры:
      Work=false;
      return(0);
      }


 

Hi all!

I can't understand the cause of the error when the EA is running. I am testing one EA on 11 pairs in one terminal at the same time (demo account). I check entry conditions at the beginning of every hour, i.e. 11 EAs start working simultaneously. The IsTradeBusy() function (from here https://www.mql5.com/ru/articles/1412) has been used not to disturb each other. Recently, the Expert Advisor has been reporting an error when it tries to change the value of the TradeIsBusy global variable instead of opening a position. Here is part of the code:

     // пытаемся менять значение TradeIsBusy с 0 на 1
     // если нам это удаётся, выходим из ф-ции, возвращая 1 - "успешное завершение"
     if(GlobalVariableSetOnCondition( "TradeIsBusy", 1.0, 0.0 )) 
         return(1);
     else
     // если нет, возможны 2 причины: TradeIsBusy = 1 (тогда надо ждать), либо 
     // возникла ошибка (это мы и проверим)
     {
        _GetLastError = GetLastError();
        // если это всё таки ошибка, выводим информацию и пробуем ещё раз
        if(_GetLastError != 0)
        {
           Print("TradeIsBusy()-GlobalVariableSetOnCondition(\" TradeIsBusy\",1.0,0.0 )-Error #",
           _GetLastError );
           continue;
        }
     }

Error codes:

#4002 - "array index - out of range"

#4105 - "No order is selected".

I do not understand what conditions may cause these errors using the GlobalVariableSetOnCondition command ?

Terminal Broco Trader 4.0 build 225.

Can the terminal glitch like this ?

 
Urain писал(а) >>

>>Thank you, I will.

 
OAndrey писал(а) >>

Hi all!

I can't understand the cause of the error when the EA is running. I am testing one EA on 11 pairs in one terminal at the same time (demo account). I check entry conditions at the beginning of every hour, i.e. 11 EAs start working simultaneously. The IsTradeBusy() function (from here https://www.mql5.com/ru/articles/1412) has been used not to disturb each other. Recently, the Expert Advisor has been reporting an error when it tries to change the value of the TradeIsBusy global variable instead of opening a position. Here is part of the code:

Error codes:

#4002 - "array index - out of range"

#4105 - "No order is selected".

I do not understand what conditions may cause these errors using the GlobalVariableSetOnCondition command ?

Terminal Broco Trader 4.0 build 225.

May terminal glitch like this?

I cannot say anything about this piece of code. And as a tip. Reset the state of the last error at the beginning of the function. It may occur somewhere else.

   GetLastError();  //Сбрасываем состояние 

   // пытаемся менять значение TradeIsBusy с 0 на 1
   // если нам это удаётся, выходим из ф-ции, возвращая 1 - "успешное завершение"
   if(GlobalVariableSetOnCondition( "TradeIsBusy", 1.0, 0.0 )) 
      return(1);
   else
   // если нет, возможны 2 причины: TradeIsBusy = 1 (тогда надо ждать), либо 
   // возникла ошибка (это мы и проверим)
   {
      _GetLastError = GetLastError();
      // если это всё таки ошибка, выводим информацию и пробуем ещё раз
      if(_GetLastError != 0)
      {
         Print("TradeIsBusy()-GlobalVariableSetOnCondition(\" TradeIsBusy\",1.0,0.0 )-Error #",
         _GetLastError );
         continue;
      }
   }
 

How to make a line break in the text? For example, I display something on a graph, in OBJ_LABEL, and I want the text to be written in several lines.

 
Mathers >> :

How to make a line break in the text? For example I display something on a chart, in OBJ_LABEL, and I want the text to be written in several lines.

Display in multiple labels.

 

What if the number of lines changes dynamically? And it can be quite large. Maybe something else can be used instead of a label?


And here's another question: let's say I have a script that does something in an infinite loop with a delay of e.g. one second. When I try to remove it - I choose "delete script" but it's not removed from the chart, it starts ramming without any delay. When I press "delete" once more it removes the script. What is the matter? Maybe something I should add to the code to complete it correctly?

 
Mathers >> :

What if the number of lines changes dynamically? And it can be quite large. Maybe something else can be used instead of a label?

Alert, alternatively. Comment -- that's good.

And here's another question: let's say I have a script that does something in an infinite loop with a delay of e.g. one second. When I try to remove it - I choose "delete script" but it's not removed from the chart, it starts ramming without any delay. When I press "delete" once more it removes the script. What is the matter? Maybe I should add some extra words into my code.

Replace while(true) with while(!IsStopped())

 
Mathers >> :

What if the number of lines changes dynamically? And it can be quite large. Maybe something else can be used instead of a label?

No. Unless the comment doesn't fit. Write a f-function where the output will be generated and write what you need through it.

And here's another question: let's say I have a script that does something in an infinite loop with a delay of e.g. one second. When I try to remove it - I choose "delete script" but it's not removed from the chart, it starts ramming without any delay. When I press "delete" once more it removes the script. What is the matter? Maybe I should add some extra words into my code.

That's how it should be.

Reason: