The Supertrend strategy is an adapted version for freqtrade, a cryptocurrency trading bot. It uses the Supertrend indicator to determine buy and sell signals. Here's a breakdown of how the strategy works:
In the populate_indicators method, the Supertrend indicator is calculated for the given DataFrame by performing calculations on the high, low, and close prices.
The True Range (TR) and Average True Range (ATR) are also calculated.
The populate_buy_trend method populates the buy signals based on the Supertrend indicator.
Multiple Supertrend indicators are calculated with different parameters (buy_m1, buy_p1, buy_m2, buy_p2, etc.). If all three indicators for the current candle are 'up' and there is positive trading volume, a buy signal is generated. The populate_sell_trend method populates the sell signals based on the Supertrend indicator. Similar to the buy signals, if all three indicators for the current candle are 'down' and there is positive trading volume, a sell signal is generated. The Supertrend indicator calculations are performed using the basic upper bound (BASIC_UB), basic lower bound (BASIC_LB), final upper bound (FINAL_UB), final lower bound (FINAL_LB), Supertrend (ST), and the closing prices. These calculations involve checking previous values and comparing them with the current values. The calculated Supertrend values (ST and STX) are stored in a DataFrame and returned as the result. Overall, the Supertrend strategy uses multiple Supertrend indicators to generate buy and sell signals based on the current candle's values, volume, and previous indicator values.