Hi
Could someone please help with the conversion of the second line of code ….. I can convert the first line
rsi14 = rsi(src, 14)
// => rsi14 = RSI[14](close)
k14 = sma(stoch(rsi14, rsi14, rsi14, 14), smoothK1)
Thanks Denmar
.oops .sorry … smoothK1 is just a value
JSParticipant
Senior
I think this is the right conversion:
smoothK1 = 5
rsi14 = RSI[14](close)
xStoch = 100 * (rsi14 – Lowest[14](rsi14)) / (Highest[14](rsi14) – Lowest[14](rsi14))
k14 = Average[smoothK1](xStoch)
Return k14
JSParticipant
Senior
A little explanation:
In TradingView / PineScript, the Stochastic is a built-in formula that is calculated with:
Stoch = 100 * (Close – Lowest (Low, Length)) / (Highest(High, Length) – Lowest(Low, Length)
De syntax is: Stoch (source, high, low, length)
As you can see, the original script uses Stoch (rsi14, rsi14, rsi14, 14)
So the source = rsi14, the high of rsi14, the low of rsi14, length = 14
xStoch = 100 * (rsi14 – Lowest[14](rsi14)) / (Highest[14](rsi14) – Lowest[14](rsi14))