The InverseV2 strategy is a trading strategy implemented as a class. Here's a short description of what the strategy does:
populate_indicators function:
It calculates informative timeframes for the given dataframe and metadata. If the informative timeframe is specified, it merges the informative indicators with the dataframe.
It drops unnecessary columns from the merged dataframe.
populate_buy_trend function:
It identifies buy signals based on various conditions:
The fisher_cci crosses above a specified threshold (buy_fisher_cci_1).
The fisher_cci crosses below another threshold (buy_fisher_cci_2) after a maximum of 8 previous crosses below. The ssl_up value is greater than the ssl_down value for the informative timeframe. The 50-day exponential moving average (ema_50) is greater than the 200-day exponential moving average (ema_200). The 50-day exponential moving average for the informative timeframe (ema_50_info_timeframe) is greater than the 100-day and 200-day exponential moving averages for the informative timeframe. The btc_cci value for the informative timeframe is less than 0. The volume is greater than 0. populate_sell_trend function:
It identifies sell signals based on the following conditions:
The fisher_cci crosses below two specified thresholds (sell_fisher_cci_1 and sell_fisher_cci_2). The volume is greater than 0. The remaining code outside the functions:
It creates a copy of the dataframe and adds additional indicators (ATR, smaHigh, smaLow, hlv, sslDown, sslUp). The ATR indicator is calculated using a time period of 14. The smaHigh indicator is the rolling mean of the high column plus the ATR indicator. The smaLow indicator is the rolling mean of the low column minus the ATR indicator. The hlv column determines whether the close price is above (1), below (-1), or in between (NaN) the smaHigh and smaLow values. The hlv column is forward-filled to propagate the last non-null value. The sslDown indicator is the smaHigh value if hlv is negative, otherwise it is the smaLow value. The sslUp indicator is the smaLow value if hlv is negative, otherwise it is the smaHigh value. The function returns the sslDown and sslUp values from the dataframe. Overall, the strategy calculates various indicators, identifies buy and sell signals based on specified conditions, and provides the sslDown and sslUp values as outputs.