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:
cnmcdee committed 2026-12-02 11:00:19 +00:00
1 parent 3792410bfe
commit 90880928c9
253 files changed
+8899 -1060

No files matched your search

+66 -14
View File
@@ -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)` |
| 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)` |
| 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,
StockFibExtension, StockPitchfork, StockParallelChannel, StockRectangle,
@@ -30,12 +31,6 @@ Two groups are **not** covered, on purpose:
(their `set_series`), which you can replace with
`set_series(xframe::load_ohlcv_csv(path, err))`, but they have no
`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
@@ -90,6 +85,11 @@ all reproducible, no network:
`StockHeikinAshi` rebuilds its Heikin-Ashi candles and `StockRenko`
rebuilds its bricks from whatever series is set; `StockBaselineChart`
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
series — `SYM-A` (`make_seeded_series(60, 42)`), `SYM-B` (seed 7),
`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`,
`StockAreaChart`, `StockHeikinAshi`, `StockRenko`, `StockHollowCandles`,
`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
the comparative widgets.
## Indicators (constructor only)
## Indicators (`load_csv` / `set_series`)
The 250 `Ind*` widgets have no `set_series`; give them the loaded series
at construction:
All 250 `Ind*` widgets take CSV data the same way the single-series
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
#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;
auto series = xframe::load_ohlcv_csv("aapl_30d.csv", err);
IndSMA w(display, screen, window, gc, &styles, 20, 20, 760, 520, series);
w.draw();
```
The indicator is computed from the series in the constructor, so a series
loaded from CSV plots exactly like the seeded template one — only the
values differ.
Two things to know:
- **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)
@@ -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
(the plot follows the file), reports 30 items, and that a missing file
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 `.` / `->`.)
+31 -5
View File
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_adx(series, period_));
line_names_.push_back("ADX(14)");
line_colors_.push_back(Srgb{0, 100, 200});
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;
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() {}
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_; }
+31 -5
View File
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_adxr(series, period_));
line_names_.push_back("ADXR(14)");
line_colors_.push_back(Srgb{120, 60, 180});
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;
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() {}
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_; }
+31 -5
View File
@@ -234,6 +234,19 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
@@ -241,12 +254,25 @@ public:
period_ = period;
offset_ = offset;
sigma_ = sigma;
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});
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;
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() {}
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_; }
+40 -5
View File
@@ -198,6 +198,24 @@ private:
int line_width_ = 2;
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:
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)
@@ -214,13 +232,30 @@ public:
name_ = "IndAPO";
text_ = "APO";
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();
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() {}
+29 -2
View File
@@ -143,6 +143,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_atr(series, period);
lines_.push_back(Line{"ATR", Srgb{200, 120, 0}, result});
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_; }
~IndATR() {}
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_; }
@@ -204,6 +204,25 @@ private:
int line_width_ = 2;
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:
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)
@@ -220,13 +239,31 @@ public:
name_ = "IndAcceleratorOscillator";
text_ = "AcceleratorOscillator";
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();
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() {}
@@ -152,6 +152,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_accumulation_distribution_line(series, period);
lines_.push_back(Line{"ADL", Srgb{0, 150, 0}, result});
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_; }
~IndAccumulationDistributionLine() {}
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_; }
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
limitMove_ = limitMove;
lines_.push_back(ind_accumulative_swing_index(series, limitMove_));
line_names_.push_back("ASI(1)");
line_colors_.push_back(Srgb{230, 126, 34});
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;
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() {}
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_; }
@@ -221,6 +221,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -237,13 +254,29 @@ public:
name_ = "IndAdaptiveCyberCycle";
text_ = "AdaptiveCyberCycle";
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();
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() {}
@@ -222,6 +222,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -238,13 +255,29 @@ public:
name_ = "IndAdaptiveRSI";
text_ = "AdaptiveRSI";
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();
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() {}
@@ -233,18 +233,44 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
shift_ = shift;
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});
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;
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() {}
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_; }
@@ -233,18 +233,44 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
shift_ = shift;
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});
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;
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() {}
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_; }
@@ -233,18 +233,44 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
shift_ = shift;
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});
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;
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() {}
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_; }
@@ -152,6 +152,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_anchored_vwap(series, period);
lines_.push_back(Line{"AnchoredVWAP", Srgb{200, 120, 0}, result});
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_; }
~IndAnchoredVWAP() {}
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_; }
+31 -5
View File
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_aroon_down(series, period_));
line_names_.push_back("AroonDown(14)");
line_colors_.push_back(Srgb{200, 30, 30});
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;
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() {}
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_; }
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_aroon_osc(series, period_));
line_names_.push_back("AroonOsc(14)");
line_colors_.push_back(Srgb{0, 100, 200});
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;
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() {}
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_; }
+31 -5
View File
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_aroon_up(series, period_));
line_names_.push_back("AroonUp(14)");
line_colors_.push_back(Srgb{0, 150, 0});
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;
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() {}
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_; }
@@ -156,6 +156,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_autocorrelation(series, period);
lines_.push_back(Line{"Autocorr", Srgb{0, 100, 200}, result});
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_; }
~IndAutocorrelation() {}
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_; }
@@ -201,6 +201,24 @@ private:
int line_width_ = 2;
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:
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)
@@ -217,13 +235,30 @@ public:
name_ = "IndAwesomeOscillator";
text_ = "AwesomeOscillator";
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();
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() {}
@@ -198,6 +198,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -214,13 +231,29 @@ public:
name_ = "IndBalanceOfPower";
text_ = "BalanceOfPower";
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();
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() {}
+38 -5
View File
@@ -199,6 +199,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -215,13 +232,29 @@ public:
name_ = "IndBearPower";
text_ = "BearPower";
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();
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() {}
@@ -155,6 +155,17 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
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});
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_; }
~IndBollingerBands() {}
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_; }
@@ -149,6 +149,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_bollinger_bandwidth(series, period, mult);
lines_.push_back(Line{"Bandwidth", Srgb{0, 100, 200}, result});
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_; }
~IndBollingerBandwidth() {}
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_; }
@@ -152,6 +152,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_bollinger_percent_b(series, period, mult);
lines_.push_back(Line{"%B", Srgb{0, 100, 200}, result});
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_; }
~IndBollingerPercentB() {}
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_; }
+38 -5
View File
@@ -199,6 +199,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -215,13 +232,29 @@ public:
name_ = "IndBullPower";
text_ = "BullPower";
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();
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() {}
+38 -5
View File
@@ -208,6 +208,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -224,13 +241,29 @@ public:
name_ = "IndCCI";
text_ = "CCI";
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();
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() {}
@@ -156,6 +156,17 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
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});
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_; }
~IndCamarillaPivotPoints() {}
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_; }
@@ -205,6 +205,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -221,13 +238,29 @@ public:
name_ = "IndCenterOfGravity";
text_ = "CenterOfGravity";
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();
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() {}
@@ -153,6 +153,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_chaikin_money_flow(series, period);
lines_.push_back(Line{"CMF", Srgb{0, 150, 0}, result});
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_; }
~IndChaikinMoneyFlow() {}
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_; }
@@ -155,6 +155,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_chaikin_oscillator(series, period);
lines_.push_back(Line{"ChaikinOsc", Srgb{0, 150, 0}, result});
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_; }
~IndChaikinOscillator() {}
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_; }
@@ -150,6 +150,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_chaikin_volatility(series, period);
lines_.push_back(Line{"ChaikinVol", Srgb{150, 0, 150}, result});
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_; }
~IndChaikinVolatility() {}
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_; }
@@ -200,6 +200,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -216,13 +233,29 @@ public:
name_ = "IndChandeForecastOscillator";
text_ = "ChandeForecastOscillator";
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();
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() {}
@@ -233,18 +233,44 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
mult_ = mult;
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});
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;
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() {}
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_; }
@@ -204,6 +204,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -220,13 +237,29 @@ public:
name_ = "IndChandeMomentumOscillator";
text_ = "ChandeMomentumOscillator";
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();
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() {}
@@ -155,6 +155,16 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
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});
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_; }
~IndChandelierExit() {}
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_; }
@@ -233,18 +233,44 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
mult_ = mult;
lines_.push_back(ind_chandelier_long(series, period_, mult_));
line_names_.push_back("ChandelierLong(22,3)");
line_colors_.push_back(Srgb{200, 30, 30});
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;
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() {}
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_; }
@@ -233,18 +233,44 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
mult_ = mult;
lines_.push_back(ind_chandelier_short(series, period_, mult_));
line_names_.push_back("ChandelierShort(22,3)");
line_colors_.push_back(Srgb{0, 150, 0});
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;
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() {}
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_; }
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_chikou_span(series_closes(series), period_));
line_names_.push_back("ChikouSpan(26)");
line_colors_.push_back(Srgb{120, 60, 180});
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;
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() {}
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_; }
@@ -210,6 +210,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -226,13 +243,29 @@ public:
name_ = "IndChoppinessIndex";
text_ = "ChoppinessIndex";
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();
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() {}
@@ -148,6 +148,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_close_volatility(series, period);
lines_.push_back(Line{"CloseVol", Srgb{150, 0, 150}, result});
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_; }
~IndCloseVolatility() {}
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_; }
@@ -215,6 +215,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -231,13 +248,29 @@ public:
name_ = "IndConnorsRSI";
text_ = "ConnorsRSI";
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();
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() {}
@@ -210,6 +210,25 @@ private:
int line_width_ = 2;
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:
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)
@@ -226,13 +245,31 @@ public:
name_ = "IndCoppockCurve";
text_ = "CoppockCurve";
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();
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() {}
@@ -158,6 +158,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_correlation(series, period);
lines_.push_back(Line{"Correlation", Srgb{0, 100, 200}, result});
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_; }
~IndCorrelation() {}
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_; }
@@ -207,6 +207,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -223,13 +240,29 @@ public:
name_ = "IndCorrelationCoefficient";
text_ = "CorrelationCoefficient";
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();
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() {}
@@ -154,6 +154,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_covariance(series, period);
lines_.push_back(Line{"Covariance", Srgb{0, 100, 200}, result});
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_; }
~IndCovariance() {}
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_; }
@@ -152,6 +152,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_cumulative_volume_delta(series, period);
lines_.push_back(Line{"CumVolDelta", Srgb{0, 150, 0}, result});
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_; }
~IndCumulativeVolumeDelta() {}
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_; }
+38 -5
View File
@@ -206,6 +206,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -222,13 +239,29 @@ public:
name_ = "IndCutlerRSI";
text_ = "CutlerRSI";
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();
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() {}
@@ -207,6 +207,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -223,13 +240,29 @@ public:
name_ = "IndCyberCycle";
text_ = "CyberCycle";
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();
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() {}
+31 -5
View File
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_dema(series_closes(series), period_));
line_names_.push_back("DEMA(14)");
line_colors_.push_back(Srgb{230, 126, 34});
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;
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() {}
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_; }
+31 -5
View File
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_dpo(series_closes(series), period_));
line_names_.push_back("DPO(20)");
line_colors_.push_back(Srgb{230, 126, 34});
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;
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() {}
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_; }
+40 -5
View File
@@ -197,6 +197,24 @@ private:
int line_width_ = 2;
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:
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)
@@ -213,13 +231,30 @@ public:
name_ = "IndDSS";
text_ = "DSS";
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();
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() {}
+31 -5
View File
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_dx(series, period_));
line_names_.push_back("DX(14)");
line_colors_.push_back(Srgb{230, 126, 34});
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;
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() {}
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_; }
+38 -5
View File
@@ -209,6 +209,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -225,13 +242,29 @@ public:
name_ = "IndDeMarker";
text_ = "DeMarker";
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();
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() {}
+38 -5
View File
@@ -202,6 +202,23 @@ private:
int grid_divisions_ = 4;
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:
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)
@@ -218,13 +235,29 @@ public:
name_ = "IndDecycler";
text_ = "Decycler";
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();
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() {}
@@ -156,6 +156,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_demand_index(series, period);
lines_.push_back(Line{"DemandIndex", Srgb{0, 100, 200}, result});
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_; }
~IndDemandIndex() {}
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_; }
@@ -202,6 +202,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -218,13 +235,29 @@ public:
name_ = "IndDetrendedPriceOscillator";
text_ = "DetrendedPriceOscillator";
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();
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() {}
@@ -198,6 +198,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -214,13 +231,29 @@ public:
name_ = "IndDisparityIndex";
text_ = "DisparityIndex";
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();
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() {}
@@ -214,6 +214,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -230,13 +247,29 @@ public:
name_ = "IndDominantCycle";
text_ = "DominantCycle";
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();
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() {}
@@ -157,6 +157,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_dominant_cycle_period(series, period);
lines_.push_back(Line{"CyclePeriod", Srgb{150, 0, 150}, result});
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_; }
~IndDominantCyclePeriod() {}
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_; }
@@ -154,6 +154,17 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
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});
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_; }
~IndDonchianChannels() {}
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_; }
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_donchian_lower(series, period_));
line_names_.push_back("DonchianLower(20)");
line_colors_.push_back(Srgb{200, 30, 30});
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;
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() {}
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_; }
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_donchian_middle(series, period_));
line_names_.push_back("DonchianMiddle(20)");
line_colors_.push_back(Srgb{0, 100, 200});
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;
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() {}
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_; }
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_donchian_upper(series, period_));
line_names_.push_back("DonchianUpper(20)");
line_colors_.push_back(Srgb{0, 150, 0});
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;
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() {}
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_; }
@@ -199,6 +199,25 @@ private:
int line_width_ = 2;
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:
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)
@@ -215,13 +234,31 @@ public:
name_ = "IndDoubleStochastic";
text_ = "DoubleStochastic";
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();
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() {}
@@ -219,6 +219,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -235,13 +252,29 @@ public:
name_ = "IndDynamicMomentumIndex";
text_ = "DynamicMomentumIndex";
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();
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() {}
+31 -5
View File
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_ema(series_closes(series), period_));
line_names_.push_back("EMA(14)");
line_colors_.push_back(Srgb{200, 30, 30});
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;
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() {}
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_; }
@@ -150,6 +150,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_ease_of_movement(series, period);
lines_.push_back(Line{"EMV", Srgb{0, 150, 0}, result});
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_; }
~IndEaseOfMovement() {}
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_; }
@@ -152,6 +152,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_efficiency_ratio(series, period);
lines_.push_back(Line{"EffRatio", Srgb{0, 100, 200}, result});
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_; }
~IndEfficiencyRatio() {}
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_; }
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_ehlers_decycler(series_closes(series), period_));
line_names_.push_back("EhlersDecycler(10)");
line_colors_.push_back(Srgb{0, 150, 150});
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;
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() {}
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_; }
@@ -196,6 +196,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -212,13 +229,29 @@ public:
name_ = "IndEhlersSmoothedRSI";
text_ = "EhlersSmoothedRSI";
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();
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() {}
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
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});
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;
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() {}
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_; }
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
alpha_ = alpha;
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});
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;
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() {}
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_; }
@@ -198,6 +198,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -214,13 +231,29 @@ public:
name_ = "IndElderForceIndex";
text_ = "ElderForceIndex";
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();
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() {}
@@ -211,6 +211,25 @@ private:
int grid_divisions_ = 4;
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:
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)
@@ -227,13 +246,31 @@ public:
name_ = "IndElderImpulse";
text_ = "ElderImpulse";
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();
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() {}
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_elder_ray_bear(series, period_));
line_names_.push_back("BearPower(13)");
line_colors_.push_back(Srgb{200, 30, 30});
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;
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() {}
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_; }
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_elder_ray_bull(series, period_));
line_names_.push_back("BullPower(13)");
line_colors_.push_back(Srgb{0, 150, 0});
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;
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() {}
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_; }
@@ -233,18 +233,44 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
mult_ = mult;
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});
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;
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() {}
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_; }
@@ -201,6 +201,24 @@ private:
int line_width_ = 2;
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:
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)
@@ -217,13 +235,30 @@ public:
name_ = "IndErgodicOscillator";
text_ = "ErgodicOscillator";
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();
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() {}
@@ -212,6 +212,27 @@ private:
int line_width_ = 2;
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:
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)
@@ -228,16 +249,30 @@ public:
name_ = "IndEvenBetterSineWave";
text_ = "EvenBetterSineWave";
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();
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() {}
+31 -5
View File
@@ -246,18 +246,44 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
fastlimit_ = fastlimit;
slowlimit_ = slowlimit;
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});
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;
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() {}
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_; }
+31 -5
View File
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_frama(series_closes(series), period_));
line_names_.push_back("FRAMA(16)");
line_colors_.push_back(Srgb{0, 150, 0});
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;
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() {}
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_; }
@@ -156,6 +156,17 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
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});
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_; }
~IndFibonacciPivotPoints() {}
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_; }
@@ -206,6 +206,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -222,13 +239,29 @@ public:
name_ = "IndFisherTransform";
text_ = "FisherTransform";
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();
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() {}
@@ -160,6 +160,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_fractal_dimension(series, period);
lines_.push_back(Line{"FractalDim", Srgb{150, 0, 150}, result});
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_; }
~IndFractalDimension() {}
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_; }
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
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});
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;
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() {}
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_; }
@@ -231,16 +231,41 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
lines_.push_back(ind_fractal_down(series));
line_names_.push_back("FractalDown");
line_colors_.push_back(Srgb{200, 30, 30});
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;
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() {}
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_; }
+30 -5
View File
@@ -231,16 +231,41 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
lines_.push_back(ind_fractal_up(series));
line_names_.push_back("FractalUp");
line_colors_.push_back(Srgb{0, 150, 0});
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;
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() {}
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_; }
@@ -215,6 +215,23 @@ private:
int grid_divisions_ = 4;
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:
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)
@@ -231,13 +248,29 @@ public:
name_ = "IndGannHiLoActivator";
text_ = "GannHiLoActivator";
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();
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() {}
@@ -205,6 +205,23 @@ private:
int line_width_ = 2;
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:
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)
@@ -221,13 +238,29 @@ public:
name_ = "IndGannSwingOscillator";
text_ = "GannSwingOscillator";
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();
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() {}
@@ -156,6 +156,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_garman_klass_volatility(series, period);
lines_.push_back(Line{"GarmanKlass", Srgb{150, 0, 150}, result});
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_; }
~IndGarmanKlassVolatility() {}
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_; }
@@ -232,14 +232,39 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
{ 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}); }
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;
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() {}
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_; }
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_gaussian_ma(series_closes(series), period_));
line_names_.push_back("GaussianMA(14)");
line_colors_.push_back(Srgb{150, 90, 30});
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;
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() {}
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_; }
@@ -154,6 +154,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_gopalakrishnan_range_index(series, period);
lines_.push_back(Line{"GAPO", Srgb{150, 0, 150}, result});
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_; }
~IndGopalakrishnanRangeIndex() {}
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_; }
+28 -3
View File
@@ -232,14 +232,39 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
{ 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]); } }
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;
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() {}
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_; }
+31 -5
View File
@@ -232,17 +232,43 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
period_ = period;
lines_.push_back(ind_hma(series_closes(series), period_));
line_names_.push_back("HMA(16)");
line_colors_.push_back(Srgb{0, 100, 200});
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;
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() {}
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_; }
+31 -5
View File
@@ -233,18 +233,44 @@ private:
Srgb candle_down_color_ = Srgb{210, 130, 130};
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:
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series) {
amplitude_ = amplitude;
channelDeviation_ = channelDeviation;
lines_.push_back(ind_half_trend(series, amplitude_, channelDeviation_));
line_names_.push_back("HalfTrend(2,2)");
line_colors_.push_back(Srgb{0, 100, 200});
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;
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() {}
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_; }
@@ -148,6 +148,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_high_low_range(series, period);
lines_.push_back(Line{"HLRange", Srgb{150, 0, 150}, result});
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_; }
~IndHighLowRange() {}
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_; }
@@ -148,6 +148,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_historical_volatility(series, period);
lines_.push_back(Line{"HistVol", Srgb{150, 0, 150}, result});
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_; }
~IndHistoricalVolatility() {}
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_; }
@@ -160,6 +160,15 @@ private:
Srgb candle_up_color_ = Srgb{0, 150, 0};
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:
std::function<void(double, double)> on_view_change;
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),
x1_(x), y1_(y), x2_(x + width), y2_(y + height), series_(series),
period_(period), mult_(mult) {
auto result = ind_hurst_exponent(series, period);
lines_.push_back(Line{"Hurst", Srgb{150, 0, 150}, result});
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_; }
~IndHurstExponent() {}
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_; }
Loaded 100 of 253 files, more files were not shown because too many files have changed in this diff. Show more