price at specific time

Questions about MultiCharts and user contributed studies.
fibonaccci
Posts: 44
Joined: 26 Dec 2009
Has thanked: 19 times
Been thanked: 1 time

price at specific time

Postby fibonaccci » 02 Nov 2010

Hi,

how do I get the (closing)price at a specific time (same day/session) in order to use this price for further calculations, e.g. price at 12:35 times xy...

Would I have to use a time frame which is maximum 5 minutes or
can I use 60minutes bars with the Intrabar function?

Thank you very much. Regards

User avatar
TJ
Posts: 6572
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 968 times
Been thanked: 1902 times

Re: price at specific time

Postby TJ » 02 Nov 2010

fibonaccci wrote:Hi,

how do I get the (closing)price at a specific time (same day/session) in order to use this price for further calculations, e.g. price at 12:35 times xy...

Would I have to use a time frame which is maximum 5 minutes or
can I use 60minutes bars with the Intrabar function?

Thank you very much. Regards


do you want the closing price of a specific bar?

or the price at a specific time?


for the price at a specific time,
you can use the keyword currenttime.
and you can use this keyword in any chart resolution (minute+).
for sub-minute charts, you can use the keyword currenttime_s.

e.g.

Code: Select all

input:
specific.time(1235);

var:
specific.price(0);

if currenttime = specific.time
then specific.price = close;




note: this code is not useful for backtesting purposes.

fibonaccci
Posts: 44
Joined: 26 Dec 2009
Has thanked: 19 times
Been thanked: 1 time

Re: price at specific time

Postby fibonaccci » 06 Nov 2010

Dear TJ,

thank you very much for your help.
In order to backtest I'd need the closing price of a specific bar.
Actually, I need for further calculations the closing price of 8 p.m. of 1 minute data.

Do you know a solution?
Many thanks in advance, Best Regards

User avatar
TJ
Posts: 6572
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 968 times
Been thanked: 1902 times

Re: price at specific time

Postby TJ » 06 Nov 2010

fibonaccci wrote:Dear TJ,

thank you very much for your help.
In order to backtest I'd need the closing price of a specific bar.
Actually, I need for further calculations the closing price of 8 p.m. of 1 minute data.

Do you know a solution?
Many thanks in advance, Best Regards


MultiCharts uses EOB (End Of Bar) as time reference.

ie. for a 1 min chart,
the bar time 2000 (8:00pm) covers the time from 07:59:01pm to 08:00:00pm inclusive. (hh:mm:ss)

try this:

Code: Select all

input:
specific.time(2000);

var:
specific.price(0);

if time = specific.time
then specific.price = close;



ps. since currenttime is not used, this code is usable in backtesting.

User avatar
furytrader
Posts: 353
Joined: 30 Jul 2010
Location: Chicago, IL
Has thanked: 154 times
Been thanked: 215 times

Re: price at specific time

Postby furytrader » 06 Nov 2010

Why don't you just say ...

Code: Select all

Inputs: TimeToCatch(2000);
Vars: TimeValue(0);

If Time = TimeToCatch Then TimeValue = Close;


At this point, you could refer to whatever the value of the variable "TimeValue" is?

fibonaccci
Posts: 44
Joined: 26 Dec 2009
Has thanked: 19 times
Been thanked: 1 time

Re: price at specific time

Postby fibonaccci » 08 Nov 2010

you guys are really awesome, many thanks again


Return to “MultiCharts”