[Watchlist] Display Metrics "MACD-12-26-9"

Please let me know how “MACD-12-26-9” is computed, which can be set as a Display Metrics for Watchlist.

Initially I thought it might be MACD Histogram, but seems not match. For example, “-0.01” is the one for A17U, but it should be 0.0006 as of 8/12/2022.

Thank you.

https://stocks.cafe/watchlist/financials?label_id=0

Hi there,

I checked my implementation. It is doing the following

MACD = EMA[stockPrices,12] - EMA[stockPrices,26]
signal = EMA[MACD,9]
returns MACD - signal

This basically means that the value you see is “MACD - Signal”

Thank you for your clarification. But please refer to the below data as of 2022/12/14. MACD-Signal seem not tally with “MACDS-12-26-9” on Watchlist.

Close 12D EMA 26D EMA MACD Signal MACD-Signal “MACD-12-26-9” on Watchlist
A17U 2.780 2.753 2.733 0.019 0.024 -0.004 -0.010
AAPL 143.21 144.56 145.43 -0.88 -0.60 -0.28 -0.33

thank you

Thanks for the values. Where did you get the 12D EMA and 26D EMA from?

these are from Yahoo Finance. Thank you

I see. EMA computation can differs slightly depending on how far we look back into the future to start the initial computation. That might explain the differences.

Thank you for your feedback & Sorry my reply being late (I have been on vacation).

As per my understanding, “X day EMA” should always average the first X days’ prices to start initial computation. (IF you take the historical data to from Yahoo Finance you can verify that Yahoo also do the same.)

May I know how EMA is computed in StocksCafe?

May I know how EMA is computed in StocksCafe?

Hi,

Yes, I have been wanting to reply you but keep procrastinating :frowning:

I am basing on this → What is EMA? How to Use Exponential Moving Average With Formula

The code is literally this

public static double compute(final List<Double> valueList){
		if(valueList == null || valueList.isEmpty()) {
            throw new Error();
        }
		
		final double decayFactor = 1.0 - (2.0 / (valueList.size() + 1));
		final List<Double> weightsList = new ArrayList<>();
		double weight = 1.0;
		for(int i = 0; i < valueList.size(); i++){
			weightsList.add(weight);
			weight /= decayFactor;
		}
		return AfcExponentialWeightedMean._compute(valueList, weightsList);
	}
	
	private static double _compute(final List<Double> valueList, final List<Double> weightsList){
		double totalWeights = 0.0;
		for(final double d : weightsList) {
            totalWeights += d;
        }
		double weightedMean = 0.0;
		for(int i = 0; i < valueList.size(); i++){
			weightedMean += valueList.get(i) * weightsList.get(i);
		}
		return weightedMean / totalWeights;
	}

Not sure if that helps but let me know if you have more questions :slight_smile: