OPEN-SOURCE SCRIPT
Aggiornato 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.
Note di rilascio
add custom alertsScript open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.