Download MetaTrader 5

Optimization by script - hmmm??

To add comments, please log in or register
Do you need a programmer? Make an order to let the developer find you!
Carl Schreiber
6586
Carl Schreiber 2015.04.29 13:31 

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 :(

whroeder1
14480
whroeder1 2015.04.29 15:57  
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.
Carl Schreiber
6586
Carl Schreiber 2015.04.29 16:46  

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 :(

Carl Schreiber
6586
Carl Schreiber 2015.04.30 08:43  

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?

Ex Ovo Omnia
3144
Ex Ovo Omnia 2015.04.30 10:09  

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.

Carl Schreiber
6586
Carl Schreiber 2015.04.30 11:14  
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.
Ex Ovo Omnia
3144
Ex Ovo Omnia 2015.04.30 11:35  
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().
Carl Schreiber
6586
Carl Schreiber 2015.04.30 11:53  
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.
whroeder1
14480
whroeder1 2015.04.30 14:30  
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.
Carl Schreiber
6586
Carl Schreiber 2015.04.30 15:32  

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

whroeder1
14480
whroeder1 2015.04.30 16:55  
  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.
12
To add comments, please log in or register