Fast and slow EMA error

 

Hi,

I am trying to compile EA, where fast EMA is crossing slow one as buy/sale signals. The problem I have is that sometimes even when EMAs are not crossing, but are close - it is considered as a signal. It is strange since I put everywhere in the code > or <, not <= or =>.

Any clue how to fix this? Thanx! :)

Example: This is considered as buy signal, because it is crossing down-up, but actually it does not...

P.S I could not find anything in the forum on this topic. Sorry if it was written already.

 

I've not looked at your code, but remember that EMA (or any MA etc) will vary during the time that a bar is active (unless based on Open price), and the historical value shown for a bar is only its value AT THE CLOSE!

This is one reason why MA (or other) line crossing indicators seem to work when you look at charts, but not in real time.

 
brewmanz:

I've not looked at your code, but remember that EMA (or any MA etc) will vary during the time that a bar is active (unless based on Open price), and the historical value shown for a bar is only its value AT THE CLOSE!

This is one reason why MA (or other) line crossing indicators seem to work when you look at charts, but not in real time.



Thank you :) I did not consider this.
 
Only look at bar 1 values at the start of a new bar.
Reason: