Trading System API  3.0
Library for Simulating and Deploying Trading and Investment Strategies
TSCPlots.h
1 /* ===================================================================
2 *
3 * T R A D I N G S Y S T E M A P I ™
4 * Copyright © 1999 - 2014 by Peter Ritter ( TradingSystemAPI.com )
5 * A L L R I G H T S R E S E R V E D
6 *
7 * Consult your license regarding permissions and restrictions.
8 * You may obtain a copy of the License at:
9 * http://www.TradingSystemAPI.com/licenses/LICENSE-TSAPI-3.0.html
10 *
11 * ====================================================================
12 */
13 #ifndef __TSC_PLOT_H
14 #define __TSC_PLOT_H
15 
16 #include "TSCPropertyMap.h"
17 #include "TSCShapes.h"
18 
19 namespace tsa {
20 
21  class chart;
22 
24  namespace plot {
25 
29  class plot_base {
31  public:
32  enum plot_type_t {
33  UNDEFINED,
34  OHLC_BAR,
35  BAR,
36  AREA,
37  LINE,
38  MARKER,
39  MULTI_MARKER,
40  ORDERS_INFO,
41  TRANS_INFO
42  };
43  public:
44  size_t m_num_series;
45  tsa::variant m_values[10];
46  public:
47  plot_type_t m_type;
48  size_t m_weight;
49  bool m_dynamic_color;
50  color m_color_primary;
51  color m_color_secondary;
52  int m_jump_signal;
53  bool m_has_pivot;
54  double m_pivot;
55  marker_t m_marker_type;
56  public:
58  plot_base(void);
60  plot_base(plot_type_t _t, const tsa::variant& _v, const color& _pc,
61  const color& _sc, size_t _w, bool _dc, int _js, bool _has_pivot, double _piv);
63  plot_base(plot_type_t _t, size_t _nv, const color& _pc, const color& _sc, size_t _w, bool _dc,
64  int _js, bool _has_pivot, double _piv);
66  ~plot_base(void);
67  };
68 
70 
72  class marker : public plot_base {
73  public:
75  explicit marker(
76  marker_t type,
77  variant y_value,
78  const color& color = color::auto_color,
79  size_t weight = DEFAULT_WEIGHT
80  );
82  ~marker(void);
83  };
84 
86  class multi_marker : public plot_base {
87  public:
88  // @brief Constructor.
89  /* explicit multi_marker(
90  marker_t type, ///< The type of marker.
91  const std::string& csv_values, ///< A comma separated list of y-values (prices) on which shapes will be drawn (e.g. "100.0, 101.0, 102.0").
92  const color& color = color::auto_color, ///< The shape color.
93  size_t weight = DEFAULT_WEIGHT ///< The weight with which the shapes are to be drawn.
94  );*/
95 
97  explicit multi_marker(
98  marker_t type,
99  const std::vector<double>& y_values,
100  const color& color = color::auto_color,
101  size_t weight = DEFAULT_WEIGHT);
102 
104  ~multi_marker(void);
105  };
106 
108  class transactions : public plot_base {
109  public:
111  explicit transactions(tsa::instrument& inst);
113  ~transactions(void);
114  };
115 
116 
118  class orders : public plot_base {
119  public:
121  explicit orders(tsa::instrument& inst);
123  ~orders(void);
124  };
125 
127  class line : public plot_base {
128  public:
130  explicit line(
131  const tsa::variant& value,
132  const color& color = color::auto_color,
133  size_t weight = DEFAULT_WEIGHT,
134  bool dynamic_color = false,
135  int jump_signal = (-1)
136  );
138  ~line(void);
139  };
140 
144 
145  class rbar : public plot_base {
146  public:
148  explicit rbar(
149  const tsa::variant& value,
150  const color& color = color::auto_color,
151  size_t weight = DEFAULT_WEIGHT,
152  bool dynamicColor = false
153  );
155  explicit rbar(
156  const tsa::variant& value,
157  const color& color_primary,
158  const color& color_secondary,
159  size_t weight = DEFAULT_WEIGHT
160  );
162  ~rbar(void);
163  };
164 
166 
169  class bar : public plot_base {
170  public:
172  explicit bar(
173  const tsa::variant& value,
174  const color& color = color::auto_color,
175  size_t weight = DEFAULT_WEIGHT,
176  bool dynamicColor = false
177  );
179  explicit bar(
180  const tsa::variant& value,
181  const color& colorPrim,
182  const color& colorSec,
183  size_t weight = DEFAULT_WEIGHT
184  );
186  ~bar(void);
187  };
188 
190 
194 
195  class rarea : public plot_base {
196  public:
198  explicit rarea(
199  const tsa::variant& value,
200  const color& color = color::auto_color,
201  bool dynamic_color = false,
202  int jump_signal = (-1),
203  bool has_pivot = false,
204  double pivot = 0.0
205  );
207  ~rarea(void);
208  };
209 
211 
213  class area : public plot_base {
214  public:
216  explicit area(
217  const tsa::variant& value,
218  const color& color = color::auto_color,
219  bool dynamic_color = false,
220  int jumpSignal = (-1)
221  );
223  explicit area(
224  const tsa::variant& value,
225  const color& color_prim,
226  const color& color_sec,
227  int jumpSignal = (-1)
228  );
230  ~area(void);
231  };
232 
234 
236  class ohlc : public plot_base {
237  public:
239  explicit ohlc(
240  const tsa::variant& op,
241  const tsa::variant& hi,
242  const tsa::variant& lo,
243  const tsa::variant& cl,
244  const color& col = color::gold,
245  size_t weight = DEFAULT_WEIGHT,
246  bool dynamic_color = false);
247 
249  explicit ohlc(
250  const tsa::in_stream&,
251  const color& col = color::gold,
252  size_t weight = DEFAULT_WEIGHT,
253  bool dynamic_color = false
254  );
255 
257  explicit ohlc(
258  const tsa::instrument&,
259  const color& col = color::gold,
260  size_t weight = DEFAULT_WEIGHT,
261  bool dynamic_color = false
262  );
263 
265  ~ohlc(void);
266  };
267 
269 
271  class hlc : public plot_base {
272  public:
274  explicit hlc(
275 
276  const tsa::variant& h,
277  const tsa::variant& l,
278  const tsa::variant& c,
279  const color& col = color::auto_color,
280  size_t weight = DEFAULT_WEIGHT,
281  bool dynamic_color = false
282  );
284  explicit hlc(
285  const tsa::in_stream&,
286  const color& col = color::auto_color,
287  size_t weight = DEFAULT_WEIGHT,
288  bool dynamic_color = false
289  );
291  explicit hlc(
292  const tsa::instrument&,
293  const color& col = color::auto_color,
294  size_t weight = DEFAULT_WEIGHT,
295  bool dynamic_color = false
296  );
298  ~hlc(void);
299  };
300 
302  //Combinations plots
303 
305  class area_line {
306  public:
307  color m_areaColor;
308  color m_altAreaColor;
309  color m_lineColor;
310  double m_dValue;
311  public:
313  explicit area_line(
314  double value,
315  const color& area_color = color::aquamarine,
316  const color& alt_area_color = color::dim_gray,
317  const color& line_color = color::white
318  );
319  };
320 
322 
325  class position {
326  public:
327  const instrument* m_instrument_ptr;
328  public:
330  explicit position(const instrument& c);
331  };
332 
334 
335  }//plot
336 
337 
339  chart& operator<<(chart&, const plot::area_line&);
340 
342  chart& operator<<(chart&, const plot::position&);
343 
344  // }//graphics
345 
346 }//tsa
347 
348 #endif
Plots an &#39;area&#39; on a chart pane. Plots are drawn from the lowest y-value to the current y-value...
Definition: TSCPlots.h:195
marker_t
Used by plot::marker and plot::multi_marker.
Definition: TSCShapes.h:28
Class representing a timeseries chart.
Definition: TSCWrapper.h:147
Namespace for the &#39;Trading System API&#39; library.
Definition: original1.TSA3Core.cpp:20
static const color auto_color
Definition: TSATypeDef.h:1099
static const color white
Definition: TSATypeDef.h:1201
Order Log.
Definition: TSATypeDef.h:429
Parent class for all plot types.
Definition: TSCPlots.h:30
Plots bars on a chart pane representing the current open position for a given instrument.
Definition: TSCPlots.h:325
Plots a &#39;bars&#39; on a chart pane where bars are drawn from the zero line. Bars essentially oscillate ar...
Definition: TSCPlots.h:169
Plots a &#39;bar plot&#39; on a chart pane. Bars are drawn from the lowest y-value to the current y-value...
Definition: TSCPlots.h:145
~plot_base(void)
Definition: TSCPlots.cpp:275
Plots an high/low/close series on a chart pane.
Definition: TSCPlots.h:271
plot_base(void)
Constructor.
Definition: TSCPlots.cpp:246
variant objects can represent values of different types.
Definition: TSAVariant.h:140
static const color aquamarine
Definition: TSATypeDef.h:1269
static const color gold
Definition: TSATypeDef.h:1315
Transaction Log.
Definition: TSATypeDef.h:427
Plots a &#39;line plot&#39; on a chart pane.
Definition: TSCPlots.h:127
static const color dim_gray
Definition: TSATypeDef.h:1207
Combines and area and line plot.
Definition: TSCPlots.h:305
Represents a color for use in graphics operations.
Definition: TSATypeDef.h:1041
Simply plots a &#39;marker&#39; which is a shape.
Definition: TSCPlots.h:72
Record stream class. Represents a standardised interface to all data sources. Instances rely on deleg...
Definition: TSAStreams.h:336
Plots multiple &#39;markers&#39; which are &#39;shapes&#39;.
Definition: TSCPlots.h:86
Draws all transactions related to the given instrument object on a chart pane.
Definition: TSCPlots.h:108
Plots an &#39;open,high,low,close&#39; series on a chart pane.
Definition: TSCPlots.h:236
Plots a series as an &#39;area plot&#39; on a chart pane.
Definition: TSCPlots.h:213
Class instrument represents a tradeable security such as a stock, option, futures contract...
Definition: TSAInstrument.h:64
Paints all orders generated by the given instrument object on a chart pane.
Definition: TSCPlots.h:118