Is there any limit on how many variables you can use in one EA?

 

To trade at better price, I need to save trade information in a string and execute the trade when market reaches a better price.

This works without problem until someday when I add variables to some point - it seems the EA has reached a limit.

This is especially about some string variables that save trade information. I printed the value of the string when it was just refreshed:

it showed something like this:

2012.08.08 23:20:15 TES_Forex_Trader20.05 NZDUSD,M15: Long2Buy = LongRecover_L*50986*0.01*0.81368&LongRecover_S*60986*0.01*0.81368

At the next tick, my EA should check whether the price lowered to 0.81368 and decide whether to execute the trades.

It normally works with no problem, but suddenly after I added more variables, it stopped working. At next tick, the value of string variable Long2Buy changed to empty. I have checked again and again. There is nowhere the value of Long2Buy can be changed after I printed its value as above.

BTW, my EA has more than 9000 lines. There are about 500 variables on global scope. And the most interesting thing is the EA works without problem in backtesting.

Does anyone have any idea about the limit of the mql4 EA?

 
More probable to be due to the code change that added more variables and lines of code rather than the number of variables the code has.
 
Ickyrus:
More probable to be due to the code change that added more variables and lines of code rather than the number of variables the code has.


Thanks for the reply! The added code has nothing to do with it.

And it works in backtesting. And I have checked carefully several times.

 
tesforex:


Thanks for the reply! The added code has nothing to do with it.

And it works in backtesting. And I have checked carefully several times.

You seem too sure of whats wrong and not-wrong about your expert. IMO- your question is too broad for anyone to answer without saying whats probably causing the issue.

*It could be due to limited system resources.

*Newly added codes which are not optimized.

*Something else within the program.

*Etc....etc....etc

Does anyone have any idea about the limit of the mql4 EA? Sounds like you want someone to just tell you a #_limit_of_variables for mql4. Well I'm not aware of any Variable-Limits. As far as general mql4 limits, they're too numerous to list.

 
ubzen:

You seem too sure of whats wrong and not-wrong about your expert. IMO- your question is too broad for anyone to answer without saying whats probably causing the issue.

*It could be due to limited system resources.

*Newly added codes which are not optimized.

*Something else within the program.

*Etc....etc....etc

Does anyone have any idea about the limit of the mql4 EA? Sounds like you want someone to just tell you a #_limit_of_variables for mql4. Well I'm not aware of any Variable-Limits. As far as general mql4 limits, they're too numerous to list.


Thanks for the response!

What I really need is just the general mql4 limit. The code should be OK because it works in backtesting.

But it doesn't work properly in real trading. It used to work without problem.

Sorry I cannot post the real code. It's a complex trading system with many many trading strategies combined together.

But for placing order, I either place an order directly, or save it in a string for a better time to trade. The problem is the string (global scope string) that saves the trading info was reset to empty when there is a new tick. There is nowhere in the code to delete info from the string unless the trade is actually made.

That's why I doubted I might have hit some mql4 limit.

 
tesforex:


Thanks for the response!

What I really need is just the general mql4 limit. The code should be OK because it works in backtesting.

But it doesn't work properly in real trading. It used to work without problem.

Sorry I cannot post the real code. It's a complex trading system with many many trading strategies combined together.

But for placing order, I either place an order directly, or save it in a string for a better time to trade. The problem is the string (global scope string) that saves the trading info was reset to empty when there is a new tick. There is nowhere in the code to delete info from the string unless the trade is actually made.

That's why I doubted I might have hit some mql4 limit.

In that case I'll strongly recommend getting familiar with file_functions. Global Scope Strings would_not keep the values when the terminal closes and restarts for whatever reason, you would-not notice this problem during a back-test. With file-functions, you have better control over the strings you Write/Save to file and Read/Retrieve from file.
 
ubzen:
In that case I'll strongly recommend getting familiar with file_functions. Global Scope Strings would_not keep the values when the terminal closes and restarts for whatever reason, you would-not notice this problem during a back-test. With file-functions, you have better control over the strings you Write/Save to file and Read/Retrieve from file.


Yes, I do use a lot file functions. All the string values are saved in files also. Other variables are saved in global variables simutaneously. But for backtesting, I still have to use the variables in global scope for strings since the MT4 has many limits on file operations in backtesting.

I googled but found out no info about general mql4 limits. If we can ask somene from Metaquote company, we might get the answer. People seldom need to deal with this kind of problems after all.

 
tesforex:


Yes, I do use a lot file functions. All the string values are saved in files also. Other variables are saved in global variables simutaneously. But for backtesting, I still have to use the variables in global scope for strings since the MT4 has many limits on file operations in backtesting.


Really ? such as what ?
 

It would be strongly recomended to save the status of all the varibles in a file and reload them in the init() to protect against internet interuption and computer meltdowns. One major problem with computers is something called 'memory leak' this is where for example a bit of memory has been reserved for use but never released from being reserved so the computer 'thinks' it has less memory while the reserved area never gets used.

 
RaptorUK:

Really ? such as what ?


like this: FileOpen(File_Name, FILE_CSV|FILE_READ, ",");

File reading is never executed properly. And it's easier to use variables in global scope in backtesting. I oly use file operations in the real trading version for backing-up as Ickyrus recommended.

 
tesforex:


like this: FileOpen(File_Name, FILE_CSV|FILE_READ, ",");

File reading is never executed properly. And it's easier to use variables in global scope in backtesting. I oly use file operations in the real trading version for backing-up as Ickyrus recommended.


If that is you experience then you are doing something very wrong.
Reason: