sgx234
December 9, 2022, 7:04am
1
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
evankoh
December 12, 2022, 1:26am
2
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”
sgx234
December 15, 2022, 4:54am
3
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
evankoh
December 15, 2022, 5:13am
4
Thanks for the values. Where did you get the 12D EMA and 26D EMA from?
sgx234
December 16, 2022, 3:34am
5
these are from Yahoo Finance. Thank you
evankoh
December 18, 2022, 2:21am
6
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.
sgx234
December 28, 2022, 5:36am
7
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?
sgx234
January 26, 2023, 3:38am
8
May I know how EMA is computed in StocksCafe?
evankoh
January 27, 2023, 10:28am
9
Hi,
Yes, I have been wanting to reply you but keep procrastinating
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