How to get datetime1, datetime2 on the chart

Created at 05 Jan 2021, 17:28
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
IM

imrealfighter

Joined 09.11.2020

How to get datetime1, datetime2 on the chart
05 Jan 2021, 17:28


Hello There! everyone needs some help here. 
how do we get datetime1, datetime2 on the chart 

as I try to create a trendline when it's on Y-axis we could use Chart.TopY; and Chart.BottomY; to set where the trendline should be drawn on the chart at the beginning.

but what about X-axis how do we get datetime1(left),datetime2(right) on the current chart?


Thank you. 

 


@imrealfighter
Replies

... Deleted by UFO ...

imrealfighter
07 Jan 2021, 03:01 ( Updated at: 07 Jan 2021, 03:09 )

RE:

strongResistance said:

the actual bar gives you your x-axis (bar.OpenTime [datetime]). The price gives you your y-axis (the bar, Open, high, Low or close)

this.Chart.DrawRectangle("RectBU", pos.EntryTime, pos.EntryPrice, curBar.OpenTime, curBar.Open, this.Bullish_Box_Color);

the line above draws a rectangle from an entry-time & price to a bar open time & price

I hope this helps.

KF

Hi There strongResistance(KF) first of all thank you for your kind and help.

just to clarify more my point on finding datetime1, datetime2 is when I draw Trendline I want it to be drawn on the current chart (can see it immediately by our eyes on the chart).

so maybe we need a datetime1 and datetime2 that correspond to the chart. Have you ever tried to use  Chart.TopY; and Chart.BottomY; it gives us the highest and the lowest price on the scale chart at that time. 

 

 


@imrealfighter

imrealfighter
07 Jan 2021, 03:05 ( Updated at: 07 Jan 2021, 03:09 )

RE: RE:

^^^^ duplicated above comment ^^^^

 


@imrealfighter

imrealfighter
07 Jan 2021, 05:45

RE: RE:

imrealfighter said:

strongResistance said:

the actual bar gives you your x-axis (bar.OpenTime [datetime]). The price gives you your y-axis (the bar, Open, high, Low or close)

this.Chart.DrawRectangle("RectBU", pos.EntryTime, pos.EntryPrice, curBar.OpenTime, curBar.Open, this.Bullish_Box_Color);

the line above draws a rectangle from an entry-time & price to a bar open time & price

I hope this helps.

KF

Edited. (Problem Solved) !! 
Thank KF i've treid to look at Chart interface and I find FirstVisibleBarIndex property it return first bar that appears on the chart  and then as your suggestion I use bar.OpenTimes Boom ! we get datetime1 that start at the beginning of the chart. 



Hi There strongResistance(KF) first of all thank you for your kind and help.

just to clarify more my point on finding datetime1, datetime2 is when I draw Trendline I want it to be drawn on the current chart (can see it immediately by our eyes on the chart).

so maybe we need a datetime1 and datetime2 that correspond to the chart. Have you ever tried to use  Chart.TopY; and Chart.BottomY; it gives us the highest and the lowest price on the scale chart at that time. 

 

Edited. (Problem Solved) !! 
Thank KF i've treid to look at Chart interface and I find FirstVisibleBarIndex property it return first bar that appears on the chart  and then as your suggestion I use bar.OpenTimes Boom ! we get datetime1 that start at the beginning of the chart. 
 

 

 


@imrealfighter