In an article written by Dennis P. Peterson i found a trading system which combines the StochRSI with Bollinger Bands. It sounds very interesing and i tried the code in metastock. Unfortunately i does not work :( . I will paste the code below and hopefully somebody can tell me what i'm doing wrong. I pasted the entry part in the bullish trends part of the expert advisor, and the exit part in the bearish part. The error that metastock displayes is that a certain variable or expression must contain only constant data, i have marked this spot below.
{ENTRY}
standarddev:= 60;
periods:= 14;
StochRSI:=(RSI(periods)-LLV(RSI(periods),periods))/
(HHV(RSI(periods),periods)-LLV(RSI(periods),periods));
rdp1:=Round(Stdev(stochrsi,standarddev)/.053);
rdp2:=Round(Stdev(stochrsi,standarddev)/.035);
rdv1:=Round(Stdev(Mov(V,periods,S)/
1000000,standarddev));
adjust1:= rdv1-rdp1+11;
adjust1:=if(adjust1<8,8,adjust1);
adjust1:=if(adjust1>12,12,adjust1);
adjust2:=rdv1-rdp2+14;
adjust2:=if(adjust1<12,12,adjust2);
adjust2:=if(adjust1>20,20,adjust2);
periods:=adjust1;
BBpds:=adjust2;
howclosetoBBbot:=0.9;
longthresholdentry:=0.3;
wprice:=(2*C+H+L)/4;
deviations:=.0625*BBpds+0.75;
StochRSI:=(RSI(periods)-LLV(RSI(periods),periods))/
(HHV(RSI(periods),periods)-LLV(RSI(periods),periods)); [color=red:cdf13f94a1]{Metastock is here displaying an error that this variable or expression must contain only constant data!??}[/color]
botpercentage:=Abs((wprice-
BBandBot(wprice,BBpds,S,deviations))/
(BBandTop(wprice,BBpds,S,deviations)-
BBandBot(wprice,BBpds,S,deviations)));
{entry conditions}
entry1:=botpercentage-howclosetoBBbot<0.3;
entry2:=C*1.05>BBandBot(wprice,BBpds,S,deviations) and
StochRSI>longthresholdentry;
volbb:=If(C>Ref(C,-1),V,0);
entry3:=Volbb>Ref(volbb,-1);
entry4:=(C-O)/(H-L)>.2;
entry1 and entry2 and entry3 and entry4
{EXIT}
standarddev:= 60;
periods:= 14;
StochRSI:=(RSI(periods)-LLV(RSI(periods),periods))/
(HHV(RSI(periods),periods)-LLV(RSI(periods),periods));
rdp1:=Round(Stdev(stochrsi,standarddev)/.053);
rdp2:=Round(Stdev(stochrsi,standarddev)/.035);
StochRSIvol:=(V-LLV(V,periods))/(HHV(V,periods)-
LLV(V,periods));
rdv1:=Round(Stdev(Mov(V,periods,S)/
1000000,standarddev));
adjust1:=rdv1-rdp2+14;
adjust1:=if(adjust1<8,8,adjust1);
adjust1:=if(adjust1>12,12,adjust1);
adjust2:=rdv1-rdp2+14;
adjust2:=if(adjust1<12,12,adjust2);
adjust2:=if(adjust1>20,20,adjust2);
periods:=adjust1;
BBpds:=adjust2;
longthresholdexit:=0.7;
howclosetoBBtop:=0.8;
wprice:=(2*C+H+L)/4;
deviations:=.0625*BBpds+0.75;
StochRSI:=(RSI(periods)-LLV(RSI(periods),periods))/
(HHV(RSI(periods),periods)-
LLV(RSI(periods),periods)); [color=red:cdf13f94a1]{Metastock also displays here an error that this variable or expression must contain only constant data!}[/color]
toppercentage:=Abs((wprice-
BBandTop(wprice,BBpds,S,deviations))/
(BBandTop(wprice,BBpds,S,deviations)-
BBandBot(wprice,BBpds,S,deviations)));
{exit conditions}
exit1:=stochrsi<longthresholdexit;
exit2:=toppercentage<howclosetoBBtop;
exit3:=C>0.95*BBandTop(wprice,BBpds,S,deviations);
exit4:=C<BBandBot(wprice,BBpds,S,deviations);
(exit1 and exit2 and exit3) or exit4