gapellegrini
22nd September 2004, 02:50 PM
I receive the following formula from equis staff for yesterday high/low on intraday charts.
{ yesterday's high }
newday:=ROC(DayOfWeek(),1,$)<>0;
ValueWhen(1,newday, Ref(HighestSince(1,newday,H),-1));
{ yesterday's low }
newday:=ROC(DayOfWeek(),1,$)<>0;
ValueWhen(1,newday, Ref(LowestSince(1,newday,L),-1));
I need a formula for the system tester tath enter a long if yesterday high is broken and enter a short if yesterday low is lost (only one signal for day)
I ´ve try everything tath I could , can someone help me?
Thanks
Gabriel
Jose
23rd September 2004, 01:11 AM
This is not such an easy task to code correctly - Equis' formulae above works OK, except for two problems:
(1) chart distortion at the left side when the ValueWhen() trigger precedes valid data on intraday charts;
(2) ROC(DayOfWeek(),1,$)<>0 doesn't work if there is enough missing data, such as on suspended stocks.
"Only one signal for day" is not possible unless you're happy with just the first breakout signals for the day.
As soon as a new High or Low is broken you will get a new signal again. To code just the first signal for the day would take me more free time than I have available at the moment.
"I need a formula for the system tester" - don't waste your time with the MS system tester.
MetaStock -> Tools -> Indicator Builder -> New
Copy and paste two indicators below.
====================
Calendar Day counter
====================
---8<---------------------------
{ Day counter from 1/1/0001, Gregorian calendar }
{ Count is independent of any missing chart data }
{ ©Copyright 2003-2004 Jose Silva }
{ For personal use only }
{ http://metastocktools.com }
limit:=Input("count calendar days from year",1,2100,2000);
LimLeap:=Frac(limit/4)=0 AND Frac(limit/100)<>0
OR Frac(limit/400)=0;
NoCount:=limit*365+Int(limit/4)
-Int(limit/100)+Int(limit/400)-LimLeap;
leap:=Frac(Year()/4)=0 AND Frac(Year()/100)<>0
OR Frac(Year()/400)=0;
y:=Year()*365+Int(Year()/4)
-Int(Year()/100)+Int(Year()/400)-NoCount;
m:=
If(Month()=2,31-leap,
If(Month()=3,59,
If(Month()=4,90,
If(Month()=5,120,
If(Month()=6,151,
If(Month()=7,181,
If(Month()=8,212,
If(Month()=9,243,
If(Month()=10,273,
If(Month()=11,304,
If(Month()=12,334,
-leap)))))))))));
DayNr:=y+m+DayOfMonth();
DayNr
---8<---------------------------
===========================
Intraday High/Low breakouts
===========================
---8<---------------------------
{Modified Daily OHLC}
{rlarsen@man.quik.co.nz}
{for use on intraday charts with
Jose Silva's "Calendar Day counter"}
A:=Input("Hour of Last Daily Bar" ,0,23,16);
B:=Input("Minute of Last Daily Bar",0,59,00);
Q:=Input("Display Mode, 0=Static 1=Dynamic 2=Test",0,2,2);
{0=Display, update at last bar of day}
{1=Display, update on each new bar}
{2=Backtest, update on first bar of new day}
G:=LastValue(Highest(Sum(DayOfWeek()<>
ValueWhen(2,1,DayOfWeek()),5))=5);
I:=Fml("Calendar Day counter");
I:=Abs(I-ValueWhen(2-G,1,I)); M:=G OR I>0;
F:=G OR (Hour()=A AND Minute()=B);
A:=LastValue(Cum(1)-1)=Cum(1);
B:=LastValue(Cum(1))=Cum(1);
J:=If(F,1,If(Alert(F,2)=0 AND M,2,0));
J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J);
J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));
Hw:=HighestSince(1,M,H);
Hw:=ValueWhen(1,J,If(J=1,Hw,ValueWhen(2-G,1,Hw)));
Lw:=LowestSince(1,M,L);
Lw:=ValueWhen(1,J,If(J=1,Lw,ValueWhen(2-G,1,Lw)));
Cw:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
Ow:=ValueWhen(1,J,If(J=1,ValueWhen(1,M,O),
ValueWhen(2-G,1,ValueWhen(1,M,O))));
{ Yesterday's OHLC }
Ow:=ValueWhen(1,Ow>0,Ow);
Hw:=ValueWhen(1,Hw>0,Hw);
Lw:=ValueWhen(1,Lw>0,Lw);
Cw:=ValueWhen(1,Cw>0,Cw);
{ Breakout signals }
long:=Cross(C,Hw);
short:=Cross(Lw,C);
{ Plot in own window below intraday chart }
long-short
---8<---------------------------
With thanks to Roy Larsen for the "Daily OHLC" code.
http://www.metastocktips.co.nz/
jose '-)
gapellegrini
23rd September 2004, 01:26 PM
Hello Jose , thanks for your help and good will. I ask for system test because tradesim doesn´t work on intraday data. Thanks for the formula.Are you Brazilian?Jose da Silva is one fo the most common names in Brazil.
Thanks
Gabriel
Jose
23rd September 2004, 10:37 PM
I'm Spanish/Australian.
jose '-)
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.