Get Visible Edge of chart

Created at 22 Jan 2021, 14:18
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!
CT

cTKit

Joined 15.09.2016

Get Visible Edge of chart
22 Jan 2021, 14:18


Is there a way to find a value that represents the last index or date time visible at the right edge of chart area.  I am drawing rectangles at specific price points and need to do so from the right edge of the chart.  At the moment I am doing it be including a parameter that allows the user to set an offset from the last bar, but I would like to do it automatically.  So if the user has dragged the bar time indicator at the bottom to make more space on the right, I want to be able to re-render from the new last visible point on the chart.


@cTKit
Replies

PanagiotisCharalampous
22 Jan 2021, 15:54

Hi cTKit,

You can use LastVisibleBarIndex.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

cTKit
22 Jan 2021, 16:07

RE:

PanagiotisCharalampous said:

Hi cTKit,

You can use LastVisibleBarIndex.

Best Regards,

Panagiotis 

Join us on Telegram

I looked at that but documentation suggests this is the index of the last actual candle/bar rather the last visible position.  I will try it out.


@cTKit

cTKit
22 Jan 2021, 16:13

RE: RE:

cTKit said:

PanagiotisCharalampous said:

Hi cTKit,

You can use LastVisibleBarIndex.

Best Regards,

Panagiotis 

Join us on Telegram

I looked at that but documentation suggests this is the index of the last actual candle/bar rather the last visible position.  I will try it out.

That doesn't work, as the documentation suggests this value is the index of the last actual candle that is visible.  I need a position for the edge of the chart window when the bars have been moved left to leave more than the default amount of space.  Ideally something like LastVisibleDateTime.


@cTKit

PanagiotisCharalampous
23 Jan 2021, 10:31

Hi cTKit,

There is no such option in the API at the moment.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous