QTradingView 1.0.0
A high-performance charting library built with C++ and Qt.
Loading...
Searching...
No Matches
CandleStickSeries.h
1/*
2 * Copyright (c) 2025 Dhruvan Gnanadhandayuthapani
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23#ifndef QTRADINGVIEW_CANDLESTICKSERIES_H
24#define QTRADINGVIEW_CANDLESTICKSERIES_H
25
26#include <QColor>
27#include "QTradingView/Data.h"
28#include "QTradingView/series/Series.h"
29#include "QTradingView/qtradingview_global.h"
30
31namespace QTradingView {
32
38class QTRADINGVIEW_EXPORT CandleStickSeries : public Series
39{
40public:
45 explicit CandleStickSeries(const QList<CandleStick>& data);
50
55 void setData(const QList<CandleStick>& data = {});
60 const QList<CandleStick>& data() const;
66 qint64 timestampAt(int index) const override;
71 int dataCount() const override;
72
77 void setBullColor(const QColor& color);
82 void setBearColor(const QColor& color);
87 void setBorderColor(const QColor& color);
92 void setBorderWidth(double width);
97 void setBodyWithRatio(double ratio);
102 void setMaxBodyWidth(double maxWidth);
107 void setAntialiasing(bool enabled);
108
109 // Rendering
110 void render(QPainter* painter, const ViewPort& viewport, IScale* scale) override;
111 bool hitTest(const QPointF& point, int& outIndex) const override;
112 void calculateRange(int startIndex, int endIndex, double& outMin, double& outMax) const override;
113
114private:
115 QList<CandleStick> m_data;
116
117 QColor m_bullColor;
118 QColor m_bearColor;
119 QColor m_borderColor;
120 double m_borderWidth;
121 double m_bodyWidthRatio;
122 double m_maxBodyWidthPx;
123 bool m_antialiasing;
124};
125
126} // namespace QTradingView
127
128#endif // QTRADINGVIEW_CANDLESTICKSERIES_H
Represents a candlestick chart series in QTradingView.
Definition CandleStickSeries.h:39
~CandleStickSeries() override
Destroys the CandleStickSeries object.
Abstract base class for value-to-pixel scaling in QTradingView.
Definition IScale.h:37
Abstract base class for data series in QTradingView charts.
Definition Series.h:49
Manages the visible range and pixel mapping for chart bars.
Definition ViewPort.h:39