Chris,
I am interested developing a market timing strategy. I use data from HGSI. I have a list of the entire NYSE plus the NYSE index ($NYA), Stock Advances ($ADVN), and Stock Declines ($DECN), that are also part of this list. The script below generates an error. The script is my buy signal which is the following; first condition (gate1) is if the stock has increased at least 3%; the second test is to determine if the symbol is $NYA, or $ADVN, or $DECN, these symbols should not trigger a buy.
PCTCHG:= 100 * (C - REF(C, 1)) / REF(C, 1);
gate1:=if(PCTCHG>3,1,0);
gate2:=if(STKLABEL="$NYA",1,0);
gate3:=if(STKLABEL="$ADVN",1,0);
gate4:=if(STKLABEL="$DECN",1,0);
gate5:=if(gate2+gate3+gate4>0,2,0);
result:=if(gate1+gate5=1,1,0)
event:if(result=1,1,0);
I believe STKLABEL is expecting a variable type symbol and I have passed a string. Please help.
Regards,
John.
using stock variables
Moderator: Chris White
-
- Posts: 212
- Joined: Mon Nov 29, 2010 9:21 pm
Re: using stock variables
Hi John,
The way you could do this to exclude normal symbols such as AAPL, GOOG, MSFT would be to use a script such as this:
However the bad news is that the symbols starting with a dollar sign are treated differently in the software and actually there is a bug which makes the script not compile if you have those symbols.
The next update of the software will have that bug fixed and so you should be okay replacing AAPL, MSFT and GOOG in the above example with $NYA, $ADVN and $DECN.
Here's an example of the entries tab after running the above script:
Of course you could just 'uncheck' $NYA, $ADVN and $DECN from your list of symbols on the LHS and they wouldn't be included either.
The way you could do this to exclude normal symbols such as AAPL, GOOG, MSFT would be to use a script such as this:
Code: Select all
PCTCHG:= 100 * (C - REF(C, 1)) / REF(C, 1);
gate1:= IF(PCTCHG > 3, 1, 0);
gate2:= IF ('AAPL' != STKLABEL, SERIES(1), SERIES(0));
gate3:= IF ('GOOG' != STKLABEL, SERIES(1), SERIES(0));
gate4:= IF ('MSFT' != STKLABEL, SERIES(1), SERIES(0));
event: gate1 & gate2 & gate3 & gate4;
The next update of the software will have that bug fixed and so you should be okay replacing AAPL, MSFT and GOOG in the above example with $NYA, $ADVN and $DECN.
Here's an example of the entries tab after running the above script:
Of course you could just 'uncheck' $NYA, $ADVN and $DECN from your list of symbols on the LHS and they wouldn't be included either.