The FreqGym_normalized strategy is a trading strategy implemented as a class in Python. It is used to populate indicators, generate buy signals, and generate sell signals for a given DataFrame of trading data. The populate_indicators method adds various technical analysis (TA) indicators to the DataFrame.
These indicators include:
PLUS_DI: Calculates the Plus Directional Indicator
MINUS_DI: Calculates the Minus Directional Indicator
ULTOSC: Calculates the Ultimate Oscillator
HT_SINE: Calculates the Hilbert Transform - Sine Wave
BOP: Calculates the Balance of Power
STOCH: Calculates the Stochastic Oscillator
STOCHF: Calculates the Fast Stochastic Oscillator
ADX: Calculates the Average Directional Movement Index
AROON: Calculates the Aroon Indicator
AROONOSC: Calculates the Aroon Oscillator
CMO: Calculates the Chande Momentum Oscillator
DX: Calculates the Directional Movement Index
MFI: Calculates the Money Flow Index
WILLR: Calculates the Williams' %R
RSI: Calculates the Relative Strength Index
STOCHRSI: Calculates the Stochastic RSI
LINEARREG_ANGLE: Calculates the Linear Regression Angle
After calculating the indicators, they are normalized to a range of 0 to 1.
The populate_buy_trend method generates buy signals based on the TA indicators.
It uses an RL model (not shown in the provided code) to predict the action to take. If the predicted action is 1, it sets the 'buy' column in the DataFrame to 1. The populate_sell_trend method generates sell signals based on the TA indicators. Similar to the populate_buy_trend method, it uses the RL model to predict the action. If the predicted action is 2, it sets the 'sell' column in the DataFrame to 1. The last part of the code segment initializes an output DataFrame and populates it with predicted results using the RL model. It uses a rolling window approach to generate predictions based on the indicators. The normalize function is used to normalize the indicator values within a specific range. Overall, this strategy calculates a variety of TA indicators, normalizes them, generates buy and sell signals based on the indicators using an RL model, and produces an output DataFrame with the predicted results.