logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
JimV  
#1 Posted : Wednesday, November 6, 2013 5:10:57 PM(UTC)
JimV

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 11/6/2013(UTC)
Posts: 2

I am trying to plot the first bar's high and low on an intraday chart. ie the first 5 min bar's high and low for the rest of the day.

Thanks in advance.
mstt  
#2 Posted : Wednesday, November 6, 2013 8:42:39 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Hi Jim

This piece of code might do exactly what you want. However it would be inappropriate for forex or other data with a timestamp of 12.00 midnight. I've assumed that your chart periodicity would be 5-minutes bars. If the chart is at a higher periodicity (than 5-minute bars) then there's no way to extract first 5-minute bar prices using just the MetaStock Formula Language. Neither will this code work for tick or 1-minute charts. However, it is possible to extract the first 5-minute bar prices from tick or 1-minute data using somewhat more sophisticated coding techniques.

{H & L for first bar of day}
D:=DayOfMonth();
D:=D<>ValueWhen(2,1,D);
H1:=ValueWhen(1,D,H);
L1:=ValueWhen(1,D,L);
H1; L1;

Roy
JimV  
#3 Posted : Thursday, November 7, 2013 2:49:06 PM(UTC)
JimV

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 11/6/2013(UTC)
Posts: 2

Thanks, that works. I need to learn how to better use the ValueWhen function.
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.