The YoyoActionStrategy is a trading strategy that uses various indicators to determine buy and sell signals. Here is a short description of what the strategy does:
Populating Indicators:
Calculates the OHLC4 (average of open, high, low, and close prices). Calculates the fast and slow exponential moving averages (EMA).
Calculates the relative strength index (RSI).
Calculates the moving average convergence divergence (MACD).
Determines bullish and bearish conditions based on the MACD. Calculates stop loss levels (sl1 and sl2) using the average true range (ATR). Drops rows with missing values. Indicator Conditions:
Calculates several boolean indicators based on conditions:
Green: Bullish condition and OHLC4 > fast EMA. Blue: Bearish condition and OHLC4 > fast EMA. Yellow: Bullish condition and OHLC4 < slow EMA. Brown: Bullish condition and OHLC4 < fast EMA and OHLC4 < slow EMA. Red: Bearish condition and OHLC4 < fast EMA. Long: Bullish condition persisting from the previous row. PreBuy: Bullish condition persisting from the previous row. Short: Bearish condition persisting from the previous row. PreSell: Bearish condition persisting from the previous row. GreenLine: True if the close price is above the trail2 level. Signal Generation:
Compares current and previous indicator states to generate buy and sell signals. Buys are triggered by:
Green buy: When green_last is False and green is True. Over ATR and blue: When greenLine is True and blue is True. Sells are triggered by:
Red sell: When red_last is False and red is True. Populating Buy and Sell Trends:
Sets the 'buy' column to 1 for rows where the buy signal is True. Sets the 'sell' column to 1 for rows where the sell signal is True. The strategy combines multiple indicators and conditions to generate buy and sell signals based on bullish and bearish market conditions and the movement of different price levels and averages.