Optimization by script - hmmm??

 

Hi,

I have coded an indicator that runs perfectly.

Now I have written a script that loops though the variables and calls this indicator (several thousand times):

double toOpti = iCustom(sym,tf, "myIndi",var1,var2,var3,var4,3,0);

While running the script (= looping: for(var1.. for(var2..)) once and a while I get no result and can read in the log many times:

0    15:08:28.274    Custom indicator myIndi EURUSD,M1: loaded successfully

1    15:08:28.276    myIndi EURUSD,M1: invalid EX4 file (8)

3    15:08:28.276    myIndi EURUSD,M1: global initialization failed

0    15:08:28.276    Custom indicator myIndi EURUSD,M1: removed

This happens many times one after the other and then again it works and I get valid results.

I checked the numbers that failed but the myIndi runs with those numbers perfectly - it cannot be the reason of the failure.

In the indi's init() (before 600+ version) I have only a return(0) - and the values do work if not called by my script?

Any ideas what to do?


PS I think I have found the reason the required memeory increases from 4GB to 8GB quite quick (there are actually locally 184'806 bars available for the m1 chart).

So it seems that after myIndi has been called its space in the ram is not returned - any idea how I can free the accessed memory?

ResourceFree("rec-name") deletes dynamically created resource (freeing the memory allocated for it), but it seems hat it cannot be used with called indicators,

as it counterpart: ResourceCreate(..) loads data sets from files but not indicators :(

 
gooly:

1    15:08:28.276    myIndi EURUSD,M1: invalid EX4 file (8)

This happens many times one after the other and then again it works and I get valid results.

In the indi's init() (before 600+ version) I have only a return(0) - and the values do work if not called by my script?


Any ideas what to do?

  1. Can someone please advise where I send a Request for Support to Metaquotes. - MQL4 forum
  2. Get in touch with developers using Service Desk! - MQL5 forum
  3. Report it to the service desk. 'MQL5.community - User Memo' - an article about the algorithmic/automated trading in MetaTrader
  4. Report it to the Service Desk, not us users.
 

WHRoeder,

I know where to ask the Service Desk, but this is one of the questions or requests - I am sure - they do not answer

as some things are coded in an easy way for the programmer but are inconvenient for the clients.

And may be some one here has found a non-official work around and/or there are new functions that might do the trick.

Beside that the service desk has lost completely any kind of text-structure tools: a step into the future by stating at the beginning of the internet :(

 

Now I have tried to put the loops within the indicator and as well it isn't working as it should!

1) I wrote to the Service Desk this:


2) This is how it looks like now:


At the moment it performs a reduced number of loops for more than 20 minutes that took in the script (loading and initializing the indicator each time it is called with a new parameter set-up) approx. 4 minutes.

By the way the Jounal-Tab-log increased up to 4 GB yesterday by the script.

Anybody here with an idea?

 

I do not think there is a chance for a workarround.

My humble private understanding of iCustom is that it creates a complete set of new buffers every time there is unique set of parameters (but the last one, the index) and keeps them for later use. And I suppose the only way how to release them is stopping the script (or the expert).

You may try to avoid iCustom if you can. In case you keep the symbol and the timeframe, and change only the parameters, you could recode the indicator and use it directly in the script, avoiding the the iCustom call.

If you need to change the symbol and timeframe as well, every new combination additionally loads the complete chart data buffers (not virtually), but it should not hit the 2 GB limit.

 
mql4 b600+ does now know ResourceFree("name") - so in my simple-mindedness I assumed that this should work with iCustom as well, especially as this requests so much memory.
 
gooly:
mql4 b600+ does now know ResourceFree("name") - so in my simple-mindedness I assumed that this should work with iCustom as well, especially as this requests so much memory.
I have no experience with that command but according to the guide it is only applicable to pictures created by ResourceCreate().
 
It is new to me too and I was very disappointed when I discovered this order but read as well for what it can be used only.
 
gooly: WHRoeder,

I know where to ask the Service Desk, but this is one of the questions or requests - I am sure - they do not answer


Beside that the service desk has lost completely any kind of text-structure tools: a step into the future by stating at the beginning of the internet :(

  1. They answer me just fine (takes several months)
  2. I have already told(shown) you, my service desk had the same, exact, tool bar that this forum has. Formatting works just fine.

  3. What you wrote there is unintelligible to me. Perhaps they couldn't understand you either and ignored you. 
  4. "I now try to put the loops withing the indicator itself - and that fails as well" What do you expect them to do that that statement. You show no code, you don't state your definition of fails. Of course they're ignoring you.
  5. "I places at some IsStopped() but I cannot use them as the chart is greyed..." You placed what at some where? You cannot use what? Intelligible.
  6. Write a simple test script, show the output, state your expected result. If you can't isolate something down to that, no one could help you.
 

1) really - I have several not answered questions and requests. One e.g. is dated 2014.11.17 21:12 and called spooky spots with my code and picture.

2) This is what I get to write a new message - even attaching files does not work!!


3) Within a longer loop of an indicator I put a IsStopped() which does not work! I can either kill the terminal or wait until the loop is finished - what is "unintelligible"?

4,5,6) I need to write a code for you to understand 3) - ok:

int OnCalculate( ...) {
...
   int x = 100000;
   while(x-->0) {
      ...
      if ( IsStopped() ) return(ChartIndicatorDelete(0,ChartWindowFind(),ShortName));
   ...

Anyway to calm down while waiting for Godot I do some bird watching: http://pontu.eenet.ee/player/juras-erglis.html

 
  1. I previous posted the image that showed service desk works fine. Here is another.x

  2. Within a longer loop of an indicator I put a IsStopped() which does not work! I can either kill the terminal or wait until the loop is finished - what is "unintelligible"? What you just wrote was English. what you previously posted was not. "I places at some IsStopped() but I cannot use them as the chart is greyed..."

  3. Since indicators run in the terminal thread, (this is why indicators can not sleep,) the terminal can not receive any event that could set _StopFlag to stop the indicator. There is nothing wrong. You must break your long indicator to do update in multiple ticks.