Using date value with ChartPoint?  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
Ram
Posts: 90
Joined: 25 Nov 2014
Has thanked: 17 times
Been thanked: 5 times

Using date value with ChartPoint?

Postby Ram » 13 Feb 2015

Hi,

The following code return the mid visible time axis:

Code: Select all

Dim TimeRangeChart As TimeSpan = Environment.RightScreenTime - Environment.LeftScreenTime
Dim MidPointTime As DateTime = Environment.LeftScreenTime.AddSeconds(timeRangeChart.TotalSeconds / 2)
My goal is to use MidPointTime value with ChartPoint but ChartPoint's time input is set by BarsBack and not date.

My question is how to translate the MidPointTime value to bar number or how to set New ChartPoint with date value instead of BarsBack?

Thx much,
Cheers,
R.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Using date value with ChartPoint?

Postby Henry MultiСharts » 13 Feb 2015

Hello Ram,

ChartPoint has 3 constructors, you can use the following:

Code: Select all

ChartPoint(
DateTime time,
double price
);
Parameters
time
System time (first coordinate)
price
Price (second coordinate)

Ram
Posts: 90
Joined: 25 Nov 2014
Has thanked: 17 times
Been thanked: 5 times

Re: Using date value with ChartPoint?  [SOLVED]

Postby Ram » 13 Feb 2015

Cant beleive it was that easy... Thx much!

Code: Select all

Dim TimeRangeChart As TimeSpan = Environment.RightScreenTime - Environment.LeftScreenTime
Dim MidPointTime As DateTime = Environment.LeftScreenTime.AddSeconds(timeRangeChart.TotalSeconds / 2)

New ChartPoint(MidPointTime, Bars.Close(0))


Return to “MultiCharts .NET”