Stochastic, PRT vs Pine script
- This topic has 6 replies, 2 voices, and was last updated 1 year ago by .
Viewing 7 posts - 1 through 7 (of 7 total)
Viewing 7 posts - 1 through 7 (of 7 total)
Similar topics:
Forums › ProRealTime English forum › ProRealTime platform support › Stochastic, PRT vs Pine script
Hi,
Trying to understand how to convert pine script for stochastic to PRT code. Been checking documentation on both Pine Script and PRT, but PRT seems to demand an extra value as input, “K”.
PRT:
Stochastic[N,K](price1,price2,price3), (5 input values)
Pine Script:
ta.stoch(source, high, low, length), (4 input values)
Does anyone here knows how to convert a Pine Script Stochastic line of code to PRT?
(for example this)
source = close
lookback = input.int(25, minval=1)
myStoch = ta.stoch(source, high, low, lookback)
appreciate the help
Hi,
Calculation Stochastic as used in PRT
hi = highest[14](high)
lo = lowest[14](low)
oscillator = (close – lo) / (hi – lo) * 100
ProcentK = average[3,0](oscillator) // 0=SMA, 1=EMA, 2=WMA
ProcentD = average[5,0](ProcentK) // 0=SMA, 1=EMA, 2=WMA
RETURN ProcentK AS “%K MA”, ProcentD AS “%D MA”
Formule Stochastics in PRT:
Stochastic[14,3](close)
Stochastic[N,K](price)
N=(lookback)period
K=period of the moving average for smoothing the oscillator
Price=Close (source)
In PRT, the Stochastics is always calculated by default with the “Close” but if you want to use other sources you can specify them in (price1, price2, price3).
If you also want to use the %D (average of %K), you must use the following indicator:
StochasticD[N,K,D](Close)
With the input used in your post, the Stochastic looks like this:
Stochastic[25,3](Close)
Thanks for the input!
I think I found a Pine Script example that’s more compatible with the PRT way…
…it looks like the smoothing is normally implemented this way in pine:
periodK = 14
smoothK = 3
k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)
Could I then assume that using K=1 in the PRT code would “switch off” the smoothing, right?
Find exclusive trading pro-tools on