Skip to content

Instantly share code, notes, and snippets.

@bespokoid
Forked from marketcalls/Parabolic SAR
Created September 8, 2019 04:20
Show Gist options
  • Save bespokoid/e598e732aaf38ec19c32a22cfbf8ff44 to your computer and use it in GitHub Desktop.
Save bespokoid/e598e732aaf38ec19c32a22cfbf8ff44 to your computer and use it in GitHub Desktop.

Revisions

  1. @marketcalls marketcalls created this gist Sep 19, 2015.
    29 changes: 29 additions & 0 deletions Parabolic SAR
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@

    study(title="Parabolic SAR", shorttitle="P-SAR", overlay=true)
    start = input(2, minval=0, maxval=10, title="Start - Default = 2 - Multiplied by .01")
    increment = input(2, minval=0, maxval=10, title="Step Setting (Sensitivity) - Default = 2 - Multiplied by .01" )
    maximum = input(2, minval=1, maxval=10, title="Maximum Step (Sensitivity) - Default = 2 - Multiplied by .10")
    sus = input(true, "Show Up Trending Parabolic Sar")
    sds = input(true, "Show Down Trending Parabolic Sar")
    disc = input(false, title="Start and Step settings are *.01 so 2 = .02 etc, Maximum Step is *.10 so 2 = .2")
    //"------Step Setting Definition------"
    //"A higher step moves SAR closer to the price action, which makes a reversal more likely."
    //"The indicator will reverse too often if the step is set too high."

    //"------Maximum Step Definition-----")
    //"The sensitivity of the indicator can also be adjusted using the Maximum Step."
    //"While the Maximum Step can influence sensitivity, the Step carries more weight"
    //"because it sets the incremental rate-of-increase as the trend develops"

    startCalc = start * .01
    incrementCalc = increment * .01
    maximumCalc = maximum * .10

    sarUp = sar(startCalc, incrementCalc, maximumCalc)
    sarDown = sar(startCalc, incrementCalc, maximumCalc)

    colUp = close >= sarDown ? lime : na
    colDown = close <= sarUp ? red : na

    plot(sus and sarUp ? sarUp : na, title="Up Trending SAR", style=circles, linewidth=4,color=colUp)
    plot(sds and sarDown ? sarDown : na, title="Up Trending SAR", style=circles, linewidth=4,color=colDown)