Conversion of regression intercept indicator

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #161311 quote
    cc267
    Participant
    Average

    Hello, I have not come across one in the library, can anyone help with converting this regression intercept indicator originally posted on tradingview – https://www.tradingview.com/v/2roMOB3L/

    For some reason its not letting me insert the code with the PRT function, I just get a white box appear with no input area to input the code.

    #161312 quote
    cc267
    Participant
    Average
    //@version=4
    ////////////////////////////////////////////////////////////
    //  Copyright by HPotter v1.1 30/05/2020
    // Linear Regression Intercept is one of the indicators calculated by using the 
    // Linear Regression technique. Linear regression indicates the value of the Y 
    // (generally the price) when the value of X (the time series) is 0. Linear 
    // Regression Intercept is used along with the Linear Regression Slope to create 
    // the Linear Regression Line. The Linear Regression Intercept along with the Slope 
    // creates the Regression line.
    //
    // WARNING:
    // - This script to change bars colors.
    ////////////////////////////////////////////////////////////
    study(title="Line Regression Intercept Strategy", overlay = true)
    Length = input(14, minval=1)
    xSeria = input(title="Source", type=input.source, defval=close)
    xX = Length * (Length - 1) * 0.5
    xDivisor = xX * xX - Length * Length * (Length - 1) * (2 * Length - 1) / 6
    xXY = 0.0
    pos = 0
    for i = 0 to Length-1
    	xXY := xXY + (i * xSeria[i])
    xSlope = (Length * xXY - xX * sum(xSeria, Length)) / xDivisor
    xLRI = (sum(xSeria, Length) - xSlope * xX) / Length
    pos := iff(close > xLRI, 1,
             iff(close < xLRI, -1, nz(pos[1], 0))) 
    barcolor(pos == -1 ? color.red: pos == 1 ? color.green : color.blue )
    plot(xLRI, color=color.blue, title="LRI")
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Conversion of regression intercept indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
cc267 @cc267 Participant
Summary

This topic contains 1 reply,
has 1 voice, and was last updated by cc267
5 years ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/13/2021
Status: Active
Attachments: No files
Logo Logo
Loading...