Errors, bugs, questions - page 2859

 
fxsaber:

In general, what are your thoughts on a possible implementation?

There are many possible implementations

but it all comes down to the task of data exchange between EAs

the easiest way is to check permission for initialization and perform the initialization itself in OnTick() - it would allow to avoid restoring charts and then running EA on them, and saving of EA before closing it would be possible to do in OnDeinit()

it' s not important who will manage this zoo - either the main EA or a service

 

In the tester log

2020.09.28 00:41:09.491 wrong tester bar time
2020.09.28 00:41:09.491 history error 9 in undefined function

What does it mean?

 
Aleksey Vyazmikin:

In the tester log

What does it mean?

It means that when the next value of m1 ohlc is received (or bar state when testing by open prices), the time field contains 0

undefined function means that the problem has occurred outside the predefined functions (OnTick, OnTimer etc.), i.e. in the main loop of the tester

 
Slava:

It means that when getting the next m1 ohlc value (or bar state when testing by open prices) the time field contains 0

undefined function means that the problem has occurred outside the predefined functions (OnTick, OnTimer etc.), i.e. in the main loop of the tester

Everything was working fine all day and then it started. What can I do as a user?

 
Slava:

It means that when getting the next m1 ohlc value (or bar state when testing by open prices) the time field contains 0

undefined function means that the problem has occurred outside the predefined functions (OnTick, OnTimer etc.), i.e. in the main loop of the tester

I don't understand, is there an error in my code or is it an error in the terminal? Wiped out all the history - didn't help.

Added:

Found a function in my code, disabling it avoids the error, but in another EA this function works correctly! How so? I can drop it in my private message.

Even when this buggy function is enabled, OnTick() runs completely on the first bar and then that error.

On different terminals the error is confirmed.

Ran on ticks - no error...

But the strangeness is in the log:

2020.09.28 17:22:22.327 2020.09.18 09:45:02   Test_01

On ticks if to look the tool, the first tick was exactly at 10:00, and trading session is still closed at this time. This is in visual mode, without tick the first print comes at 10 o'clock.

 
Igor Makanu:

The easiest way is to check the initialisation permission at the beginning of each EA in OnTick()

This is the main sticking point of the problem.
 
fxsaber:
This is the main problem of the task.

Try to pay attention to the chart IDs and run by seniority. But this does not cancel the interaction of EAs. Or make a file or maybe a SQLite database with chart IDs in the launch sequence.

Something like, at the first initialization, if there is no Chart_ID() in the list, then it is entered into the list. If it is not closed due to terminal closure, then it is removed from the list. In this way it will be possible to configure the interaction of EAs.

 
fxsaber:
This is the main sticking point of the problem.

sketching out how I see it... created 2 EA with this code:

#define  PREFIX_NAME "QWERTY_"
enum ENUM_EA_STATE {WORK, READY_TO_INIT, ENABLE_INIT, ERROR_GLOBAL_VARIABLE};
const string this_ea_name = PREFIX_NAME + MQLInfoString(MQL_PROGRAM_NAME);
void OnTick()
{
   static ENUM_EA_STATE state = GlobalVariableSet(this_ea_name, ENUM_EA_STATE::READY_TO_INIT) > 0 ? READY_TO_INIT : ERROR_GLOBAL_VARIABLE;
   Comment(EnumToString(state));
   if(state != WORK)
   {
      if(state == ERROR_GLOBAL_VARIABLE) return;
      if(!My_Init(this_ea_name)) return;
      GlobalVariableSet(this_ea_name, ENUM_EA_STATE::WORK);
      state = WORK;
   }
   Print(this_ea_name, " ", __FUNCTION__);
}
//+------------------------------------------------------------------+
bool My_Init(const string chek_ea_name)
{
   if(GlobalVariableGet(chek_ea_name) == (ENUM_EA_STATE)ENABLE_INIT)
   {
      Print("EA is init");
      return(true);
   }
   return(false);
}
//+------------------------------------------------------------------+

and one control EA, which works in timer ( 5 sec )

#define  PREFIX_NAME "QWERTY_"
enum ENUM_EA_STATE {WORK, READY_TO_INIT, ENABLE_INIT, ERROR_GLOBAL_VARIABLE};
//+------------------------------------------------------------------+
int OnInit()
{
   EventSetTimer(5);
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
   EventKillTimer();
}
//+------------------------------------------------------------------+
void OnTimer()
{
   for(int i = GlobalVariablesTotal() - 1; i >= 0; i--)
   {
      string curr_gname = GlobalVariableName(i);
      if(StringFind(curr_gname, PREFIX_NAME) !=-1)
      {
         if(GlobalVariableGet(curr_gname) == (ENUM_EA_STATE)READY_TO_INIT)
         {
            if(GlobalVariableSet(curr_gname, ENUM_EA_STATE::ENABLE_INIT) > 0)
            {
               Print("Enable Init : ", curr_gname, ".....exit");
               return;
            }
         }
      }
   }
}
//+------------------------------------------------------------------+


Checked it, everything works, the only thing, or it didn't work with GlobalVariableSetOnCondition() to make a record in global variables

 
fxsaber:
This is the main problem of the task.

GlobalVariableSetOnCondition is all that is needed to solve the problem.

Operation is only allowed when GlobalVariableSetOnCondition has returned true.
After successful initialization and release of resources, return the main variable to its original state and another EA starts.

In DeInit - unconditional deletion of the variable, so as not to run into the terminal without EAs at all (if the previous loading was not completed correctly).

 
Alexey Viktorov:
Igor Makanu:
Andrey Khatimlianskii:

Thanks for the recommendations. I will look at GlobalVariableSetOnCondition.