Point of Intersection for Price and Exponential Moving Average

TraderKevin

New member
Joined
Aug 6, 2020
Messages
4
I am working on creating my first algorithm to trade on the stock market, and I am stumped in coming up with a formula to calculate the point of intersection between price and a 5 period Exponential Moving Average (EMA). Here are the details:

The formula to calculate an EMA is: EMA = Price * (2 / (period + 1)) + EMA(of the previous period) * (1 - (2 / period + 1))
To simplify this for my chosen period of 5, I've got: EMA = (Price + 2 * EMA(previous)) / 3

Now, I need to figure out what price would be required for price = EMA. The variables I will know at the time of calculation are the previous EMA and the current price. As price gets closer to the plot of the EMA, though, the EMA moves away from it at a slower rate (by the ratio given by the formula).

A formula based on the original EMA formula would be most helpful, but one based on the simplified formula using a period of 5 would be amazing as well. Any help at all is greatly appreciated!
 
I am willing to help here, but based on my initial reading, a 5 period result may not be reliable. Also, it is highly probable that there is no closed form solution. Thirdly, do you have a citation to a site that shows how technical analysts compute this in correct mathematical notation. The investopedia site uses some weird notation of its own, and the wikipedia article, which does use normal mathematical notation, seems to be saying something quite different from investopedia. And what do you mean by price here? Price usually means a data point. A point is either on a curve or off a curve: a point does not have an intersection point with a curve. Two curves may have no or any number of intersection points with each other. So I am guessing that you are talking about some curve of prices (plural). To have any hope of helping, we need to understand both curves.
 
Thanks so much for your willingness to help!

I'm sorry, but apparently I don't understand what you mean when you say "correct mathematical notation". I am limited by using a keyboard of course, but do you have confusion about the formula as I typed it, other than about the price? The formula I posted is correct, with Price, Period, and EMA(previous) being variables. The only unknown variables at the time of calculation will be the price and the EMA, which are the two variables we want to be equal to each other.

By price, I mean the price of the stock. It is not a curve you could define by an equation, but a point as you mentioned.

So, for example, if you lets take the formula I provided for EMA and plug in values of 100 for the previous EMA and 5 for the period. Using my simplified formula, the only unknown on the right side of the equation now is price, so we can plug in any value for price and determine what the current EMA would be at that price point.

What I want to calculate is what price would be required in order for the current EMA and price point to be equal to each other.

My best guess was to plug the formula I provided for EMA into the variable of price. This gave me the formula:
EMA(point of intersection) = (((Price + 2 * EMA(previous)) / 3) + 2 * EMA(previous)) / 3

I am not sure if this is correct or not, hence I've come to those much smarter than me!

Thanks again for any help you can provide, and let me know what else I can clarify for you.
 
I'll also just add a brief description of the variables as I imagine that might be helpful to understand.

An EMA of a price is essentially an average of the most recent prices, with more weight given to more recent prices than older ones. It is calculated over a certain period, which in my case I've chosen 5, and I'm plotting the EMA on a chart consisting of 1 minute periods. This means that the EMA I am concerned with is calculating an exponential average of the most recent 5 minutes worth of price data. The price data it uses specifically is the price of the stock at the end of each 1 minute period (typically called the closing price).

Again, thanks for the help!
 
OK I will do more research and may need to ask more questions. I am sorry to say that I am very busy, and my responses may be slow.
 
Thanks, Jeff!

A user on another forum actually gave me what I think is the correct answer:

"EMA = Price * (2 / (period + 1)) + EMA(of the previous period) * (1 - (2 / period + 1))
ema=p * (2 / 6) + pema * (1 - (2 / 6))
ema=p * (1/3) + pema * (2/3)

First equation just simplified. Second equation/requirement:

ema=p

We now have two unknowns, and two equations. We should be able to now solve:

Substituting, since ema=p:

p=p * (1/3) + pema * (2/3)

times 3

3p=p+2pema

subtract p from both sides

2p=2pema

divide by 2

p=pema

As it should be: The price where they touch is the EMA of the previous bar."

Thank you for the help anyway!
 
Top