Sharing data between an EA and a script in MT4 - URGENT HELP REQUIRED

 

Hi all,

I wonder if any of you MT4 gurus could be of assistance to me? I would greatly appreciate it.

I have an MT4 application which consists of 1 EA and 1 script. The EA, as you know, executes the start() method per tick. The script I have written has a while loop which sleeps every 1 milliseconds and performs several functions. One of its functions is to maintain and update the elements in a 2 dimensional string array. This array is declared as a global variable at the top of the script. This script must run independently of the EA.

My problem is......I need the EA (in its start() method) to be able to read the value of the array declared in the script. Is there any way to do this without having to use something like reading/writing to the file system?

I know i CANNOT use GlobalVariableGet because these global variable do NOT support arrays. You can only use them to insert double values! Is there any other way?

 
I'm no guru. Buy why not use an Indicator for the task since the script does-not perform any trade functions?
 

Hi ubzen,

so if I moved the code from the script into a custom indicator, how can the EA get the value from the indicator?

Can can EA call an indicator? If so, then this will work, once I can write an indicator to implement a 'start' script with a permanent 'while' loop

 
Ea can call Indicators. Indicators work with Arrays. You can get values from Indicator to EA by using Buffers. I'm not so sure about the endless loop tho.
 

Do you know if an EA can refer to a global variable or call a custom method in an Indicator?

If so...then you have found a solution for me :)

 
I usually use iCustom to retrieve indicator values within the EA. I'm not sure if you're aware of the iCustom(). And I'm not sure why it would not work for you if you are aware of it.
 
Actually...hang on...my script DOES make trades....so I cannot use an indicator. Can you think of another approach?
 

Yeah, just looked it up. You cannot do endless loops in indicators. So no milliseconds stuff. But this topic comes up allot. I'm sure there are other solutions if you search.

 

http://www.fx1.net/wiki/pmwiki.php/PermVar/PermVar may be interesting for you.

Also check this video as demonstration:

https://www.youtube.com/watch?v=rZCZJaQkLEA

Reason: