Linear Progression Slope code

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #229975 quote
    brian gilbert
    Participant
    Junior

    Hello, can someone tell me how the “Linear Regression Slope” indicator is calculated in ProRealTime? I tried following the indicator description instructions, but I am getting different values…

    #230049 quote
    robertogozzi
    Moderator
    Master

    Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.Thanks 🙂

    I moved it from the Italian forum.

    Which indicator?

    #230051 quote
    brian gilbert
    Participant
    Junior

    Ah, ok, scusatemi… credevo che l’inglese fosse un po’ la lingua “universale” del Forum….

    Comunque, parlavo della “Pendenza di Regressione Lineare”, io ho provato a ricostruire l’indicatore servendomi della seguente formula:

    Slope = (N * Sum(xy) – Sum(x) * Sum(y)) / (N * Sum(x^2) – (Sum(x))^2)

    ma non sono riuscito ad ottenere alcunchè, oppure ottengo valori sballati, per cui volevo sapere qual è il codice applicato su Prorealtime per ottenere il suddetto indicatore.

    Grazie in anticipo.

    Ah, ok, sorry… I thought that English was somewhat of the “universal” language of the Forum….

    However, I was talking about the “Linear Regression Slope”, I tried to reconstruct the indicator using the following formula:

    Slope = (N * Sum(xy) – Sum(x) * Sum(y)) / (N * Sum(x^2) – (Sum(x))^2)

    but I wasn’t able to get anything, or I get incorrect values, so I wanted to know what code is applied on Prorealtime to obtain the aforementioned indicator.

    Thanks in advance.

    #230066 quote
    JS
    Participant
    Senior

    Hi Brian,

    Try this one:

     

    Sumx=0
    Sumy=0
    Sumx2=0
    Sumxy=0
    
    N=10
    
    For i=1 To N
    x=i
    y=Close[i-1]
    Sumx=Sumx+x
    Sumy=Sumy+y
    Sumx2=Sumx2+(x*x)
    Sumxy=Sumxy+(x*y)
    Next
    
    Slope=(N*Sumxy-Sumx*Sumy)/(N*Sumx2-(Square(Sumx)))*-1
    
    Return Slope
    brian gilbert thanked this post
    #230074 quote
    robertogozzi
    Moderator
    Master

    @brian gilbert

    please stick to the chosen language. Thanks 🙂

    #230140 quote
    brian gilbert
    Participant
    Junior

    Sorry, but i don’t understand if i must write in italian or english… however, thank’s a lot for your helping.

    #230154 quote
    robertogozzi
    Moderator
    Master

    Read the basic rules highlighted in yellow below.

    Choose the correct language forum and stick to it, using only that language.

    You chose the Italian forum but you used the English to write your first post. I then switched it to the English forum.

    Use only the English language here.

    Should you create a new topic you may choose any one of the supported languages, but then stick to it, please 🙂

    #230166 quote
    PeterSt
    Participant
    Master

    You chose the Italian forum but you used the English to write your first post. I then switched it to the English forum.

    Which is a most unclear thing to do. Please don’t blame the user/customer. Instead blame yourself. Or at least don’t bash the user for it.

    brian gilbert thanked this post
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

Linear Progression Slope code


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 7 replies,
has 4 voices, and was last updated by PeterSt
1 year, 10 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/18/2024
Status: Active
Attachments: No files
Logo Logo
Loading...