Normalized MACD #1242
Replies: 2 comments 1 reply
-
I'm doing a quick reformat-only of your code so I can visualize it better. // calculate regular MACD
var a_madcList = quotesPredicationList
.GetMacd()
.RemoveWarmupPeriods()
.ToList();
// calculate a MACD of the MACD and
// fetch its last 'MacdResult' entry
var a_madc = a_madcList.GetMacd().Last();
// create a copy of it for normalized conversion,
// to avoid using ref of 'a_macd'
var a_madcNormalized = new MacdResult(a_madc.Date) {
Macd = a_madc.Macd,
Signal = a_madc.Signal,
Histogram = a_madc.Histogram,
FastEma = a_madc.FastEma,
SlowEma = a_madc.SlowEma
};
// recalculate 'normalized' property values
// for MACD
a_madcNormalized.Macd = (float)_util.Normalize(
(decimal)a_madc.Macd,
(decimal)a_madcList.Min(m => m.Macd),
(decimal)a_madcList.Max(m => m.Macd),
-1000, 1000);
// for Signal
a_madcNormalized.Signal = (float)_util.Normalize(
(decimal)a_madc.Signal,
(decimal)a_madcList.Min(m => m.Signal),
(decimal)a_madcList.Max(m => m.Signal),
-1000, 1000);
// for Histogram
a_madcNormalized.Histogram = (float)_util.Normalize(
(decimal)a_madc.Histogram,
(decimal)a_madcList.Min(m => m.Histogram),
(decimal)a_madcList.Max(m => m.Histogram),
-1000, 1000);
// for FastEma
a_madcNormalized.FastEma = (float)_util.Normalize(
(decimal)a_madc.FastEma,
(decimal)a_madcList.Min(m => m.FastEma),
(decimal)a_madcList.Max(m => m.FastEma),
-1000, 1000);
// for SlowEma
a_madcNormalized.SlowEma = (float)_util.Normalize(
(decimal)a_madc.SlowEma,
(decimal)a_madcList.Min(m => m.SlowEma),
(decimal)a_madcList.Max(m => m.SlowEma),
-1000, 1000); From what I'm seeing, I suspect you're trying to create a bounded oscillator version of MACD by using a custom normalization method with a signature like this: public decimal Normalize(
decimal value,
decimal minValue,
decimal maxValue,
int lowerBoundary,
int upperBoundary) {
// calculate normalized value based on lower/upper boundaries
} I'm not sure if you're proposing that we add this What I can tell you, if you're looking for an interesting related fact about MACD-based bounded oscillators, is that the Schaff Trend Cycle (STC) is just a Stochastic Oscillator of a Moving Average Convergence / Divergence (MACD) indicator. |
Beta Was this translation helpful? Give feedback.
-
I have included the topic of normalization in this section because I am missing this basic method of organizing data in Skender.Stock.Indicators |
Beta Was this translation helpful? Give feedback.
-
in Skender.Stock.Indicators I miss normalization
a_madcList = quotesPredicationList.GetMacd().RemoveWarmupPeriods().ToList();
a_madc = a_madcList.GetMacd().Last();
a_madcNormalized = new MacdResult(a_madc.Date);// { Macd = a_madc.Macd, Signal = a_madc.Signal, Histogram = a_madc.Histogram, FastEma= a_madc.FastEma, SlowEma= a_madc.SlowEma}; //Helper.CreateDeepCopy(a_madc);
a_madcNormalized.Macd = (float)_util.Normalize((decimal)a_madc.Macd, (decimal)a_madcList.Min(m => m.Macd), (decimal)a_madcList.Max(m => m.Macd), -1000, 1000);
a_madcNormalized.Signal = (float)_util.Normalize((decimal)a_madc.Signal, (decimal)a_madcList.Min(m => m.Signal), (decimal)a_madcList.Max(m => m.Signal), -1000, 1000);
a_madcNormalized.Histogram = (float)_util.Normalize((decimal)a_madc.Histogram, (decimal)a_madcList.Min(m => m.Histogram), (decimal)a_madcList.Max(m => m.Histogram), -1000, 1000);
a_madcNormalized.FastEma = (float)_util.Normalize((decimal)a_madc.FastEma, (decimal)a_madcList.Min(m => m.FastEma), (decimal)a_madcList.Max(m => m.FastEma), -1000, 1000);
a_madcNormalized.SlowEma = (float)_util.Normalize((decimal)a_madc.SlowEma, (decimal)a_madcList.Min(m => m.SlowEma), (decimal)a_madcList.Max(m => m.SlowEma), -1000, 1000);
Beta Was this translation helpful? Give feedback.
All reactions