Metastock bollinger bands formula - Aussie Stock Forums

# Thread: Metastock bollinger bands formula

1. ## Metastock bollinger bands formula

This is the exit.

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
H<=Ref(H,-1) AND Ref(H,-1)>=Ref(H,-2) AND
Ref(RSI(14)>65,-1)) AND
Can anybody please offer the english translation?

2. ## Re: Metastock bollinger bands formula

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?

3. ## Re: Metastock bollinger bands formula

Running late at the moment.

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

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
H<=Ref(H,-1) AND Ref(H,-1)>=Ref(H,-2) AND
Ref(RSI(14)>65,-1)) AND

ExitTrigger;

Then insert indicator in new window of chart - when it fires vaue of indicator will equal 1.

4. ## Re: Metastock bollinger bands formula

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/Exampl...GrailPart1.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.

5. ## Re: Metastock bollinger bands formula

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:=

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

AND

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:=
{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

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

AND

{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

6. ## Re: Metastock bollinger bands formula

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

7. ## Re: Metastock bollinger bands formula

Wabbit.
Thanks so much bro, your a champion. Much appreciated.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Aussie Stock Forums