parabolic SAR code definition

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #204167 quote
    jmcenteno
    Participant
    New

    Hello everybody,

    I would like to run a simulation of parabolic SAR but when I try to code the indicator in eg python I don´t really get the same results as in PRT,

    How can I get to know the details of how SAR is defined / specified?

    As I said, I´ve looked at a number of places but the code I come up with casts different results as PRT

    Many many thanks in advance,

    #204175 quote
    JS
    Participant
    Senior

    Hi @jmcenterio

    Here is the code of the parabolic SAR.

    This code gives the same results as the “internal PRT” indicator…

    increment = 0.02
    initial = 0.02
    limite = 0.2
     
    IF BARINDEX < 2 THEN
    Lparabolic = LOW
    islong = 1
    af = limite
    hp = HIGH
    lp = LOW
    ELSE
    IF islong THEN
    Lparabolic = Lparabolic + af * (hp - Lparabolic)
    Lparabolic = MIN(Lparabolic, LOW[1])
    Lparabolic = MIN(Lparabolic, LOW[2])
    ELSE
    Sparabolic=Sparabolic + af * (lp - Sparabolic)
    Sparabolic=MAX(Sparabolic, HIGH[1])
    Sparabolic=MAX(Sparabolic, HIGH[2])
    ENDIF
         
    reverse = 0
         
    IF islong THEN
    IF LOW < Lparabolic THEN
    islong = 0
    reverse = 1
    Sparabolic = hp
    lp = LOW
    af = initial
    ENDIF
    ELSE
    IF HIGH > Sparabolic THEN
    islong = 1
    reverse =1
    Lparabolic = lp
    hp = HIGH
    af = initial
    ENDIF
    ENDIF
         
    IF NOT reverse THEN
    IF islong THEN
    IF HIGH > hp THEN
    hp = HIGH
    af = af + increment
    af = MIN (af,limite)
    ENDIF
    ELSE
    IF LOW < lp THEN
    lp = LOW
    af = af + increment
    af = MIN (af,limite)
    ENDIF
    ENDIF
    ENDIF
         
    ENDIF
    
    If isLong then
    DRAWPOINT(barindex, Lparabolic, 2) Coloured(0,255,0)
    EndIf
    If NOT isLong then
    DRAWPOINT(barindex,Sparabolic,2) Coloured(255,0,0)
    EndIf
    Return
    
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

parabolic SAR code definition


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
jmcenteno @jmcenteno Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by JS
3 years, 2 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 11/14/2022
Status: Active
Attachments: No files
Logo Logo
Loading...