Skip to content
All library documents

Awesome Oscillator Zero Crosses Filtered by MACD Direction

Code Freqtrade

Summary

This strategy template combines the Awesome Oscillator (AO) with MACD on a one-hour timeframe. It enters a long position when MACD is above zero and AO crosses from negative to positive. It exits when MACD is below zero and AO crosses from positive to negative. ADX and the MACD signal and histogram are calculated, but they do not affect the entry or exit conditions shown.

The template also specifies a minimal return-on-investment target and a stop-loss, with a note that configuration can override the target. It supplies no backtest results, market selection, or explanation for the parameter choices. As presented, the rules cover long entries and exits only; the document does not describe short trades or position sizing. The indicator conditions are a concrete example of confirming an oscillator crossover with MACD direction, but their effectiveness remains untested in the document.

Key ideas

  • Long entries require MACD above zero and an AO cross above zero.
  • Long exits require MACD below zero and an AO cross below zero.
  • ADX and MACD signal and histogram values are calculated but unused in the rules.
  • The template states a one-hour timeframe, a return target, and a stop-loss, but provides no test results.

Tags

Full text
# AwesomeMacd.py


```py
# --- Do not remove these libs ---
from freqtrade.strategy import IStrategy
from pandas import DataFrame
import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib


# --------------------------------


class AwesomeMacd(IStrategy):
    """

    author@: Gert Wohlgemuth

    converted from:

    https://github.com/sthewissen/Mynt/blob/master/src/Mynt.Core/Strategies/AwesomeMacd.cs

    """

    INTERFACE_VERSION: int = 3
    # Minimal ROI designed for the strategy.
    # adjust based on market conditions. We would recommend to keep it low for quick turn arounds
    # This attribute will be overridden if the config file contains "minimal_roi"
    minimal_roi = {
        "0": 0.1
    }

    # Optimal stoploss designed for the strategy
    stoploss = -0.25

    # Optimal timeframe for the strategy
    timeframe = '1h'

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe['adx'] = ta.ADX(dataframe, timeperiod=14)
        dataframe['ao'] = qtpylib.awesome_oscillator(dataframe)

        macd = ta.MACD(dataframe)
        dataframe['macd'] = macd['macd']
        dataframe['macdsignal'] = macd['macdsignal']
        dataframe['macdhist'] = macd['macdhist']

        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (
                    (dataframe['macd'] > 0) &
                    (dataframe['ao'] > 0) &
                    (dataframe['ao'].shift() < 0)

            ),
            'enter_long'] = 1
        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (
                    (dataframe['macd'] < 0) &
                    (dataframe['ao'] < 0) &
                    (dataframe['ao'].shift() > 0)

            ),
            'exit_long'] = 1
        return dataframe

```

Shown in full with attribution under the source's licence. Licence: GPL-3.0

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.