How I can define the name of the file with respect to the chart symbol?

To add comments, please log in or register
jaffer wilson
780
jaffer wilson  

I have tried the following and got the error:

#define filename  _Symbol+"_Trade_reatime.csv";

input string forecast_fetch=filename;

Error got is: 

'+' - constant expected Trade_Real_Time.mq5     87      29

Please let me know what I can do to have this sort of file name. My signal vary with respect to the symbol on chart. Hence, I need to have the file name with respect to chart to avoid typing file name every time. Please let me know the way out.

Carl Schreiber
Moderator
7142
Carl Schreiber  

Try:

string filename  _Symbol+"_Trade_reatime.csv";

The compiler doesn't allow 'your' #define!

jaffer wilson
780
jaffer wilson  
Carl Schreiber:

Try:

The compiler doesn't allow 'your' #define!

I tried this:  

string filename = _Symbol+"_Trade_reatime.csv";
input string forecast_fetch=filename;

Got this error:  

'filename' - constant expected  Trade_Real_Test.mq5     85      29
Still the error persists.
Marco vd Heijden
Moderator
8180
Marco vd Heijden  
No that is because you are trying to assign a value to a static input which you can not change.
Carl Schreiber
Moderator
7142
Carl Schreiber  

You can't even change input variables ion mql5 (other than extern in mql4!!)

input string forecast_fetch = "";
string _forecast_fetch; //aux. var.
...
int OnInit() {
   _forecast_fetch = (forecast_fetch != "") forecast_fetch : filename;
...
}
jaffer wilson
780
jaffer wilson  
Carl Schreiber:

You can't even change input variables ion mql5 (other than extern in mql4!!)

So that means there is no way out for my problem.. right?

Marco vd Heijden
Moderator
8180
Marco vd Heijden  
string filename = _Symbol+"_Trade_reatime.csv";

This should be sufficient.

If you want to add more by input parameter:

static input string somestring="blablablah_";

string filename = somestring+_Symbol+"_Trade_reatime.csv";
Not the way around.
nicholi shen
1918
nicholi shen  
Carl Schreiber:

You can't even change input variables ion mql5 (other than extern in mql4!!)

MQL5 has `extern` as well. 

To add comments, please log in or register