1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//! Core indicator trait and value types.
//!
//! This module defines the [`Indicator`] trait that every technical indicator
//! (built-in or custom) must implement, as well as the [`IndicatorValue`]
//! enum used to represent computed output at each bar.
use crateBar;
use Color32;
/// The output value of an indicator at a single bar position.
///
/// Indicators produce one `IndicatorValue` per input [`Bar`]. The variant
/// depends on the indicator:
///
/// - **`Single(f64)`** -- used by single-line indicators (SMA, EMA, RSI, ATR, ...).
/// - **`Multiple(Vec<f64>)`** -- used by multi-line indicators. For example,
/// MACD emits `[macd_line, signal_line, histogram]` and Bollinger Bands
/// emits `[upper, middle, lower]`.
/// - **`None`** -- emitted for bars that fall within the indicator's warmup
/// period (i.e. not enough prior data to compute a value).
/// The core trait that every technical indicator must implement.
///
/// The trait defines the full indicator lifecycle: naming, calculation,
/// value access, color management, and display properties. It is
/// object-safe so indicators can be stored as `Box<dyn Indicator>` in
/// the [`IndicatorRegistry`](super::IndicatorRegistry).
///
/// # Implementors
///
/// All 150+ built-in indicators implement this trait (e.g. [`SMA`](super::SMA),
/// [`RSI`](super::RSI), [`MACD`](super::MACD)), and users can implement it
/// for their own indicators or use [`CustomIndicator`](super::CustomIndicator)
/// to define one at runtime via a closure.
///
/// # Lifecycle
///
/// 1. Construct the indicator with desired parameters.
/// 2. Call [`calculate`](Indicator::calculate) with bar data.
/// 3. Read results via [`values`](Indicator::values).
/// 4. The rendering layer queries [`is_overlay`](Indicator::is_overlay),
/// [`colors`](Indicator::colors), [`line_names`](Indicator::line_names),
/// etc. for drawing.
/// Blanket `Clone` implementation for boxed indicators, delegating to
/// [`Indicator::clone_box`].