Question about iHighest when the range to count is 0

 

Hi everyone,

First time working with iHighest.

When the number of bars to count is == 0, iHighest counts the whole array.

However, in certain situations, the candle with the highest value is the same candle from which to start counting.

As you can see, this is a problem.

As a result, I've added the highlighted part to make sure that the range of candles to count will always be at least 1.

My question is: will adding +1 to the range of candles to count skew the results of always grabbing the highest value between the range I want to search through? I was wondering if I should stick with this or just add an if statement that makes 'maeShift' = 1 if x-i is equal to 0.

int maeShift = iHighest(Symbol(),PERIOD_H1,MODE_HIGH,(x-i)+1,i);

In case you're wondering what the variables x and i are:

x = H1 Sunday Gap Open Candle

i = H1 Sunday Gap Fill Candle

 
user3822:

When the number of bars to count is == 0, iHighest counts the whole array.

However, in certain situations, the candle with the highest value is the same candle from which to start counting. As you can see, this is a problem.

As a result, I've added the highlighted part to make sure that the range of candles to count will always be at least 1.

  1. iHighest has nothing to do with arrays (documentation translation should say chart.) For arrays, use ArrayMaximum - Array Functions - MQL4 Reference
  2. Why is that a problem - there are no mind readers here. From [a .. b] (inclusive) there are a-b+1 always.
  3. iHighest(Symbol(),PERIOD_H1,MODE_HIGH,x-i+1,i);
    This only works on the H1 chart. Don't hard code
 
whroeder1:
  1. iHighest has nothing to do with arrays (documentation translation should say chart.) For arrays, use ArrayMaximum - Array Functions - MQL4 Reference
  2. Why is that a problem - there are no mind readers here. From [a .. b] (inclusive) there are a-b+1 always.
  3. This only works on the H1 chart. Don't hard code
I'm not using an array. x is a variable representing a Sunday Gap Open. i is a variable representing a Sunday Gap Fill. What's not clear?
 

user3822:
I'm not using an array.

x is a variable representing a Sunday Gap Open.

i is a variable representing a Sunday Gap Fill.

What's not clear?

  1. is == 0, iHighest counts the whole array.
    That's not what you initially implied.
  2. Whatever "Sunday Gap Open" means
  3. Whatever "Sunday Gap Fill" means
  4. What your problem is.
Reason: