- MetaTrader 5 Help → Price Charts, Technical and Fundamental Analysis → Technical Indicators → Oscillators → Stochastic Oscillator
MetaQuotes, 2010.01.26 11:24
The Stochastic Oscillator compares where a security’s price closed relative to its price range over a given time period.
That's exactly what is not useful for me - and was easy to find. To give context, the following information was more useful in regards to applying EMA to the %K and %D values, from a different site:
steema.com/docs/financialFunctionsRef/expMovingAverageFunction.htm
The MQL help material doesn't specify what the calculation methodology is, when it comes to calculating %K and %D when non-simple calculations are necessary - and in my case, there is also no mention of how calculations are modified when price field = "Low/High"; the outlined "slowing" periods text simply states "general" information, but no actual formulas on how this is actually, mathematically done.
So far, I have managed to "almost" figure out how %K and %D is calculated when the exponential method is used (by trial and error in Excel), but I am still not getting the exact results that MetaTrader displays.
Do you mean using an EMA instead of an SMA for the %D?
%K = (Current Close - Lowest Low)/(Highest High - Lowest Low) * 100
"Close/Close" not sure, but it might use the maximum and minimum close prices to determine the upper/lower range.
You can see what "slowing" is doing in the example code. It is just a bar shift.

- www.mql5.com
Do you mean using an EMA instead of an SMA for the %D?
"Low/High" is just the normal equation ...%K = (Current Close - Lowest Low)/(Highest High - Lowest Low) * 100
"Close/Close" not sure, but it might use the maximum and minimum range of the close prices.
You can see what "slowing" is doing in the example code. It is just a bar shift.
Regarding Low/High - I just checked - looks like I forgot that Low/High is the default, and Close/Close is the other option - would be good to know how close/close is calculated, in such a case... it's not that important for now, but would be important to understand this as well.
Regarding EMA: I need to understand how the field "Method" is used to calculate the stochastic, when the method = Exponential
From what I have gathered so far, by default, when method = Simple, an SMA would be applied to the %K, HOWEVER, when Exponential is used, it seems that an EMA is applied to both the %K as well as %D values, not just %K - but this is just a hunch, based on what I have seen my Excel calculations lead to (as in an EMA that is applied to either only %D or %K yields results that look further away from what MetaTrader displays).
As for "Slowing": long story short, I don't code in MQL - I came here to find mathematical answers. From what I have seen so far within the code that you linked, there do seem to be some visually seen equations there, not just code. I will see if I can deduct useful info from it.
Method is just the type of averaging used for the %D calculation—Simple Moving Average (SMA), Exponential Moving Average (EMA), etc.
- %D = SMA (%K, N)
- %D = EMA (%K, N)
- etc.
The difference between the Slow and Fast Stochastic Oscillator is the Slow %K incorporates a %K slowing period of 3 that controls the internal smoothing of %K. Setting the smoothing period to 1 is equivalent to plotting the Fast Stochastic Oscillator.—https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/slow-stochastic
Slow %K= 100[Sum of the (C - L14) for the %K Slowing Period / Sum of the (H14 – L14) for the %K Slowing Period]
Slow %D = SMA of Slow %K
Where: C = Latest Close L14 = Lowest low for the last 14 periods H14 = Highest high for the same 14 periods %K Slowing Period = 3
Hello everyone,
I have spent countless hours trying to find the mathematical formulas for the stochastic oscillator both on the web in general, as well as MQL, and I don't seem to be able to find the answers that I am looking for.
To be clear, I am not interested in the simple formula that is used for the stochastic oscillator, which is essentially what keeps getting thrown at me by Google and all the help material on MQL - which is useless for me.
I need to know the mathematical (non-code) formulas that are used to calculate the stochastic oscillator when the "exponential" method is used, the Price field = "Low/High" (instead of "Close/Close"), as well as how the "slowing" value is used for calculations (where does this value fit in, within the mathematical equations (?)).
Thanks in advance.