OPEN-SOURCE SCRIPT
Atualizado MAHAR K Stochastic Indicator

What It Does
%K line calculates fast stochastic of _src over length, then re-smoothed twice: sk (smoothK), %D (smoothD), and slower %F (smoothF).
Plots the three lines, draws 80/50/20 bands, and highlights extreme values by drawing red circles when sk hits 100 and green when it hits 0.
Notable Details
sma_signal chooses the smoothing kernel (SMA, EMA, WMA, DEMA). ma() delegates to the selected function and contains a VWMA branch even though VWMA is not listed in the input options.
A custom dema() helper implements the classic double EMA.
stOBOS is always true, so the ternary wrappers around the circle plots can be simplified.
Risk / Edge Cases
If highestHigh == lowestLow (flat price over the window) the %K calculation divides by zero, yielding na. Consider guarding against that or defaulting to previous values.
To actually expose VWMA, add it to the input options; otherwise remove the dead code branch.
Next Steps
Decide whether to safeguard the denominator before plotting.
Align the smoothing options with the available choices and prune the redundant conditionals if desired.
%K line calculates fast stochastic of _src over length, then re-smoothed twice: sk (smoothK), %D (smoothD), and slower %F (smoothF).
Plots the three lines, draws 80/50/20 bands, and highlights extreme values by drawing red circles when sk hits 100 and green when it hits 0.
Notable Details
sma_signal chooses the smoothing kernel (SMA, EMA, WMA, DEMA). ma() delegates to the selected function and contains a VWMA branch even though VWMA is not listed in the input options.
A custom dema() helper implements the classic double EMA.
stOBOS is always true, so the ternary wrappers around the circle plots can be simplified.
Risk / Edge Cases
If highestHigh == lowestLow (flat price over the window) the %K calculation divides by zero, yielding na. Consider guarding against that or defaulting to previous values.
To actually expose VWMA, add it to the input options; otherwise remove the dead code branch.
Next Steps
Decide whether to safeguard the denominator before plotting.
Align the smoothing options with the available choices and prune the redundant conditionals if desired.
Notas de Lançamento
add custom alertsScript de código aberto
No verdadeiro espirito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam entendê-lo e verificá-lo. Parabéns ao autor Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações e regida pelas Regras da Casa.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.
Script de código aberto
No verdadeiro espirito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam entendê-lo e verificá-lo. Parabéns ao autor Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações e regida pelas Regras da Casa.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.