This user guide explains how to use the
TakeChartshot() method when creating cTrader algorithms. If you are eager to get started, simply read our one-minute summary below.
Chartshot Methods in One Minute!
TakeChartshot()method allows cTrader algos to take chartshots of the charts on which they are running but only if this chart is visible.
- Chartshots are a great tool to communicate with other traders and share technical analysis. With the
TakeChartshot()method, this process becomes easier than ever!
TakeChartshot()method returns an array of bytes, meaning that you can easily share chartshots as
.PNGfiles. You can also share the chartshot on the Internet using the network access feature.
TakeChartshot()method is essential if you want to make chartshots whenever your algos do something (e.g., when a cBot places an order). This feature provides a great visual aid for anyone who wants to evaluate how their solutions perform without keeping an eye on the chart 24/7.
How to Use the
Chartshots offer a way to quickly create screenshots of trading charts. If you create a chartshot manually via the cTrader toolbar, the screenshot is saved on your local machine in addition to being automatically uploaded to a special portal that offers several ways via which you can share it (e.g., via embeddable HTML code).
In turn, our API allows for making chartshots automatically. In contrast to regular chartshots, chartshots made by cTrader algos are not saved anywhere by default. Instead, such chartshots are returned as byte arrays that you are free to save wherever you want by specifying an additional action in the code.
byte TakeChartshot() method works as follows.
byte TakeChartshot(). Takes a chartshot of the chart on which the algorithm is running and returns it as an array of bytes.
Note that the method only works if a chart is visible. To allow for easily checking chart visibility, the
Chart interface includes the
IsVisible property. It is equal to
true for a visible chart and
false for an invisible one.
Chartshots in Backtesting and Optimization
- In optimization and non-visual backtesting, the
TakeChartshot()method always returns
nulland invokes the
OnException()handler if you have specified it.
- In visual mode backtesting, the method works as intended.
Creating an Example cBot¶
To demonstrate how taking chartshots automatically works, we will create a simple cBot that will make a chartshot of the current chart and save it in the family system of your local machine.
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
On start, the
.PNG file containing the chartshot of the chart to which we have attached the cBot instance will be added to
TakeChartshot() method allows cTrader algos to make easily sharable chartshots, making it essential for anyone who wants to share information with other traders or track how their automated solutions perform in response to certain conditions. This method is also usable in visual backtesting, allowing you to easily match the actions of your cBots to events occurring on charts.