Download MetaTrader 5

OnInit : init_agent_not_suitable : how to use it ?

To add comments, please log in or register
Icham Aidibe
10376
Icham Aidibe  

Hi,

Previous post. The service told me to use init_agent_not_suitable but I can't find any examples on how to use it ?

genetic pass (0, 37) tested with error "no memory in OnTick function (cannot get 960 Kb, used 0 Mb)" in 140 ms (PR 137)
Alain Verleyen
Moderator
33488
Alain Verleyen  
blouf:

Hi,

Previous post. The service told me to use init_agent_not_suitable but I can't find any examples on how to use it ?

For example :

   if(TerminalInfoInteger(TERMINAL_MEMORY_AVAILABLE<10)
      return(INIT_AGENT_NOT_SUITABLE);
Icham Aidibe
10376
Icham Aidibe  
angevoyageur:

For example :

Precisely. How to know how much mb required for the EA to run it ? Will 10 filter well ?
Alain Verleyen
Moderator
33488
Alain Verleyen  
blouf:
Precisely. How to know how much mb required for the EA to run it ? Will 10 filter well ?
It depends of your EA needs, it's up to you to find good settings
Icham Aidibe
10376
Icham Aidibe  
angevoyageur:
It depends of your EA needs, it's up to you to find good settings

So here's the answer of the support team.

Support Team 2014.12.12 15:02

Check this example:

int OnInit()
  {
//--- the EA consumes 1 GB for calculations
//--- don't use agents with less than 2 GB memory available
   if(TerminalInfoInteger(TERMINAL_MEMORY_PHYSICAL)<2048)  return(INIT_AGENT_NOT_SUITABLE);
//--- available memory should not be less than 1 Gb
   if(TerminalInfoInteger(TERMINAL_MEMORY_AVAILABLE)<1024) return(INIT_AGENT_NOT_SUITABLE);
//--- OK
   return(INIT_SUCCEEDED);
  }


void OnDeinit(const int reason)
  {
//--- show the approximate size of memory used
   Print("Used ",TerminalInfoInteger(TERMINAL_MEMORY_USED)," Mb of memory");
//---
  }  
So, to estimate the size of memory consumed by the EA, use TERMINAL_MEMORY_USED in OnDeinit. Then use this value for checks in OnInit.
Alain Verleyen
Moderator
33488
Alain Verleyen  
blouf:

So here's the answer of the support team.

Support Team 2014.12.12 15:02

Check this example:

So, to estimate the size of memory consumed by the EA, use TERMINAL_MEMORY_USED in OnDeinit. Then use this value for checks in OnInit.
It's a very good answer, you are lucky.
Icham Aidibe
10376
Icham Aidibe  
angevoyageur:
It's a very good answer, you are lucky.
Indeed. The EA gives good results on weekly testing, worried it won't run on yearly. Let's see ...
Icham Aidibe
10376
Icham Aidibe  
blouf:
Indeed. The EA gives good results on weekly testing, worried it won't run on yearly. Let's see ...
'return' - 'void' function returns a value 

Using the code above inside OnInit, that's the error I get. Any idea ?
Icham Aidibe
10376
Icham Aidibe  
int OnInit()
{
Use OnInit as an int when using the retcodes. Here we are ...
Icham Aidibe
10376
Icham Aidibe  
blouf:
Use OnInit as an int when using the retcodes. Here we are ...

:) I yet not solved the optimization problem. Even when allowing 3 gb.  Without the agent (I btw have to repay each pass requeued) how much time will it take ? On MQL4, there's no agent, does it last ... err a month ?

2014.12.15 15:23:53	MQL5 Cloud Europe 2	genetic pass (0, 265) tested with error "no memory in OnTick function (cannot get 4096 Kb, used 0 Mb)" in 812 ms (PR 193)
2014.12.15 15:24:02     MQL5 Cloud Europe 2     genetic pass (0, 470) tested with error "critical runtime error 520 in global initialization function (cannot load expert because of transformation error)" in 1 ms (PR 193)
Alain Verleyen
Moderator
33488
Alain Verleyen  
blouf:

:) I yet not solved the optimization problem. Even when allowing 3 gb.  Without the agent (I btw have to repay each pass requeued) how much time will it take ? On MQL4, there's no agent, does it last ... err a month ?

Seems an another error :

"critical runtime error 520 in global initialization function (cannot load expert because of transformation error)"

Did you report it to ServiceDesk ?

Your code seems to consume a lot of memory, possible ?

12
To add comments, please log in or register