William Roeder #:
- Does not matter.
- The array is released on return; the ArrayFree is unnecessary.
-
Don't worry about performance, until you have a problem. Then, and only then, use the profiler, find the problem, fix the problem, and remeasure.
Thank you William for your reply, very clear!
1. Thats great, i will then use the generic one as it will be less effort than having a new function for every indicator.
2. Always had some doubt on that, thanks for the feedback,will remove it.
Is it the same for IndicatorRelease function in OnDeinit? or is that still usefull? (please see below example)
void OnDeinit(const int reason) { //--- //release handles after removing EA if(maSlowHandle!=INVALID_HANDLE) IndicatorRelease(maSlowHandle); }
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
Hello,
I am wondering what would you consider a better practice for storing values of an indicator. Keeping a seperate Array to store values for each indicator or having one array where you temporary use it to store values and clear for each indicator?
Example below for a moving average indicator:
later I can call the function MA value in my code as follows (note: IsPrevBar is used for when I want to calculate by BAR with other code, you can ignore this part):
where the slow and fast handles are for differing lookback periods. The benefit I see from not having seperate functions would make allow me to use less code which always makes life easier (could even in theory have a generic one that includes other indicators that follow similar structure). On the other hand am worried it may create some issue in the code itself.
Would this approach cause any issues? Is is it better to create a seperate function for the MAslow and MAfast to store in its own seperate arrays or it would not matter?
very curious to know opinions on this!
Thank you