wrong results with iMaOnArray - or bad code

 

What can one do wrong on that simple code ? - But something is going wrong !

 ArraySetAsSeries(arrValues, true);
 ArraySetAsSeries(bufCenterline, true);
 // ...

 newBegin = 1;

 for (i = newBegin; i >= 0; i--)
   {

      bufCenterline[i] = iMAOnArray(arrValues, rates_total, 13, 0, MODE_LWMA, i);
            
      if (i==0) Print("CenterLine: " + bufCenterline[i] + " - TotalQuotes: " + rates_total + " - QuoteValue: " + arrValues[i]);
      // the same static output on i==1 !
   }


The output with that is always the same - wrong - value. Is there a bug in that iMaOnArray() or did I found a silly way using it wrong ?

If the loop works with the long distance over the historic values up to 0 it is fine ! But with only the recent values from 1 to 0:

2016.03.28 16:18:28.187 xx GBPJPY,M1: CenterLine: 161.5353955941705 - TotalQuotes: 66039 - QuoteValue: 161.52
2016.03.28 16:17:28.593 xx GBPJPY,M1: CenterLine: 161.5353955941705 - TotalQuotes: 66038 - QuoteValue: 161.515
2016.03.28 16:16:28.796 xx GBPJPY,M1: CenterLine: 161.5353955941705 - TotalQuotes: 66037 - QuoteValue: 161.511
2016.03.28 16:15:30.921 xx GBPJPY,M1: CenterLine: 161.5353955941705 - TotalQuotes: 66036 - QuoteValue: 161.455
2016.03.28 16:14:29.609 xx GBPJPY,M1: CenterLine: 161.5353955941705 - TotalQuotes: 66035 - QuoteValue: 161.452
2016.03.28 16:13:31.125 xx GBPJPY,M1: CenterLine: 161.5353955941705 - TotalQuotes: 66034 - QuoteValue: 161.494
 
Abejorro:


What can one do wrong on that simple code ? - But something is going wrong !


The output with that is always the same - wrong - value. Is there a bug in that iMaOnArray() or did I found a silly way using it wrong ?

If the loop works with the long distance over the historic values up to 0 it is fine ! But with only the recent values from 1 to 0:

No one any idea ? Me too ! I could play with 'ArraySetAsSeries(..)' as I like, nothing went better.

Now I wrote my own MA-routines. It works in the same code-environment as these insides don't.

 
Abejorro:

No one any idea ? Me too ! I could play with 'ArraySetAsSeries(..)' as I like, nothing went better.

Now I wrote my own MA-routines. It works in the same code-environment as these insides don't.


Your problem is not clear. what is wrong ? Nobody can guess, so nobody can help.

You should provide code that compiles to demonstrate your issue.

 
zirkoner: You should provide code that compiles to demonstrate your issue.
  1. He already did.
    2016.03.28 16:18:28.187 xx GBPJPY,M1: CenterLine: 161.5353955941705 - TotalQuotes: 66039 - QuoteValue: 161.52
    2016.03.28 16:17:28.593 xx GBPJPY,M1: CenterLine: 161.5353955941705 - TotalQuotes: 66038 - QuoteValue: 161.515
    2016.03.28 16:16:28.796 xx GBPJPY,M1: CenterLine: 161.5353955941705 - TotalQuotes: 66037 - QuoteValue: 161.511
    2016.03.28 16:15:30.921 xx GBPJPY,M1: CenterLine: 161.5353955941705 - TotalQuotes: 66036 - QuoteValue: 161.455
    2016.03.28 16:14:29.609 xx GBPJPY,M1: CenterLine: 161.5353955941705 - TotalQuotes: 66035 - QuoteValue: 161.452
    2016.03.28 16:13:31.125 xx GBPJPY,M1: CenterLine: 161.5353955941705 - TotalQuotes: 66034 - QuoteValue: 161.494
  2. Tell Metaquotes
     
    1. I can't compiled the code provided.
    2. Why do you want to report it to Metaquotes ?
     
    zirkoner: Why do you want to report it to Metaquotes ?
    Who do you think can fix a broken iMAonArray? Us users or Metaquotes?
     
    WHRoeder:
    zirkoner: Why do you want to report it to Metaquotes ?
    Who do you think can fix a broken iMAonArray? Us users or Metaquotes?
    As you agree that the bug is not in front of the keyboard, I reported a bug at the service-desk. We will see what went wrong...
     
    zirkoner:

    Your problem is not clear. what is wrong ? Nobody can guess, so nobody can help.

    You should provide code that compiles to demonstrate your issue.

    WHRoeder pointed the misthake very well. The results are the same up to 10E-13. Impossible with this input-values.

    And the results are correct and different with my own routines.

     
    Abejorro:

    WHRoeder pointed the misthake very well. The results are the same up to 10E-13. Impossible with this input-values.

    And the results are correct and different with my own routines.

    Maybe or not...

    To be sure 100% the problem need to be reproduced, which I can't do. If you report something to Metaquotes they will ask you the code to reproduce the problem.

     
    zirkoner:

    Maybe or not...

    To be sure 100% the problem need to be reproduced, which I can't do. If you report something to Metaquotes they will ask you the code to reproduce the problem.

    I also have been unable to reproduce the problem.

    I suspect that

     ArraySetAsSeries(arrValues, true);
     ArraySetAsSeries(bufCenterline, true);
    is not in the same block of code and is reset somewhere else. so that iMAOnArray is calculating using the same elements every time. Hence the duplicated result.
     
    zirkoner:

    Maybe or not...

    To be sure 100% the problem need to be reproduced, which I can't do. If you report something to Metaquotes they will ask you the code to reproduce the problem.

    Ok, with a litlle time I will extract the codes which are necessary up to my point so it can be reproduced. The whole code now is a long walk through classes and other inludes.

    Three things made me sure, I could keep it simple:
    1) The iMaOnArray() is fine on the long walk from the very beginning to 0 with the same code.
    2) The output of arrValues[i] did not show any issue.
    3) My own code replacing the iMaOnArray() is working without any other changes.

    But if you can't reproduce it, there must be something special in my other code...


    @GumRai:

    that's what I thought. But I checked the state with ArrayGetAsSeries() a lot of times and set the state a line above the iMaOnArray()... Nothing changes


    Thank you for your answers :-)

    Reason: