Key Components:
- Indicators:
- ATR (Average True Range): Measures the degree of price volatility over a 14-period timeframe.
- Close Change: Absolute value of the difference between consecutive closing prices.
- Timeframe: Operates on 1-hour candlestick charts.
- Buy Conditions:
- Buy signals triggered when the absolute close change exceeds the ATR value in a candle.
- Both long and short positions are allowed.
- Sell Conditions:
- Sell signals generated when the opposite buy signal occurs (e.g., a sell signal for a long position).
- Custom Stake Amount: Initial entry stake is 50% of the proposed stake.
- Position Adjustment: Can adjust trade positions based on new signals and profit levels.
- Leverage: Uses a fixed leverage of 2.0 for futures trades.(You can change as per your requirement)
Strategy Logic:
- Calculates Indicators:
- ATR is calculated on a 3-minute resampled dataset.
- Close Change and Absolute Close Change are also derived.
- Generates Buy/Sell Signals:
- Buy signals are triggered when the absolute close change exceeds the ATR value in a candle.
- Sell signals are triggered when the opposite buy signal occurs.
- Determines Entry/Exit Trends:
- Populates ‘enter_long’ and ‘enter_short’ columns for buy signals.
- Populates ‘exit_long’ and ‘exit_short’ columns for sell signals.
- Custom Stake Amount:
- Halves the initial stake amount for a more conservative approach.
- Adjusts Trade Positions:
- Can potentially increase position size if a new signal arises and conditions are met.
- Sets Leverage:
- Employs a leverage of 2.0 for futures trades.
Here are the code examples for backtesting and hyperoptimizing the VolatilitySystem strategy, as well as important considerations:
Data Downloading:
Bash
#docker compose run --rm freqtrade download-data \
--config user_data/config.json \
--timerange 20190101-20240101 -t 5m
Backtesting:
Bash
#docker compose run --rm freqtrade backtesting \
--config user_data/config.json \
--strategy VolatilitySystem
Hyperoptimization:
Bash
#docker compose run --rm freqtrade hyperopt \
--hyperopt-loss SharpeHyperOptLossDaily \
--spaces roi stoploss trailing \
--strategy VolatilitySystem \
--config user_data/config.json -e 10
Key Points:
- Configuration File (
user_data/config.json
): Contains essential settings for Freqtrade, such as exchange credentials, pairs to trade, capital allocation, and risk management parameters. Ensure it’s configured correctly. - Docker Compose: Assuming Freqtrade is set up within a Docker container, these commands execute backtesting and hyperoptimization within that environment.
- Hyperoptimization: Explores different combinations of strategy parameters to potentially find more optimal settings. The example focuses on optimizing ROI (return on investment), stop-loss, and trailing stop-loss values.
Additional Considerations:
- Backtesting Analysis: Thoroughly analyze backtesting results to evaluate the strategy’s performance in various market conditions, assessing its potential profitability and risk profile.
- Hyperoptimization Results: Carefully review the optimized parameters after hyperoptimization to understand the potential improvements and trade-offs.
- Risk Management: Always prioritize robust risk management measures, such as stop-losses and position sizing, to protect your capital.
- Thorough Testing: Conduct extensive backtesting and hyperoptimization before deploying the strategy in live trading, considering different market phases and potential risks.
- Documentation: Refer to the Freqtrade documentation for detailed guidance on configuration, backtesting, hyperoptimization, and managing risks specific to your setup.
Remember:
- Backtesting with historical data is crucial to assess potential performance and identify weaknesses.
- Futures trading involves considerable risks, including leverage, which can amplify both profits and losses.
- Thorough research and a solid understanding of the risks are essential before deploying any strategy in live trading.