Ind* CSV series API: load_csv/set_series/clear_series on all 250 indicators
Every Ind* widget recomputes its lines from a loaded OHLCV series: private recompute_lines() (moved out of the constructor), public set_series()/load_csv()/clear_series()/series() matching the Stock* chart widgets, same loader and CSV spec (StockData.h). Constructor defaults keep the seeded 250-bar template; failed loads leave the series untouched; clear_series() empties lines and draws clean. Params that were constructor-only (fast/slow/period/...) are now stored as members so a reloaded series uses the same settings. Tests: widgets/tests/ind_csv_harness.cpp + test_ind_csv.py — 250/250 harnesses build, 250/250 numeric PASS, 39/39 screenshots PASS, 250/250 demo mains build. Docs: docs/stock-market-csv-data.md Indicators section rewritten; all 250 cdoc pages updated (update-ind-csv.py).
This commit is contained in:
1 parent
3792410bfe
commit
90880928c9
253 files changed
+8899
-1060
No files matched your search
@@ -18,8 +18,9 @@ one-call way to use it.
|
|||||||
| OHLC / price charts (8) | StockCandlestickChart, StockOHLCBarChart, StockLineChart, StockAreaChart, StockHeikinAshi, StockRenko, StockHollowCandles, StockBaselineChart | `load_csv(path, error)` |
|
| OHLC / price charts (8) | StockCandlestickChart, StockOHLCBarChart, StockLineChart, StockAreaChart, StockHeikinAshi, StockRenko, StockHollowCandles, StockBaselineChart | `load_csv(path, error)` |
|
||||||
| Volume / flow indicators (7) | StockVolumeBars, StockVolumeCandles, StockVolumeProfile, StockAccumulationDistribution, StockMoneyFlowChart, StockOBVChart, StockVWAP | `load_csv(path, error)` |
|
| Volume / flow indicators (7) | StockVolumeBars, StockVolumeCandles, StockVolumeProfile, StockAccumulationDistribution, StockMoneyFlowChart, StockOBVChart, StockVWAP | `load_csv(path, error)` |
|
||||||
| Comparative plotting (8) | StockOverlayChart, StockMultiSymbolChart, StockIndexedComparison, StockRelativePerformance, StockRatioChart, StockSpreadChart, StockCorrelationView, StockSectorComparison | `add_series_csv(path, name, error)` |
|
| Comparative plotting (8) | StockOverlayChart, StockMultiSymbolChart, StockIndexedComparison, StockRelativePerformance, StockRatioChart, StockSpreadChart, StockCorrelationView, StockSectorComparison | `add_series_csv(path, name, error)` |
|
||||||
|
| Indicators (250) | All `Ind*` widgets (IndSMA, IndRSI, IndMACD, IndBollingerBands, …) | `load_csv(path, error)` — recomputes the indicator lines from the file |
|
||||||
|
|
||||||
Two groups are **not** covered, on purpose:
|
One group is **not** covered, on purpose:
|
||||||
|
|
||||||
- **Drawing / annotation tools (14)** — StockTrendline, StockFibRetracement,
|
- **Drawing / annotation tools (14)** — StockTrendline, StockFibRetracement,
|
||||||
StockFibExtension, StockPitchfork, StockParallelChannel, StockRectangle,
|
StockFibExtension, StockPitchfork, StockParallelChannel, StockRectangle,
|
||||||
@@ -30,12 +31,6 @@ Two groups are **not** covered, on purpose:
|
|||||||
(their `set_series`), which you can replace with
|
(their `set_series`), which you can replace with
|
||||||
`set_series(xframe::load_ohlcv_csv(path, err))`, but they have no
|
`set_series(xframe::load_ohlcv_csv(path, err))`, but they have no
|
||||||
`load_csv` of their own because there is no series to plot.
|
`load_csv` of their own because there is no series to plot.
|
||||||
- **The 250 `Ind*` indicator widgets** take a series only through their
|
|
||||||
constructor — they have no `set_series` at all. Pass a loaded series
|
|
||||||
there (see [Indicators](#indicators-constructor-only) below). Adding a
|
|
||||||
`set_series` to all 250 is a separate job: each one recomputes its own
|
|
||||||
lines from the series in its constructor, so there is no single generic
|
|
||||||
setter to add.
|
|
||||||
|
|
||||||
## The CSV format
|
## The CSV format
|
||||||
|
|
||||||
@@ -90,6 +85,11 @@ all reproducible, no network:
|
|||||||
`StockHeikinAshi` rebuilds its Heikin-Ashi candles and `StockRenko`
|
`StockHeikinAshi` rebuilds its Heikin-Ashi candles and `StockRenko`
|
||||||
rebuilds its bricks from whatever series is set; `StockBaselineChart`
|
rebuilds its bricks from whatever series is set; `StockBaselineChart`
|
||||||
resets its baseline to the first bar's close.
|
resets its baseline to the first bar's close.
|
||||||
|
- **Indicators (250):** constructor default
|
||||||
|
`xframe::make_seeded_series(250)` — 250 bars, same generator as the OHLC
|
||||||
|
group. Each widget recomputes its own lines from that series in the
|
||||||
|
constructor (see [Indicators](#indicators-load_csv--set_series) below);
|
||||||
|
loading a CSV replaces the series and recomputes the lines.
|
||||||
- **Comparative widgets (8):** the constructor seeds two or three named
|
- **Comparative widgets (8):** the constructor seeds two or three named
|
||||||
series — `SYM-A` (`make_seeded_series(60, 42)`), `SYM-B` (seed 7),
|
series — `SYM-A` (`make_seeded_series(60, 42)`), `SYM-B` (seed 7),
|
||||||
`SYM-C` (seed 99) — so the multi-line / comparison rendering is visible
|
`SYM-C` (seed 99) — so the multi-line / comparison rendering is visible
|
||||||
@@ -116,7 +116,8 @@ if (!w.load_csv("aapl_30d.csv", err)) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
`load_csv` is the same shape on all 15 single-series widgets
|
`load_csv` is the same shape on all 15 single-series widgets — and on
|
||||||
|
all 250 `Ind*` indicators (see [Indicators](#indicators-load_csv--set_series)):
|
||||||
(`StockCandlestickChart`, `StockOHLCBarChart`, `StockLineChart`,
|
(`StockCandlestickChart`, `StockOHLCBarChart`, `StockLineChart`,
|
||||||
`StockAreaChart`, `StockHeikinAshi`, `StockRenko`, `StockHollowCandles`,
|
`StockAreaChart`, `StockHeikinAshi`, `StockRenko`, `StockHollowCandles`,
|
||||||
`StockBaselineChart`, `StockVolumeBars`, `StockVolumeCandles`,
|
`StockBaselineChart`, `StockVolumeBars`, `StockVolumeCandles`,
|
||||||
@@ -184,22 +185,62 @@ candles for `StockHeikinAshi`, bricks for `StockRenko` (30 CSV bars build
|
|||||||
25 bricks at the default brick size), and the longest series length for
|
25 bricks at the default brick size), and the longest series length for
|
||||||
the comparative widgets.
|
the comparative widgets.
|
||||||
|
|
||||||
## Indicators (constructor only)
|
## Indicators (`load_csv` / `set_series`)
|
||||||
|
|
||||||
The 250 `Ind*` widgets have no `set_series`; give them the loaded series
|
All 250 `Ind*` widgets take CSV data the same way the single-series
|
||||||
at construction:
|
charts do — `load_csv`, `set_series`, `clear_series`, `series()` — with
|
||||||
|
one difference: an indicator does not plot the bars themselves, it plots
|
||||||
|
lines *computed from* the bars (SMA, RSI, Bollinger bands, …), so setting
|
||||||
|
a series recomputes those lines from the new bars.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
#include "IndSMA.h"
|
#include "IndSMA.h"
|
||||||
|
|
||||||
|
IndSMA w(display, screen, window, gc, &styles, 20, 20, 760, 520);
|
||||||
|
std::string err;
|
||||||
|
if (!w.load_csv("aapl_30d.csv", err)) {
|
||||||
|
std::fprintf(stderr, "cannot load CSV: %s\n", err.c_str());
|
||||||
|
// The old series is untouched: the widget keeps drawing what it had.
|
||||||
|
} else {
|
||||||
|
w.draw(); // now plots the SMA of the CSV closes; view resets
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
How it works, per widget:
|
||||||
|
|
||||||
|
- The constructor still computes the lines once, from the constructor
|
||||||
|
series (default: the seeded template, 250 bars). `set_series` stores
|
||||||
|
the new series, resets the view (`reset_view()`, where the widget has
|
||||||
|
one), and recomputes the lines with the widget's own formula and its
|
||||||
|
stored parameters (period, multiplier, fast/slow, …) — the parameters
|
||||||
|
that used to be constructor-only are now stored as members, so a
|
||||||
|
reloaded series uses the same settings the widget was built with.
|
||||||
|
- `load_csv` loads the file with `xframe::load_ohlcv_csv` and, on
|
||||||
|
success, calls `set_series`. On failure it returns `false` and leaves
|
||||||
|
the series — and the lines — unchanged.
|
||||||
|
- `clear_series()` empties the series (and the lines); the widget draws
|
||||||
|
its empty frame. The seeded template is only the constructor default —
|
||||||
|
`clear_series` does not restore it. To get the template back, call
|
||||||
|
`set_series(xframe::make_seeded_series(250))`.
|
||||||
|
- Passing a loaded series to the constructor still works, exactly as
|
||||||
|
before:
|
||||||
|
|
||||||
|
```cpp
|
||||||
std::string err;
|
std::string err;
|
||||||
auto series = xframe::load_ohlcv_csv("aapl_30d.csv", err);
|
auto series = xframe::load_ohlcv_csv("aapl_30d.csv", err);
|
||||||
IndSMA w(display, screen, window, gc, &styles, 20, 20, 760, 520, series);
|
IndSMA w(display, screen, window, gc, &styles, 20, 20, 760, 520, series);
|
||||||
w.draw();
|
w.draw();
|
||||||
```
|
```
|
||||||
|
|
||||||
The indicator is computed from the series in the constructor, so a series
|
Two things to know:
|
||||||
loaded from CSV plots exactly like the seeded template one — only the
|
|
||||||
values differ.
|
- **Line colours reset on recompute.** `set_line_color(i, c)` tints are
|
||||||
|
part of the rebuilt lines, so a `set_series` / `load_csv` restores the
|
||||||
|
widget's default line colours. Re-apply tints after loading if you
|
||||||
|
customised them.
|
||||||
|
- **Warm-up bars stay NaN.** A 30-row CSV into a period-20 indicator
|
||||||
|
leaves the first 19 line values NaN, exactly as the template series
|
||||||
|
does — only the values differ, never the shape of the computation.
|
||||||
|
|
||||||
## The designer's own CSV support (different thing)
|
## The designer's own CSV support (different thing)
|
||||||
|
|
||||||
@@ -249,3 +290,14 @@ nanoseconds), plus the plain `date,open,high,low,close,volume` layout.
|
|||||||
and checks the CSV shot is non-blank, differs from the template shot
|
and checks the CSV shot is non-blank, differs from the template shot
|
||||||
(the plot follows the file), reports 30 items, and that a missing file
|
(the plot follows the file), reports 30 items, and that a missing file
|
||||||
exits without touching the series. Result: **23/23 widgets PASS**.
|
exits without touching the series. Result: **23/23 widgets PASS**.
|
||||||
|
- `widgets/tests/ind_csv_harness.cpp` + `widgets/tests/test_ind_csv.py`
|
||||||
|
— the same treatment for all 250 `Ind*` indicators: per-widget harness
|
||||||
|
(template dump → `load_csv` 30-row fixture → `set_series` 1170-row
|
||||||
|
Massive fixture → failed load leaves the series untouched →
|
||||||
|
`clear_series` empties lines and draws clean) plus template-vs-CSV
|
||||||
|
screenshots for a 39-widget sample and a rebuild of all 250 demo
|
||||||
|
mains. Result: **250/250 harnesses build, 250/250 numeric PASS,
|
||||||
|
39/39 screenshots PASS, 250/250 demo mains build**. (One generator bug
|
||||||
|
found en route: a `signal` parameter colliding with a result-struct
|
||||||
|
field was rewritten to `result.signal_` in IndMACD — fixed, and the
|
||||||
|
generator now skips identifiers after `.` / `->`.)
|
||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_adx(series_, period_));
|
||||||
|
line_names_.push_back("ADX(14)");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndADX(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
IndADX(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_adx(series, period_));
|
|
||||||
line_names_.push_back("ADX(14)");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndADX() {}
|
~IndADX() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_adxr(series_, period_));
|
||||||
|
line_names_.push_back("ADXR(14)");
|
||||||
|
line_colors_.push_back(Srgb{120, 60, 180});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndADXR(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
IndADXR(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_adxr(series, period_));
|
|
||||||
line_names_.push_back("ADXR(14)");
|
|
||||||
line_colors_.push_back(Srgb{120, 60, 180});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndADXR() {}
|
~IndADXR() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -234,6 +234,19 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_alma(series_closes(series_), period_, offset_, sigma_));
|
||||||
|
line_names_.push_back("ALMA(9)");
|
||||||
|
line_colors_.push_back(Srgb{200, 30, 30});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndALMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 9, double offset = 0.85, double sigma = 6.0)
|
IndALMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 9, double offset = 0.85, double sigma = 6.0)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
@@ -241,12 +254,25 @@ public:
|
|||||||
period_ = period;
|
period_ = period;
|
||||||
offset_ = offset;
|
offset_ = offset;
|
||||||
sigma_ = sigma;
|
sigma_ = sigma;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_alma(series_closes(series), period_, offset_, sigma_));
|
|
||||||
line_names_.push_back("ALMA(9)");
|
|
||||||
line_colors_.push_back(Srgb{200, 30, 30});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndALMA() {}
|
~IndALMA() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -198,6 +198,24 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int fast_ = 12;
|
||||||
|
int slow_ = 26;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_apo(xframe::series_closes(series_), fast_, slow_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("APO");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndAPO(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndAPO(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int fast = 12, int slow = 26)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int fast = 12, int slow = 26)
|
||||||
@@ -214,13 +232,30 @@ public:
|
|||||||
name_ = "IndAPO";
|
name_ = "IndAPO";
|
||||||
text_ = "APO";
|
text_ = "APO";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_apo(xframe::series_closes(series), fast, slow);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("APO");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
fast_ = fast;
|
||||||
|
slow_ = slow;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndAPO() {}
|
~IndAPO() {}
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_atr(series_, period_);
|
||||||
|
lines_.push_back(Line{"ATR", Srgb{200, 120, 0}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndATR(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndATR(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -151,9 +160,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_atr(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"ATR", Srgb{200, 120, 0}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndATR() {}
|
~IndATR() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -204,6 +204,25 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int fast_ = 5;
|
||||||
|
int slow_ = 34;
|
||||||
|
int smooth_ = 5;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_accelerator_oscillator(series_, fast_, slow_, smooth_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("AcceleratorOscillator");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndAcceleratorOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndAcceleratorOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int fast = 5, int slow = 34, int smooth = 5)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int fast = 5, int slow = 34, int smooth = 5)
|
||||||
@@ -220,13 +239,31 @@ public:
|
|||||||
name_ = "IndAcceleratorOscillator";
|
name_ = "IndAcceleratorOscillator";
|
||||||
text_ = "AcceleratorOscillator";
|
text_ = "AcceleratorOscillator";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_accelerator_oscillator(series, fast, slow, smooth);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("AcceleratorOscillator");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
fast_ = fast;
|
||||||
|
slow_ = slow;
|
||||||
|
smooth_ = smooth;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndAcceleratorOscillator() {}
|
~IndAcceleratorOscillator() {}
|
||||||
|
|
||||||
|
|||||||
+29
-2
@@ -152,6 +152,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_accumulation_distribution_line(series_, period_);
|
||||||
|
lines_.push_back(Line{"ADL", Srgb{0, 150, 0}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndAccumulationDistributionLine(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndAccumulationDistributionLine(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -160,9 +169,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_accumulation_distribution_line(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"ADL", Srgb{0, 150, 0}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndAccumulationDistributionLine() {}
|
~IndAccumulationDistributionLine() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_accumulative_swing_index(series_, limitMove_));
|
||||||
|
line_names_.push_back("ASI(1)");
|
||||||
|
line_colors_.push_back(Srgb{230, 126, 34});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndAccumulativeSwingIndex(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), double limitMove = 1.0)
|
IndAccumulativeSwingIndex(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), double limitMove = 1.0)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
limitMove_ = limitMove;
|
limitMove_ = limitMove;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_accumulative_swing_index(series, limitMove_));
|
|
||||||
line_names_.push_back("ASI(1)");
|
|
||||||
line_colors_.push_back(Srgb{230, 126, 34});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndAccumulativeSwingIndex() {}
|
~IndAccumulativeSwingIndex() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -221,6 +221,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int dummy_ = 0;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_adaptive_cyber_cycle(xframe::series_closes(series_), dummy_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("AdaptiveCyberCycle");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndAdaptiveCyberCycle(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndAdaptiveCyberCycle(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int dummy = 0)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int dummy = 0)
|
||||||
@@ -237,13 +254,29 @@ public:
|
|||||||
name_ = "IndAdaptiveCyberCycle";
|
name_ = "IndAdaptiveCyberCycle";
|
||||||
text_ = "AdaptiveCyberCycle";
|
text_ = "AdaptiveCyberCycle";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_adaptive_cyber_cycle(xframe::series_closes(series), dummy);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("AdaptiveCyberCycle");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
dummy_ = dummy;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndAdaptiveCyberCycle() {}
|
~IndAdaptiveCyberCycle() {}
|
||||||
|
|
||||||
|
|||||||
@@ -222,6 +222,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 14;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_adaptive_rsi(xframe::series_closes(series_), period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("AdaptiveRSI");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndAdaptiveRSI(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndAdaptiveRSI(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
||||||
@@ -238,13 +255,29 @@ public:
|
|||||||
name_ = "IndAdaptiveRSI";
|
name_ = "IndAdaptiveRSI";
|
||||||
text_ = "AdaptiveRSI";
|
text_ = "AdaptiveRSI";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_adaptive_rsi(xframe::series_closes(series), period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("AdaptiveRSI");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndAdaptiveRSI() {}
|
~IndAdaptiveRSI() {}
|
||||||
|
|
||||||
|
|||||||
@@ -233,18 +233,44 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_alligator_jaw(series_closes(series_), period_, shift_));
|
||||||
|
line_names_.push_back("Jaw(13,8)");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndAlligatorJaw(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 13, int shift = 8)
|
IndAlligatorJaw(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 13, int shift = 8)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
shift_ = shift;
|
shift_ = shift;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_alligator_jaw(series_closes(series), period_, shift_));
|
|
||||||
line_names_.push_back("Jaw(13,8)");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndAlligatorJaw() {}
|
~IndAlligatorJaw() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -233,18 +233,44 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_alligator_lips(series_closes(series_), period_, shift_));
|
||||||
|
line_names_.push_back("Lips(5,3)");
|
||||||
|
line_colors_.push_back(Srgb{0, 150, 0});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndAlligatorLips(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 5, int shift = 3)
|
IndAlligatorLips(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 5, int shift = 3)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
shift_ = shift;
|
shift_ = shift;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_alligator_lips(series_closes(series), period_, shift_));
|
|
||||||
line_names_.push_back("Lips(5,3)");
|
|
||||||
line_colors_.push_back(Srgb{0, 150, 0});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndAlligatorLips() {}
|
~IndAlligatorLips() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -233,18 +233,44 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_alligator_teeth(series_closes(series_), period_, shift_));
|
||||||
|
line_names_.push_back("Teeth(8,5)");
|
||||||
|
line_colors_.push_back(Srgb{200, 30, 30});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndAlligatorTeeth(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 8, int shift = 5)
|
IndAlligatorTeeth(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 8, int shift = 5)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
shift_ = shift;
|
shift_ = shift;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_alligator_teeth(series_closes(series), period_, shift_));
|
|
||||||
line_names_.push_back("Teeth(8,5)");
|
|
||||||
line_colors_.push_back(Srgb{200, 30, 30});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndAlligatorTeeth() {}
|
~IndAlligatorTeeth() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -152,6 +152,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_anchored_vwap(series_, period_);
|
||||||
|
lines_.push_back(Line{"AnchoredVWAP", Srgb{200, 120, 0}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndAnchoredVWAP(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndAnchoredVWAP(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -160,9 +169,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_anchored_vwap(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"AnchoredVWAP", Srgb{200, 120, 0}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndAnchoredVWAP() {}
|
~IndAnchoredVWAP() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_aroon_down(series_, period_));
|
||||||
|
line_names_.push_back("AroonDown(14)");
|
||||||
|
line_colors_.push_back(Srgb{200, 30, 30});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndAroonDown(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
IndAroonDown(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_aroon_down(series, period_));
|
|
||||||
line_names_.push_back("AroonDown(14)");
|
|
||||||
line_colors_.push_back(Srgb{200, 30, 30});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndAroonDown() {}
|
~IndAroonDown() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_aroon_osc(series_, period_));
|
||||||
|
line_names_.push_back("AroonOsc(14)");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndAroonOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
IndAroonOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_aroon_osc(series, period_));
|
|
||||||
line_names_.push_back("AroonOsc(14)");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndAroonOscillator() {}
|
~IndAroonOscillator() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_aroon_up(series_, period_));
|
||||||
|
line_names_.push_back("AroonUp(14)");
|
||||||
|
line_colors_.push_back(Srgb{0, 150, 0});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndAroonUp(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
IndAroonUp(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_aroon_up(series, period_));
|
|
||||||
line_names_.push_back("AroonUp(14)");
|
|
||||||
line_colors_.push_back(Srgb{0, 150, 0});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndAroonUp() {}
|
~IndAroonUp() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -156,6 +156,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_autocorrelation(series_, period_);
|
||||||
|
lines_.push_back(Line{"Autocorr", Srgb{0, 100, 200}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndAutocorrelation(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndAutocorrelation(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -164,9 +173,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_autocorrelation(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"Autocorr", Srgb{0, 100, 200}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndAutocorrelation() {}
|
~IndAutocorrelation() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -201,6 +201,24 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int fast_ = 5;
|
||||||
|
int slow_ = 34;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_awesome_oscillator(series_, fast_, slow_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("AwesomeOscillator");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndAwesomeOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndAwesomeOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int fast = 5, int slow = 34)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int fast = 5, int slow = 34)
|
||||||
@@ -217,13 +235,30 @@ public:
|
|||||||
name_ = "IndAwesomeOscillator";
|
name_ = "IndAwesomeOscillator";
|
||||||
text_ = "AwesomeOscillator";
|
text_ = "AwesomeOscillator";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_awesome_oscillator(series, fast, slow);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("AwesomeOscillator");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
fast_ = fast;
|
||||||
|
slow_ = slow;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndAwesomeOscillator() {}
|
~IndAwesomeOscillator() {}
|
||||||
|
|
||||||
|
|||||||
@@ -198,6 +198,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 14;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_balance_of_power(series_, period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("BalanceOfPower");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndBalanceOfPower(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndBalanceOfPower(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
||||||
@@ -214,13 +231,29 @@ public:
|
|||||||
name_ = "IndBalanceOfPower";
|
name_ = "IndBalanceOfPower";
|
||||||
text_ = "BalanceOfPower";
|
text_ = "BalanceOfPower";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_balance_of_power(series, period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("BalanceOfPower");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndBalanceOfPower() {}
|
~IndBalanceOfPower() {}
|
||||||
|
|
||||||
|
|||||||
@@ -199,6 +199,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 13;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_bear_power(series_, period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("BearPower");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndBearPower(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndBearPower(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 13)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 13)
|
||||||
@@ -215,13 +232,29 @@ public:
|
|||||||
name_ = "IndBearPower";
|
name_ = "IndBearPower";
|
||||||
text_ = "BearPower";
|
text_ = "BearPower";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_bear_power(series, period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("BearPower");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndBearPower() {}
|
~IndBearPower() {}
|
||||||
|
|
||||||
|
|||||||
@@ -155,6 +155,17 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_bollinger_bands(series_, period_, mult_);
|
||||||
|
lines_.push_back(Line{"Upper", Srgb{200, 30, 30}, result.upper});
|
||||||
|
lines_.push_back(Line{"Middle", Srgb{0, 100, 200}, result.middle});
|
||||||
|
lines_.push_back(Line{"Lower", Srgb{200, 30, 30}, result.lower});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndBollingerBands(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndBollingerBands(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -163,11 +174,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_bollinger_bands(series, period, mult);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"Upper", Srgb{200, 30, 30}, result.upper});
|
|
||||||
lines_.push_back(Line{"Middle", Srgb{0, 100, 200}, result.middle});
|
|
||||||
lines_.push_back(Line{"Lower", Srgb{200, 30, 30}, result.lower});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndBollingerBands() {}
|
~IndBollingerBands() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -149,6 +149,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_bollinger_bandwidth(series_, period_, mult_);
|
||||||
|
lines_.push_back(Line{"Bandwidth", Srgb{0, 100, 200}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndBollingerBandwidth(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndBollingerBandwidth(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -157,9 +166,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_bollinger_bandwidth(series, period, mult);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"Bandwidth", Srgb{0, 100, 200}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndBollingerBandwidth() {}
|
~IndBollingerBandwidth() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -152,6 +152,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_bollinger_percent_b(series_, period_, mult_);
|
||||||
|
lines_.push_back(Line{"%B", Srgb{0, 100, 200}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndBollingerPercentB(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndBollingerPercentB(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -160,9 +169,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_bollinger_percent_b(series, period, mult);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"%B", Srgb{0, 100, 200}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndBollingerPercentB() {}
|
~IndBollingerPercentB() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -199,6 +199,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 13;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_bull_power(series_, period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("BullPower");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndBullPower(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndBullPower(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 13)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 13)
|
||||||
@@ -215,13 +232,29 @@ public:
|
|||||||
name_ = "IndBullPower";
|
name_ = "IndBullPower";
|
||||||
text_ = "BullPower";
|
text_ = "BullPower";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_bull_power(series, period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("BullPower");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndBullPower() {}
|
~IndBullPower() {}
|
||||||
|
|
||||||
|
|||||||
@@ -208,6 +208,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 20;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_cci(series_, period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("CCI");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndCCI(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndCCI(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 20)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 20)
|
||||||
@@ -224,13 +241,29 @@ public:
|
|||||||
name_ = "IndCCI";
|
name_ = "IndCCI";
|
||||||
text_ = "CCI";
|
text_ = "CCI";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_cci(series, period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("CCI");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndCCI() {}
|
~IndCCI() {}
|
||||||
|
|
||||||
|
|||||||
@@ -156,6 +156,17 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_camarilla_pivot_points(series_, period_);
|
||||||
|
lines_.push_back(Line{"Pivot", Srgb{0, 100, 200}, result.pivot});
|
||||||
|
lines_.push_back(Line{"R1", Srgb{200, 30, 30}, result.r1});
|
||||||
|
lines_.push_back(Line{"S1", Srgb{0, 150, 0}, result.s1});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndCamarillaPivotPoints(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndCamarillaPivotPoints(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -164,11 +175,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_camarilla_pivot_points(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"Pivot", Srgb{0, 100, 200}, result.pivot});
|
|
||||||
lines_.push_back(Line{"R1", Srgb{200, 30, 30}, result.r1});
|
|
||||||
lines_.push_back(Line{"S1", Srgb{0, 150, 0}, result.s1});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndCamarillaPivotPoints() {}
|
~IndCamarillaPivotPoints() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -205,6 +205,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 10;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_center_of_gravity(xframe::series_closes(series_), period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("CenterOfGravity");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndCenterOfGravity(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndCenterOfGravity(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10)
|
||||||
@@ -221,13 +238,29 @@ public:
|
|||||||
name_ = "IndCenterOfGravity";
|
name_ = "IndCenterOfGravity";
|
||||||
text_ = "CenterOfGravity";
|
text_ = "CenterOfGravity";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_center_of_gravity(xframe::series_closes(series), period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("CenterOfGravity");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndCenterOfGravity() {}
|
~IndCenterOfGravity() {}
|
||||||
|
|
||||||
|
|||||||
@@ -153,6 +153,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_chaikin_money_flow(series_, period_);
|
||||||
|
lines_.push_back(Line{"CMF", Srgb{0, 150, 0}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndChaikinMoneyFlow(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndChaikinMoneyFlow(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -161,9 +170,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_chaikin_money_flow(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"CMF", Srgb{0, 150, 0}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndChaikinMoneyFlow() {}
|
~IndChaikinMoneyFlow() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -155,6 +155,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_chaikin_oscillator(series_, period_);
|
||||||
|
lines_.push_back(Line{"ChaikinOsc", Srgb{0, 150, 0}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndChaikinOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndChaikinOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -163,9 +172,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_chaikin_oscillator(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"ChaikinOsc", Srgb{0, 150, 0}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndChaikinOscillator() {}
|
~IndChaikinOscillator() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -150,6 +150,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_chaikin_volatility(series_, period_);
|
||||||
|
lines_.push_back(Line{"ChaikinVol", Srgb{150, 0, 150}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndChaikinVolatility(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndChaikinVolatility(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -158,9 +167,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_chaikin_volatility(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"ChaikinVol", Srgb{150, 0, 150}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndChaikinVolatility() {}
|
~IndChaikinVolatility() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -200,6 +200,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 5;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_chande_forecast_oscillator(xframe::series_closes(series_), period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("ChandeForecastOscillator");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndChandeForecastOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndChandeForecastOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 5)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 5)
|
||||||
@@ -216,13 +233,29 @@ public:
|
|||||||
name_ = "IndChandeForecastOscillator";
|
name_ = "IndChandeForecastOscillator";
|
||||||
text_ = "ChandeForecastOscillator";
|
text_ = "ChandeForecastOscillator";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_chande_forecast_oscillator(xframe::series_closes(series), period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("ChandeForecastOscillator");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndChandeForecastOscillator() {}
|
~IndChandeForecastOscillator() {}
|
||||||
|
|
||||||
|
|||||||
@@ -233,18 +233,44 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_chande_kroll_stop(series_, period_, mult_));
|
||||||
|
line_names_.push_back("ChandeKrollStop(10,1)");
|
||||||
|
line_colors_.push_back(Srgb{230, 126, 34});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndChandeKrollStop(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10, double mult = 1.0)
|
IndChandeKrollStop(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10, double mult = 1.0)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
mult_ = mult;
|
mult_ = mult;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_chande_kroll_stop(series, period_, mult_));
|
|
||||||
line_names_.push_back("ChandeKrollStop(10,1)");
|
|
||||||
line_colors_.push_back(Srgb{230, 126, 34});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndChandeKrollStop() {}
|
~IndChandeKrollStop() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -204,6 +204,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 20;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_chande_momentum_oscillator(xframe::series_closes(series_), period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("ChandeMomentumOscillator");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndChandeMomentumOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndChandeMomentumOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 20)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 20)
|
||||||
@@ -220,13 +237,29 @@ public:
|
|||||||
name_ = "IndChandeMomentumOscillator";
|
name_ = "IndChandeMomentumOscillator";
|
||||||
text_ = "ChandeMomentumOscillator";
|
text_ = "ChandeMomentumOscillator";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_chande_momentum_oscillator(xframe::series_closes(series), period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("ChandeMomentumOscillator");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndChandeMomentumOscillator() {}
|
~IndChandeMomentumOscillator() {}
|
||||||
|
|
||||||
|
|||||||
@@ -155,6 +155,16 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_chandelier_exit(series_, period_, mult_);
|
||||||
|
lines_.push_back(Line{"Long Exit", Srgb{0, 150, 0}, result.long_exit});
|
||||||
|
lines_.push_back(Line{"Short Exit", Srgb{200, 30, 30}, result.short_exit});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndChandelierExit(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndChandelierExit(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -163,10 +173,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_chandelier_exit(series, period, mult);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"Long Exit", Srgb{0, 150, 0}, result.long_exit});
|
|
||||||
lines_.push_back(Line{"Short Exit", Srgb{200, 30, 30}, result.short_exit});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndChandelierExit() {}
|
~IndChandelierExit() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -233,18 +233,44 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_chandelier_long(series_, period_, mult_));
|
||||||
|
line_names_.push_back("ChandelierLong(22,3)");
|
||||||
|
line_colors_.push_back(Srgb{200, 30, 30});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndChandelierExitLong(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 22, double mult = 3.0)
|
IndChandelierExitLong(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 22, double mult = 3.0)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
mult_ = mult;
|
mult_ = mult;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_chandelier_long(series, period_, mult_));
|
|
||||||
line_names_.push_back("ChandelierLong(22,3)");
|
|
||||||
line_colors_.push_back(Srgb{200, 30, 30});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndChandelierExitLong() {}
|
~IndChandelierExitLong() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -233,18 +233,44 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_chandelier_short(series_, period_, mult_));
|
||||||
|
line_names_.push_back("ChandelierShort(22,3)");
|
||||||
|
line_colors_.push_back(Srgb{0, 150, 0});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndChandelierExitShort(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 22, double mult = 3.0)
|
IndChandelierExitShort(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 22, double mult = 3.0)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
mult_ = mult;
|
mult_ = mult;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_chandelier_short(series, period_, mult_));
|
|
||||||
line_names_.push_back("ChandelierShort(22,3)");
|
|
||||||
line_colors_.push_back(Srgb{0, 150, 0});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndChandelierExitShort() {}
|
~IndChandelierExitShort() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_chikou_span(series_closes(series_), period_));
|
||||||
|
line_names_.push_back("ChikouSpan(26)");
|
||||||
|
line_colors_.push_back(Srgb{120, 60, 180});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndChikouSpan(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 26)
|
IndChikouSpan(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 26)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_chikou_span(series_closes(series), period_));
|
|
||||||
line_names_.push_back("ChikouSpan(26)");
|
|
||||||
line_colors_.push_back(Srgb{120, 60, 180});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndChikouSpan() {}
|
~IndChikouSpan() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -210,6 +210,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 14;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_choppiness_index(series_, period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("ChoppinessIndex");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndChoppinessIndex(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndChoppinessIndex(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
||||||
@@ -226,13 +243,29 @@ public:
|
|||||||
name_ = "IndChoppinessIndex";
|
name_ = "IndChoppinessIndex";
|
||||||
text_ = "ChoppinessIndex";
|
text_ = "ChoppinessIndex";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_choppiness_index(series, period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("ChoppinessIndex");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndChoppinessIndex() {}
|
~IndChoppinessIndex() {}
|
||||||
|
|
||||||
|
|||||||
@@ -148,6 +148,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_close_volatility(series_, period_);
|
||||||
|
lines_.push_back(Line{"CloseVol", Srgb{150, 0, 150}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndCloseVolatility(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndCloseVolatility(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -156,9 +165,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_close_volatility(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"CloseVol", Srgb{150, 0, 150}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndCloseVolatility() {}
|
~IndCloseVolatility() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -215,6 +215,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 3;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_connors_rsi(series_, period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("ConnorsRSI");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndConnorsRSI(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndConnorsRSI(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 3)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 3)
|
||||||
@@ -231,13 +248,29 @@ public:
|
|||||||
name_ = "IndConnorsRSI";
|
name_ = "IndConnorsRSI";
|
||||||
text_ = "ConnorsRSI";
|
text_ = "ConnorsRSI";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_connors_rsi(series, period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("ConnorsRSI");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndConnorsRSI() {}
|
~IndConnorsRSI() {}
|
||||||
|
|
||||||
|
|||||||
@@ -210,6 +210,25 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int roc1_ = 14;
|
||||||
|
int roc2_ = 11;
|
||||||
|
int wma_ = 10;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_coppock_curve(xframe::series_closes(series_), roc1_, roc2_, wma_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("CoppockCurve");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndCoppockCurve(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndCoppockCurve(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int roc1 = 14, int roc2 = 11, int wma = 10)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int roc1 = 14, int roc2 = 11, int wma = 10)
|
||||||
@@ -226,13 +245,31 @@ public:
|
|||||||
name_ = "IndCoppockCurve";
|
name_ = "IndCoppockCurve";
|
||||||
text_ = "CoppockCurve";
|
text_ = "CoppockCurve";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_coppock_curve(xframe::series_closes(series), roc1, roc2, wma);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("CoppockCurve");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
roc1_ = roc1;
|
||||||
|
roc2_ = roc2;
|
||||||
|
wma_ = wma;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndCoppockCurve() {}
|
~IndCoppockCurve() {}
|
||||||
|
|
||||||
|
|||||||
@@ -158,6 +158,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_correlation(series_, period_);
|
||||||
|
lines_.push_back(Line{"Correlation", Srgb{0, 100, 200}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndCorrelation(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndCorrelation(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -166,9 +175,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_correlation(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"Correlation", Srgb{0, 100, 200}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndCorrelation() {}
|
~IndCorrelation() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -207,6 +207,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 14;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_correlation_coefficient(xframe::series_closes(series_), period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("CorrelationCoefficient");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndCorrelationCoefficient(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndCorrelationCoefficient(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
||||||
@@ -223,13 +240,29 @@ public:
|
|||||||
name_ = "IndCorrelationCoefficient";
|
name_ = "IndCorrelationCoefficient";
|
||||||
text_ = "CorrelationCoefficient";
|
text_ = "CorrelationCoefficient";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_correlation_coefficient(xframe::series_closes(series), period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("CorrelationCoefficient");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndCorrelationCoefficient() {}
|
~IndCorrelationCoefficient() {}
|
||||||
|
|
||||||
|
|||||||
@@ -154,6 +154,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_covariance(series_, period_);
|
||||||
|
lines_.push_back(Line{"Covariance", Srgb{0, 100, 200}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndCovariance(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndCovariance(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -162,9 +171,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_covariance(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"Covariance", Srgb{0, 100, 200}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndCovariance() {}
|
~IndCovariance() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -152,6 +152,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_cumulative_volume_delta(series_, period_);
|
||||||
|
lines_.push_back(Line{"CumVolDelta", Srgb{0, 150, 0}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndCumulativeVolumeDelta(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndCumulativeVolumeDelta(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -160,9 +169,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_cumulative_volume_delta(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"CumVolDelta", Srgb{0, 150, 0}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndCumulativeVolumeDelta() {}
|
~IndCumulativeVolumeDelta() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -206,6 +206,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 14;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_cutler_rsi(xframe::series_closes(series_), period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("CutlerRSI");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndCutlerRSI(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndCutlerRSI(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
||||||
@@ -222,13 +239,29 @@ public:
|
|||||||
name_ = "IndCutlerRSI";
|
name_ = "IndCutlerRSI";
|
||||||
text_ = "CutlerRSI";
|
text_ = "CutlerRSI";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_cutler_rsi(xframe::series_closes(series), period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("CutlerRSI");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndCutlerRSI() {}
|
~IndCutlerRSI() {}
|
||||||
|
|
||||||
|
|||||||
@@ -207,6 +207,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int dummy_ = 0;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_cyber_cycle(xframe::series_closes(series_), dummy_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("CyberCycle");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndCyberCycle(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndCyberCycle(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int dummy = 0)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int dummy = 0)
|
||||||
@@ -223,13 +240,29 @@ public:
|
|||||||
name_ = "IndCyberCycle";
|
name_ = "IndCyberCycle";
|
||||||
text_ = "CyberCycle";
|
text_ = "CyberCycle";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_cyber_cycle(xframe::series_closes(series), dummy);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("CyberCycle");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
dummy_ = dummy;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndCyberCycle() {}
|
~IndCyberCycle() {}
|
||||||
|
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_dema(series_closes(series_), period_));
|
||||||
|
line_names_.push_back("DEMA(14)");
|
||||||
|
line_colors_.push_back(Srgb{230, 126, 34});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndDEMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
IndDEMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_dema(series_closes(series), period_));
|
|
||||||
line_names_.push_back("DEMA(14)");
|
|
||||||
line_colors_.push_back(Srgb{230, 126, 34});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndDEMA() {}
|
~IndDEMA() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_dpo(series_closes(series_), period_));
|
||||||
|
line_names_.push_back("DPO(20)");
|
||||||
|
line_colors_.push_back(Srgb{230, 126, 34});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndDPO(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 20)
|
IndDPO(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 20)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_dpo(series_closes(series), period_));
|
|
||||||
line_names_.push_back("DPO(20)");
|
|
||||||
line_colors_.push_back(Srgb{230, 126, 34});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndDPO() {}
|
~IndDPO() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -197,6 +197,24 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 10;
|
||||||
|
int smooth_ = 3;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_dss(series_, period_, smooth_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("DSS");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndDSS(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndDSS(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10, int smooth = 3)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10, int smooth = 3)
|
||||||
@@ -213,13 +231,30 @@ public:
|
|||||||
name_ = "IndDSS";
|
name_ = "IndDSS";
|
||||||
text_ = "DSS";
|
text_ = "DSS";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_dss(series, period, smooth);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("DSS");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
smooth_ = smooth;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndDSS() {}
|
~IndDSS() {}
|
||||||
|
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_dx(series_, period_));
|
||||||
|
line_names_.push_back("DX(14)");
|
||||||
|
line_colors_.push_back(Srgb{230, 126, 34});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndDX(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
IndDX(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_dx(series, period_));
|
|
||||||
line_names_.push_back("DX(14)");
|
|
||||||
line_colors_.push_back(Srgb{230, 126, 34});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndDX() {}
|
~IndDX() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -209,6 +209,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 14;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_demarker(series_, period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("DeMarker");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndDeMarker(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndDeMarker(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
||||||
@@ -225,13 +242,29 @@ public:
|
|||||||
name_ = "IndDeMarker";
|
name_ = "IndDeMarker";
|
||||||
text_ = "DeMarker";
|
text_ = "DeMarker";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_demarker(series, period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("DeMarker");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndDeMarker() {}
|
~IndDeMarker() {}
|
||||||
|
|
||||||
|
|||||||
@@ -202,6 +202,23 @@ private:
|
|||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
Srgb overlay_candle_color_ = Srgb{180, 180, 180};
|
Srgb overlay_candle_color_ = Srgb{180, 180, 180};
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 10;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_decycler(xframe::series_closes(series_), period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("Decycler");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndDecycler(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndDecycler(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10)
|
||||||
@@ -218,13 +235,29 @@ public:
|
|||||||
name_ = "IndDecycler";
|
name_ = "IndDecycler";
|
||||||
text_ = "Decycler";
|
text_ = "Decycler";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_decycler(xframe::series_closes(series), period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("Decycler");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndDecycler() {}
|
~IndDecycler() {}
|
||||||
|
|
||||||
|
|||||||
@@ -156,6 +156,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_demand_index(series_, period_);
|
||||||
|
lines_.push_back(Line{"DemandIndex", Srgb{0, 100, 200}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndDemandIndex(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndDemandIndex(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -164,9 +173,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_demand_index(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"DemandIndex", Srgb{0, 100, 200}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndDemandIndex() {}
|
~IndDemandIndex() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -202,6 +202,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 20;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_detrended_price_oscillator(xframe::series_closes(series_), period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("DetrendedPriceOscillator");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndDetrendedPriceOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndDetrendedPriceOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 20)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 20)
|
||||||
@@ -218,13 +235,29 @@ public:
|
|||||||
name_ = "IndDetrendedPriceOscillator";
|
name_ = "IndDetrendedPriceOscillator";
|
||||||
text_ = "DetrendedPriceOscillator";
|
text_ = "DetrendedPriceOscillator";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_detrended_price_oscillator(xframe::series_closes(series), period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("DetrendedPriceOscillator");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndDetrendedPriceOscillator() {}
|
~IndDetrendedPriceOscillator() {}
|
||||||
|
|
||||||
|
|||||||
@@ -198,6 +198,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 20;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_disparity_index(xframe::series_closes(series_), period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("DisparityIndex");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndDisparityIndex(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndDisparityIndex(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 20)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 20)
|
||||||
@@ -214,13 +231,29 @@ public:
|
|||||||
name_ = "IndDisparityIndex";
|
name_ = "IndDisparityIndex";
|
||||||
text_ = "DisparityIndex";
|
text_ = "DisparityIndex";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_disparity_index(xframe::series_closes(series), period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("DisparityIndex");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndDisparityIndex() {}
|
~IndDisparityIndex() {}
|
||||||
|
|
||||||
|
|||||||
@@ -214,6 +214,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int dummy_ = 0;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_dominant_cycle(xframe::series_closes(series_), dummy_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("DominantCycle");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndDominantCycle(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndDominantCycle(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int dummy = 0)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int dummy = 0)
|
||||||
@@ -230,13 +247,29 @@ public:
|
|||||||
name_ = "IndDominantCycle";
|
name_ = "IndDominantCycle";
|
||||||
text_ = "DominantCycle";
|
text_ = "DominantCycle";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_dominant_cycle(xframe::series_closes(series), dummy);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("DominantCycle");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
dummy_ = dummy;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndDominantCycle() {}
|
~IndDominantCycle() {}
|
||||||
|
|
||||||
|
|||||||
@@ -157,6 +157,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_dominant_cycle_period(series_, period_);
|
||||||
|
lines_.push_back(Line{"CyclePeriod", Srgb{150, 0, 150}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndDominantCyclePeriod(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndDominantCyclePeriod(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -165,9 +174,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_dominant_cycle_period(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"CyclePeriod", Srgb{150, 0, 150}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndDominantCyclePeriod() {}
|
~IndDominantCyclePeriod() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -154,6 +154,17 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_donchian_channels(series_, period_);
|
||||||
|
lines_.push_back(Line{"Upper", Srgb{200, 30, 30}, result.upper});
|
||||||
|
lines_.push_back(Line{"Middle", Srgb{0, 100, 200}, result.middle});
|
||||||
|
lines_.push_back(Line{"Lower", Srgb{200, 30, 30}, result.lower});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndDonchianChannels(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndDonchianChannels(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -162,11 +173,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_donchian_channels(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"Upper", Srgb{200, 30, 30}, result.upper});
|
|
||||||
lines_.push_back(Line{"Middle", Srgb{0, 100, 200}, result.middle});
|
|
||||||
lines_.push_back(Line{"Lower", Srgb{200, 30, 30}, result.lower});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndDonchianChannels() {}
|
~IndDonchianChannels() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_donchian_lower(series_, period_));
|
||||||
|
line_names_.push_back("DonchianLower(20)");
|
||||||
|
line_colors_.push_back(Srgb{200, 30, 30});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndDonchianLower(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 20)
|
IndDonchianLower(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 20)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_donchian_lower(series, period_));
|
|
||||||
line_names_.push_back("DonchianLower(20)");
|
|
||||||
line_colors_.push_back(Srgb{200, 30, 30});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndDonchianLower() {}
|
~IndDonchianLower() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_donchian_middle(series_, period_));
|
||||||
|
line_names_.push_back("DonchianMiddle(20)");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndDonchianMiddle(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 20)
|
IndDonchianMiddle(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 20)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_donchian_middle(series, period_));
|
|
||||||
line_names_.push_back("DonchianMiddle(20)");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndDonchianMiddle() {}
|
~IndDonchianMiddle() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_donchian_upper(series_, period_));
|
||||||
|
line_names_.push_back("DonchianUpper(20)");
|
||||||
|
line_colors_.push_back(Srgb{0, 150, 0});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndDonchianUpper(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 20)
|
IndDonchianUpper(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 20)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_donchian_upper(series, period_));
|
|
||||||
line_names_.push_back("DonchianUpper(20)");
|
|
||||||
line_colors_.push_back(Srgb{0, 150, 0});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndDonchianUpper() {}
|
~IndDonchianUpper() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -199,6 +199,25 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 14;
|
||||||
|
int short_period_ = 5;
|
||||||
|
int smooth_ = 3;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_double_stochastic(series_, period_, short_period_, smooth_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("DoubleStochastic");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndDoubleStochastic(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndDoubleStochastic(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14, int short_period = 5, int smooth = 3)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14, int short_period = 5, int smooth = 3)
|
||||||
@@ -215,13 +234,31 @@ public:
|
|||||||
name_ = "IndDoubleStochastic";
|
name_ = "IndDoubleStochastic";
|
||||||
text_ = "DoubleStochastic";
|
text_ = "DoubleStochastic";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_double_stochastic(series, period, short_period, smooth);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("DoubleStochastic");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
short_period_ = short_period;
|
||||||
|
smooth_ = smooth;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndDoubleStochastic() {}
|
~IndDoubleStochastic() {}
|
||||||
|
|
||||||
|
|||||||
@@ -219,6 +219,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 14;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_dynamic_momentum_index(xframe::series_closes(series_), period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("DynamicMomentumIndex");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndDynamicMomentumIndex(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndDynamicMomentumIndex(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
||||||
@@ -235,13 +252,29 @@ public:
|
|||||||
name_ = "IndDynamicMomentumIndex";
|
name_ = "IndDynamicMomentumIndex";
|
||||||
text_ = "DynamicMomentumIndex";
|
text_ = "DynamicMomentumIndex";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_dynamic_momentum_index(xframe::series_closes(series), period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("DynamicMomentumIndex");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndDynamicMomentumIndex() {}
|
~IndDynamicMomentumIndex() {}
|
||||||
|
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_ema(series_closes(series_), period_));
|
||||||
|
line_names_.push_back("EMA(14)");
|
||||||
|
line_colors_.push_back(Srgb{200, 30, 30});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndEMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
IndEMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_ema(series_closes(series), period_));
|
|
||||||
line_names_.push_back("EMA(14)");
|
|
||||||
line_colors_.push_back(Srgb{200, 30, 30});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndEMA() {}
|
~IndEMA() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -150,6 +150,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_ease_of_movement(series_, period_);
|
||||||
|
lines_.push_back(Line{"EMV", Srgb{0, 150, 0}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndEaseOfMovement(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndEaseOfMovement(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -158,9 +167,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_ease_of_movement(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"EMV", Srgb{0, 150, 0}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndEaseOfMovement() {}
|
~IndEaseOfMovement() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -152,6 +152,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_efficiency_ratio(series_, period_);
|
||||||
|
lines_.push_back(Line{"EffRatio", Srgb{0, 100, 200}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndEfficiencyRatio(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndEfficiencyRatio(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -160,9 +169,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_efficiency_ratio(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"EffRatio", Srgb{0, 100, 200}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndEfficiencyRatio() {}
|
~IndEfficiencyRatio() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_ehlers_decycler(series_closes(series_), period_));
|
||||||
|
line_names_.push_back("EhlersDecycler(10)");
|
||||||
|
line_colors_.push_back(Srgb{0, 150, 150});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndEhlersDecycler(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10)
|
IndEhlersDecycler(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_ehlers_decycler(series_closes(series), period_));
|
|
||||||
line_names_.push_back("EhlersDecycler(10)");
|
|
||||||
line_colors_.push_back(Srgb{0, 150, 150});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndEhlersDecycler() {}
|
~IndEhlersDecycler() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -196,6 +196,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 14;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_ehlers_smoothed_rsi(xframe::series_closes(series_), period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("EhlersSmoothedRSI");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndEhlersSmoothedRSI(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndEhlersSmoothedRSI(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
||||||
@@ -212,13 +229,29 @@ public:
|
|||||||
name_ = "IndEhlersSmoothedRSI";
|
name_ = "IndEhlersSmoothedRSI";
|
||||||
text_ = "EhlersSmoothedRSI";
|
text_ = "EhlersSmoothedRSI";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_ehlers_smoothed_rsi(xframe::series_closes(series), period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("EhlersSmoothedRSI");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndEhlersSmoothedRSI() {}
|
~IndEhlersSmoothedRSI() {}
|
||||||
|
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_ehlers_super_smoother(series_closes(series_), period_));
|
||||||
|
line_names_.push_back("SuperSmoother(10)");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndEhlersSuperSmoother(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10)
|
IndEhlersSuperSmoother(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_ehlers_super_smoother(series_closes(series), period_));
|
|
||||||
line_names_.push_back("SuperSmoother(10)");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndEhlersSuperSmoother() {}
|
~IndEhlersSuperSmoother() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_ehlers_trendline(series_closes(series_), alpha_));
|
||||||
|
line_names_.push_back("EhlersTrendline(0.07)");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndEhlersTrendline(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), double alpha = 0.07)
|
IndEhlersTrendline(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), double alpha = 0.07)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
alpha_ = alpha;
|
alpha_ = alpha;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_ehlers_trendline(series_closes(series), alpha_));
|
|
||||||
line_names_.push_back("EhlersTrendline(0.07)");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndEhlersTrendline() {}
|
~IndEhlersTrendline() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -198,6 +198,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 13;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_elder_force_index(series_, period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("ElderForceIndex");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndElderForceIndex(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndElderForceIndex(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 13)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 13)
|
||||||
@@ -214,13 +231,29 @@ public:
|
|||||||
name_ = "IndElderForceIndex";
|
name_ = "IndElderForceIndex";
|
||||||
text_ = "ElderForceIndex";
|
text_ = "ElderForceIndex";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_elder_force_index(series, period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("ElderForceIndex");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndElderForceIndex() {}
|
~IndElderForceIndex() {}
|
||||||
|
|
||||||
|
|||||||
@@ -211,6 +211,25 @@ private:
|
|||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
Srgb overlay_candle_color_ = Srgb{180, 180, 180};
|
Srgb overlay_candle_color_ = Srgb{180, 180, 180};
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int ema_period_ = 13;
|
||||||
|
int fast_ = 12;
|
||||||
|
int slow_ = 26;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_elder_impulse(series_, ema_period_, fast_, slow_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("ElderImpulse");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndElderImpulse(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndElderImpulse(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int ema_period = 13, int fast = 12, int slow = 26)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int ema_period = 13, int fast = 12, int slow = 26)
|
||||||
@@ -227,13 +246,31 @@ public:
|
|||||||
name_ = "IndElderImpulse";
|
name_ = "IndElderImpulse";
|
||||||
text_ = "ElderImpulse";
|
text_ = "ElderImpulse";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_elder_impulse(series, ema_period, fast, slow);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("ElderImpulse");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
ema_period_ = ema_period;
|
||||||
|
fast_ = fast;
|
||||||
|
slow_ = slow;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndElderImpulse() {}
|
~IndElderImpulse() {}
|
||||||
|
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_elder_ray_bear(series_, period_));
|
||||||
|
line_names_.push_back("BearPower(13)");
|
||||||
|
line_colors_.push_back(Srgb{200, 30, 30});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndElderRayBear(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 13)
|
IndElderRayBear(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 13)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_elder_ray_bear(series, period_));
|
|
||||||
line_names_.push_back("BearPower(13)");
|
|
||||||
line_colors_.push_back(Srgb{200, 30, 30});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndElderRayBear() {}
|
~IndElderRayBear() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_elder_ray_bull(series_, period_));
|
||||||
|
line_names_.push_back("BullPower(13)");
|
||||||
|
line_colors_.push_back(Srgb{0, 150, 0});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndElderRayBull(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 13)
|
IndElderRayBull(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 13)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_elder_ray_bull(series, period_));
|
|
||||||
line_names_.push_back("BullPower(13)");
|
|
||||||
line_colors_.push_back(Srgb{0, 150, 0});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndElderRayBull() {}
|
~IndElderRayBull() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -233,18 +233,44 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_elder_safe_zone(series_, period_, mult_));
|
||||||
|
line_names_.push_back("ElderSafeZone(10,2)");
|
||||||
|
line_colors_.push_back(Srgb{200, 30, 30});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndElderSafeZone(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10, double mult = 2.0)
|
IndElderSafeZone(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10, double mult = 2.0)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
mult_ = mult;
|
mult_ = mult;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_elder_safe_zone(series, period_, mult_));
|
|
||||||
line_names_.push_back("ElderSafeZone(10,2)");
|
|
||||||
line_colors_.push_back(Srgb{200, 30, 30});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndElderSafeZone() {}
|
~IndElderSafeZone() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -201,6 +201,24 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int long_period_ = 5;
|
||||||
|
int short_period_ = 3;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_ergodic_oscillator(xframe::series_closes(series_), long_period_, short_period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("ErgodicOscillator");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndErgodicOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndErgodicOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int long_period = 5, int short_period = 3)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int long_period = 5, int short_period = 3)
|
||||||
@@ -217,13 +235,30 @@ public:
|
|||||||
name_ = "IndErgodicOscillator";
|
name_ = "IndErgodicOscillator";
|
||||||
text_ = "ErgodicOscillator";
|
text_ = "ErgodicOscillator";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_ergodic_oscillator(xframe::series_closes(series), long_period, short_period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("ErgodicOscillator");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
long_period_ = long_period;
|
||||||
|
short_period_ = short_period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndErgodicOscillator() {}
|
~IndErgodicOscillator() {}
|
||||||
|
|
||||||
|
|||||||
@@ -212,6 +212,27 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 10;
|
||||||
|
int hp_period_ = 48;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
xframe::IndEvenBetterSineWaveResult result = xframe::ind_even_better_sinewave(xframe::series_closes(series_), period_, hp_period_);
|
||||||
|
lines_.push_back(result.sine);
|
||||||
|
line_names_.push_back("sine");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
lines_.push_back(result.lead_sine);
|
||||||
|
line_names_.push_back("lead_sine");
|
||||||
|
line_colors_.push_back(Srgb{200, 30, 30});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndEvenBetterSineWave(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndEvenBetterSineWave(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10, int hp_period = 48)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10, int hp_period = 48)
|
||||||
@@ -228,16 +249,30 @@ public:
|
|||||||
name_ = "IndEvenBetterSineWave";
|
name_ = "IndEvenBetterSineWave";
|
||||||
text_ = "EvenBetterSineWave";
|
text_ = "EvenBetterSineWave";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
xframe::IndEvenBetterSineWaveResult result = xframe::ind_even_better_sinewave(xframe::series_closes(series), period, hp_period);
|
|
||||||
lines_.push_back(result.sine);
|
|
||||||
line_names_.push_back("sine");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
lines_.push_back(result.lead_sine);
|
|
||||||
line_names_.push_back("lead_sine");
|
|
||||||
line_colors_.push_back(Srgb{200, 30, 30});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
hp_period_ = hp_period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndEvenBetterSineWave() {}
|
~IndEvenBetterSineWave() {}
|
||||||
|
|
||||||
|
|||||||
@@ -246,18 +246,44 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_fama(series_closes(series_), fastlimit_, slowlimit_));
|
||||||
|
line_names_.push_back("FAMA(0.5,0.05)");
|
||||||
|
line_colors_.push_back(Srgb{200, 30, 30});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndFAMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), double fastlimit = 0.5, double slowlimit = 0.05)
|
IndFAMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), double fastlimit = 0.5, double slowlimit = 0.05)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
fastlimit_ = fastlimit;
|
fastlimit_ = fastlimit;
|
||||||
slowlimit_ = slowlimit;
|
slowlimit_ = slowlimit;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_fama(series_closes(series), fastlimit_, slowlimit_));
|
|
||||||
line_names_.push_back("FAMA(0.5,0.05)");
|
|
||||||
line_colors_.push_back(Srgb{200, 30, 30});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndFAMA() {}
|
~IndFAMA() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_frama(series_closes(series_), period_));
|
||||||
|
line_names_.push_back("FRAMA(16)");
|
||||||
|
line_colors_.push_back(Srgb{0, 150, 0});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndFRAMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 16)
|
IndFRAMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 16)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_frama(series_closes(series), period_));
|
|
||||||
line_names_.push_back("FRAMA(16)");
|
|
||||||
line_colors_.push_back(Srgb{0, 150, 0});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndFRAMA() {}
|
~IndFRAMA() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -156,6 +156,17 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_fibonacci_pivot_points(series_, period_);
|
||||||
|
lines_.push_back(Line{"Pivot", Srgb{0, 100, 200}, result.pivot});
|
||||||
|
lines_.push_back(Line{"R1", Srgb{200, 30, 30}, result.r1});
|
||||||
|
lines_.push_back(Line{"S1", Srgb{0, 150, 0}, result.s1});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndFibonacciPivotPoints(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndFibonacciPivotPoints(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -164,11 +175,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_fibonacci_pivot_points(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"Pivot", Srgb{0, 100, 200}, result.pivot});
|
|
||||||
lines_.push_back(Line{"R1", Srgb{200, 30, 30}, result.r1});
|
|
||||||
lines_.push_back(Line{"S1", Srgb{0, 150, 0}, result.s1});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndFibonacciPivotPoints() {}
|
~IndFibonacciPivotPoints() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -206,6 +206,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 10;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_fisher_transform(xframe::series_closes(series_), period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("FisherTransform");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndFisherTransform(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndFisherTransform(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 10)
|
||||||
@@ -222,13 +239,29 @@ public:
|
|||||||
name_ = "IndFisherTransform";
|
name_ = "IndFisherTransform";
|
||||||
text_ = "FisherTransform";
|
text_ = "FisherTransform";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_fisher_transform(xframe::series_closes(series), period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("FisherTransform");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndFisherTransform() {}
|
~IndFisherTransform() {}
|
||||||
|
|
||||||
|
|||||||
@@ -160,6 +160,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_fractal_dimension(series_, period_);
|
||||||
|
lines_.push_back(Line{"FractalDim", Srgb{150, 0, 150}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndFractalDimension(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndFractalDimension(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -168,9 +177,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_fractal_dimension(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"FractalDim", Srgb{150, 0, 150}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndFractalDimension() {}
|
~IndFractalDimension() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_fractal_dimension_index(series_closes(series_), period_));
|
||||||
|
line_names_.push_back("FDI(30)");
|
||||||
|
line_colors_.push_back(Srgb{120, 60, 180});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndFractalDimensionIndex(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 30)
|
IndFractalDimensionIndex(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 30)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_fractal_dimension_index(series_closes(series), period_));
|
|
||||||
line_names_.push_back("FDI(30)");
|
|
||||||
line_colors_.push_back(Srgb{120, 60, 180});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndFractalDimensionIndex() {}
|
~IndFractalDimensionIndex() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -231,16 +231,41 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
lines_.push_back(ind_fractal_down(series_));
|
||||||
|
line_names_.push_back("FractalDown");
|
||||||
|
line_colors_.push_back(Srgb{200, 30, 30});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndFractalDown(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250))
|
IndFractalDown(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250))
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_fractal_down(series));
|
|
||||||
line_names_.push_back("FractalDown");
|
|
||||||
line_colors_.push_back(Srgb{200, 30, 30});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndFractalDown() {}
|
~IndFractalDown() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -231,16 +231,41 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
lines_.push_back(ind_fractal_up(series_));
|
||||||
|
line_names_.push_back("FractalUp");
|
||||||
|
line_colors_.push_back(Srgb{0, 150, 0});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndFractalUp(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250))
|
IndFractalUp(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250))
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_fractal_up(series));
|
|
||||||
line_names_.push_back("FractalUp");
|
|
||||||
line_colors_.push_back(Srgb{0, 150, 0});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndFractalUp() {}
|
~IndFractalUp() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -215,6 +215,23 @@ private:
|
|||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
Srgb overlay_candle_color_ = Srgb{180, 180, 180};
|
Srgb overlay_candle_color_ = Srgb{180, 180, 180};
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int period_ = 3;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_gann_hilo_activator(series_, period_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("GannHiLoActivator");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndGannHiLoActivator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndGannHiLoActivator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 3)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int period = 3)
|
||||||
@@ -231,13 +248,29 @@ public:
|
|||||||
name_ = "IndGannHiLoActivator";
|
name_ = "IndGannHiLoActivator";
|
||||||
text_ = "GannHiLoActivator";
|
text_ = "GannHiLoActivator";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_gann_hilo_activator(series, period);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("GannHiLoActivator");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndGannHiLoActivator() {}
|
~IndGannHiLoActivator() {}
|
||||||
|
|
||||||
|
|||||||
@@ -205,6 +205,23 @@ private:
|
|||||||
int line_width_ = 2;
|
int line_width_ = 2;
|
||||||
int grid_divisions_ = 4;
|
int grid_divisions_ = 4;
|
||||||
|
|
||||||
|
// Series parameters stored for recompute_lines() (these were
|
||||||
|
// constructor-only before the CSV series API).
|
||||||
|
int dummy_ = 0;
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
std::vector<double> result = xframe::ind_gann_swing_oscillator(series_, dummy_);
|
||||||
|
lines_.push_back(result);
|
||||||
|
line_names_.push_back("GannSwingOscillator");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndGannSwingOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndGannSwingOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int dummy = 0)
|
int x, int y, int width, int height, const xframe::OHLCVSeries& series = xframe::make_seeded_series(250), int dummy = 0)
|
||||||
@@ -221,13 +238,29 @@ public:
|
|||||||
name_ = "IndGannSwingOscillator";
|
name_ = "IndGannSwingOscillator";
|
||||||
text_ = "GannSwingOscillator";
|
text_ = "GannSwingOscillator";
|
||||||
series_ = series;
|
series_ = series;
|
||||||
std::vector<double> result = xframe::ind_gann_swing_oscillator(series, dummy);
|
|
||||||
lines_.push_back(result);
|
|
||||||
line_names_.push_back("GannSwingOscillator");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
view_count_ = (double)item_count();
|
view_count_ = (double)item_count();
|
||||||
|
dummy_ = dummy;
|
||||||
|
recompute_lines();
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
|
|
||||||
~IndGannSwingOscillator() {}
|
~IndGannSwingOscillator() {}
|
||||||
|
|
||||||
|
|||||||
@@ -156,6 +156,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_garman_klass_volatility(series_, period_);
|
||||||
|
lines_.push_back(Line{"GarmanKlass", Srgb{150, 0, 150}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndGarmanKlassVolatility(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndGarmanKlassVolatility(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -164,9 +173,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_garman_klass_volatility(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"GarmanKlass", Srgb{150, 0, 150}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndGarmanKlassVolatility() {}
|
~IndGarmanKlassVolatility() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -232,14 +232,39 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
{ auto gr = ind_gator(series_closes(series_)); lines_.push_back(gr.upper); line_names_.push_back("Gator+"); line_colors_.push_back(Srgb{0, 150, 0}); lines_.push_back(gr.lower); line_names_.push_back("Gator-"); line_colors_.push_back(Srgb{200, 30, 30}); }
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndGatorOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250))
|
IndGatorOscillator(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250))
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
|
recompute_lines();
|
||||||
{ auto gr = ind_gator(series_closes(series)); lines_.push_back(gr.upper); line_names_.push_back("Gator+"); line_colors_.push_back(Srgb{0, 150, 0}); lines_.push_back(gr.lower); line_names_.push_back("Gator-"); line_colors_.push_back(Srgb{200, 30, 30}); }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndGatorOscillator() {}
|
~IndGatorOscillator() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_gaussian_ma(series_closes(series_), period_));
|
||||||
|
line_names_.push_back("GaussianMA(14)");
|
||||||
|
line_colors_.push_back(Srgb{150, 90, 30});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndGaussianMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
IndGaussianMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 14)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_gaussian_ma(series_closes(series), period_));
|
|
||||||
line_names_.push_back("GaussianMA(14)");
|
|
||||||
line_colors_.push_back(Srgb{150, 90, 30});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndGaussianMA() {}
|
~IndGaussianMA() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -154,6 +154,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_gopalakrishnan_range_index(series_, period_);
|
||||||
|
lines_.push_back(Line{"GAPO", Srgb{150, 0, 150}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndGopalakrishnanRangeIndex(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndGopalakrishnanRangeIndex(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -162,9 +171,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_gopalakrishnan_range_index(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"GAPO", Srgb{150, 0, 150}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndGopalakrishnanRangeIndex() {}
|
~IndGopalakrishnanRangeIndex() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -232,14 +232,39 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
{ auto gr = ind_guppy_mma(series_closes(series_)); const int ps[12] = {3, 5, 8, 10, 12, 15, 30, 35, 40, 45, 50, 60}; const Srgb cols[12] = {Srgb{0, 100, 200}, Srgb{0, 150, 0}, Srgb{200, 30, 30}, Srgb{230, 126, 34}, Srgb{120, 60, 180}, Srgb{0, 150, 150}, Srgb{150, 90, 30}, Srgb{60, 60, 180}, Srgb{180, 60, 120}, Srgb{90, 140, 40}, Srgb{40, 120, 160}, Srgb{160, 40, 40}}; for (int k = 0; k < 12; ++k) { lines_.push_back(gr.lines[(size_t)k]); line_names_.push_back(std::string("EMA(") + std::to_string(ps[k]) + ")"); line_colors_.push_back(cols[k]); } }
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndGuppyMMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250))
|
IndGuppyMMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250))
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
|
recompute_lines();
|
||||||
{ auto gr = ind_guppy_mma(series_closes(series)); const int ps[12] = {3, 5, 8, 10, 12, 15, 30, 35, 40, 45, 50, 60}; const Srgb cols[12] = {Srgb{0, 100, 200}, Srgb{0, 150, 0}, Srgb{200, 30, 30}, Srgb{230, 126, 34}, Srgb{120, 60, 180}, Srgb{0, 150, 150}, Srgb{150, 90, 30}, Srgb{60, 60, 180}, Srgb{180, 60, 120}, Srgb{90, 140, 40}, Srgb{40, 120, 160}, Srgb{160, 40, 40}}; for (int k = 0; k < 12; ++k) { lines_.push_back(gr.lines[(size_t)k]); line_names_.push_back(std::string("EMA(") + std::to_string(ps[k]) + ")"); line_colors_.push_back(cols[k]); } }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndGuppyMMA() {}
|
~IndGuppyMMA() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -232,17 +232,43 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_hma(series_closes(series_), period_));
|
||||||
|
line_names_.push_back("HMA(16)");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndHMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 16)
|
IndHMA(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int period = 16)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
period_ = period;
|
period_ = period;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_hma(series_closes(series), period_));
|
|
||||||
line_names_.push_back("HMA(16)");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndHMA() {}
|
~IndHMA() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -233,18 +233,44 @@ private:
|
|||||||
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
Srgb candle_down_color_ = Srgb{210, 130, 130};
|
||||||
int point_size_ = 5;
|
int point_size_ = 5;
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
line_names_.clear();
|
||||||
|
line_colors_.clear();
|
||||||
|
|
||||||
|
lines_.push_back(ind_half_trend(series_, amplitude_, channelDeviation_));
|
||||||
|
line_names_.push_back("HalfTrend(2,2)");
|
||||||
|
line_colors_.push_back(Srgb{0, 100, 200});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IndHalfTrend(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int amplitude = 2, double channelDeviation = 2.0)
|
IndHalfTrend(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles, int x, int y, int width, int height, const OHLCVSeries& series = xframe::make_seeded_series(250), int amplitude = 2, double channelDeviation = 2.0)
|
||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
|
||||||
amplitude_ = amplitude;
|
amplitude_ = amplitude;
|
||||||
channelDeviation_ = channelDeviation;
|
channelDeviation_ = channelDeviation;
|
||||||
|
recompute_lines();
|
||||||
lines_.push_back(ind_half_trend(series, amplitude_, channelDeviation_));
|
|
||||||
line_names_.push_back("HalfTrend(2,2)");
|
|
||||||
line_colors_.push_back(Srgb{0, 100, 200});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
|
||||||
~IndHalfTrend() {}
|
~IndHalfTrend() {}
|
||||||
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
void set_bounds(int x, int y, int w, int h) { x1_ = x; y1_ = y; x2_ = x + w; y2_ = y + h; }
|
||||||
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
int width() { return x2_ - x1_; } int height() { return y2_ - y1_; }
|
||||||
|
|||||||
@@ -148,6 +148,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_high_low_range(series_, period_);
|
||||||
|
lines_.push_back(Line{"HLRange", Srgb{150, 0, 150}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndHighLowRange(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndHighLowRange(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -156,9 +165,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_high_low_range(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"HLRange", Srgb{150, 0, 150}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndHighLowRange() {}
|
~IndHighLowRange() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -148,6 +148,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_historical_volatility(series_, period_);
|
||||||
|
lines_.push_back(Line{"HistVol", Srgb{150, 0, 150}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndHistoricalVolatility(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndHistoricalVolatility(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -156,9 +165,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_historical_volatility(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"HistVol", Srgb{150, 0, 150}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndHistoricalVolatility() {}
|
~IndHistoricalVolatility() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
@@ -160,6 +160,15 @@ private:
|
|||||||
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
Srgb candle_up_color_ = Srgb{0, 150, 0};
|
||||||
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
Srgb candle_down_color_ = Srgb{200, 30, 30};
|
||||||
|
|
||||||
|
// Rebuild lines_ (and line_names_/line_colors_ where present)
|
||||||
|
// from series_ with the stored parameters. Called by the
|
||||||
|
// constructor and by set_series().
|
||||||
|
void recompute_lines() {
|
||||||
|
lines_.clear();
|
||||||
|
auto result = ind_hurst_exponent(series_, period_);
|
||||||
|
lines_.push_back(Line{"Hurst", Srgb{150, 0, 150}, result});
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::function<void(double, double)> on_view_change;
|
std::function<void(double, double)> on_view_change;
|
||||||
IndHurstExponent(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
IndHurstExponent(Display* display, int screen, Window window, GC gc, SStyle_Manager* styles,
|
||||||
@@ -168,9 +177,27 @@ public:
|
|||||||
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
: display_(display), screen_(screen), window_(window), gc_(gc), styles_(styles),
|
||||||
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
|
||||||
period_(period), mult_(mult) {
|
period_(period), mult_(mult) {
|
||||||
auto result = ind_hurst_exponent(series, period);
|
recompute_lines();
|
||||||
lines_.push_back(Line{"Hurst", Srgb{150, 0, 150}, result});
|
|
||||||
}
|
}
|
||||||
|
// Series API (CSV): replace the plotted series and recompute the
|
||||||
|
// indicator lines from it — same shape as the Stock* chart widgets
|
||||||
|
// (see docs/stock-market-csv-data.md). load_csv leaves the old
|
||||||
|
// series untouched on failure; clear_series() empties the series
|
||||||
|
// (the seeded template is only the constructor default).
|
||||||
|
void set_series(const xframe::OHLCVSeries& s) {
|
||||||
|
series_ = s;
|
||||||
|
reset_view();
|
||||||
|
recompute_lines();
|
||||||
|
}
|
||||||
|
bool load_csv(const std::string& path, std::string& error) {
|
||||||
|
xframe::OHLCVSeries s = xframe::load_ohlcv_csv(path, error);
|
||||||
|
if (!error.empty()) return false;
|
||||||
|
set_series(s);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
void clear_series() { set_series(xframe::OHLCVSeries{}); }
|
||||||
|
const xframe::OHLCVSeries& series() const { return series_; }
|
||||||
|
|
||||||
~IndHurstExponent() {}
|
~IndHurstExponent() {}
|
||||||
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
void set_bounds(int x, int y, int width, int height) { x1_ = x; y1_ = y; x2_ = x + width; y2_ = y + height; }
|
||||||
int width() { return x2_ - x1_; }
|
int width() { return x2_ - x1_; }
|
||||||
|
|||||||
Loaded 100 of 253 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user