Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Have a play with this.... as an indicator (System Tester code to follow, soon)
Change the "m" value to set the band widths to find the overbought and oversold levels:
prd1:=Input("ROC Periods",1,100,1);
prd2:=Input("MA Periods",1,100,25);
prd3:=Input("Smoothing Periods",1,100,13);
prd4:=Input("Trigger Periods",1,100,7);
{plot:=Input("1-Use Lastvalue(), 2-Dynamic",1,2,2);}
plot:=2;
{use any other indicator in here}
ind:=100*Mov(Mov(ROC(C,prd1,$)/Abs(ROC(C,prd1,$)+0.00001),prd2,E),prd3,E);
fmDate:=Input("Start ddmmyy (0=first trade)",0,311299,0);
fmDay:=If(fmDate=0,ValueWhen(1,Cum(1)=1,DayOfMonth()),Int(fmDate/10000));
fmMonth:=If(fmDate=0,ValueWhen(1,Cum(1)=1,Month()),Int((fmDate-fmDay*10000)/100));
fmYear:=If(fmDate=0,ValueWhen(1,Cum(1)=1,Year()),Int(fmDate-Int(fmDate/100)*100));
fmYear:=If(fmYear<100,If(fmYear<40,fmYear+2000,fmYear+1900),fmYear);
toDate:=Input("End ddmmyy (0=last trade)",0,311299,0);
toDay:=If(toDate=0,LastValue(DayOfMonth()),Int(toDate/10000));
toMonth:=If(toDate=0,LastValue(Month()),Int((toDate-toDay*10000)/100));
toYear:=If(toDate=0,LastValue(Year()),Int(toDate-Int(toDate/100)*100));
toYear:=If(toYear<100,If(toYear<40,toYear+2000,toYear+1900),toYear);
betweenDates:=((DayOfMonth()>=fmDay AND Month()=fmMonth AND Year()=fmYear) OR (Month()>fmMonth AND Year()=fmYear) OR Year()>fmYear) AND ((DayOfMonth()<=toDay AND Month()=toMonth AND Year()=toYear) OR (Month()<toMonth AND Year()=toYear) OR Year()<toYear);
MV:=Cum(If(betweenDates,ind,0))/Cum(If(betweenDates,1,0.00001));
MV:=If(plot=1,LastValue(MV),MV);
SD:=Sqrt(Cum(Power(If(betweenDates,ind-MV,0),2))/Cum(If(betweenDates,1,0.00001)));
SD:=If(plot=1,LastValue(SD),SD);
{shift:=LastValue(BarsSince(betweenDates));}
m:=1;
MV:=Ref(Ref(ValueWhen(1,betweenDates,MV),-LastValue(BarsSince(betweenDates))),+LastValue(BarsSince(betweenDates)));
LL:=Ref(Ref(ValueWhen(1,betweenDates,MV-m*SD),-LastValue(BarsSince(betweenDates))),+LastValue(BarsSince(betweenDates)));
UL:=Ref(Ref(ValueWhen(1,betweenDates,MV+m*SD),-LastValue(BarsSince(betweenDates))),+LastValue(BarsSince(betweenDates)));
ind; {red solid}
mv; {blue solid}
Mov(ind,prd4,E); {green solid}
UL; {blue solid}
LL; {blue solid}
wabbit :D
|