Hi I'm going through an old EA I found on a post from some years back, I've come to this and don't understand what logic is behind it.
I don't understand why == shift is used.. as shift is 2 how can iLowest/Highest be 2 when the data for highest and lowest is always a double of considerably less value than 2..
It's probably me missing something but anyone who can explain this to me will be appreciated!
ah so it is an integer, why then would it be set to 2?
how can iLowest/Highest be 2 when the data for highest and lowest is always a double of considerably less value than 2..
ah so it is an integer
It is indeed an integer. A very common misconception is that iHighest and iLowest return the highest and lowest values respectively. They don't. They return the bar index that contains the highest/lowest values.
If the highest value is 1.10045 and it occurred on the previous bar, iHighest returns 1 (not 1.10045)
Being very, very pedantic... the built-in MT4 definition is very slightly different. It allows one or more equal highs with two lower highs before and after. A valid fractal is therefore not necessarily a 5-bar sequence.
For example, there is a six-bar fractal sequence at 13:31/13:32 today on EURUSD M1 in the MetaQuotes demo server price feed; equal highs at 1.06689. Screenshot attached.