I am using a variant of the attached Super Smoother MACD and am encountering a subscripting problem for negative numbers in the following code:
i = Bars-i-1;
int s = instanceNo*2;
workSsm[s+_price] = price;
//Note by Tzuman: invalid subscript of -1 & -2 when i=BARS for i, i-1,i-2
workSsm[s+_ssm] = workSsmCoeffs[_c1]*(workSsm[s+_price]+workSsm[s+_price])/2.0 +
I'm wondering if the subscript reversal is necessary?
I made a couple of changes to declare integers prior to loops and if statements rather than inside to correct scope problems. The full code is attached.
ps this is the cause of my #property strict issue I found earlier today
Here is a version that works OK
As of arrays : no, it would not be better. I was trying to do so when I was solving the problem of necessary calculating buffers, but then, cases when the array should be resized, you have to do the
since metatrader had problems resizing arrays set as series properly, and then you might encounter 2 issues :
So I decided to use classical C like arrays (and metatader 5, btw) and am using them this way ever since wth no issue at all. It is fast, simple to use once when you get used to it and in some cases I could be able to use equivalent of over 200 buffers that way (imagine just the upper block of code done on all those 200+ arrays)
Now, with strict applied we shall have some work to do, but admit it - it is due to us (coders) being lazy at the first place when the original code was written so we skipped the necessary checks. Man, when I think what would C/C++ do to me if I would do something like that using it - it was able to kill windows when array elements were addressed improperly
Thanks for your reply, here is the attachment, regards
Ybhattacharyya, would need the mq4 file before it can be modified.
here is the mql file, thank you
Good day, possible to convert the attached indicator to use on new MT4 version or similar function better indicator?
It could be if it was an original source code. That is a decompiled code. Do you have the original source code?
Hi Mladen, sorry, I don't have. It's ok, thanks anyway.
By the way, do you have any similar simple indicator that show currency strength on chart? Thanks
You do not need to convert anything in that indicator. The only thing you have to make sure that the ZigZagDepth is greater than 3 (ZigZag will not work if back step is smaller or equal than ZIgZag depth - that is why it does not show any results). In the "old" metatrader 4 it worked OK even in that case but new metatrader 4 does not allow it
PS: you have to have ZigZag indicator in the indicators folder to make the indicator work
PPS: here is how that indicator looks like on chart when depth is set to 4. No changes in the code at all
Thanks a lot, its a great help, regards.