programatically get extern variable value

 
Is this possible with mql??

indicator X is active on the chart and it has 1 extern value set to Y.
Indicator Z is active on the same chart and wants to know the value of Y
 
medc77:
Is this possible with mql??
indicator X is active on the chart and it has 1 extern value set to Y.
Indicator Z is active on the same chart and wants to know the value of Y

Not directly, AFAIK. However, you can use Win32 file functions to read the .chr file for the chart within the profiles directory, and extract the parameters for EAs and indicators via that.


Anyone else got a better way?

 

You can use GlobalVariableSet/Get to transfer numerical values between indicators or EAs.

In the code, set the value of a global to be equal to the extern, and get it with the other.

 
jjc:

Not directly, AFAIK. However, you can use Win32 file functions to read the .chr file for the chart within the profiles directory, and extract the parameters for EAs and indicators via that.


Anyone else got a better way?


Thats a good idea except I dont have much experience working with Windows functions and libraries.


Would this be the same as using the WindowsAPI functions?


Would I have to import a dll into my mql script??


Does MetaTrader allow the import of any of the microsoft SDK dll's and libraries??


thanks!!

 
phy:

You can use GlobalVariableSet/Get to transfer numerical values between indicators or EAs.

In the code, set the value of a global to be equal to the extern, and get it with the other.

I thought of this way but it would mean I would have add code to every individual indicator that i currently use and any other indicators that i start using in the future. It's not a lot of work anyway, because it's not like I use hundreds of indicators, but I was just looking for other alternatives.


But I also think it is the most native way to do it that MT4 allows. thanks.

 
medc77:

Thats a good idea except I dont have much experience working with Windows functions and libraries.

Hmmm. I've used my method before to handle EAs. It turns out it's not so reliable on custom indicators: the .chr files aren't updated immediately when custom indicators are added or removed. But it's still probably the best/only option you've got if you're dealing with indicators where you don't control the code, or if you're dealing with string parameters, and therefore you can't implement phy's suggestion of using global variables.


Would this be the same as using the WindowsAPI functions?

Would I have to import a dll into my mql script??

Does MetaTrader allow the import of any of the microsoft SDK dll's and libraries??

Yes, yes, and yes. See, for example, my post at https://www.mql5.com/en/forum/118999

 
jjc:

Hmmm. I've used my method before to handle EAs. It turns out it's not so reliable on custom indicators: the .chr files aren't updated immediately when custom indicators are added or removed. But it's still probably the best/only option you've got if you're dealing with indicators where you don't control the code, or if you're dealing with string parameters, and therefore you can't implement phy's suggestion of using global variables.


Yes, yes, and yes. See, for example, my post at 'Reading and writing files anywhere on disk using CreateFileA() etc.'


this is excellent!!! I wasnt aware of the possibilities of using the windows API with metatrader... its pretty much unlimited the things you can do


thank you so much!

 
medc77 wrote >>

this is excellent!!! I wasnt aware of the possibilities of using the windows API with metatrader... its pretty much unlimited the things you can do

thank you so much!

With C, you can do absolutely anything. There's literally no limit except for the ones you set for yourself. Since MT4 can import DLL's, you can import the full power of the C language. Therefore, EA's don't have limits either.

.

Jon