Petr Nosek:
Mr Rakic, could I ask you what reason is for using a template (for high[], low[] and close[]) in the function "calculate". Is there any possibility to be something else than double? Thank you for your answer in advance.
Mr Rakic, could I ask you what reason is for using a template (for high[], low[] and close[]) in the function "calculate". Is there any possibility to be something else than double? Thank you for your answer in advance.
Those are "const double" used there, not "double"
And yes, it will work with "double" too the way it was written and it would not work if it was "hard-coded" to either "double" or "const double" without a code change
Mladen Rakic:
Those are "const double" used there, not "double"
And yes, it will work with "double" too the way it was written and it would not work if it was "hard-coded" to either "double" or "const double" without a code change
Thank you for your response.
Maybe I've missed something but IMHO this piece of code:
double calculate(const double& high[], const double& low[],const double& close[], int i, int bars)
will work in the same way as your piece of code:
template <typename T> double calculate(T& high[], T& low[],T& close[], int i, int bars)
It will work both with "const double" and with "double". And I was just curious if is there a reason for using a template.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
ATR:
Average true range
Author: Mladen Rakic