Chart Events
Chart Events
10 May 2019, 10:03
Dear Panagiotis!
Thank you for the previous answer. It help.
Another issue I have to deal with is the memory.
I 'll explaing
I built a porfolio, where I may change the orders parameters (Stop loss, Take Profit, size of the order based on the Stop Loss)
If I want to make this changes online, fast (the timeframe is at least one hour), then I have to put the logic on tick.
Question: is it possible to start some kind of chart event, when , for example, I move a stop loss of the order?
In that case I would not need OnTick (which is processor intensive), but rather raise and event
Regards, Alexander
Replies
alexander.n.fedorov
10 May 2019, 10:38
Panagiotis!
Well, thank you , but it would not help. I will need to change a whole set of parameters, as event occur, and it could not wait for the timer, unless, I make interval very small, which will still keep processor busy.
Are not there any chart events? I just don't know how to use them
Regards,
Alexander
@alexander.n.fedorov
PanagiotisCharalampous
10 May 2019, 10:49
Hi Alexander,
What chart events are you looking for? You can find all available chart events here.
Best Regards,
Panagiotis
@PanagiotisCharalampous
alexander.n.fedorov
10 May 2019, 11:03
ChartArea.MouseUp
That is the event .
I just do not know how to grammar it
Please help
Alexander
@alexander.n.fedorov
PanagiotisCharalampous
10 May 2019, 11:18
Hi Alexander,
See below
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 { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } protected override void OnStart() { Chart.MouseUp += OnChartMouseUp; } void OnChartMouseUp(ChartMouseEventArgs obj) { Print("Mouse up event triggered"); } protected override void OnTick() { // Put your core logic here } protected override void OnStop() { // Put your deinitialization logic here } } }
Best Regards,
Panagiotis
@PanagiotisCharalampous
alexander.n.fedorov
10 May 2019, 11:30
Does this even works only if Mouse on chart?
And relates only to the Chart?
@alexander.n.fedorov
PanagiotisCharalampous
10 May 2019, 11:41
Hi Alexander,
Yes it works when occurs when the left mouse button is released inside the chart area.
Best Regards,
Panagiotis
@PanagiotisCharalampous
alexander.n.fedorov
10 May 2019, 11:53
RE:
Panagiotis Charalampous said:
Hi Alexander,
Yes it works when occurs when the left mouse button is released inside the chart area.
Best Regards,
Panagiotis
Thank you, but it does not seem to work
I have a function
ProcessOrders();
which works perfectly OnTick ()
and does not work on evnet
Regards
Sasha
@alexander.n.fedorov
PanagiotisCharalampous
10 May 2019, 11:59
Hi Sasha,
Can you please provide more information e.g. the cBot code? What do you mean it doesn't work? Is the event not triggered? Did you try the sample I sent? Does it print the message in the log on MouseUp?
Best Regards,
Panagiotis
@PanagiotisCharalampous
alexander.n.fedorov
10 May 2019, 12:46
I will explain. It works in a certain way
My Bot is semi-automatic
When I start it it builds Zones of Demand and Supply
While the Bot is working I can place orders
I can put like Buy Limit order, and move the handles to make the SL and TP
then I ModifiyOrder(order, null, null)
in the mean time I record the values of SL and TP into array and delete the old orders (with any volume) and initiate new ones, volume is calculated based on SL
OnTick() everything was changing, so the SL & TP stayed on my VPS only and On Tick () it was checking the SL value and TP value
Then I wanted ot change onTick to OnBar when the candle closes below or above the array number. I also draw lines, to make it visible
First time I tried Mouse even was right click placing the limit order, then left click moving the hadles.
At that point I would think the event would work. But it did not. I discovered that it will work if after the whole procedrure I will click left button on the chart again.
I think it is one of my best bots, if you interested, I could send you the bot and more details
Regards,
Sasha
@alexander.n.fedorov
PanagiotisCharalampous
10 May 2019, 10:11
Hi Alexander,
You can consider Timer which allows you to execute actions on a specific interval.
Best Regards,
Panagiotis
@PanagiotisCharalampous