========================= Weekly Standard Deviation ========================= A prerequisite for this indicator is Jose Silva's "Calendar Week counter". "Weekly Standard Deviation" plots the weekly standard deviation (or multiple) signal on any daily chart. ---8<--------------------------- {Weekly Standard Deviation} {© 2004 Roy Larsen, rlarsen@man.quik.co.nz} {for use on daily charts with Jose Silva's "Calendar Week counter"} N:=Input("Weekly Standard Deviation Periods",2,26,10); X:=Input("Deviations",0,9,2); F:=Input("End of Week, 5=Friday 6=Saturday 7=Sunday",5,7,5); Q:=Input("Display Mode, 0=Static 1=Dynamic 2=Test",0,2,2); {0=Display, update on Friday when possible} {1=Display, update on each new bar} {2=Backtest, update on first bar of new week} G:=LastValue(Highest(Sum(DayOfWeek()=F,5))=5); I:=Fml("Calendar Week counter"); I:=Abs(I-ValueWhen(2-G,1,I)); M:=G OR I>0; F:=G OR (DayOfWeek()=F AND I=0); 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)); K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C))); M:=(Cum(If(J,K,0))-ValueWhen(N+1,J,Cum(If(J,K,0))))/N; N1:=LastValue((N>5)*5); N2:=LastValue((N>10)*10); N3:=LastValue((N>15)*15); N4:=LastValue((N>20)*20); Y:=Power(M-ValueWhen(1,J,K),2)+ Power(M-ValueWhen(2,J,K),2)+ (N>2)*Power(M-ValueWhen(3,J,K),2)+ (N>3)*Power(M-ValueWhen(4,J,K),2)+ (N>4)*Power(M-ValueWhen(5,J,K),2)+ (N>5)*Power(M-ValueWhen(N1+1,J,K),2)+ (N>6)*Power(M-ValueWhen(N1+2,J,K),2)+ (N>7)*Power(M-ValueWhen(N1+3,J,K),2)+ (N>8)*Power(M-ValueWhen(N1+4,J,K),2)+ (N>9)*Power(M-ValueWhen(N1+5,J,K),2)+ (N>10)*Power(M-ValueWhen(N2+1,J,K),2)+ (N>11)*Power(M-ValueWhen(N2+2,J,K),2)+ (N>12)*Power(M-ValueWhen(N2+3,J,K),2)+ (N>13)*Power(M-ValueWhen(N2+4,J,K),2)+ (N>14)*Power(M-ValueWhen(N2+5,J,K),2)+ (N>15)*Power(M-ValueWhen(N3+1,J,K),2)+ (N>16)*Power(M-ValueWhen(N3+2,J,K),2)+ (N>17)*Power(M-ValueWhen(N3+3,J,K),2)+ (N>18)*Power(M-ValueWhen(N3+4,J,K),2)+ (N>19)*Power(M-ValueWhen(N3+5,J,K),2)+ (N>20)*Power(M-ValueWhen(N4+1,J,K),2)+ (N>21)*Power(M-ValueWhen(N4+2,J,K),2)+ (N>22)*Power(M-ValueWhen(N4+3,J,K),2)+ (N>23)*Power(M-ValueWhen(N4+4,J,K),2)+ (N>24)*Power(M-ValueWhen(N4+5,J,K),2)+ (N>25)*Power(M-ValueWhen(N4+6,J,K),2); X*Sqrt(Y/N); ---8<--------------------------- http://www.metastocktips.co.nz/