Chart Summary Represents the Chart Interface.
Signature
public abstract interface Chart
Namespace cAlgo.API
Examples Example 1 (C#) Example 2 (PYTHON)
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170 using cAlgo.API ;
namespace cAlgo
{
// This sample indicator display's the chart data by using the current Chart object
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class ChartSample : Indicator
{
private Grid _grid ;
private TextBlock _mouseLocationTextBlock ;
private TextBlock _mouseWheelDeltaTextBlock ;
private TextBlock _objectsNumberTextBlock ;
protected override void Initialize ()
{
Chart . ChartTypeChanged += args => CreateAndAddGridToChart ();
Chart . ColorsChanged += args => CreateAndAddGridToChart ();
Chart . DisplaySettingsChanged += args => CreateAndAddGridToChart ();
Chart . Drag += args => CreateAndAddGridToChart ();
Chart . DragEnd += args => CreateAndAddGridToChart ();
Chart . DragStart += args => CreateAndAddGridToChart ();
Chart . IndicatorAreaAdded += args => CreateAndAddGridToChart ();
Chart . IndicatorAreaRemoved += args => CreateAndAddGridToChart ();
Chart . MouseMove += args =>
{
if ( _mouseLocationTextBlock == null )
return ;
_mouseLocationTextBlock . Text = string . Format ( "({0}, {1})" , args . MouseX , args . MouseY );
};
Chart . MouseLeave += args =>
{
if ( _mouseLocationTextBlock == null )
return ;
_mouseLocationTextBlock . Text = "(Null, Null)" ;
_mouseWheelDeltaTextBlock . Text = "0" ;
};
Chart . MouseWheel += args =>
{
if ( _mouseWheelDeltaTextBlock == null )
return ;
_mouseWheelDeltaTextBlock . Text = args . Delta . ToString ();
};
Chart . ObjectsAdded += args => _objectsNumberTextBlock . Text = Chart . Objects . Count . ToString ();
Chart . ObjectsRemoved += args => _objectsNumberTextBlock . Text = Chart . Objects . Count . ToString ();
Chart . ZoomChanged += args => CreateAndAddGridToChart ();
CreateAndAddGridToChart ();
}
public override void Calculate ( int index )
{
}
private void CreateAndAddGridToChart ()
{
if ( _grid != null )
Chart . RemoveControl ( _grid );
_grid = new Grid ( 10 , 2 )
{
BackgroundColor = Color . Gold ,
Opacity = 0.6 ,
HorizontalAlignment = HorizontalAlignment . Left ,
VerticalAlignment = VerticalAlignment . Bottom
};
var style = new Style ();
style . Set ( ControlProperty . Margin , 5 );
style . Set ( ControlProperty . FontWeight , FontWeight . ExtraBold );
style . Set ( ControlProperty . ForegroundColor , Color . Red );
_grid . AddChild ( new TextBlock
{
Text = "Height" ,
Style = style
}, 0 , 0 );
_grid . AddChild ( new TextBlock
{
Text = Chart . Height . ToString (),
Style = style
}, 0 , 1 );
_grid . AddChild ( new TextBlock
{
Text = "Width" ,
Style = style
}, 1 , 0 );
_grid . AddChild ( new TextBlock
{
Text = Chart . Width . ToString (),
Style = style
}, 1 , 1 );
_grid . AddChild ( new TextBlock
{
Text = "Zoom Level" ,
Style = style
}, 2 , 0 );
_grid . AddChild ( new TextBlock
{
Text = Chart . ZoomLevel . ToString (),
Style = style
}, 2 , 1 );
_grid . AddChild ( new TextBlock
{
Text = "Objects #" ,
Style = style
}, 3 , 0 );
_objectsNumberTextBlock = new TextBlock
{
Style = style ,
Text = Chart . Objects . Count . ToString ()
};
_grid . AddChild ( _objectsNumberTextBlock , 3 , 1 );
_grid . AddChild ( new TextBlock
{
Text = "Top Y" ,
Style = style
}, 4 , 0 );
_grid . AddChild ( new TextBlock
{
Text = Chart . TopY . ToString (),
Style = style
}, 4 , 1 );
_grid . AddChild ( new TextBlock
{
Text = "Bottom Y" ,
Style = style
}, 5 , 0 );
_grid . AddChild ( new TextBlock
{
Text = Chart . BottomY . ToString (),
Style = style
}, 5 , 1 );
_grid . AddChild ( new TextBlock
{
Text = "Type" ,
Style = style
}, 6 , 0 );
_grid . AddChild ( new TextBlock
{
Text = Chart . ChartType . ToString (),
Style = style
}, 6 , 1 );
_grid . AddChild ( new TextBlock
{
Text = "Mouse Location" ,
Style = style
}, 7 , 0 );
_mouseLocationTextBlock = new TextBlock
{
Style = style ,
Text = "(Null, Null)"
};
_grid . AddChild ( _mouseLocationTextBlock , 7 , 1 );
_grid . AddChild ( new TextBlock
{
Text = "Indicator Areas #" ,
Style = style
}, 8 , 0 );
_grid . AddChild ( new TextBlock
{
Text = Chart . IndicatorAreas . Count . ToString (),
Style = style
}, 8 , 1 );
_grid . AddChild ( new TextBlock
{
Text = "Mouse Wheel Delta" ,
Style = style
}, 9 , 0 );
_mouseWheelDeltaTextBlock = new TextBlock
{
Style = style ,
Text = "0"
};
_grid . AddChild ( _mouseWheelDeltaTextBlock , 9 , 1 );
Chart . AddControl ( _grid );
}
}
}
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 import clr
clr . AddReference ( "cAlgo.API" )
from cAlgo.API import *
class Test ():
def on_mouse_move ( self , args ):
if self . mouseLocationTextBlock is None :
return
self . mouseLocationTextBlock . Text = f "( { args . MouseX } , { args . MouseY } )"
def on_mouse_leave ( self , args ):
if self . mouseLocationTextBlock is None :
return
self . mouseLocationTextBlock . Text = "(Null, Null)"
self . mouseWheelDeltaTextBlock . Text = "0"
def on_mouse_wheel ( self , args ):
if self . mouseWheelDeltaTextBlock is None :
return
self . mouseWheelDeltaTextBlock . Text = str ( args . Delta )
def update_objects_count ( self ):
self . objectsNumberTextBlock . Text = str ( api . Chart . Objects . Count )
def get_text_block ( self , text ):
textBlock = TextBlock ()
textBlock . Text = text
textBlock . Style = self . style
return textBlock
def create_and_add_grid_to_chart ( self ):
if hasattr ( self , "grid" ) and self . grid is not None :
api . Chart . RemoveControl ( self . grid )
self . grid = Grid ( 10 , 2 )
self . grid . BackgroundColor = Color . Gold
self . grid . Opacity = 0.6
self . grid . HorizontalAlignment = HorizontalAlignment . Left
self . grid . VerticalAlignment = VerticalAlignment . Bottom
self . style = Style ()
self . style . Set ( ControlProperty . Margin , 5 )
self . style . Set ( ControlProperty . FontWeight , FontWeight . ExtraBold )
self . style . Set ( ControlProperty . ForegroundColor , Color . Red )
self . grid . AddChild ( self . get_text_block ( "Height" ), 0 , 0 )
self . grid . AddChild ( self . get_text_block ( str ( api . Chart . Height )), 0 , 1 )
self . grid . AddChild ( self . get_text_block ( "Width" ), 1 , 0 )
self . grid . AddChild ( self . get_text_block ( str ( api . Chart . Width )), 1 , 1 )
self . grid . AddChild ( self . get_text_block ( "Zoom Level" ), 2 , 0 )
self . grid . AddChild ( self . get_text_block ( str ( api . Chart . ZoomLevel )), 2 , 1 )
self . grid . AddChild ( self . get_text_block ( "Objects #" ), 3 , 0 )
self . objectsNumberTextBlock = self . get_text_block ( str ( api . Chart . Objects . Count ))
self . grid . AddChild ( self . objectsNumberTextBlock , 3 , 1 )
self . grid . AddChild ( self . get_text_block ( "Top Y" ), 4 , 0 )
self . grid . AddChild ( self . get_text_block ( str ( api . Chart . TopY )), 4 , 1 )
self . grid . AddChild ( self . get_text_block ( "Bottom Y" ), 5 , 0 )
self . grid . AddChild ( self . get_text_block ( str ( api . Chart . BottomY )), 5 , 1 )
self . grid . AddChild ( self . get_text_block ( "Type" ), 6 , 0 )
self . grid . AddChild ( self . get_text_block ( str ( api . Chart . ChartType )), 6 , 1 )
self . grid . AddChild ( self . get_text_block ( "Mouse Location" ), 7 , 0 )
self . mouseLocationTextBlock = self . get_text_block ( "(Null, Null)" )
self . grid . AddChild ( self . mouseLocationTextBlock , 7 , 1 )
self . grid . AddChild ( self . get_text_block ( "Indicator Areas #" ), 8 , 0 )
self . grid . AddChild ( self . get_text_block ( str ( api . Chart . IndicatorAreas . Count )), 8 , 1 )
self . grid . AddChild ( self . get_text_block ( "Mouse Wheel Delta" ), 9 , 0 )
self . mouseWheelDeltaTextBlock = self . get_text_block ( "0" )
self . grid . AddChild ( self . mouseWheelDeltaTextBlock , 9 , 1 )
api . Chart . AddControl ( self . grid )
def initialize ( self ):
api . Chart . ChartTypeChanged += lambda _ : self . create_and_add_grid_to_chart ()
api . Chart . ColorsChanged += lambda _ : self . create_and_add_grid_to_chart ()
api . Chart . DisplaySettingsChanged += lambda _ : self . create_and_add_grid_to_chart ()
api . Chart . Drag += lambda _ : self . create_and_add_grid_to_chart ()
api . Chart . DragEnd += lambda _ : self . create_and_add_grid_to_chart ()
api . Chart . DragStart += lambda _ : self . create_and_add_grid_to_chart ()
api . Chart . IndicatorAreaAdded += lambda _ : self . create_and_add_grid_to_chart ()
api . Chart . IndicatorAreaRemoved += lambda _ : self . create_and_add_grid_to_chart ()
api . Chart . ZoomChanged += lambda _ : self . create_and_add_grid_to_chart ()
api . Chart . MouseMove += self . on_mouse_move
api . Chart . MouseLeave += self . on_mouse_leave
api . Chart . MouseWheel += self . on_mouse_wheel
api . Chart . ObjectsAdded += lambda _ : self . update_objects_count ()
api . Chart . ObjectsRemoved += lambda _ : self . update_objects_count ()
self . create_and_add_grid_to_chart ()
Methods Summary
Scrolls the chart by the X-axis for the specified number of bars.
Signature
public abstract void ScrollXBy ( int bars )
Parameters
Name Type Description bars int The number of bars
Return Value
void
ScrollXTo (1 of 2)
Summary
Scrolls the chart by the X-axis to the bar with the specified index.
Signature
public abstract void ScrollXTo ( int barIndex )
Parameters
Name Type Description barIndex int The index of the bar.
Return Value
void
ScrollXTo (2 of 2)
Summary
Scrolls the chart by the X-axis to the specified date time.
Signature
public abstract void ScrollXTo ( DateTime time )
Parameters
Name Type Description time DateTime The X-axis date time
Return Value
void
SetBarColor Summary
Sets the color of the bar at the specified bar index. It will change the bar fill color and the outline color.
Signature
public abstract void SetBarColor ( long barIndex , Color color )
Parameters
Name Type Description barIndex long The bar index number color Color The color for the bar
Return Value
void
SetBarFillColor Summary
Sets the fill color of the bar at the specified bar index.
Signature
public abstract void SetBarFillColor ( long barIndex , Color color )
Parameters
Name Type Description barIndex long The bar index number color Color The color for filling the bar
Return Value
void
SetBarOutlineColor Summary
Sets the outline color of the bar at the specified bar index.
Signature
public abstract void SetBarOutlineColor ( long barIndex , Color color )
Parameters
Name Type Description barIndex long The bar index number color Color The color for bar outline
Return Value
void
SetTickVolumeColor Summary
Sets the color of tick volume line at the specified bar index.
Signature
public abstract void SetTickVolumeColor ( long barIndex , Color color )
Parameters
Name Type Description barIndex long The bar index number color Color The color for bar tick volume
Return Value
void
ResetBarColor Summary
Resets the color of the bar to the default.
Signature
public abstract void ResetBarColor ( long barIndex )
Parameters
Name Type Description barIndex long The bar index number
Return Value
void
ResetBarColors Summary
Resets the colors of all the bars.
Signature
public abstract void ResetBarColors ()
Return Value
void
ResetTickVolumeColor Summary
Resets the color of the tick volume line to the default at the specified bar index.
Signature
public abstract void ResetTickVolumeColor ( long barIndex )
Parameters
Name Type Description barIndex long The bar index number
Return Value
void
ResetTickVolumeColors Summary
Resets the color of all the tick volume bars.
Signature
public abstract void ResetTickVolumeColors ()
Return Value
void
AddHotkey (4) AddHotkey (1 of 4)
Summary
Adds an hotkey to the chart that will call the handler when pressed
Signature
public abstract bool AddHotkey ( Action < ChartKeyboardEventArgs > hotkeyHandler , Key key , ModifierKeys modifiers )
Parameters
Name Type Description hotkeyHandler Action The action delegate handler that will be called with a ChartKeyboardEventArgs key Key The Hotkey main key modifiers ModifierKeys The hotkey modifier key, default to None which means no modifer key
Return Value
bool
See Also
AddHotkey (2 of 4)
Summary
Adds an hotkey to the chart that will call the handler when pressed
Signature
public abstract bool AddHotkey ( Action < ChartKeyboardEventArgs > hotkeyHandler , string hotkey )
Parameters
Name Type Description hotkeyHandler Action The action delegate handler that will be called with a ChartKeyboardEventArgs hotkey string The keyboard key for hotkey
Return Value
bool
See Also
AddHotkey (3 of 4)
Summary
Adds an hotkey to the chart that will call the handler when pressed
Signature
public abstract bool AddHotkey ( Action hotkeyHandler , Key key , ModifierKeys modifiers )
Parameters
Name Type Description hotkeyHandler Action The action delegate handler that will be called key Key The Hotkey main key modifiers ModifierKeys The hotkey modifier key, default to None which means no modifer key
Return Value
bool
AddHotkey (4 of 4)
Summary
Adds an hotkey to the chart that will call the handler when pressed
Signature
public abstract bool AddHotkey ( Action hotkeyHandler , string hotkey )
Parameters
Name Type Description hotkeyHandler Action The action delegate handler that will be called hotkey string The keyboard key for hotkey
Return Value
bool
TryChangeTimeFrame Summary
Changes the time frame on the chart.
Signature
public abstract bool TryChangeTimeFrame ( TimeFrame timeFrame )
Parameters
Name Type Description timeFrame TimeFrame The time frame to change the current chart time frame to
Return Value
bool
TryChangeTimeFrameAndSymbol Summary
Changes the time frame and the symbol on the chart.
Signature
public abstract bool TryChangeTimeFrameAndSymbol ( TimeFrame timeFrame , string symbolName )
Parameters
Name Type Description timeFrame TimeFrame The time frame to change the current chart time frame to symbolName string The symbol name to change the current chart symbol to
Return Value
bool
TakeChartshot Summary
Takes a chartshot from the chart that indicator / cBot runs on.
Remarks
TakeChartshot only works if chart is visible.
Signature
public abstract byte [] TakeChartshot ()
Return Value
byte[]
See Also
Related Tutorials
DrawRiskReward (2) DrawRiskReward (1 of 2)
Summary
Draws a risk reward.
Signature
public abstract ChartRiskReward DrawRiskReward ( string name , int barIndex1 , int barIndex2 , double entryPrice , OrderType orderType , TradeType tradeType , ChartRiskRewardType type )
Parameters
Name Type Description name string The chart object name - a unique name that can be only used once for a chart. If duplicated, the chart object will be replaced with a new one of the same name. barIndex1 int Bar index of start point barIndex2 int Bar index of end point entryPrice double Entry price orderType OrderType Order type tradeType TradeType Trade type for risk reward type ChartRiskRewardType Type of risk reward
Return Value
ChartRiskReward
Examples
var riskRewardType = new ChartRiskRewardFixedRiskType ( ChartRiskRewardAmountType . EquityPercentage , 1 );
var riskReward = Chart . DrawRiskReward ( "RR" , Chart . LastVisibleBarIndex - 10 , Chart . LastVisibleBarIndex , Bars . ClosePrices [ Chart . LastVisibleBarIndex ], OrderType . Market , TradeType . Buy , riskRewardType );
See Also
DrawRiskReward (2 of 2)
Summary
Draws a risk reward.
Signature
public abstract ChartRiskReward DrawRiskReward ( string name , DateTime time1 , DateTime time2 , double entryPrice , OrderType orderType , TradeType tradeType , ChartRiskRewardType type )
Parameters
Name Type Description name string The chart object name - a unique name that can be only used once for a chart. If duplicated, the chart object will be replaced with a new one of the same name. time1 DateTime Time of start point time2 DateTime Time of end point entryPrice double Entry price orderType OrderType Order type tradeType TradeType Trade type for risk reward type ChartRiskRewardType Type of risk reward
Return Value
ChartRiskReward
Examples
var riskRewardType = new ChartRiskRewardFixedSizeType ( 1000 );
var riskReward = Chart . DrawRiskReward ( "RR" , Bars . OpenTimes [ Chart . LastVisibleBarIndex - 10 ], Bars . OpenTimes [ Chart . LastVisibleBarIndex ], Bars . ClosePrices [ Chart . LastVisibleBarIndex ], OrderType . Market , TradeType . Buy , riskRewardType );
See Also
Properties Id Summary
Gets the unique Id of Chart.
Signature
public abstract Guid Id { get ;}
Return Value
Guid
IndicatorAreas Summary
Gets the read only list of the indicator areas.
Signature
public abstract IReadonlyList < IndicatorArea > IndicatorAreas { get ;}
Return Value
IReadonlyList
DisplaySettings Summary
Gets the chart display settings.
Signature
public abstract ChartDisplaySettings DisplaySettings { get ;}
Return Value
ChartDisplaySettings
ColorSettings Summary
Gets the chart color settings.
Signature
public abstract ChartColorSettings ColorSettings { get ;}
Return Value
ChartColorSettings
ChartType Summary
Gets or sets the type of the chart - Bar, Candlesticks, Line or Dots chart.
Signature
public abstract ChartType ChartType { get ; set ;}
Return Value
ChartType
ZoomLevel Summary
Gets or sets the zoom percent values. Valid values are from 5 to 500 with a step of 5, as can be seen on UI in thecharts Zoom control.
Signature
public abstract int ZoomLevel { get ; set ;}
Return Value
int
FirstVisibleBarIndex Summary
Gets the index of the first visible bar on the chart.
Signature
public abstract int FirstVisibleBarIndex { get ;}
Return Value
int
LastVisibleBarIndex Summary
Gets the index of the last visible bar on the chart.
Signature
public abstract int LastVisibleBarIndex { get ;}
Return Value
int
MaxVisibleBars Summary
Gets the maximum number of the visible bars on the chart.
Signature
public abstract int MaxVisibleBars { get ;}
Return Value
int
BarsTotal Summary
Gets the total number of the bars on the chart.
Signature
public abstract int BarsTotal { get ;}
Return Value
int
Bars Summary
Gets the chart Bar objects.
Signature
public abstract Bars Bars { get ;}
Return Value
Bars
Related Tutorials
TimeFrame Summary
Gets the time frame of the chart from 1 minute to 1 month.
Signature
public abstract TimeFrame TimeFrame { get ;}
Return Value
TimeFrame
Symbol Summary
Gets the chart symbol.
Signature
public abstract Symbol Symbol { get ;}
Return Value
Symbol
SymbolName Summary
Gets the symbol name.
Signature
public abstract string SymbolName { get ;}
Return Value
string
Summary
Gets or sets the value indicating whether the scrolling is enabled or disabled for the chart. If disabled, then thechart is not affected by scrolling, dragging, scaling, or pressing any keyboard keys, but is still affected byresizing, zooming, and API calls for changing X or Y-axis positions on the chart.
Signature
public abstract bool IsScrollingEnabled { get ; set ;}
Return Value
bool
IsActive Summary
True if Chart is active otherwise False
Signature
public abstract bool IsActive { get ;}
Return Value
bool
IsVisible Summary
True if Chart is visible otherwise False.
Signature
public abstract bool IsVisible { get ;}
Return Value
bool
Indicators Summary
Gets the ChartIndicators operating on a chart.
Signature
public abstract ChartIndicators Indicators { get ;}
Return Value
ChartIndicators
Related Tutorials
Robots Summary
Gets the ChartRobots operating on a chart.
Signature
public abstract ChartRobots Robots { get ;}
Return Value
ChartRobots
Events Activated Summary
Occurs when chart is activated
Signature
public abstract event Action < ChartActivationChangedEventArgs > Activated ;
See Also
Deactivated Summary
Occurs when chart is deactivated
Signature
public abstract event Action < ChartActivationChangedEventArgs > Deactivated ;
See Also
DisplaySettingsChanged Summary
Occurs when one or several charts display settings change.
Signature
public abstract event Action < ChartDisplaySettingsEventArgs > DisplaySettingsChanged ;
ColorsChanged Summary
Occurs when the chart color settings change.
Signature
public abstract event Action < ChartColorEventArgs > ColorsChanged ;
ChartTypeChanged Summary
Occurs when the chart type changes.
Signature
public abstract event Action < ChartTypeEventArgs > ChartTypeChanged ;
ZoomChanged Summary
Occurs when the chart zoom options change.
Signature
public abstract event Action < ChartZoomEventArgs > ZoomChanged ;
IndicatorAreaAdded Summary
Occurs when the indicator area is added.
Signature
public abstract event Action < IndicatorAreaAddedEventArgs > IndicatorAreaAdded ;
IndicatorAreaRemoved Summary
Occurs when the indicator area is removed.
Signature
public abstract event Action < IndicatorAreaRemovedEventArgs > IndicatorAreaRemoved ;
KeyDown Summary
Occurs when a keyboard key pressed while the mouse cursor is over the chart
Signature
public abstract event Action < ChartKeyboardEventArgs > KeyDown ;
VisibilityChanged Summary
Occurs when chart visibility changes.
Signature
public abstract event Action < ChartVisibilityChangedEventArgs > VisibilityChanged ;
See Also