The YoyoActionStrategy is a trading strategy that uses various indicators to generate buy and sell signals. Here is a summary of what the strategy does:
Populating Indicators:
Calculates the OHLC4 (average of open, high, low, and close prices). Computes exponential moving averages (ema_fast and ema_slow) using different time periods.
Calculates the relative strength index (rsi) using a specified period.
Computes the moving average convergence divergence (macd) as the difference between ema_fast and ema_slow.
Determines bullish and bearish states based on the macd values. Setting Stop Loss Levels:
Calculates stop loss levels (sl1 and sl2) based on the average true range (atr) using different time periods. Creating Indicator Flags:
Initializes flags for different indicator states such as green, blue, aqua, yellow, brown, red, long, preBuy, short, preSell, over_sole, over_bought, and bullish_last. Updates the flags based on the indicator conditions for each data point. Trail Stop Loss Calculation:
Computes the trailing stop loss (trail2) based on the current close price and previous trail2 value. Adjusts the trail2 value based on the close price movement relative to the trail2 value and stop loss levels. Generating Buy and Sell Signals:
Determines the buy signal based on the conditions when the green_last flag is False and the green flag is True. Sets the atr_stop value as the trail2 when the buy signal is True and the greenLine flag is True. Updates the atr_stop value based on the previous atr_stop value when the buy signal is False. Determines the sell signal based on the conditions when the red_last flag is False and the red flag is True, or when the atr_stop value is greater than the close price. Populating Buy and Sell Trends:
Sets the "buy" column to 1 for the rows where the buy signal is True. Sets the "sell" column to 1 for the rows where the sell signal is True. The strategy uses a combination of indicators and trailing stop loss levels to identify potential buying and selling opportunities in the market.