[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Referring from a 5 minute chart, to a 1 hour chart of the same security?



PureBytes Links

Trading Reference Links

Nick

> I wonder if anyone can help me with a coding problem. My goal is to base
signals in an expert on a 5-minute chart, partially on moving
> average conditions found in a 1 hour chart of the same security. I cannot
see a way to do this using the 'security' function because that
> only seems to be able to reference a different security altogether.
>
> Logically I guess you could do some simple calculations based on groups of
12 bars, i.e. 12 bars of 5 mins each equals 1 hour.
> However I cannot see a way in Metastock to 'loop' the calculation in order
to do this to a sufficient extent for a long-term moving
> average eg 144 hours.
>
> Maybe I'm missing something obvious. Can anyone help?

You need a series of indicators that compress 5 minute bars down into 1 hour
bars, then you need a mechanism to apply the new data array to your
preferred indicators. To get you started here are some indicators providing
15 and 30 minute bar prices which I'm sure you can adapt. The next step will
be a little more difficult as you need to sample a given price only once
rather than on every 5 minute bar. I haven't worked out the details of how
to do this but I'm confident it can be done with a little thought and
effort.

Roy

  {30 minute frame close - 5 minute bars}
Eb:=(Minute()=25 OR Minute()=55);
ValueWhen(1,Eb OR Cum(1)=1,CLOSE);

  {30 minute frame high - 5 minute bars}
Sb:=(Minute()=00 OR Minute()=30);
Eb:=(Minute()=25 OR Minute()=55);
In:=Cum(1)=1;
Hh:=ValueWhen(1,In OR Eb,HighestSince(1,In OR Sb,H));
Hh;

  {30 minute frame low - 5 minute bars}
Sb:=(Minute()=00 OR Minute()=30);
Eb:=(Minute()=25 OR Minute()=55);
In:=Cum(1)=1;
Ll:=ValueWhen(1,In OR Eb,LowestSince(1,In OR Sb,L));
Ll;

  {30 minute frame open - 5 minute bars}
Sb:=Minute()=25 OR Minute()=55;
Eb:=Minute()=00 OR Minute()=30;
In:=Cum(1)=1;
Op:=ValueWhen(1,Sb OR In,ValueWhen(1,Eb OR In,OPEN));
Op;

  {15 minute frame close - 5 minute bars}
E15:=Minute()=10 OR Minute()=25 OR Minute()=40 OR Minute()=55;
C15:=ValueWhen(1,E15 OR Cum(1)=1,C);
C15;

  {15 minute frame high - 5 minute bars}
Sb:=Minute()=00 OR Minute()=15 OR Minute()=30 OR Minute()=45;
Eb:=Minute()=10 OR Minute()=25 OR Minute()=40 OR Minute()=55;
In:=Cum(1)=1;
Hh:=ValueWhen(1,In OR Eb,HighestSince(1,In OR Sb,H));
Hh;

  {15 minute frame low - 5 minute bars}
Sb:=Minute()=00 OR Minute()=15 OR Minute()=30 OR Minute()=45;
Eb:=Minute()=10 OR Minute()=25 OR Minute()=40 OR Minute()=55;
In:=Cum(1)=1;
Ll:=ValueWhen(1,In OR Eb,LowestSince(1,In OR Sb,L));
Ll;

  {15 minute frame open - 5 minute bars}
Sb:=Minute()=00 OR Minute()=15 OR Minute()=30 OR Minute()=45;
Eb:=Minute()=10 OR Minute()=25 OR Minute()=40 OR Minute()=55;
In:=Cum(1)=1;
Op:=ValueWhen(1,Sb OR In,ValueWhen(1,Eb OR In,OPEN));
Op;