Stochastic, PRT vs Pine script

Forums ProRealTime English forum ProRealTime platform support Stochastic, PRT vs Pine script

Viewing 7 posts - 1 through 7 (of 7 total)
  • #218287

    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

     

    #218293
    JS

    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)

    #218295

    That was a lot… Thanks… 🙂

    So, by keeping K=3, then it’s comparable to how it’s calculated in Pine Script… did I get that right?

    #218300
    JS

    ta.stoch(source, high, low, length)

    As you can see, the period for the average is not specified in the Pine Script formula…

    Normally you keep 1 for a fast stochastic and 3 or 5 for a slower…

    #218302

    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?

    #218303
    JS

    That’s right, when you use K=1 there is no “smoothing”…

    #218304

    Thanks!

    1 user thanked author for this post.
    avatar JS
Viewing 7 posts - 1 through 7 (of 7 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login