Many calls to the same iCustom causes Memory Error, please HELP !!!

 
Hi,


I wrote a script that would help me determine which bar after opening an order gives the best profit. I am using custom indicator that gives me the signal. It worked fine with providing variables for the indicator manually (there are 4 of them: Short EMA, Long EMA and 2 more).


I went one step further. I wrote 4 nested FOR loops that would increment values for my variables so I can list all the results, write them into the CSV file and analyze them in Excel. This is my way of having an optimizer that isn't affected by all the order handling issues.


Now the problem. Each time the loop calls a custom indicator, memory usage increases. After couple of iterations I get the "Not enough memory for custom indicator" message and the script fails. It seems that indicators called once are stored in memory until the end of the script, just like it was adding invisible indicator windows to the chart.

Is there any way of telling MT that I don't need that custom indicator anymore and it can be removed? Maybe they should go to the same "virtual window" so the next one would overwrite the previous? Any suggestions?


Thanks,

Allerune

 

I can see a workaround here. I would have to convert my script into EA, run EA in optimizer mode with parameters as set before. The only thing is that I would have to run an "InvestigateOpenings" function only once per iteration, for the tick closest to the current date as possible.


PROBLEM: how would I display the results. Isn't the optimizer turning off all the file operations ? There would be no orders open in this case so the standard report wouldn't give me any information.

 
in tester the EA is writing files to the folder tester/files/
 
meikel:
in tester the EA is writing files to the folder tester/files/

you're right, Optimizer doesn't stop the file from beeing created that's good



The problem is that it is DEAD SLOW !!! 5 runs in 48 seconds, only fraction of this time is used for my algorithm

 

+ stringoperations slow down, try to use StringConcatenate() instead of " hello"+"world"+somevariable.

i mostly disable logging while optimizing, or only 1 time per day, not each minute,hour or most slowly, each tick

 
meikel:

+ stringoperations slow down, try to use StringConcatenate() instead of " hello"+"world"+somevariable.

For the record, I did some testing of this a while ago, and StringConcatenate() seems to be slower than the + operator in almost any conceivable real-life scenario. However, in some extreme cases I have had the + operator appear to leak memory...

 

jjc, i had an EA with massive + operations, after rewriting to Concatenate it had run much faster, but who knows the miracles inside of MQ4

maybe sometimes this and sometimes the other way works better, i dont know ... ;-)

 
meikel:

+ stringoperations slow down, try to use StringConcatenate() instead of " hello"+"world"+somevariable.

i mostly disable logging while optimizing, or only 1 time per day, not each minute,hour or most slowly, each tick

Do you have ANY idea of what I'm trying to do? It doesn't seem like it from your posts...