How to find the open price at a specific time in the past

Created at 24 Jul 2015, 12: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!
NE

newbee

Joined 24.07.2015

How to find the open price at a specific time in the past
24 Jul 2015, 12:18


Hello there I'm new C# language coding all together. Been reading up and experimenting however am stuck and would appreciate it if anyone can confirm how to obtain:

A) The Open price at a particular time. (eg Open price at 5:00pm)

Is this possible?

Thanks in advance

 


@newbee
Replies

Spotware
24 Jul 2015, 12:56

Dear Trader,

First you have to get the MarketSeries of the symbol and timeframe of your choice.

Then you will have to get the index of the bar that was build around the time you want to to find the open price.

Once you get the index of the Bar you will be able to retrieve the OpenPrice of that Bar.

The following code snippet illustrates it:

            MarketSeries marketserie = MarketData.GetSeries(TimeFrame);
            int index = marketserie.OpenTime.GetIndexByTime(DateTime.Parse("24-Jul-15 03:20AM"));
            double openprice = marketserie.Open[index];

 


@Spotware

newbee
24 Jul 2015, 15:20

That's fantastic.

Thank you so much. I'll play around with this further.


@newbee