Page 1 of 1

IF statement problem

Posted: Sat Jul 24, 2010 2:10 pm
by 00tailor
Hi,

would you please help me to find a cause for the following error: else statement unterminated at "if y(!i)<0 then" in the following code. This is actually a program for a value-at-risk (risk metrics) computation for long and short trading positions, thus a need for the if statement:

Code: Select all

smpl 1 1632 series y1= 100*log(sp500/sp500(-1)) scalar nobs = 1632 scalar nw = 1000 matrix(1632,1) results for !i = nw+1 to nobs smpl !i-nw !i equation eq_y1.arch(1,1,integrated,m=2000,h) y1 c smpl !i 1632 if y1(!i)<0 then smpl !i+1 !i+1 eq_y1.forecast y1f var genr meant=@mean(y1) genr vatr=meant-2,32635*sqr(var) smpl !i+1 1632 results(!i+1,1)=@elem(vatr, @otod(!i+1)) else smpl !i+1 !i+1 eq_y1.forecast y1f var genr meant=@mean(y1) genr vatr=meant+2,32635*sqr(var) smpl !i+1 1632 results(!i+1,1)=@elem(vatr, @otod(!i+1)) next
thank you in advance
P.S. program run by the version 6

Re: IF statement problem

Posted: Sat Jul 24, 2010 3:41 pm
by startz
You left off the

Code: Select all

endif

Re: IF statement problem

Posted: Sat Jul 24, 2010 3:54 pm
by 00tailor
Thanks a lot!