Skip to content

Creating Custom Weapons

Create your own trading strategies to use in ANGO DUNGEON.

Strategy Structure

Weapons are Python classes that inherit from Freqtrade's IStrategy interface. Here's a basic structure:

python
from freqtrade.strategy import IStrategy
from pandas import DataFrame
import talib.abstract as ta

class MyStrategy(IStrategy):
    # Strategy settings
    timeframe = '5m'

    # ROI table - when to take profits
    minimal_roi = {
        "0": 0.1,    # 10% profit anytime
        "30": 0.05,  # 5% after 30 minutes
        "60": 0.02,  # 2% after 60 minutes
    }

    # Stop loss
    stoploss = -0.10  # -10%

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """Add technical indicators to the dataframe"""
        dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
        dataframe['sma'] = ta.SMA(dataframe, timeperiod=20)
        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """Define buy conditions"""
        dataframe.loc[
            (dataframe['rsi'] < 30) &  # RSI oversold
            (dataframe['close'] > dataframe['sma']),  # Price above SMA
            'enter_long'
        ] = 1
        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """Define sell conditions"""
        dataframe.loc[
            (dataframe['rsi'] > 70),  # RSI overbought
            'exit_long'
        ] = 1
        return dataframe

Key Components

Timeframe

The candle timeframe for analysis:

python
timeframe = '5m'  # Options: 1m, 5m, 15m, 30m, 1h, 4h, 1d

ROI (Return on Investment)

Defines when to take profits based on time and profit percentage:

python
minimal_roi = {
    "0": 0.10,   # Take 10% profit immediately
    "30": 0.05,  # After 30 min, take 5%
    "60": 0.02,  # After 60 min, take 2%
    "120": 0     # After 120 min, take any profit
}

Stop Loss

Maximum loss before automatic exit:

python
stoploss = -0.10  # Exit if position drops 10%

Trailing Stop (Optional)

Dynamic stop loss that follows price:

python
trailing_stop = True
trailing_stop_positive = 0.02  # Activate when 2% in profit
trailing_stop_positive_offset = 0.03  # Keep 1% distance

Technical Indicators

Use TA-Lib for technical analysis:

python
# Moving Averages
dataframe['sma'] = ta.SMA(dataframe, timeperiod=20)
dataframe['ema'] = ta.EMA(dataframe, timeperiod=20)

# Momentum
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
dataframe['macd'] = ta.MACD(dataframe)['macd']

# Volatility
dataframe['bb_upper'] = ta.BBANDS(dataframe)['upperband']
dataframe['atr'] = ta.ATR(dataframe, timeperiod=14)

# Volume
dataframe['obv'] = ta.OBV(dataframe)

Uploading Your Weapon

  1. Go to WEAPONS page
  2. Click CREATE NEW WEAPON
  3. Upload your .py file
  4. Enter weapon details (name, type, description)
  5. Click CREATE

The file name must match the class name. For class MyStrategy, use MyStrategy.py.

Best Practices

Begin with 2-3 indicators. Add complexity only if needed.


Always backtest on multiple time periods before going live.


Always define a stop loss to limit potential losses.


Add comments explaining your strategy logic.

Common Mistakes

Overfitting: Optimizing too much for historical data leads to poor live performance.

No Stop Loss: Without a stop loss, a single bad trade can wipe out profits.

Too Many Indicators: More indicators don't always mean better results.

ANGO DUNGEON - Game-Style Crypto Trading Toolkit