anandanand84 / technicalindicators

A javascript technical indicators written in typescript with pattern recognition right in the browser
MIT License
2.14k stars 557 forks source link

Indicator Ergodic Oscillator (SMIO) #200

Open trevisanweb opened 4 years ago

trevisanweb commented 4 years ago

Is it possible to create this indicator?

If anyone knows how to create in javascript can help me?

image

cwouter commented 4 years ago

Everything is possible. I've found the math on the following page: https://www.motivewave.com/studies/smi_ergodic_oscillator.htm

//price (user defined, default is closing price)
//method = moving average (user defined, default is EMA)
//prevP = previousPrice, index = current bar number
//abs = absolute value
//ma = moving average

prevP = price[index-1];
change = price - prevP;
absChange = abs(price - prevP);
tempChange = ma(method, index, fastPeriod, change);
tempAbsC = ma(method, index, fastPeriod, absChange);
tempChange = ma(method, index, slowPeriod, tempChange);
tempAbsC = ma(method, index, slowPeriod, tempAbsC);
SMI = tempChange / tempAbsC;
SIGNAL = ma(method, index, sigPeriod, SMI);
Plot: SMIEO = SMI - SIGNAL;

The difficulty may be that you need to combine multiple indicators to create the output value. But this has been done before in the ADX indicator: https://github.com/anandanand84/technicalindicators/blob/master/src/directionalmovement/ADX.ts