PSAR Optimization Script


User @henryph24 suggested I make this script!

This script calculates the cumulative and average gain/Loss of rising SAR following a price crossover of SAR.
The cumulative and average gain/Loss of falling SAR following a price crossunder is also measured.
Changes to the parameters of SAR will return the requisite calculations for evaluating performance.
Benchmark SAR can be used to compare performance against test SAR.

When changing the SAR parameters the script will recalculate and display the rising SAR and falling SAR performance of the modified parameters. The script works for any asset on any timeframe.

Essentially, this script allows you to optimize SAR parameters, and quickly ascertain what can/cannot work for an asset.

The script automatically plots the best performing SAR between a benchmark SAR (SAR #1) and a test SAR (SAR #2). Both benchmark SAR and test SAR works the same. The two are used to compare performance between different SAR parameters. If you would like the script not to plot the best performing SAR you can select "On" for the "Override SAR" input box. Doing so will plot the SAR parameters of your choice while still allowing you to compare the performance of benchmark SAR and test SAR.

There are tooltips available in the user input tab that explain the SAR parameters, in addition to what your modifications of the parameters will do, should you be unfamiliar with the indicator!

Release Notes:
Memory calculation compliant

•Access to Next-Gen Optimization Tools:

•Access to Proprietary Data:

•Discord Server:
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.


The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?