Trading System API  3.0
Library for Simulating and Deploying Trading and Investment Strategies
TSCPane.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 
14 #ifndef _AESubchartInt_h_
15 #define _AESubchartInt_h_
16 
17 #include "TSCDef.h"
18 #include "TSCIncludes.h"
19 #include "TSCImage.h" // Image, Color, ColorManager classes definition
20 #include "TSCPaneHeader.h" // PaneHeaderWindow - generic header to SubCharts class def
21 #include "TSCPriceAxis.h" // Def of YAxisCalc class - Y-axis numbers processing
22 #include "TSCPlotArea.h"
23 
24 #include "TSCPropertyMap.h"
25 
26 namespace tsa {
27  //namespace graphics {
28  class time_master;
29  class TimeScale;
30  class pane_imp;
31  class plot_imp_base;
32  class DefaultPlotDef;
33  class FillArea;
34 
36 
37  class chart_maker;
38 
39  class pane_imp : public tsa::object, public chart_property_map {
40  friend class cm_pane_handle;
41  protected:
42  color_id m_YAxisTextColor_ID;
43  color_id m_XAxisTextColor_ID;
44  color_id m_PaneBackgroundColor_ID;
45  double m_dExtraTopBottomMarginPercent;
46  double m_dPaneMaxValue;
47  double m_dPaneMinValue;
48  bool m_bAdjustLow;
49  double m_dDesiredLow;
50  tsa::date_time m_StartTimestamp;
51  tsa::date_time m_EndTimestamp;
52  bool m_bIsDirty;
53  tsa::string m_sName;
54  public:
55  bool m_bShowHeader;
56  bool m_bPaintXAxisText;
57  double GetPaneMin(void)const;
58  double GetPaneMax(void)const;
59  void UpdatePaneMax(double _value);
60  void UpdatePaneMin(double _value);
61  void SetStartTimestamp(const tsa::date_time& _s);
62  void SetEndTimestamp(const tsa::date_time& _e);
63  public:
64  tsa::mem_table* m_mem_table_ptr;
65  chart_maker* m_chart_maker_ptr; //holds main data array
66  chart_maker* GetChartMaker(void)const { return m_chart_maker_ptr; }
67  std::vector<plot_imp_base*> m_Plots;
68  public: //****** H-LINE ********
69  struct HorizontalGridLine {
70  double dValue;
71  color_id iColor;
72  int iThickness;
73  };
74  std::vector<HorizontalGridLine> m_HorizontalGridLines; // Horizontal lines
75  void AddHLine(double value, const color_id&, size_t width);
76  public:
77  struct TrendLine {
78  tsa::date_time startDateTime;
79  tsa::date_time endDateTime;
80  double startPrice;
81  double endPrice;
82  color linecolor;
83  int weight;
84  int nY1;
85  int nY2;
86  };
87  std::vector<TrendLine> m_TrendLines;
88  void AddTrendLine(const tsa::date_time& _startDateTime,
89  double _startPrice, const tsa::date_time& _endDateTime,
90  double _endPrice, const color& color, int weight
91  );
92  public:
93  Window m_PaneWindow;
94  PaneHeaderWindow m_HeaderArea;
95  PlotWindow m_PlotWindow;
96  Window m_PlotAndAxisWindow;
97  Window m_XAxisTextWindow;
98  TimeAxisMan* m_pTimeAxisMan;
99  protected:
100  YAxisCalc m_YAxis; // Y-values scale calculator
101  int m_iTempHeight;
102  bool m_bAutoCalibrateYAxis; // true - automaticaly calc Y-scale axis values
103  bool m_bAutoScaleLines; // true - automaticaly draw horizontal lines
104  double m_dYAxisStep; // Step for scale, if AutoScale option turned on
105  double m_dStep; // Externally specified step for scale (AutoScale option turned off)
106  double m_dValueRange; // Distance between high and low limits
107  char m_axisFormat[16]; // Format for Y-axis
108 
109  bool m_bPaintingAllowed;
110  public:
111  PlotWindow* GetPlotWindow(void) { return &m_PlotWindow; }
112  int BarIdxToXPixel(size_t barIdx)const;
113  //int BarIdxToBarWidth(size_t barIdx)const;
114  int ValueToYPixel(double _value)const;
115  public:
116  void PaintHorizontalGridLineAndYAxisText();
117  void PaintXAxisText(void);
118  public:
119  void SetAreaFillYs(plot_imp_base* pscg);
120  void PaintAreaOfLine(FillArea& sca, LineXYs& lxy);
121  void DefineYAxisItems();
122  void AutodetectRange();
123  public:
124  pane_imp(color_manager*, size_t nHeight, TimeAxisMan*);
125  ~pane_imp(void);
126  public:
127  void RememberHeight(size_t _h) { m_iTempHeight = (int)_h; }
128  void CalculateAreaCoordinates(void);
129  public:
130  void AddTinyRightHeader(const tsa::string&);
131  void AddRightHeader(const tsa::string&);
132  void AddRightHeaderTimespanInfo(void);
133 
134  void AdjustLowTo(double _low);
135  bool AddToHeader(const char* pText, unsigned uOptions, long plotID);
136  void SetAxisFormat(char* sFormat);
137  int AddAxisItem(double dValue);
138  void AddAxisItems(int nItems, double* pdValues);
139  void SetAxisRange(double dLoLimit, double dHiLimit, double dStep, unsigned int uOptions);
140  public:
141  void SetHorzLineColor(double dAxisValue, color_id rgbHorzLine);
142  void AddLineAreas(int idGraph, double iLoLimit, double iHighLimit, color_id rgbArea);
143  public: //PLOTS
144 
145  void add_ohlc_plot(const chart_property_map& );
146  void add_jump_line_plot(const chart_property_map& );
147  void add_bar_plot(const chart_property_map& );
148  void add_area_plot(const chart_property_map& );
149  void add_line_plot(const chart_property_map& );
150  void add_multi_marker_plot(const chart_property_map& );
151  void add_orders_plot(const chart_property_map& );
152  void add_transact_plot(const chart_property_map& );
153 
154  /*long Add_OHLC_PLOT(
155  const std::string& _sourceOpen, const std::string& _sourceHigh,
156  const std::string& _sourceLow, const std::string& _sourceClose,
157  size_t width, const color& color);
158  long AddLinePlot(const std::string& _sourceFieldName, size_t width, const color& color);
159  long AddDiscontinuousLinePlot(const std::string& _valueFieldName,
160  const std::string& _jumpFieldName, size_t _width, const color& _color);
161  long AddBarPlot(const std::string& _sourceFieldName,
162  size_t width, const color& colorAbove, bool centerAtThreshold,
163  double threshold, const color& colorBelow, bool showAbove, bool showBelow);
164  long AddAreaPlot(const std::string& _sourceFieldName, const color& color, bool centerAtZero);
165 */
166  public:
167  void DrawXYAxis(void);
168  void PaintHeaderOutline(void);
169  void PaintHeader(void);
170  void PaintVerticalLinesAndBG(void);
171  void CalculateValueRange(void);
172  void PaintPlots(void); // plot lines
173  void PaintTrendLines(void);
174  public:
175  void DefineData(const tsa::mem_table&, size_t _startIdx, size_t _endIdx);
176  void GetTransactionsForInterval(const tsa::date_time&, std::vector<tsa::transaction>&)const;
177  public:
178  color GetNextAutoColor(void)const;
179  };
180  //}
181 }
182 
183 #endif
Namespace for the &#39;Trading System API&#39; library.
Definition: original1.TSA3Core.cpp:20
***** TRENDLINE *****
Definition: TSCPane.h:77
Parent class for many library classes.
Definition: TSATypeDef.h:462
x
Definition: TSCColor.h:23
Represents a color for use in graphics operations.
Definition: TSATypeDef.h:1041
Class representing a gregorian-date and time-of-day combination. The time component has microsecond r...
Definition: TSATime.h:428
Class mem_table represents a memory based table. mem_table objects can be used in strategies both for...
Definition: TSAMemTable.h:48