Changing values of variables using external file in common by EA that attached to 20 charts.

 

Hello everybody.
I have a question.
I have an EA and the EA has attached to 20 charts(for example).
I want to use external file(includes values of variables) copied in COMMON folder that the EA check it every 5 minute(for example and this is possible by timer functions), and change values of variables for all 20 charts.

There are some ways:

1 - #include used just once ,while compiling EA, and could not be changed.

2 - fopen function should processed to find variables and maybe miscommunication while opening by all charts at the same time.

Thanks

Documentation on MQL5: Integration / MetaTrader for Python / order_calc_margin
Documentation on MQL5: Integration / MetaTrader for Python / order_calc_margin
  • www.mql5.com
order_calc_margin - MetaTrader for Python - Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
J-C: I have a question. I have an EA and the EA has attached to 20 charts(for example). I want to use external file(includes values of variables) copied in COMMON folder that the EA check it every 5 minute(for example and this is possible by timer functions), and change values of variables for all 20 charts.

That is not a question. That is just saying what you want. What is your question?

 
Fernando Carreiro #:

That is not a question. That is just saying what you want. What is your question?

What I want is the way or function to have control of all charts (variable's values)  by one unique file in common directory.
When I change values in that file , All charts of the EA attached change the values.

 
J-C #: What I want is the way or function to have control of all charts (variable's values)  by one unique file in common directory.

When I change values in that file , All charts of the EA attached change the values.

You have already explained it in your description. Write a file to the COMMON folder and have the EAs read the file every 5 minutes.

Use either OnTimer() with a 5min interval, or simply detect a new 5 Min interval in the OnTick() event handler and then use FileOpen() with the "FILE_COMMON" flag to open the file and read and process it.

Instead of files, I personally prefer using Global Terminal Variables as I can update their values from within MetaTrader itself without needing any extra software and the EAs can easily check for the update times of those Global Terminal Variables and then read the contents and update the internal workings.

Documentation on MQL5: File Functions / FileOpen
Documentation on MQL5: File Functions / FileOpen
  • www.mql5.com
FileOpen - File Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Fernando Carreiro #:

You have already explained it in your description. Write a file to the COMMON folder and have the EAs read the file every 5 minutes.

Use either OnTimer() with a 5min interval, or simply detect a new 5 Min interval in the OnTick() event handler and then use FileOpen() with the "FILE_COMMON" flag to open the file and read and process it.

Instead of files, I personally prefer using Global Terminal Variables as I can update their values from within MetaTrader itself without needing any extra software and the EAs can easily check for the update times of those Global Terminal Variables and then read the contents and update the internal workings.

Global Terminal Variables is great idea and what I want. Please right a simple example a code or how to use and change them.
Thank you very much Fernando.

 
J-C #:

Global Terminal Variables is great idea and what I want. Please right a simple example a code or how to use and change them.
Thank you very much Fernando.

just look in the documentation

https://www.mql5.com/en/docs/globals

Documentation on MQL5: Global Variables of the Terminal
Documentation on MQL5: Global Variables of the Terminal
  • www.mql5.com
Global Variables of the Terminal - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

You can give this code a try

https://www.mql5.com/en/code/27741

CSetFileReader
CSetFileReader
  • www.mql5.com
Class to provide simple reading mechanism from MetaTrader set files.
 
amrali #:

You can give this code a try

https://www.mql5.com/en/code/27741

Thanks. It is very useful too.

Reason: