openpine_vm/visuals/
plotcandle.rs

1use openpine_compiler::instructions::Color;
2use serde::{Deserialize, Serialize};
3
4use crate::{
5    series::Series,
6    visuals::{Bar, PlotDisplay, PlotFormat},
7};
8
9/// Plot candle series.
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct PlotCandle {
12    /// Plot title (`None` when the caller did not supply one).
13    pub title: Option<String>,
14    /// Per-bar OHLC values.
15    pub series: Series<Option<Bar>>,
16    /// Per-bar body color.
17    pub colors: Series<Option<Color>>,
18    /// Per-bar wick color.
19    pub wick_colors: Series<Option<Color>>,
20    /// Per-bar border color.
21    pub border_colors: Series<Option<Color>>,
22    /// Whether the plot is user-editable.
23    pub editable: bool,
24    /// Optional limit for the number of visible bars.
25    pub show_last: Option<usize>,
26    /// Display targets.
27    pub display: PlotDisplay,
28    /// Optional formatting hint.
29    pub format: Option<PlotFormat>,
30    /// Optional decimal precision.
31    pub precision: Option<i32>,
32    /// Whether to force overlay rendering.
33    pub force_overlay: bool,
34}
35
36impl PlotCandle {
37    pub(crate) fn append_new(&mut self) {
38        self.series.append_new();
39        self.colors.append_new();
40        self.wick_colors.append_new();
41        self.border_colors.append_new();
42    }
43}