I am using two exponential moving average(EMA) for stock trading. I use two EMAs, 5-day EMA and 10-day EMA and the formula for each EMA is as follow:
multiplier = (2/time period+1)
EMA = (current price - previous EMA) * multiplier + previous EMA
for example the multiplier for 5-day EMA is equal to: 2/6.
Now what I use is the difference in percentage between the two EMAs for example if 5-day EMA is 105 and 10-day EMA is 100 the difference is 5 percent.
My problem is that I want to find the next price (that is tomorrow's price) that keeps the difference of the two EMAs. For example if the difference of the two EMAs for today is 5 percent, I want to find tomorrow's price that keeps the difference at 5 percent.
If you have $m_5$ and $m_{10}$ as your two values and the next price is $p$ then your two new values become $\frac26(p-m_5)+m_5$ and $\frac2{11}(p-m_{10})+m_{10}$
You want the proportionate difference to stay the same so $$\frac{\frac26(p-m_5)+m_5}{\frac2{11}(p-m_{10})+m_{10}} = \frac{ m_5}{m_{10}}$$
which gives $$11pm_{10}-6pm_{5}= 5m_5m_{10}$$ i.e. $$p = \frac{ 5m_5m_{10}}{11m_{10}-6m_{5}}$$
With $m_5=105$ and $m_{10}=100$ this gives $p=\frac{5250}{47} \approx 111.7021$ and the two new values of $\frac{5040}{47}\approx 107.2340$ and $\frac{4800}{47}\approx 102.1277$, which are indeed still $5\%$ apart