How to get the name of the set file in an EA?

 

Hi fellow coders,

Is there a way in MQL5 code (a global variable maybe?) to get the name of the SET file being used by the EA? I have searched the forum but cannot find any examples.

I have coded an EA and I am testing the same EA on different accounts with different SET files and I want to display the name of the SET file on the chart somewhere. I just want to know if it's possible to access the name of the file.

 
Khima Hathia Gorania:

Is there a way in MQL5 code (a global variable maybe?) to get the name of the SET file being used by the EA?

I don't think so. The .set file just sets the inputs and is then forgotten.

You could have an input variable inside the .set file that specifies the name of the strategy.

You can also use Templates to save settings of the EA. Templates can also store text objects, so you could put a text name on each Template that specifies the settings for that particular EA.

 
Anthony Garot:

I don't think so. The .set file just sets the inputs and is then forgotten.

You could have an input variable inside the .set file that specifies the name of the strategy.

You can also use Templates to save settings of the EA. Templates can also store text objects, so you could put a text name on each Template that specifies the settings for that particular EA.

Thank you Anthony. I will look into your suggestions.

Your suggestion for using an input variable will achieve what I am looking for in the easiest way for me.

I have not used Templates before but I will also have a play with that.


 
Khima Hathia Gorania:

I have not used Templates before but I will also have a play with that.

Templates are magically delicious. Embrace templates—they will make your life easier.
 
Anthony Garot:
Templates are magically delicious. Embrace templates—they will make your life easier.

I cannot directly answer your question, but I can suggest another approach:


You can configure the setting on the fly, this way you can: Configure the parameters, Store the parameters in variables, save them inside a reference TXT file, reuse, etc... 


Check how to do it:

https://www.mql5.com/en/docs/event_handlers/ontesterinit


//+------------------------------------------------------------------+ 
//| TesterInit function                                              | 
//+------------------------------------------------------------------+ 
void OnTesterInit() 
  { 
//--- set the values of inputs for optimization 
   ParameterSetRange("lots",false,0.1,0,0,0); 
   ParameterSetRange("kATR",true,3.0,1.0,0.3,7.0); 
   ParameterSetRange("ATRperiod",true,10,15,1,30); 
   ParameterSetRange("holdbars",true,5,3,1,15); 
   ParameterSetRange("slippage",false,10,0,0,0); 
   ParameterSetRange("revers",true,false,false,1,true); 
   ParameterSetRange("EXPERT_MAGIC",false,123456,0,0,0); 
   Print("Initial values and optimization parameter limitations are set"); 
//--- remember optimization start 
   optimization_start=TimeLocal(); 
   report=StringFormat("%s: optimization launched at %s", 
                       __FUNCTION__,TimeToString(TimeLocal(),TIME_MINUTES|TIME_SECONDS)); 
//--- show messages on the chart and the terminal journal 
   Print(report); 
   Comment(report); 
//---    
Documentation on MQL5: Event Handling / OnTesterInit
Documentation on MQL5: Event Handling / OnTesterInit
  • www.mql5.com
//|                                          OnTesterInit_Sample.mq5 | //|                        Copyright 2018, MetaQuotes Software Corp. | //|                                             https://www.mql5.com | //| TesterInit function                                              |...
Reason: