cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
lwx228
Level VIII

How to use JMP to calculate the technical indicators of stock————MACD?

New Year is coming, I wish community friends a happy New Year!
Now I want to use JMP for stock data statistics, but it is still a novice, find a few stock JMP sample file, did not see the calculation of technical indicators example.


For example, in the calculation of "MACD", I still don't understand the calculation of EMA.


After searching the manual books, the formula (mark 1 in the Image) for EMA in the manual is at the first place, but the formula (mark 2) in the example file does not seem to be this one
Consult to everybody expert, thank!

 


MACD calculation formula:


DIF : EMA(CLOSE,12) - EMA(CLOSE,26);
DEA : EMA(DIF,6);
MACD : 2*(DIF-DEA);

 

 

2018-12-31_18-31-46.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
gzmorgan0
Super User (Alumni)

Re: How to use JMP to calculate the technical indicators of stock————MACD?

I found another website with an Excel sheet with MACD. The table I posted had the correct formulas except for MACD, it should have been EMA12-EMA26, my sign was the opposite.

 

The site with the Excel sheet is how-to-calculate-macd-in-excel.

 

Attached is a script that can be run on any table as long as the columns Date and Close  exist.  I simplified the EMA12 and EMA26 and Signal so that the SMA columns are not required. If High and Low are columns then the area plot is drawn, otherwise, not.

 

Below is the picture from the website regarding Excel followed by the Graphbuilder picture. 

 

To test, open the JMP sample data table Current Stock Averages.jmp then run the attached script CalculateMACD.jsl. Note the graph will be dirfferent than the previously posted, since previously, I had the MACD sign reversed.  

The formulas for your calculation are reasonable, however, be careful calling it MACD if you are publishing it.  it is my experience that when there is a widely accepted metric, even slight deviations without clear notice will create distrust for any results.

 

image.pngimage.png

View solution in original post

12 REPLIES 12
lwx228
Level VIII

Re: How to use JMP to calculate the technical indicators of stock————MACD?

dt = Open( "$SAMPLE_DATA/Current Stock Averages.jmp" );
lwx228
Level VIII

Re: How to use JMP to calculate the technical indicators of stock————MACD?

It seems that EMA calculation of stock software is different from JMP formula?

2019-01-01_9-27-18.png

gzmorgan0
Super User (Alumni)

Re: How to use JMP to calculate the technical indicators of stock————MACD?

EMA represents an exponential moving average, which can be found with with more recent versions of JMP usinge the Moving Average and proper weighting.  EMA[i] = EMA[i-1] + (Close[i] - EMA[i-1]) *lambda  In your example below, lambda is 2/(12+1) 

 

This link explains the MACD /what-moving-average-convergence-divergence-macd-formula-and-how-it-calculated

lwx228
Level VIII

Re: How to use JMP to calculate the technical indicators of stock————MACD?

Thank gzmorgan0!

In this way, my calculation method on the second floor is the same as that in the link.

EMA of JMP is another algorithm?How can JMP methods use parameters to calculate this effect?Thank you very much!
gzmorgan0
Super User (Alumni)

Re: How to use JMP to calculate the technical indicators of stock————MACD?

If I read the link that I posted correctly, the attached JMP file is a modification of the JMP sample data Current Stock Prices.JMP

I believe there was a previous discussion (or wish list) for Hi-Lo-Close bars for GraphBuilder.  I did not look it up, but copped out with an area range for Hi-Lo and used a line for Close. 

The script to create this plot is attached to the data table. Note to get the histogram of the difference of MACD and its signal to be red when negative and green when positive, two columns were used. They are named Bull (green) and Bear (red) and use the same difference formula but is conditioned on whether MACD > Signal.  

 

The JMP statistical column formula Col Moving Average() uses a weighted average and produces a result as long as a single value is non-empty versus returning empty if any of the "n" values are missing. Also in JMP,  the EWMA or EMA  intial value is the value itself, while these stock indicators begin with a simple moving average.

 

