How does this indicator filter crosses??

 

Beginner with indicators here: Thanks in advance for the guidance.

I'm trying to understand the logic of this EMA cross indicator (attached) as it seems to filter close crosses. Take a look at the pic below:

It's an EMA 5/4 cross (of close). You'll notice 2 red down arrows and no up arrow in between. There's a cross in there but the indi filtered it.... I took a look at the code and my guess is that it's got something do do with the avgrange and count stuff in there... if somebody could spell out the logic for this Luddite I'd be most appreciative.

I guess the other question is does that mean the indi repaints? I didn't notice any in a visual test I did with strategy tester but my 9 month old was dividing my attention at the time....

Again thanks for the help!

ema_crossover_signal.mq4

 

Hi stubish,

I am not the coder but from what I see from inside the code:

Cross UP arrow:

- fasterEMA on close bar > slowerEMA on close bar

AND

- fasterEMA on close previous close bar < slowerEMA on close previous close bar

AND

- fasterEMA on next close bar > slowerEMA on close next close bar

Means: if fast EMA is crossing slow EMA to uptrend, and fast EMA is remaining > slow EMA on next bar after crossing so we can see the arrows.

Cross Down arrow:

- fasterEMA on close bar < slowerEMA on close bar

AND

- fasterEMA on close previous close bar > slowerEMA on close previous close bar

AND

- fasterEMA on next close bar < slowerEMA on close next close bar

So, the arrows will be appeared only if the next bar after crossing will be confirmed the direction.

 

Thanks newdigital, I see that now.

the next question would be, does that work as a repainting indicator or does the arrow only appear after the next bar, I could swear the visual backtest I just did the arrow appears before the 'next' bar is closed.... but I could be wrong. As well.... or does the arrow dissapear if the signal is not valid (I.E repainting).

thanks!

Stuart

 

I do not know sorry ...

because from what I see - this "i-1" is next close bar after crossing. But it is also can be future bar ... but closed bar can not be future bar ... so sorry - no idea ...

I think - it should be easy to name the bars as

i = next closed bar after crossing

i +1 = closed bar now

i +2 = previous closed bar

But the author of indicator named it as

i - 1 = next closed bar after crossing

i = closed bar now

i +1 = previous closed bar

so ... I am not a coder but when I see something as "i - 1" - I will always think about repainting. Because "-1" is future bar (which does not exist)

May be - I am wrong ...

You can try to use SnapShotI indicator for screenshorts just to know - repainting or not.

- re-painting indicators: evaluation and fixing thread.

- SnapShotI indicator: this indicator makes screen shots of active chart at regular intervals. By default, one tick after beginning of a new bar. Some evaluation of some indicators using SnapShotI indicator is on this post.

- SnapShotI indicator new version is on this post.

- Snapshot 2 indicator is on this post. The latest snapshot indicator that allows to specify how many ticks have to pass between the shots got lost in this migration.

 

because enumeration of the bars on the chart (and for any indicator or EA) is going as

0 is current open bar

1 is close bar (previous bar)

2 next after close bar

so, it is going as +1, +2 to the left side of the chart to count the bars.

but if I see -1, -2 so those bars are future bars which do not exist yet

May be I am wrong ...

 

Yep, I see that now. Simply modded the indi to have it paint the arrow on the 3rd bar, so I've got i, +1 and +2 now, not -1's in sight...

only problem now is that my money making indicator doesn't seem all that brilliant

Have a great night, thanks for the help!

 
stubish:
Thanks newdigital, I see that now.

the next question would be, does that work as a repainting indicator or does the arrow only appear after the next bar, I could swear the visual backtest I just did the arrow appears before the 'next' bar is closed.... but I could be wrong. As well.... or does the arrow dissapear if the signal is not valid (I.E repainting).

thanks!

Stuart

Hi Stuart,

Might want to try this one it doesn't repaint and is as fast as the repainter. The other one, Newdigital was right it repaints.

 

Stuart you don't need +1 or +2 look at the one i posted it uses the closed bar (i) and the main engine was coded by Mladen(so you can be sure no repaint), and its just as fast if not faster.

Reason: