DEV Community

Cover image for Article 6: Freqtrade - "Visualize Your Data with Charts! Plot-Dataframe Visualization Tutorial"
itrade icu
itrade icu

Posted on • Originally published at itrade.icu

Article 6: Freqtrade - "Visualize Your Data with Charts! Plot-Dataframe Visualization Tutorial"

πŸ“˜ Article 6: Freqtrade - "Visualize Your Data with Charts! Plot-Dataframe Visualization Tutorial"

During strategy development, backtest results are often presented in tabular form, making it hard to quickly identify issues. The plot-dataframe command visualizes buy/sell points, indicator lines, and price trends as charts, helping you instantly understand strategy performance.


πŸš€ Want to Learn Quantitative Trading?

πŸ‘‰ Visit: https://www.itrade.icu
Find Freqtrade Basics, Strategy Practices, Indicator Analysis, and more to help you master quantitative trading skills effortlessly!


🎯 1. Basic Usage: Generating Charts

freqtrade plot-dataframe \
  --config user_data/config.json \
  --strategy MyStrategy \
  --timerange 20230101-20230201
Enter fullscreen mode Exit fullscreen mode

This command generates an .html file in the user_data/plot/ directory, which you can open in a browser to view:

  • Candlestick price trends
  • Buy/Sell points (marked with arrows)
  • Technical indicators (e.g., EMA, MACD)

🧾 2. Parameter Breakdown

Parameter Description
--config Path to the configuration file (includes trading pairs, timeframes, etc.)
--strategy Strategy class name (e.g., MyStrategy)
--timerange Time range for the chart (e.g., 20230101-20230201)
--indicators1 Indicators for the main chart (e.g., EMA, close)
--indicators2 Indicators for the subplot (e.g., RSI, MACD)
--exportfilename Output file path (supports .html or .png)
--userdir Custom user_data directory (default is fine)

Example Image

πŸ“ 3. Adding Custom Indicators

You can include additional indicators in the chart to validate signal logic:

Code Example:

def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
    dataframe['ema'] = ta.EMA(dataframe['close'], timeperiod=20)
    dataframe['fast_ema'] = ta.EMA(dataframe['close'], timeperiod=10)
    dataframe['slow_ema'] = ta.EMA(dataframe['close'], timeperiod=50)
    dataframe['rsi'] = ta.RSI(dataframe['close'], timeperiod=14)
    macd, macdsignal, macdhist = ta.MACD(dataframe['close'])
    dataframe['macd'] = macd
    return dataframe
Enter fullscreen mode Exit fullscreen mode
  • --indicators1 plots on the main chart (price chart), e.g., EMA lines.
  • --indicators2 plots on the subplot, e.g., RSI, MACD.

Complete Example:

freqtrade plot-dataframe \
  --config user_data/config.json \
  --strategy MyStrategy \
  --timerange 20230101-20230201 \
  --indicators1 close ema fast_ema slow_ema \
  --indicators2 rsi macd
Enter fullscreen mode Exit fullscreen mode

❗ Note:

  • Indicator names must match the column names in the DataFrame created in the populate_indicators() method of your strategy.
  • Mismatched names won’t cause errors, but the indicators won’t appear on the chart.
  • Indicators must be defined in populate_indicators() to take effect.

πŸ’Ύ 4. Exporting to HTML / PNG

By default, the output is an HTML file. To specify:

--exportfilename user_data/plot/myplot.html
Enter fullscreen mode Exit fullscreen mode

To export as PNG (static image):

--exportfilename user_data/plot/myplot.png
Enter fullscreen mode Exit fullscreen mode

πŸ“Œ Note: Exporting to PNG requires additional tools like Puppeteer or headless Chrome. Beginners should stick to HTML format.

🐳 5. Running in a Docker Environment

To use the command in Docker:

docker compose run --rm freqtrade plot-dataframe \
  --config /quants/freqtrade/user_data/config.json \
  --strategy MyStrategy \
  --timerange 20230101-20230201
Enter fullscreen mode Exit fullscreen mode

Ensure the /quants/freqtrade/user_data directory is correctly mounted in docker-compose.yml.

βœ… 6. Usage Tips

Purpose Method
Verify strategy logic Check if buy/sell points are correctly positioned
Debugging Compare indicators with signal logic
Strategy sharing Export charts as HTML for easy presentation
Evaluate indicator performance Plot multiple indicators to check for redundancy

πŸ“Œ Summary

plot-dataframe is a powerful visualization tool in Freqtrade, ideal for debugging complex strategies and validating buy/sell logic.

Recommended Workflow:

  1. Run Backtest:
freqtrade backtesting \
  --config user_data/config.json \
  --strategy MyStrategy \
  --timeframe 15m \
  --timerange 20220101-20230101
Enter fullscreen mode Exit fullscreen mode
  1. Generate Chart:
freqtrade plot-dataframe \
  --config user_data/config.json \
  --strategy MyStrategy \
  --timerange 20250601-20250626
Enter fullscreen mode Exit fullscreen mode
  1. Analyze Chart:
  2. Are buy signals triggered too early or too late?
  3. Are there frequent false signals?
  4. Are the indicators effective?

Master plot-dataframe to optimize strategies efficiently with data-driven insights!

Top comments (0)