Go Back   BabyPips.com Forex Forum > "The Holy Grails" > Expert Advisors and Automated Trading


Expert Advisors and Automated Trading Questions about automated trading? Which brokers allow automated systems? How do I create my own expert advisor? These questions and many more on automated trading can be answered here! (Note: forum rules do apply and any threads/posts deemed by moderators as spam or promotion of services, products, or websites will be deleted!)

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-04-2009, 12:05 PM
 

Join Date: Nov 2009
Posts: 2
Default Oanda EMA

Hi all!

I've been strugling recently to understand how EMA is calculated. I use Oanda FXTrade, but their calculations never match my - please find mistake:

Let's use a hypothetical example of the follwoign prices to make it easier:

Hour1 1
Hour2 2
Hour3 3
Hour4 4
Hour5 5
Hour6 6
Hour7 7
Hour8 8
Hour9 9
Hour10 10
Hour11 11
Hour12 12

Now we want to calculate EMA using their formula fxtrade.oanda.com/learn/graphs/overlays/ema.shtml

First we calculate SMA for first EMA_yersterday (SMA(6) for hours 1-6)
SMA(6) = (1+2+3+4+5+6)/6 = 3.5
EMA(1) = alpha * price_hour7 + (1-alpha) * yesterdayEMA = 2/7 * 7 + 5/7 * 3.5 = 4,5
EMA(2) = alpha * price_hour8 + (1-alpha) * yesterdayEMA = 2/7 * 8 + 5/7 * 4.5 = 5.5
EMA(3) = alpha * price_hour9 + (1-alpha) * yesterdayEMA = 2/7 * 9 + 5/7 * 5.5 = 6.5
EMA(4) = alpha * price_hour10 + (1-alpha) * yesterdayEMA = 2/7 * 10 + 5/7 * 6.5 = 7.5
EMA(5) = alpha * price_hour11 + (1-alpha) * yesterdayEMA = 2/7 * 11 + 5/7 * 7.5 = 8.5
EMA(6) = alpha * price_hour12 + (1-alpha) * yesterdayEMA = 2/7 * 12 + 5/7 * 8.5 = 9.5

But when I apply this method to real-time data taken from Oanda in the program I have written it is slighltly different from the Oanda indicators. The difference is quite small 0.0001-0.0002 but at the same time big enough to be introduced by absolute/fractional error or by lost of precision.

What is wrong? Thanks for help

Last edited by Nica; 11-04-2009 at 01:58 PM. Reason: Link Violation
Reply With Quote
  #2 (permalink)  
Old 11-04-2009, 04:52 PM
 

Join Date: Nov 2009
Posts: 2
Default

Common, nobody knows how EMA is calculated??
Reply With Quote
  #3 (permalink)  
Old 11-07-2009, 02:42 PM
pipso facto's Avatar
Junior Member
 

Join Date: Jul 2008
Posts: 70
Default

I don't know if this helps, but this is the formula I use to calculate the EMA:

Current EMA = Previous EMA + (Current Price - Previous EMA) / Time Constant

I try to compare my results to yours, but I don't know what the variable ALPHA represents in your formula. Maybe you can let me know.

In the meantime, I would contact Oanda to get their formula, then see if there is a slight difference in the way they calculate theirs.

Let me know your thoughts, as I am interested in details as well
Reply With Quote
  #4 (permalink)  
Old 11-11-2009, 10:25 AM
 

Join Date: Nov 2009
Posts: 4
Default

MA as calculated based on previous prices. The reason that your MA calculations do not match Oandas is that you are both using different prices. No 2 brokers have the same Open Close High Lows!!! The benefit of the "unregulated market".
Reply With Quote
  #5 (permalink)  
Old 11-11-2009, 12:52 PM
pipso facto's Avatar
Junior Member
 

Join Date: Jul 2008
Posts: 70
Default

Quote:
Originally Posted by forexdaddy View Post
MA as calculated based on previous prices. The reason that your MA calculations do not match Oandas is that you are both using different prices. No 2 brokers have the same Open Close High Lows!!! The benefit of the "unregulated market".
I don't know what "different" prices you think he's using, but since he is using FXTrade, the Oanda platform, I think it's safe to assume that he's using Oanda's prices no?

Good point on the different broker's quotes though, I am amazed at the huge differences at times.
Reply With Quote
  #6 (permalink)  
Old 11-11-2009, 04:27 PM
 

Join Date: Nov 2009
Posts: 4
Default

hmm..yes...should have elaborated. Well, the thing is the Fx companies
readjust historical prices at least once a week (courtesy of the unregulated FX market). In Oanda's case that maybe every day .

Ergo, the prices they dispense to the public is NOT the same as the prices they use for calculations. The difference may very from a 1 pip on every other candlestick to a lot more than just 1 pip.

While unethical, it is not illegal! (Again, courtesy of the unregulated FX market).
Reply With Quote
Reply



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

All times are GMT -4. The time now is 12:10 AM.
Content Relevant URLs by vBSEO 3.3.1
"Whether you think you can or think you can't, you're right."
Henry Ford
Feedback Form