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
Endast inbjudanskript.

Tillgången till detta skript är begränsat till användare som har godkänts av författaren och kräver vanligtvis betalning. Du kan lägga till det till dina favoriter men du kan bara använda det efter att ha begärt och fått författarens tillstånd. Kontakta Starbots för mer information eller följ författarens instruktioner här under.

TradingView rekommenderar inte att du betalar för ett skript och använder det om du inte litar till 100% på författaren och förstår hur skriptet fungerar. I många fall kan du hitta ett bra alternativ med öppen källkod gratis i våra Community skripts .

Frånsägelse av ansvar

Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i Användarvillkoren.

Författarens instruktioner

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

Vill du använda det här skriptet i ett diagram?

Varning:Var god läs innan du begär åtkomst.