Back to Community
Help with SMA crossover with EWMA

I'm building an algorithm comparing an SMA with an EMWA (using an if conditional). If the SMA is bigger than the exponencial, the algorithm will sell any given position, in the case where the exponencial is bigger the algorithm will choose a long position. However, i'm having trouble when the values of both MA's are too close. I wonder if any of you could help me in the design of the if conditional, in order to stablish some kind of parameter that allows the algorithm to enter on any position only when the difference between the two MA is significant.