Need price at a specific time- using tick bars

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Need price at a specific time- using tick bars

Postby sptrader » 08 Sep 2013

The subject line says it all, I'm looking to capture the price at a specific time (say 9am) on CL using 800 tick bars... sometimes I get a bar that closes at 8:58 and the next bar closes at 9:02.. BUT there is a price at 9am, how can I capture it ?
I know a GV from a minute chart would work but I'm looking for somthing more elegant than a GV sledge hammer... I thought using intrabarpersist somehow ....

I tried this but no luck..

Code: Select all

vars:intrabarpersist prc(0);

If time = 0900 then begin
Prc = C;
end;

plot1(prc,"price at 9am");

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Need price at a specific time- using tick bars

Postby TJ » 08 Sep 2013

The subject line says it all, I'm looking to capture the price at a specific time (say 9am) on CL using 800 tick bars... sometimes I get a bar that closes at 8:58 and the next bar closes at 9:02.. BUT there is a price at 9am, how can I capture it ?
I know a GV from a minute chart would work but I'm looking for somthing more elegant than a GV sledge hammer... I thought using intrabarpersist somehow ....
I tried this but no luck..

Code: Select all

vars:intrabarpersist prc(0);
If time = 0900 then begin
Prc = C;
end;
plot1(prc,"price at 9am");
You have almost got it... ;-)>

Give this a try:

Code: Select all

vars: intrabarpersist prc( 0 );

If time < 0900 then Prc = C;

plot1( prc, "price at 9am" );

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Need price at a specific time- using tick bars

Postby sptrader » 08 Sep 2013

TJ- That's a huge improvement but how do I erase everything before the "captured" 9am price ?? - see chart attached...
(I'm trying to create an opening range indicator fo tick bars)..
Attachments
9am Price Test.png
(26.91 KiB) Downloaded 1170 times

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Need price at a specific time- using tick bars

Postby sptrader » 08 Sep 2013

I think I have it with this slight change--

Plot it as "point" style .... I was ploting as a line before, can't believe I did that..

Thanks TJ !!
Attachments
9am Price Test3.png
(29.37 KiB) Downloaded 1162 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Need price at a specific time- using tick bars

Postby TJ » 08 Sep 2013

a few additional points:

1. intrabarpersist works only in real time.

2. you should use time_s for non-minute charts.

3. you can use a condition to limit the plots before 9:00.

eg.

Code: Select all

vars:intrabarpersist prc( 0 );

If time_s < 090000 then Prc = C;

if time_s >= 90000 then
plot1( prc, "price at 9am" );

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Need price at a specific time- using tick bars

Postby TJ » 08 Sep 2013

ps. my logic actually gives you the tick before 0900.

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: Need price at a specific time- using tick bars

Postby sptrader » 08 Sep 2013

ps. my logic actually gives you the tick before 0900.
***********************************************

I changed it to <= 0900 and it's very close... If I have a 9:00am tick bar, it's perfect, without a 9am bar, it's very close.. .

Thanks again TJ..


Return to “User Contributed Studies and Indicator Library”