Ok. Did you check those values? Apparently the formulae are correct, but I find it weird substracting a MA value to the ask price. Is that what you really need or maybe you are looking for the distance in pips between those two values?