πŸ“˜Chapter 6: "Show and Tell! plot-dataframe Chart Visualization Tutorial"

This article was produced by the Quantitative Trading Lab at https://www.itrade.icu. Visit for more benefits.

During strategy development, backtesting results are often presented in tabular form, making it difficult to quickly identify issues. The plot-dataframe command can visualize buy/sell points, indicator lines, and price movements in charts, helping you instantly see strategy performance.


🎯 1. Basic Usage: Plotting Charts

freqtrade plot-dataframe \
  --config user_data/config.json \
  --strategy MyStrategy \
  --timerange 20230101-20230201

After execution, an .html file will be generated under user_data/plot/, which can be opened directly in a browser. It includes:

  • Candlestick price movements

  • Buy/Sell points (arrows)

  • Technical indicators (e.g., EMA, MACD)


🧾 2. Parameter Details

Parameter
Description

--config

Path to the config file, including trading pairs and timeframes

--strategy

Strategy class name (e.g., MyStrategy)

--timerange

Specify the plotting period, format like 20230101-20230201

--indicators1

Indicators plotted on the main chart (e.g., EMA, close)

--indicators2

Sub-chart indicators (e.g., RSI, MACD)

--exportfilename

Export file path (supports .html or .png)

--userdir

Custom user_data path (default is fine)


πŸ“ 3. Adding Custom Indicators

You can add extra indicators to the chart to validate signal logic:

Example code:

  • --indicators1 will be plotted on the main chart (price chart), e.g., EMA lines.

  • --indicators2 will be plotted on sub-charts, e.g., RSI, MACD.

Full example:

❗ Note:

These indicator names must match the column names in your strategy class’s populate_indicators() method (added to the DataFrame).

  • Names must exactly match your dataframe column names.

  • Otherwise, no error will occur, but the chart will not display the desired lines.

  • Indicators must be defined in populate_indicators() to take effect.


πŸ’Ύ 4. Export as HTML / PNG

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

To export as PNG (static image):

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


🐳 5. Running in Docker

Example command in Docker:

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


βœ… 6. Usage Suggestions

Purpose
Method

Check strategy logic

See if buy/sell points are at appropriate positions

Assist debugging

Compare indicators with signal relationships

Share strategy

Export chart as HTML for easy presentation

Evaluate indicator performance

Plot multiple indicators to check redundancy


πŸ“Œ Summary

plot-dataframe is a powerful visualization tool provided by Freqtrade, especially useful for debugging complex strategies and validating buy/sell logic.

  1. Backtest the strategy:

  1. Plot the chart:

  1. Analyze the chart:

  • Are strategy buys too early or too late?

  • Are there frequent false signals?

  • Are the indicators effective?

Mastering plot-dataframe provides a solid foundation for strategy optimization and more efficient tuning!

Last updated