What was not clear in the MACD documentation is the weighting factor. For EMA12 it used  2/(12+1). Does that imply that EMA26 uses 2/(26+1) and the Signal for MACD does it use 2/(9+1), or was 12 used as scaling for 12 months, that is the lambda is always the same?? I used formulas so they can be adjusted if needed.

 

Maybe one of the super experts have a solution for red and green bars to depict the daily range, or someone has knowledge regarding the smoothing lambda for EMA26 or the Signal which is an EMA9 of MACD. 

 

 image.png

 

lwx228
Level VIII

Re: How to use JMP to calculate the technical indicators of stock————MACD?

t seems to be a little different. On the right hand side are the formulas and results of my calculation.

 

Nevertheless I may use the result of the index oneself of stock software and computation check, the problem was solved,Thank gzmorgan0!

 

2019-01-03_18-40-53.png


@gzmorgan0 wrote:

If I read the link that I posted correctly, the attached JMP file is a modification of the JMP sample data Current Stock Prices.JMP

I believe there was a previous discussion (or wish list) for Hi-Lo-Close bars for GraphBuilder.  I did not look it up, but copped out with an area range for Hi-Lo and used a line for Close. 

The script to create this plot is attached to the data table. Note to get the histogram of the difference of MACD and its signal to be red when negative and green when positive, two columns were used. They are named Bull (green) and Bear (red) and use the same difference formula but is conditioned on whether MACD > Signal.  

 

The JMP statistical column formula Col Moving Average() uses a weighted average and produces a result as long as a single value is non-empty versus returning empty if any of the "n" values are missing. Also in JMP,  the EWMA or EMA  intial value is the value itself, while these stock indicators begin with a simple moving average.

 

What was not clear in the MACD documentation is the weighting factor. For EMA12 it used  2/(12+1). Does that imply that EMA26 uses 2/(26+1) and the Signal for MACD does it use 2/(9+1), or was 12 used as scaling for 12 months, that is the lambda is always the same?? I used formulas so they can be adjusted if needed.

 

Maybe one of the super experts have a solution for red and green bars to depict the daily range, or someone has knowledge regarding the smoothing lambda for EMA26 or the Signal which is an EMA9 of MACD. 

 

 

 




lwx228
Level VIII

Re: How to use JMP to calculate the technical indicators of stock————MACD?

I'm going to try to compute the implementation of the "SMA" function in the RSI formula.Thanks!

 

2019-01-03_18-03-49.png

gzmorgan0
Super User (Alumni)

Re: How to use JMP to calculate the technical indicators of stock————MACD?

I found another website with an Excel sheet with MACD. The table I posted had the correct formulas except for MACD, it should have been EMA12-EMA26, my sign was the opposite.

 

The site with the Excel sheet is how-to-calculate-macd-in-excel.

 

Attached is a script that can be run on any table as long as the columns Date and Close  exist.  I simplified the EMA12 and EMA26 and Signal so that the SMA columns are not required. If High and Low are columns then the area plot is drawn, otherwise, not.

 

Below is the picture from the website regarding Excel followed by the Graphbuilder picture. 

 

To test, open the JMP sample data table Current Stock Averages.jmp then run the attached script CalculateMACD.jsl. Note the graph will be dirfferent than the previously posted, since previously, I had the MACD sign reversed.  

The formulas for your calculation are reasonable, however, be careful calling it MACD if you are publishing it.  it is my experience that when there is a widely accepted metric, even slight deviations without clear notice will create distrust for any results.

 

image.pngimage.png

lwx228
Level VIII

Re: How to use JMP to calculate the technical indicators of stock————MACD?

Thank gzmorgan0! I'm so touched by your help!

The parenthesis indicated by the arrow can be omitted so that the two formulas are basically the same.If you have a lot of data, the error is negligible.

 

2019-01-03_20-19-08.png