Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
OK, for years, I've been applying EMAs to code (Exponential MA). Until lately, I never really considered how they are calculated. I thought they were some derivative of a simple moving average (sum of value / number of values).
With that being said, I looked at the function code for the EMA (XAVERAGE) function in multicharts and saw this:
That really looks nothing like the SMA calculation. So I Googled EMA calculation and got this explanation...
EMA = Closing price x multiplier + EMA (previous day) x (1-multiplier)
Again, that looks close to the formula but not quite exact to what MC has in their function.
So, who's right? And am I reading this right... Is the EMA simply the current close X the multiplier described by Investopedia as...
Next, you must calculate the multiplier for smoothing (weighting) the EMA, which typically follows the formula: [2 ÷ (number of observations + 1)]. For a 20-day moving average, the multiplier would be [2/(20+1)]= 0.0952.
PLUS the EMA value of the previous day x (1-Multiplier)???
In other words, it's not summing up values for X number of periods?
Again, I'm feeling a little dumb right now. Please clarify.
BTW, I am asking this because as you might have seen in several threads, I'm having a real hard time with multi-data strats giving me the same result as an indicator does let alone if a strat is calculating the same EMA if only one instrument in the chart. And I'm exploring my options here. Thanks
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
You'd have to do the math in a spreadsheet to compare the 2 calculations, you might find they are equivalent.
In any event, you might be getting different results with multi-data charts because the calculations might be starting at different times. Expo. Moving Average is start point dependent - if you have different starting points, you'll have different results forever.
You'd have to do the math in a spreadsheet to compare the 2 calculations, you might find they are equivalent.
I'm trying to, but it's hard for me to reconcile. At your recommendation, I opened a spreadsheet and made a comparison of the two. I attached the pic. As you can see, the multiplier is correct, but the EMA equation doesn't seem to match. Please explain where I'm going wrong here.
kevinkdog
In any event, you might be getting different results with multi-data charts because the calculations might be starting at different times. Expo. Moving Average is start point dependent - if you have different starting points, you'll have different results forever.
I agree with you on starting points. But here's my issue. When I insert an EMA "Indicator" and in the formatting, I select Data2 (25 tick bar for example), It gives me the SAME indicator as if I had a single data chart with either the indicator or STRATEGY. BUT, when I setup a simple strategy code asking the XAverage function to calculate on Data2, the results are NOT the same. In other words, I can have all this loaded at the same time on the same chart and get different results which is unacceptable. Hence, my struggle is real
I'm trying to, but it's hard for me to reconcile. At your recommendation, I opened a spreadsheet and made a comparison of the two. I attached the pic. As you can see, the multiplier is correct, but the EMA equation doesn't seem to match. Please explain where I'm going wrong here.
I agree with you on starting points. But here's my issue. When I insert an EMA "Indicator" and in the formatting, I select Data2 (25 tick bar for example), It gives me the SAME indicator as if I had a single data chart with either the indicator or STRATEGY. BUT, when I setup a simple strategy code asking the XAverage function to calculate on Data2, the results are NOT the same. In other words, I can have all this loaded at the same time on the same chart and get different results which is unacceptable. Hence, my struggle is real
EMA code comparison
In the line where you write "NOT SAME" if you do the math, you will say they are the same.
For the data2 discrepancy, it sounds like you have a data aliasing issue, where the average might be calculated on the frequency (bar size) of data1, rather than data2.
In the line where you write "NOT SAME" if you do the math, you will say they are the same.
So using those two formulas... I entered closing prices for about 20 or so candles. I then entered the formulas for both and the outcomes are NOT equal. What am I doing wrong?
EDIT, I just noticed that the Investipedia value is the same
So using those two formulas... I entered closing prices for about 20 or so candles. I then entered the formulas for both and the outcomes are NOT equal. What am I doing wrong?
EMA code comparison calcs
If you can post the spreadsheet, or PM me the spreadsheet. I am teaching all day class right now, so it will have to wait until tonight, sorry.