First is a function call, second is a predefined variable. Both give the same extract string.
In general, which one is faster?
Forum on trading, automated trading systems and testing trading strategies
What is different between Symbol() and _Symbol
fxsaber, 2019.07.07 14:47
void Func( const string& ) {} void OnStart() { Func(Symbol()); // ERROR: 'Symbol' - parameter passed as reference, variable expected Func(_Symbol); // OK }
dear @William Roeder
In general, which one is faster?
Faster is to use _Symbol because it is a definition.
Symbol() is a function, so it has to be executed to retrieve the symbol name every time it is called.
Your code is returning error because your Func() definition expects a CONST string. So it only accepts Static parameters. And you cannot pass a function return to it.
Either modify it removing CONST so you can pass Symbol() to it as a parameter. Or use _Symbol which is faster and ALSO IS a Static Variable ;)
Faster is to use _Symbol because it is a definition.
Symbol() is a function, so it has to be executed to retrieve the symbol name every time it is called.
Your code is returning error because your Func() definition expects a CONST string. So it only accepts Static parameters. And you cannot pass a function return to it.
Either modify it removing CONST so you can pass Symbol() to it as a parameter. Or use _Symbol which is faster and ALSO IS a Static Variable ;)
Faster is to use _Symbol because it is a definition.
Symbol() is a function, so it has to be executed to retrieve the symbol name every time it is called.
Actually I think there's no difference in speed, it gets sort of optimized during compilation.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use