Working with price on specific timestamps

Created at 25 Jul 2014, 14:33
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!
FL

flannery

Joined 25.07.2014

Working with price on specific timestamps
25 Jul 2014, 14:33


Hey,

So I have been working on a bot where I need to get the price on the forex cross at specific times. This is not a problem when working with realtime. A snippet of what I have used for that part:

string day_0 = DateTime.Today.AddDays(0).ToString("dd/MM/yyyy");
..
cAlgo.API.Internals.MarketSeries barSeries = MarketData.GetSeries(TimeFrame.Minute15);
..
barSer_08 = barSeries.OpenTime.GetIndexByExactTime(DateTime.Parse(day_0 + " 8:00AM"));    double History_Price_08 = MarketSeries.Open[barSer_08];

Now this will give me the open price of the bar at the exact time: today (bot is running after the time that day) at 8 AM.

 

However, when I try to use the same bot for historical testing it will not get the price of the "day today" for each day in the historical test.

Is it possible to do this with the historical tester?


@flannery
Replies

Spotware
25 Jul 2014, 14:38

RE:

DateTime.Today returns System current time. You need Server.Time

 

flannery said:

Hey,

So I have been working on a bot where I need to get the price on the forex cross at specific times. This is not a problem when working with realtime. A snippet of what I have used for that part:

string day_0 = DateTime.Today.AddDays(0).ToString("dd/MM/yyyy");
..
cAlgo.API.Internals.MarketSeries barSeries = MarketData.GetSeries(TimeFrame.Minute15);
..
barSer_08 = barSeries.OpenTime.GetIndexByExactTime(DateTime.Parse(day_0 + " 8:00AM"));    double History_Price_08 = MarketSeries.Open[barSer_08];

Now this will give me the open price of the bar at the exact time: today (bot is running after the time that day) at 8 AM.

 

However, when I try to use the same bot for historical testing it will not get the price of the "day today" for each day in the historical test.

Is it possible to do this with the historical tester?

 


@Spotware