EA using fractals
-
Trying to get an EA to do the following
Daily - Price above 20EMA - long (for clarity drew a 480EMA on hourly chart - see picture)
price below 20EMA -short
Fractals to form an abc pattern, with bar 2 breaking the 20EMA, bar 3 having a higher high than bar 2 high, bar 3 low to be higher than bar 2 high.drawing lines for testing, but can't see my mistake. Would appreciate a fresh set of eyes.
Kind Regards
https://fxdreema.com/shared/dAAFW5sgc

getting this

-
Listen, I only opened the first block of your project and saw that you use candle ID 0, review your project using candle ID1, candle ID0 is an error, and keep in mind that fractal is a little repaint indicator (often appears on candle ID 02)
-
I just had a look at the examples and for a price v indicator, and it used candle ID 0. This is to simply to give direction on a higher time frame.
I got some assistance on the fractals from other posts
-
Using ID0 on the daily filter shouldn't be a problem in this case.
This is a slight problem:

You see, when candle ID 2 has no fractal, then its value is 0, which is below candle high. This will mess up your last_fractal variable and so on.
Since we know that fractals (up and down) have value 0 when there are no fractals, we don't have to compare price at all to find the fractals - simply use "fractal down != 0" and "fractal up != 0" as your blocks #51 and #52