The "AverageStrategy" is a simple proof-of-concept trading strategy implemented for backtesting purposes. It aims to generate buy and sell signals based on crossover events between two moving averages. Here's how the strategy works:
Indicators:
The strategy calculates two exponential moving averages (EMAs) using different time periods: a shorter EMA with a time period of 8 and a medium EMA with a time period of 21.
Buy Signal:
The buy signal is generated when the shorter EMA crosses above the medium EMA.
This crossover is detected using the "crossed_above" function from the "qtpylib" library.
When this crossover occurs, the strategy sets the "buy" column of the dataframe to 1, indicating a buy signal. Sell Signal:
The sell signal is generated when the medium EMA crosses above the shorter EMA. Again, the crossover is detected using the "crossed_above" function. When the crossover happens, the strategy sets the "sell" column of the dataframe to 1, indicating a sell signal. ROI and Stop Loss:
The strategy has a predefined minimal return on investment (ROI) of 0.5. This means that if a trade achieves a 0.5% ROI, it will be considered profitable. The stop loss is set at -0.2, indicating a 0.2% loss threshold. If the trade incurs a 0.2% loss, it will trigger a sell signal. Ticker Interval:
The strategy is designed to work with 4-hour (4h) ticker intervals. It's important to note that the strategy is described as not performing well and is primarily meant as a proof of concept.