The YoyoActionStrategy is a trading strategy that uses several indicators to generate buy and sell signals. Here is a short description of what the strategy does:
Populates indicators: The strategy calculates various indicators such as OHLC4 (average of open, high, low, and close), exponential moving averages (fast and slow), relative strength index (RSI), MACD, and bullish/bearish indicators based on MACD values. It also calculates stop loss levels (sl1 and sl2) using the average true range (ATR).
Determines color states: The strategy determines color states for different conditions based on the calculated indicators.
It sets values for red, brown, yellow, blue, and green based on specific combinations of indicator values.
Trail stop loss: The strategy calculates a trailing stop loss level (trail2) based on the closing price and the previous trail2 value. The trail2 value is adjusted based on the relationship between the closing price and trail2. Sets long and short signals: The strategy determines long and short signals based on the bullish and bearish states, as well as their previous states. It sets values for long, preBuy, short, and preSell based on specific combinations of indicator values. Calculates greenLine: The strategy determines the greenLine state based on the closing price being above the trail2 value. Determines buy and sell signals: The strategy identifies buy signals when specific conditions are met, such as a transition from a non-green state to a green state or when the greenLine is above the ATR and the blue state is present. It identifies sell signals when there is a transition from a non-red state to a red state. Populates buy and sell trends: The strategy populates the buy and sell columns in the dataframe based on the identified buy and sell signals. Overall, the YoyoActionStrategy combines various indicators and color states to generate buy and sell signals for a trading strategy.