NexusFi: Find Your Edge


Home Menu

 





Calculate MACD divergence


Discussion in Traders Hideout

Updated
    1. trending_up 8,027 views
    2. thumb_up 1 thanks given
    3. group 1 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread

Calculate MACD divergence

  #1 (permalink)
scarr
Preston
 
Posts: 12 since Aug 2011
Thanks Given: 0
Thanks Received: 0

Hi all,

New'ish to trading but need a little help and hopefully found the right place.

I have written a small VB program to signal trades, I capture data from CMC Markets (web scraping) and put this in a MySQL Database for realtime and historical analysis. I want to calculate the MACD to add divergamce into to my trade trigger but I am NO maths guru (yes yes yes, I should have paid more attention at school but back then PC's had just arrived and I spent far too long programming them!!) and hoped some nice person would explain what I need to do.

Ideally in a dumb person guide to formulas

A = number of database entries for 9 days
B = average of all A entries
C = Maximum of A entries

MACD = A/B*C ^3

(Only an example or format!! not an attepmt at MACD or anything else lol)

Also as I said I grab my data by scapping CMC Markets I am sure this is not the best way so any help on getting good data, price, place, integration would be a great help. but I do want to use VB6 with any datafeed.

Regards

Steve

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
How to apply profiles
Traders Hideout
REcommedations for programming help
Sierra Chart
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Tao te Trade: way of the WLD
24 thanks
Just another trading journal: PA, Wyckoff & Trends
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
davel
Australia
 
Posts: 10 since Jul 2011
Thanks Given: 12
Thanks Received: 1



scarr View Post
I want to calculate the MACD to add divergamce into to my trade trigger
Steve

If you are after the MACD formula, you can find it at Metastock com Support/Techinical Resources/Technical Analysis from A to Z.

Reply With Quote
  #4 (permalink)
davel
Australia
 
Posts: 10 since Jul 2011
Thanks Given: 12
Thanks Received: 1


scarr View Post
I want to calculate the MACD to add divergamce into to my trade trigger
Steve

You'll also find the Metastock version of divergence. there Equis International, a Thomson Reuters company

Reply With Quote
  #5 (permalink)
scarr
Preston
 
Posts: 12 since Aug 2011
Thanks Given: 0
Thanks Received: 0

Thanks Davel,

However it does not help too much as I cannot see the actual formula and even if I did unless it was in a noddy format (for idiots) then I would not be able to read/understand it any way

One thing that might be easier to answer is what data is used to create the 26/12 and 9 day EMA equations, is it the open / close / or open and close prices or something else?

Also if anyone can help on the initial questions that would be fantastic (a=b/c etc). thanks


Steve

Reply With Quote
  #6 (permalink)
davel
Australia
 
Posts: 10 since Jul 2011
Thanks Given: 12
Thanks Received: 1

Hi Scarr,

MACD is based on exponential moving averages of the close. The Metastock divergence formula can be readily adapted for a spreadsheet or VBA/VB.NET. References for the functions and the ema can be found at the same site.

Alternatively, try googling MACD Excel or VB which returned MACD VBA | ExcelTrader.

Reply With Quote
  #7 (permalink)
davel
Australia
 
Posts: 10 since Jul 2011
Thanks Given: 12
Thanks Received: 1

Hi Scarr,

I suppose this is what you are after.

A = exponential moving average (EMA) of the last 12 periods of the close
B = EMA of the last 26 periods of the close
C= (A minus B)
D = trigger line = EMA of C of the last 9 periods of the close
E = differential = C minus D

C,D and E are collectively known as the MACD and any of them can be used for divergence comparison against the price.

A good explanation of the EMA can be found here https://stockcharts.com:443/school/doku.php?id=chart_school:technical_indicators:moving_averages

Reply With Quote
Thanked by:
  #8 (permalink)
scarr
Preston
 
Posts: 12 since Aug 2011
Thanks Given: 0
Thanks Received: 0

Thankd Dave, few more questions, is it just the close prices we are using? as I am looking at a 1min chart

so this correct given I am using a 1 min chart.

To create the 26 days EMA we use close price for last 12 mins
To create the 26 days EMA we use close price for last 26 mins
To create the 26 days EMA we use close price for last 9 mins

Thanks

Steve

Reply With Quote
  #9 (permalink)
davel
Australia
 
Posts: 10 since Jul 2011
Thanks Given: 12
Thanks Received: 1


scarr View Post
Thankd Dave, few more questions, is it just the close prices we are using? as I am looking at a 1min chart

so this correct given I am using a 1 min chart.

To create the 26 days EMA we use close price for last 12 mins
To create the 26 days EMA we use close price for last 26 mins
To create the 26 days EMA we use close price for last 9 mins

Thanks

Steve

Yes, you use only the close. You can calculate the MACD based on any period. If you are calculating the MACD based on a 1min interval, then the 12 period EMA is based on the past 12 closes of the 1min interval and so forth.

You simply substitute the desired price interval in the brackets, be it weeks, days, 30mins or 1min.

A = exponential moving average (EMA) of the last 12 (1min closes)
B = EMA of the last 26 (1min closes)
C= A minus B
D = trigger line = EMA of the last 9 values of C
E = differential = C minus D

This might be helpful Moving Average Convergence-[AUTOLINK]Divergence[/AUTOLINK] (MACD) - ChartSchool - StockCharts.com

Reply With Quote
  #10 (permalink)
scarr
Preston
 
Posts: 12 since Aug 2011
Thanks Given: 0
Thanks Received: 0


Loks like Davel has given me all I need to calculate the MACD now but it looks like I need closing prices as I only scrape "current price" from CMC Markets and I don't think the will work with MACD (not that I have tried it) as the values can be points away.

Anyone know where I can get min by min closing prices?

thanks

Reply With Quote




Last Updated on August 20, 2011


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts