A question regarding the SAR parabolic indicator

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

    Hello! Is it possible to code the SAR parabolic indicator so that it is calculated from a moving average value.

    #228192 quote
    Iván González
    Moderator
    Master

    Hi!
    Parabolic SAR needs high and low to be calculated.

    calculo de parabolica sar

    Here you have the code so you could make your own tests

    // SAR - Parabolic SAR
    //
    // https://www.prorealcode.com/topic/parabolic-sar-code/page/2/#post-174049
    //
    //    Parameters:
    //
    SARinit  = 0.02
    SARstep  = 0.02
    SARlimit = 0.2
    //
    IF BARINDEX < 2 THEN
       parabolic = LOW
       islong    = 1
       af        = SARlimit
       hp        = HIGH
       lp        = LOW
    ELSE
       IF islong THEN
          parabolic = parabolic + af * (hp - parabolic)
          parabolic = MIN(parabolic, LOW[1])
          parabolic = MIN(parabolic, LOW[2])
       ELSE
          parabolic = parabolic + af * (lp - parabolic)
          parabolic = MAX(parabolic, HIGH[1])
          parabolic = MAX(parabolic, HIGH[2])
       ENDIF
       reverse = 0
       IF islong THEN
          IF LOW < parabolic THEN
             islong    = 0
             reverse   = 1
             parabolic = hp
             lp        = LOW
             af        = SARinit
          ENDIF
       ELSE
          IF HIGH > parabolic THEN
             islong    = 1
             reverse   = 1
             parabolic = lp
             hp        = HIGH
             af        = SARinit
          ENDIF
       ENDIF
       IF NOT reverse THEN
          IF islong THEN
             IF HIGH > hp THEN
                hp = HIGH
                af = af + SARstep
                af = MIN (af,SARlimit)
             ENDIF
          ELSE
             IF LOW < lp THEN
                lp = LOW
                af = af + SARstep
                af = MIN (af,SARlimit)
             ENDIF
          ENDIF
       ENDIF
    ENDIF
    RETURN parabolic as "parabolic SAR"
    Sogor thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

A question regarding the SAR parabolic indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Sogor @sogor Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Iván González
2 years ago.

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