The "CustomStoplossWithPSAR" strategy is an example class that implements a trailing stop loss based on the Parabolic SAR (PSAR) indicator. Here's a brief description of what the strategy does:
Timeframe: The strategy operates on the 1-hour timeframe. Stoploss: The stoploss is set to -0.2, which means that if the current profit of a trade drops by 20%, the position will be sold.
Custom Info: The strategy maintains a dictionary called "custom_info" to store custom information for each trading pair.
Use Custom Stoploss: The strategy enables the use of a custom stoploss.
Custom Stoploss Function: The custom_stoploss() function calculates a new stoploss value based on the difference between the current rate and the Parabolic SAR indicator value. The result is a relative negative offset required by the return implementation of the custom_stoploss() function. Populate Indicators Function: The populate_indicators() function adds the Parabolic SAR indicator ("sar") to the dataframe. In backtesting or hyperopt mode, the function stores the SAR values in the "custom_info" dictionary for each trading pair. Populate Buy Trend Function: The populate_buy_trend() function generates a buy signal when the SAR value is smaller than the SAR value of the previous candle. It sets the "buy" column to 1 for the corresponding rows in the dataframe. Populate Sell Trend Function: The populate_sell_trend() function does nothing and keeps the "sell" column as 0, allowing the strategy to work correctly. This strategy demonstrates how to implement a custom stoploss using the PSAR indicator and how to generate buy signals based on the SAR values. You can adapt this strategy and modify the buy and sell conditions according to your own trading strategy requirements.