Skip to content

feat: candlestick chart support CandleMarkerPainter#2032

Open
artshooter wants to merge 1 commit intoimaNNeo:mainfrom
artshooter:feat/support_CandleMarkerPainter
Open

feat: candlestick chart support CandleMarkerPainter#2032
artshooter wants to merge 1 commit intoimaNNeo:mainfrom
artshooter:feat/support_CandleMarkerPainter

Conversation

@artshooter
Copy link
Copy Markdown
Contributor

Hi, I've made improvements and refinements based on the feedback from the previous PR.


Feature Summary

This PR adds a candle marker system to CandlestickChart for marking trading signals on candlestick charts.


Key Features:

  • CandleMarkerPainter - Abstract base class for custom candle marker implementations
  • BuyAndSellSignalPainter - Built-in implementation with flexible condition-based signal detection,
    customizable bubble styles and labels to easily extend various trading signal scenarios

@SAGARSURI
Copy link
Copy Markdown

SAGARSURI commented Dec 2, 2025

Can I draw a line to show trade indicators? Something like this:

@artshooter
Copy link
Copy Markdown
Contributor Author

artshooter commented Jan 3, 2026

@SAGARSURI
Unfortunately, this PR implements buy/sell signal markers on individual candles, not horizontal lines across the chart. The screenshot shows an order line feature that displays price lines, position size, and P&L information. These are fundamentally different features, which are not currently supported.

/// [spotIndex] is the index of the spot in the candlestickSpots list.
///
/// Return true if you want to draw this marker on this spot, false otherwise.
bool shouldShow(CandlestickSpot spot, int spotIndex);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need it? I think we can have an empty paint() implementation to not show anything.
This way simplifies the implementation

}

/// Signal type enum for buy/sell markers.
enum BuyAndSellSignalType {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, we should prevent defining domain-specific models inside the fl_chart. And it's better to keep things generic.

So I suggest removing it (and adding it inside the candlestick_chart_sample1.dart if you want), and here we can rename the BuyAndSellSignalPainter() to CandleBalloonTextPainter(). This way, it feels like a generic implementation of balloon text, and you can use it to show buy/sell in your implementation.

And the logic of CandleBalloonTextPainter() will be way simpler, and the complexity goes into the candlestick_chart_sample1.dart where you want to show sell/buy points.

/// For example, buy/sell signal markers, important point markers, etc.
/// If null, no markers will be drawn.
/// You can use the built-in [BuySellSignalMarkerPainter] or implement your own.
final CandleMarkerPainter? candleMarkerPainter;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think if we allow users to have a list of CandleMarkerPainter?
This way, we can let the user compose different marker painters to render on top of each other.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants