#### Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

# Calculating a Percent Variance

I'd like to calculate the absolute difference between's today's 9EMA and 20EMA then divide that result by the original 9EMA. Once that value has been determine, I want to test that it is less than 1%.

The formula I'm after is: (AbsVal(9EMA-20EMA)/(9EMA))<.01

I tried nesting the difference in EMA's with brackets (with & without the AbsVal operator), then used the "/" division component to divided that value by the 9EMA (also with brackets). However, I received a syntax error as it does not recognize the "/" operator.

What am I missing or is there another way to approach this calculation?

Thanks

• mod
Unfortunately, the absval function only returns the absolute value of an indicator, not a mathematical operation.

so, you have to do it with or statements. The first or statement would account for the 9 above the 20, the second would account for the 20 above the nine. I'm not sure if want to account for the 9 equals the 20.
• ✭✭
It sounds like you are looking for a very tight condition. If the 9 ema is at 10 and the 20 ema is at 9 the absolute difference is 1 and 1 divided by 10 is 0.10 or 10% . If they were reversed with the 9ema at 9 and 20ema at 10 the difference would be -1, absolute difference of 1. 1 divided by 9 is 0.11 or 11%.

The MACD uses the EMA's. The MACD Line is the difference between the 1st 2 parameters in the MACD on a dollar or point value

MACD Line(12,26,1) The MACD line value is the difference between the 12EMA and the 26EMA in points. If the 12 is below the 26 the line value is negative, if the 12 is above the 26 the line value is positive.

PPO is exactly the same as MACD except PPO values are expressed as percentages. MACD is point values. So maybe just look for PPO line 9,20,1 is greater than or equal to -0.01 and less than or equal to 0.01 and see how that works for what you are seeking.