New metatrader 4 compatible indicators - page 43

Bob Fisher
316
Bob Fisher  

MLaden, MrTools.

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 +

workSsmCoeffs[_c2]*workSsm[s+_ssm] +

workSsmCoeffs[_c3]*workSsm[s+_ssm];

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.

Thanks,

Tzuman

ps this is the cause of my #property strict issue I found earlier today

Mladen Rakic
160090
Mladen Rakic  
Tzuman:
MLaden, MrTools.

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 +

workSsmCoeffs[_c2]*workSsm[s+_ssm] +

workSsmCoeffs[_c3]*workSsm[s+_ssm];

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.

Thanks,

Tzuman

ps this is the cause of my #property strict issue I found earlier today

Tzuman

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

ArraySetAsSeries(array,false);

ArrayResize(arraySize);

ArraySetAsSeries(array,true);

since metatrader had problems resizing arrays set as series properly, and then you might encounter 2 issues :

  1. it is not sure that the job will be done as it should (that the correct values are going to be at correct indexes - there were some builds of metatrader that messed up the whole array after that)
  2. the builds that did that correctly took ages for that (my guess is that they copied values 1 by 1 in order to keep the original contents of the array elements)

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

ybhattacharyya
14
ybhattacharyya  
mladen:
Yash Can you post, as a link or as an attachment, the version that you are using?

Thanks for your reply, here is the attachment, regards

Files:
William Snyder
9492
William Snyder  
ybhattacharyya:
Thanks for your reply, here is the attachment, regards

Ybhattacharyya, would need the mq4 file before it can be modified.

ybhattacharyya
14
ybhattacharyya  
mrtools:
Ybhattacharyya, would need the mq4 file before it can be modified.

here is the mql file, thank you

Files:
alvinkon
69
alvinkon  

Hi all,

Good day, possible to convert the attached indicator to use on new MT4 version or similar function better indicator?

Thank you.

Mladen Rakic
160090
Mladen Rakic  
alvinkon:
Hi all,

Good day, possible to convert the attached indicator to use on new MT4 version or similar function better indicator?

Thank you.

It could be if it was an original source code. That is a decompiled code. Do you have the original source code?

alvinkon
69
alvinkon  

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

Mladen Rakic
160090
Mladen Rakic  
ybhattacharyya:
here is the mql file, thank you

ybhattacharyya

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

Files:
ybhattacharyya
14
ybhattacharyya  
mladen:
ybhattacharyya

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.