A simple example to treat MouseDown event on chart?
A simple example to treat MouseDown event on chart?
27 Nov 2018, 19:24
Hi,
I'm trying to use the new events added lately in the API,
but I don't even know where to start.
In MT5,
There is OnChartEvent() method available, to deal with events.
How would be we go in cTrader?
I would love a small example to Print() datetime and price when you click the chart.
ps.
It would be very useful to have more documentation and example using the API and creating indicators and bots.
Replies
if.mihai@gmail.com
28 Nov 2018, 10:59
@if.mihai@gmail.com
if.mihai@gmail.com
28 Nov 2018, 15:32
RE:
Panagiotis Charalampous said:
Hi Mihai,
Here it is
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { protected override void OnStart() { Chart.MouseDown += Chart_MouseDown; } private void Chart_MouseDown(ChartMouseEventArgs obj) { Print("Time: " + obj.TimeValue); Print("Price: " + obj.YValue); } protected override void OnTick() { // Put your core logic here } protected override void OnStop() { // Put your deinitialization logic here } } }We are working on the documentation as well :)
Best Regards,
Panagiotis
I tried to create an indicator based on this,
and tried like few hours (not kidding) to find the Log, where Print() prints
Just to find out (through a random post in forum), that a guy succeeded to Print(), by using a robot instead of indicator.
Ok, I copied-pasted exactly your code, creating a new bot, just to find out where is Log window in cTrader.
I saw a new tab, CBot Log, great, it works now.
But I have a question: isn't it logical to have also an Indicator Log too? Or is it already planned but not implemented yet?
@if.mihai@gmail.com
ClickAlgo
28 Nov 2018, 16:31
Hi,
You could also use this free plugin for logging information.
https://clickalgo.com/ctrader-cbot-indicator-data-logger
Paul.
@ClickAlgo
PanagiotisCharalampous
28 Nov 2018, 16:46
Hi Mihai,
At this moment, Indicators print only in the Log tab of the cTrader Automate section. We will enable them to print in the cBot Log as well in one of the future releases.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
28 Nov 2018, 10:01
Hi Mihai,
Here it is
We are working on the documentation as well :)
Best Regards,
Panagiotis
@PanagiotisCharalampous