NQuotes has a built-in XML config file - nquotes.config - that is located at “%TERMINAL_DATA_PATH%\MQL4\nquotes.config”. Read more about it here.
It is possible to use this file to add your own custom settings for your EA such as a database connection string.
Consider the MovingAverageExpert example. Let’s say you’d like to have the MovingPeriod and MovingShift values in a config file that can be modified after compilation.
appSettings
section:...
<add key="MovingPeriod" value="12" />
<add key="MovingShift" value="6" />
...
private static NQuotes.Config LoadConfig()
{
string libDirPath = NQuotes.ConfigSettings.SharedSettings.LibraryDirPath;
string configFilePath = NQuotes.Config.FindFilePath(libDirPath);
return new NQuotes.Config(configFilePath);
}
init()
method:int MovingPeriod = 12;
int MovingShift = 6;
public override int init()
{
var config = LoadConfig();
this.MovingPeriod = int.Parse(config.Get("MovingPeriod"));
this.MovingShift = int.Parse(config.Get("MovingShift"));
return 0;
}
You can then pass these variables to the iMA()
function.