The Supertrend strategy is a trading strategy that utilizes the Supertrend indicator to generate buy and sell signals. The strategy calculates the Supertrend values based on the high, low, close prices, and average true range (ATR) of the asset's price data. The Supertrend indicator consists of two components: the Supertrend value (ST) and the Supertrend direction (STX).
The ST value represents the current trend level, while the STX indicates the trend direction as either "up" or "down."
To calculate the Supertrend values, the strategy first computes the ATR using the true range (TR) of each period.
It then calculates the basic upper and lower bands by adding or subtracting a multiple of the ATR from the average of the high and low prices.
The strategy iteratively determines the final upper and lower bands based on the previous period's values and the current price action. Once the Supertrend values are calculated, the strategy populates three Supertrend indicators with different parameters: supertrend_3_12, supertrend_1_10, and supertrend_2_11. These indicators capture variations of the Supertrend strategy with different multiplier and period settings. In the buy signal generation step, the strategy identifies a buy signal when all three Supertrend indicators (supertrend_3_12, supertrend_1_10, and supertrend_2_11) indicate an "up" trend. In the sell signal generation step, the strategy identifies a sell signal when all three Supertrend indicators indicate a "down" trend. The strategy also includes additional indicators for graphing purposes, such as Bollinger Bands. The Supertrend strategy has a predefined minimal return on investment (ROI) and stop-loss values. The ROI specifies the minimum desired return, while the stop-loss defines the maximum tolerable loss. These values can be adjusted in the strategy configuration file. The strategy operates on a 5-minute timeframe by default, but this can also be modified in the configuration. Overall, the Supertrend strategy aims to capture trending market conditions and generate buy and sell signals based on the Supertrend indicator and its variations.