Download MetaTrader 5
To add comments, please log in or register
Do you need private account monitoring? The Signals will provide you one!
Clock
1183
Clock 2013.07.03 13:36 

Hi!

I have the following problem:

in one of my EAs, I want to change the lookback period of an indicator, depending on market conditions.


I thought

if(h_ind!=INVALID_HANDLE){IndicatorRelease(h_ind;}

h_ind=iCustom(...)


should do the trick.

However, I constantly run into "out of memory" errors, no single cloud agent finishes it's job, and so on.


Do I have to, or can I manually not only release the indicator, but also the memory it used?

I really don't understand, what's not working for me.



Thanks in advance,

Clock

Alain Verleyen
Moderator
30203
Alain Verleyen 2013.07.03 13:57  

Clock:

I thought

if(h_ind!=INVALID_HANDLE){IndicatorRelease(h_ind;}

h_ind=iCustom(...)

This approach seems correct, but you have to check the returned value of IndicatorRelease(). If you need more help you have to provide some snippets of codes that reproduce your issue AND compiles.
Clock
1183
Clock 2013.07.03 23:35  
Well, it really just is the iATR indicator, with a Period of between 50 and 500 on a 15 Min Chart...
Documentation on MQL5: Technical Indicators / iATR
Documentation on MQL5: Technical Indicators / iATR
  • www.mql5.com
Technical Indicators / iATR - Documentation on MQL5
Alain Verleyen
Moderator
30203
Alain Verleyen 2013.07.04 00:20  
Clock:
Well, it really just is the iATR indicator, with a Period of between 50 and 500 on a 15 Min Chart...
The problem is obviously not in the indicator but in your code (EA).
Clock
1183
Clock 2013.07.04 01:48  

Then I'd be interested to know what might be wrong with this simple script.

Because it crashes with a "too low memory" error when tested in EURUSD, 15Min, 01/01/08 till 12/31/12 pretty soon.

Just a simple demonstration of my problem. Can you reproduce it?

//+------------------------------------------------------------------+
//|                                                       TestEA.mq5 |
//+------------------------------------------------------------------+
int         h_atr;
datetime    lastbar;
int OnInit()
  {
   h_atr=iATR(_Symbol,_Period,100);
   if(h_atr==INVALID_HANDLE){return -1;}
   MathSrand(10);
   return(INIT_SUCCEEDED);
  }
void OnDeinit(const int reason)
  {
  }
void OnTick()
  {
   datetime now[1];
   if(CopyTime(_Symbol,_Period,0,1,now)<1){return;}
   if(now[0]==lastbar){return;}
   lastbar=now[0];

   int period=(int)MathFloor(MathRand()/1000+50);
   if(h_atr!=INVALID_HANDLE){IndicatorRelease(h_atr);}
   h_atr=iATR(_Symbol,_Period,period);

  }
Alain Verleyen
Moderator
30203
Alain Verleyen 2013.07.04 10:40  
Clock:

Then I'd be interested to know what might be wrong with this simple script.

Because it crashes with a "too low memory" error when tested in EURUSD, 15Min, 01/01/08 till 12/31/12 pretty soon.

Just a simple demonstration of my problem. Can you reproduce it?

You are right, same problem. I can't see a problem in the code, or we do not see, or there is a bug in mql5. You have to report this to ServiceDesk.
Get in touch with developers using Service Desk!
Get in touch with developers using Service Desk!
  • www.mql5.com
We therefore attach great importance to all user reports about issues in our programs and try to answer each one of them.
Clock
1183
Clock 2013.07.04 10:44  

Thanks for checking my code. I cannot say I'm happy that you get the same results, but at least it's not a problem with my hardware.

I'll try to explain it to the service desk then.

Clock
1183
Clock 2013.07.04 17:49  
So I wrote it to the Service Desk. Any experience, on how fast they answer? So I get a response, once my bug was at least noticed?
Alain Verleyen
Moderator
30203
Alain Verleyen 2013.07.04 19:07  
Clock:
So I wrote it to the Service Desk. Any experience, on how fast they answer? So I get a response, once my bug was at least noticed?
Between 1 hour and 1 year
Simon Gniadkowski
Moderator
17990
Simon Gniadkowski 2013.07.07 10:49  
Clock:

Then I'd be interested to know what might be wrong with this simple script.

Because it crashes with a "too low memory" error when tested in EURUSD, 15Min, 01/01/08 till 12/31/12 pretty soon.

Just a simple demonstration of my problem. Can you reproduce it?

Perhaps you should check if  period  is 0  you can't have an averaging period of 0,  the code for iATR should handle this but maybe it doesn't.
Alain Verleyen
Moderator
30203
Alain Verleyen 2013.07.07 11:46  
RaptorUK:
Perhaps you should check if  period  is 0  you can't have an averaging period of 0,  the code for iATR should handle this but maybe it doesn't.

It's always a good idea to check values, but

   int period=(int)MathFloor(MathRand()/1000+50);

period can't be 0.

/ /123
To add comments, please log in or register