LOGISTIC REGRESSION INDICATOR FOR PRT

Forums ProRealTime English forum ProBuilder support LOGISTIC REGRESSION INDICATOR FOR PRT

Viewing 4 posts - 1 through 4 (of 4 total)
  • #224036

    Hi all,

    I´m  trying to find a solution to migrate a logistic regression indicator from Tradingview , but not had much success  yet.

    I have the source code from Tradingview.

    It could be possible translate the pinescript code (applied on price)??

    I attach the source code.

    //@version=3
    // Logistic Regression
    study(“LogReg”, overlay=true)
    //
    // Functions
    //
    dot(v, w, p) => sum(v * w, p)
    sigmoid(z) => 1 / (1 + exp(-z))
    logistic_regression(X,Y,p,W,lr,steps)=>
        w = 0.0, loss = 0.0
        for i=0 to steps
            hypothesis = sigmoid(dot(X, W, p))  // prediction
            loss := -1 / p * (dot(dot(Y, log(hypothesis) + (1 – Y), p), log(1 – hypothesis), p))  // loss function, gradient, training
            gradient = 1 / p * (dot(X, hypothesis – Y, p))
            w := w – lr * gradient
        [loss, sigmoid(dot(X, w, p))]  // current loss & prediction
    scaleMinimax(X,p,min,max)=>
        hi = highest(X, p), lo = lowest(X, p)
        (max – min) * (X – lo)/(hi – lo) + min
    //
    // Inputs
    //
    X = input(close)
    p = input(3)
    //
    // Main
    //
    Y = log(abs(pow(X, 2) – 1) + .5)  // generate dataset
    W = 0.0
    [x,y]=logistic_regression(X,Y,p,W,0.001,100)
    x_scaled = scaleMinimax(x, 1000, lowest(X, 1000), highest(X, 1000))
    y_scaled = scaleMinimax(y, 1000, lowest(X, 1000), highest(X, 1000))
    plot(x_scaled, linewidth=3)
    plot(y_scaled, linewidth=3, color=lime)

    Thanks,

    Óscar

    #224038

     

    #224042

    Hello,

    I add it to the waiting list of code translations, however given the code seems fairly short, hopefully one of the forum members fluent in both platforms languages is more than welcome to translate it first

    #224045

    Cela ressemble à deux MM de régression linéaire de même période mais avec la première réglée sur les plus hauts et la deuxième alignée sur les plus bas…

    Visuellement, j’arrive au même indicateur en tout cas.

    As tu essayé sur PRT ?

    Edit: with google translate, into English (please use English in English forum as per forum rules in yellow box at bottom of the page just above “submit” button, thanks)

    This looks like two linear regression MAs of the same period but with the first set to the highs and the second aligned to the lows…

    Visually, I arrive at the same indicator in any case.

    Have you tried on PRT?

Viewing 4 posts - 1 through 4 (of 4 total)

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