Starbots

Self Optimizing PSAR [Starbots]

Self Optimizing Parabolic SAR Strategy (non-repainting)

Strategy constantly backtest 169 different combinations of Parabolic SAR indicator for maximum profitability and trades based on the best performing combination at that time.
---------------------------------------------------------------------------------------------------------
# Parabolic SAR (PSAR)
Parabolic SAR is a time and price technical analysis tool created by J. Welles Wilder and it's primarily used to identify points of potential stops and reverses. In fact, the SAR in Parabolic SAR stands for "Stop and Reverse". The indicator's calculations create a parabola which is located below price during a Bullish Trend and above Price during a Bearish Trend.
You can read more about this indicator here:
www.tradingview.com/chart/?solution=4...
-----------------------------------------------------------------------------------------------------------

The logic of self - optimizing:
This script is always backtesting 169 different combinations of Parabolic SAR settings in the background and saves the net. profit gained for every single one of them, then strategy selects and use the best performing combination of settings currently available for you to trade.
It's recalculating on every bar close - if one of the parameters starts performing better than others - have a higher net profit gain (it's literally like running 169 backtests with different settings) strategy switches to that parameter and continues trading like that until one of the other indicator parameters starts performing better again and switches to that settings.

We are optimizing our strategy based on 13 different 'Increment' factors of PSAR. We keep the 'Start' factor (default 0.02) and 'Max Value' factor (default 0.2) at default for all of them.
According to creator of this indicator J. Welles Wilder, we usually want to change only 'Increment' factors of PSAR in the calculation and leave the rest at default and that's what we do, we are changing only 'Increment' input.

Inputs : (you don't need to change them at all, it's a good balance for fast and slow detection of trends on PSAR)
Start = 0.02
Max value = 0.2
Increment1 = 0.005, Increment2 = 0.01, Increment3 = 0.015
Increment4 = 0.02, Increment5 = 0.025, Increment6 = 0.03
Increment7 = 0.035, Increment8 = 0.04, Increment9 = 0.045
Increment10 = 0.05, Increment11 = 0.055, Increment12 = 0.06
Increment13 = 0.065

PSAR buy / sell conditions looks like this:
PSAR1 = start 0.02, max value 0.2, increment1 0.005
PSAR2 = start 0.02, max value 0.2, increment2 0.01
PSAR3 = start 0.02, max value 0.2, increment3 0.015
PSAR4 = start 0.02, max value 0.2, increment3 0.02
...
PSAR13 = start 0.02, max value 0.2, increment13 0.065

Backtester in the background works like this:
backtest buying PSAR1 settings with selling PSAR1 settings => save net. profit
backtest buy PSAR1 with sell PSAR2 ;
backtest buy PSAR1 with sell PSAR3 ;
backtest buy PSAR1 with sell PSAR4 ;
..........
backtest buy PSAR1 with sell PSAR13 ;
..........
backtest buy PSAR13 with sell PSAR1 ;
backtest buy PSAR13 with sell PSAR2 ;
......
backtest buy PSAR13 with sell PSAR13 ;
=>
It will backtest 16x16=169 different PSAR settings and save their profits.
Your strategy then trades based on the best performing (highest net.profit) PSAR Setting currently available. It will check the calculations and backtest them on every new bar close - it's like running 169 strategies at time, and manually selecting the best performing one.
________________________________________________________________________


If you wish to use it as INDICATOR - turn on 'Recalculate after every tick' in Properties tab to have this script updating constantly and use it as a normal Indicator tool for manual trading.

Strategy example is backtested on Daily chart of SHIBUSDT Binance
All settings at default. (1000 capital, 100 order size, 0.1% fee, 1 tick slippage)

Settings:
-Start = default Parabolic SAR setting is 0.02
-Max Value = default Parabolic SAR setting is 0.2
--Recommended PSAR Increment settings:
0.02 is default, higher timeframes usually performs good on the faster Increment factors 0.03-0.05+, smaller timeframes on slow Increment factors 0.005-0.02. I recommend you the most common and logical 13 different Increment factors for optimizing in the strategy as default already (from 0.005 to 0.065 - strategy will then optimize and trade based on the most profitable combination).

- Noise-Intensity Filter 🐎0.00-0.20%🐢
This will punish the tiny trades made by certain combinations and give more advantage to big average trades. It's basically like fee calculation, it will deduct 0.xx% fee from every trade when optimizing on their backtests.
You will usually want to have it around 0.05-0.10% like your fees on exchange.
-> 🐎Less than <0.10% allows strategy to be VERY SENSITIVE to market. (a lot of trades - quick buy-sell changes)
-> 🐢More than >0.10% will slow down the strategy, it will be LESS SENSITIVE to market volatility. (less trades - slowly switches the trend direction from buy to sell)

Close Trades on Neutral
After a lot of Trades, Algo starts developing self-intelligence. It can also have a neutral score. (Grey Plots). Sell when the strategy is neutral.

Other settings:
-Take Profit, Multiple Take Profit, Trailing Take Profit, Stop Loss, Trailing Stop Loss with functional alerts.
-Backtesting Range - backtest within your desired time window. Example: 'from 01 / 01 /2020 to 01 / 01 /2023'.
- Strategy is trading on the bar close without repaint. You can trade Long-Sell/Short Sell or Long-Short both directions. Alerts available, insert webhook messages in the inputs.
- Turn on Profit Calendar for better overview of how your strategy performs monthly/annualy
- Notes window : add your custom comments in here or save your webhook message text inside here for later use. I find this helpful to save texts inside.

Recommended TF : 4h, 8h, 1d (Trend Indicators are good at detecting directions of the market, but we can have a lot of noise and false movements on charts, you want to avoid that and ride the long term movements)

This script is fairly simple to use. It's self-optimizing and adjusting to the markets on the go.

Private strategies and Signaler. www.star-bots.com
仅限邀请脚本

仅限作者授权的用户访问此脚本,并且通常需要付费。您可以将其添加到收藏中,但是只有在向作者请求并获得许可之后,才能使用它。 请与Starbots联系以获取更多信息,或按照以下作者的说明进行操作。

在您100%信任脚本作者并了解脚本的工作原理之前,TradingView不建议您购买脚本并使用它。在很多情况下,您可以在我们的公共指标库中免费找到一个不错的开源替代品。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

作者的说明

PM for free access or visit www.star-bots.com for more information.

想在图表上使用此脚本?

警告:请阅读,然后再请求访问权限。