The EMAAlarm strategy is a backtesting strategy that uses the Exponential Moving Average (EMA) indicator to generate trading signals. Here's a breakdown of what the strategy does:
Calculates the EMA50 (50-period Exponential Moving Average) for the given timeframe. Calculates the percentage distance between the low price and the EMA50 and stores it in the "distance_low_ema50" column.
Defines the "buy_criteria" as a combination of conditions:
The previous candle's close price is higher than the previous EMA50 value.
The "distance_low_ema50" is greater than 0 (positive).
The "distance_low_ema50" is less than or equal to 1. Populates the "buy" column in the dataframe with a value of 1 for rows that meet the "buy_criteria" conditions. Populates the "sell" column in the dataframe with a value of 1 for all rows. Additionally, the strategy has the following parameters:
"minimal_roi" is a dictionary specifying the minimum return on investment (ROI) required for the strategy to consider selling. In this case, a return of 10% or higher is needed. "stoploss" is set to -0.99, indicating a fixed stop-loss value of 99%. "timeframe" is set to '1h', representing the timeframe on which the strategy operates. This strategy aims to generate buy signals when the price is above the EMA50 and the distance between the low price and the EMA50 is within a specific range. It doesn't have a specific sell condition defined, so it will generate sell signals for all rows.