Array Maximum is not returning the correct value

 

Hello forum,

I am trying to get the Array Maximum value of an array. For this purpose, I copied the Bull Power Indicator. 

  ArrayResize(HighestBullValueData, 15);

   for(int i=0; i<15; i++)
     {
      HighestBullValueData[i] = ExtBullsBuffer[i];
      //    PrintFormat("HighestBullValueData = %d, %f ", i, HighestBullValueData[i]);

      HighestBullValue[i] = ArrayMaximum(HighestBullValueData, WHOLE_ARRAY, i);
      PrintFormat("HighestBullValue = %d, %f ", i, HighestBullValue[i]);

     }

 I get the value of the HighestBullValueData array, but when I use the array maximum function, it gives me a different number (which is way off the value of the range of values from the HighestBullValueData array ).

Thanks in advance for any explanation.

 
Leo A.:

Hello forum,

I am trying to get the Array Maximum value of an array. For this purpose, I copied the Bull Power Indicator. 

 I get the value of the HighestBullValueData array, but when I use the array maximum function, it gives me a different number (which is way off the value of the range of values from the HighestBullValueData array ).

Thanks in advance for any explanation.

If you only need the Highest value from the HighestBullValueData bar 0-14 (15 bars), then you don't need to use iterations.

 
Leo A.: , it gives me a different number (which is way off
  1. Fill the array. Then, outside the loop, search the entire array for the one value

    ArrayMaximum(HighestBullValueData, WHOLE_ARRAY, 0);

  2. Or eliminate the copying and just search the source array
    ArrayMaximum(ExtBullsBuffer, 15, 0);
 
William Roeder:
  1. Fill the array. Then, outside the loop, search the entire array for the one value

  2. Or eliminate the copying and just search the source array

Thanks. Here is now the code. Didn't realize it's that simple.

for(int i=0; i<15; i++)
     {
      ArrayMaximum(ExtBullsBuffer, 15, 0);
      PrintFormat("ExtBullsBuffer = %f ", ExtBullsBuffer[i]);
     }
 
Roberto Jacobs:

If you only need the Highest value from the HighestBullValueData bar 0-14 (15 bars), then you don't need to use iterations.

Got it. Thanks.
 
Leo A.:

Thanks. Here is now the code. Didn't realize it's that simple.

for(int i=0; i<15; i++)
     {
      ArrayMaximum(ExtBullsBuffer, 15, 0);
      PrintFormat("ExtBullsBuffer = %f ", ExtBullsBuffer[i]);
     }

No, wrong. Read the specs.

int i=ArrayMaximum(ExtBullsBuffer, 15, 0);
PrintFormat("ExtBullsBuffer maximum = %f ", ExtBullsBuffer[i]);
No loop required.
Reason: