It sounds a bit sarcastic, maybe impossible to do as well, but if you can give any trick/workaround, please have a look!
(the red-colored lines gives you details of the areas in discussion). The goal is to : not to import functions, not to define functions in global scope, either.
... #define JOIN_MACRO(a,b) a+b ... Alert(JOIN_MACRO("good", " day!")); ...
Hi Peter, thanks for passing by.
how about defining a full-fledge/complex function, rather-than simple string-concatenation? (example ->)
void DeleteAllObjects() { int objs = ObjectsTotal(); string name; for(int cnt=ObjectsTotal()-1;cnt>=0;cnt--) { name=ObjectName(cnt); if (StringFind(name,"xpMA",0)>-1) ObjectDelete(name); ObjectsRedraw(); } }
How to avoid defining function-body in global-scope OR importing them from dlls, but still being able to use the function just like all other normal functions?
Maybe the function will reside in memory, not in physical global-scope???? (well this is exactly why i called it "GHOST FUNCTION" :D )
Hi Peter, thanks for passing by.
how about defining a full-fledge/complex function, rather-than simple string-concatenation? (example ->)
How to avoid defining function-body in global-scope OR importing them from dlls, but still being able to use the function just like all other normal functions?
Maybe the function will reside in memory, not in physical global-scope???? (well this is exactly why i called it "GHOST FUNCTION" :D )
Hi Peter, thanks for passing by.
how about defining a full-fledge/complex function, rather-than simple string-concatenation? (example ->)
How to avoid defining function-body in global-scope OR importing them from dlls, but still being able to use the function just like all other normal functions?
Maybe the function will reside in memory, not in physical global-scope???? (well this is exactly why i called it "GHOST FUNCTION" :D )
Is it what you mean ?
#define GHOST_FUNCTION_DeleteAllObjects \ { \ int objs=ObjectsTotal(); \ string name; \ for(int cnt=ObjectsTotal()-1;cnt>=0;cnt--) \ { \ name=ObjectName(cnt); \ if(StringFind(name,"xpMA",0)>-1) ObjectDelete(name); \ ObjectsRedraw(); \ } \ } void OnStart() { GHOST_FUNCTION_DeleteAllObjects }
to put it another way :
how to define a function/method from string??
A JavaScript example comes to mind :
//Create string representation of function var s = "function test(){ alert(1); }"; //"Register" the function eval(s); //Call the function test();
Anyway to register function in MQL?
Is it what you mean ?
that great sir, I'm thinking on it!
string func="Alert(\"less than 5\");"; #define GHOST_FUNCTION(x) (func!=NULL)?func:x int OnInit() { GHOST_FUNCTION(7);//I'm expecting it to pop up the alertbox }
Suppose, the string(which is basically a "whole-function" converted into a literal-string) comes from a remote server/webrequest. I want to turn it into a function via macros, that can be used/called anywhere!
This is almost close to what exactly i'm trying to achieve!
Is it what you mean ?
What is the advantage/reason (in this case) in using a macro instead of simple calling the function?
void DeleteAllObjects() { int objs = ObjectsTotal(); string name; for(int cnt=ObjectsTotal()-1;cnt>=0;cnt--) { name=ObjectName(cnt); if (StringFind(name,"xpMA",0)>-1) ObjectDelete(name); ObjectsRedraw(); } } void OnStart() { DeleteAllObjects(); }
Suppose, the string(which is basically a "whole-function" converted into a literal-string) comes from a remote server/webrequest. I want to turn it into a function via macros, that can be used/called anywhere!
This is almost close to what exactly i'm trying to achieve!
to put it another way :
how to define a function/method from string??
A JavaScript example comes to mind :
Anyway to register function in MQL?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
It sounds a bit sarcastic, maybe impossible to do as well, but if you can give any trick/workaround, please have a look!
(the red-colored lines gives you details of the areas in discussion). The goal is to : not to import functions, not to define functions in global scope, either.