This is a mobile optimized page that loads fast, if you want to load the real page, click this text.

Metastock bollinger bands formula

Joined
5 January 2006
Posts
4,461
Reactions
1
This is the exit.


Can anybody please offer the english translation?
 
Each line of code or the jist of it?

Its creating an absolute value for the combination of all the code conditions.
I presume the exit itself has a line like Abs = X.

Where's a wabbit when you need one?
 
Running late at the moment.

To see when it fires creat a new indicator with the following code:-

ExitTrigger:=Abs(13-BarsSince(Ref(C>BBandTop(C,20,S,2),-1) AND
H<=Ref(H,-1) AND Ref(H,-1)>=Ref(H,-2) AND
Ref(RSI(14)>65,-1)))<=7 AND
Ref(C>BBandTop(C,20,S,1.25),-1) AND Ref(C<BBandTop(C,20,S,2),-1) AND
H<=Ref(H,-1) AND Ref(H,-1)>=Ref(H,-2) AND
Ref(RSI(14),-1)<ValueWhen(1,Ref(C>BBandTop(C,20,S,2),-1) AND
H<=Ref(H,-1) AND Ref(H,-1)>=Ref(H,-2) AND
Ref(RSI(14)>65,-1),Ref(RSI(14),-1)) AND
BarsSince(C<BBandTop(C,20,S,1.25))<BarsSince(Ref(C >BBandTop(C,20,S,2),-1) AND
H<=Ref(H,-1) AND Ref(H,-1)>=Ref(H,-2) AND
Ref(RSI(14)>65,-1)) AND
BarsSince(C>BBandTop(C,20,S,2))>BarsSince(C<BBandT op(C,20,S,1.25));

ExitTrigger;

Then insert indicator in new window of chart - when it fires vaue of indicator will equal 1.
 
Yeh tech line by line would be great.
Im just keen to find out why this exit works so well.

http://www.compuvision.com.au/Examples/HolyGrailPart1.htm

You have probably seen this or in any case you're well beyond this, but i found it interesting. That bollinger band exit coupled with a random entry produced returns that werent staggering, but with what i would consider low drawdowns. Also over 20,000 simulations not 1 returned a loss.

MaxDD was 14% and over 1987 the drawdown was about 8%. Not bad considering the index lost >20%.

I think Stevo's system is based on bollinger bands (?) so its probably a good starting point.
 
I find the easiest way to analyse complex codes is to break the expressions down into simpler expressions, which makes the code much more readable. Judiscous use of find-and-replace makes the job a lot easier. Here is my version of the above script:

Code:
cond1:=C>BBandTop(C,20,S,2);
cond2:=H<=Ref(H,-1) AND Ref(H,-1)>=Ref(H,-2);
cond3:=RSI(14)>65;
cond4:=Ref(cond1,-1) AND cond2 AND Ref(cond3,-1);
cond5:=C<BBandTop(C,20,S,1.25);

ExitTrigger:=
Abs(13-BarsSince(cond4))<=7

AND

Ref(C>BBandTop(C,20,S,1.25),-1)

AND

Ref(C<BBandTop(C,20,S,2),-1)

AND

cond2

AND

Ref(RSI(14),-1)<ValueWhen(1,cond4,Ref(RSI(14),-1))

AND

BarsSince(cond5)<BarsSince(cond4)

AND

BarsSince(cond1)>BarsSince(cond5);

Now that the code is easier to read, we can look at each line to see how it works. Liberal use of comments will make the job easier!

I end up with something that looks like this:

Code:
cond1:=C>BBandTop(C,20,S,2);
{the CLOSE price of the current bar must be higher than the top BB}
{notice the value of the SD argument}

cond2:=H<=Ref(H,-1) AND Ref(H,-1)>=Ref(H,-2);
{the HIGH of the current bar must be ltoe the HIGH of the previous bar, and
the HIGH of the previous bar must be gtoe the HIGH of the bar previous}

cond3:=RSI(14)>65;
{the RSI must be gt 65}

cond4:=Ref(cond1,-1) AND cond2 AND Ref(cond3,-1);
{the value of (cond1) on the previous bar must be TRUE, and
the value of (cond2) on the current bar must be TRUE, and
the value of (cond3) on the previous bar must be TRUE}

cond5:=C<BBandTop(C,20,S,1.25);
{the CLOSE of the current bar must be lt the top BB}
{notice the value of the SD argument}

ExitTrigger:=
Abs(13-BarsSince(cond4))<=7
{the value of (cond4) must have been true at any time between
6 to 20 bars ago (inclusive)}

AND

Ref(C>BBandTop(C,20,S,1.25),-1)
{on the previous bar, the CLOSE must be gt the top BB}
{notice the value of the SD argument}

AND

Ref(C<BBandTop(C,20,S,2),-1)
{on the previous bar, the CLOSE must be lt the top BB}
{notice the value of the SD argument}

AND

cond2
{must be true}

AND

Ref(RSI(14),-1)<ValueWhen(1,cond4,Ref(RSI(14),-1))
{the value of the RSI on the previous bar must be lt the
value of the RSI on the previous bar on the last occasion
when (cond4) was TRUE}

AND

BarsSince(cond5)<BarsSince(cond4)
{the period elapsed since (cond5) was last TRUE is lt
than the period elapsed since (cond4) was TRUE}

AND

BarsSince(cond1)>BarsSince(cond5);
{the periods elapsed since (cond1) was last TRUE is gt
the period elapsed since (cond5) was TRUE}

Now, all you have to do is evaluate whether the criteria make any sense in the context of the trading system. Maybe it does, maybe it doesn't?


Hope this helps.

wabbit
 
I guess I should also have mentioned that you should be looking for contradictions and things that don't quite make sense. For example you have a number of expression that involve BBTops, does the use of these make sense? There is a criteria that uses (cond2) but (cond2) must also be true on the current bar to trigger the exit, does this make sense? etc etc etc


wabbit
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more...