Forum for TradeSim Users  

Go Back   Forum for TradeSim Users > BullCharts > BullCharts Issues

Reply
 
Thread Tools Display Modes
  #1  
Old 17th May 2010, 07:38 AM
FSeppelt FSeppelt is offline
Junior Member
Site Admin
 
Join Date: May 2007
Posts: 5
Question BullCharts Coding For Bollinger Bands Exit

Hi all,
Has anybody managed to port over the Metastock code for this System with any success.
Thanks in advance.
Regards,
Frank S.
Reply With Quote
  #2  
Old 20th May 2010, 10:32 AM
oztrader oztrader is offline
Junior Member
Site Admin
 
Join Date: Sep 2007
Posts: 26
Default

Hi Frank,

What is the MetaStock code for the Bollinger Bands exit to which you are referring?

Cheers,
oz
Reply With Quote
  #3  
Old 26th May 2010, 01:10 AM
FSeppelt FSeppelt is offline
Junior Member
Site Admin
 
Join Date: May 2007
Posts: 5
Default Metastock Code Bollinger Band Exit

Hi Oz,
The code below is a copy of the code posted on Page 252 of the TradeSim Users Manual. However, on my translation of the code and running a Monte Carlo Simulation I get a crash with the message EInvalidOp, which is some form of exception error.

EntryTrig:=ExtFml("TradeSim.Rand")>0.5;
EntryPrice:=CLOSE;
InitialStop:=CLOSE-3*ATR(10);
ExitTrig:=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));
ExitPrice:=CLOSE;
ExtFml( "TradeSim.Initialize"); { Initialize internal variables }
ExtFml( "TradeSim.RecordTrades",
"Rand Entry + Bollinger Bands Exit",
LONG,
EntryTrig,
EntryPrice,
InitialStop,
ExitTrig,
ExitPrice,
START);

Regards,
Frank
Reply With Quote
  #4  
Old 26th May 2010, 05:05 AM
oztrader oztrader is offline
Junior Member
Site Admin
 
Join Date: Sep 2007
Posts: 26
Default

Hi Frank,

The link below discusses the same error code as you have mentioned so is definitely worth a read with particular reference to the Exit Trigger not working or a Position Sizing problem.

http://www.compuvision.com.au/vBulle...ght=EInvalidOp

This is my take on the BullScript code but I use MetaStock and don’t have BullCharts to run a check! For ease of coding I have broken the ExitTrig down into the 5 separate components required to trigger an exit.

EntryTrig := ExtFml("TradeSim.Rand")>0.5;
EntryPrice := c;
InitialStop := c-3*atr(10);
ETtest1 := abs(13-barssince(hist(C>bbandtop(c,20,s,2),1) AND h<=hist(h,1) AND hist(h,1)>=hist(h,2) AND hist(rsi(14)>65,1)))<=7;
ETtest2 := hist(c>bbandtop(c,20,s,1.25),1) AND hist(c<bbandtop(c,20,s,2),1) AND h<=hist(h,1) AND hist(h,1)>=hist(h,2);
ETtest3 := hist(rsi(14),1)<valuewhen(1,hist(c>bbandtop(c,20,s ,2),1) AND h<=hist(h,1) AND hist(h,1)>=hist(h,2) AND hist(rsi(14)>65,1),hist(rsi(14),1));
ETtest4 := barssince(c<bbandtop(c,20,s,1.25))<barssince(hist( c>bbandtop(c,20,s,2),1) AND h<=hist(h,1) AND hist(h,1)>=hist(h,2) AND hist(rsi(14)>65,1));
ETtest5 := barssince(c>bbandtop(c,20,s,2))>barssince(c<bbandt op(c,20,s,1.25));
ExitTrig := ETtest1 AND ETtest2 AND ETtest3 AND ETtest4 AND ETtest5;
ExitPrice := c;
ExtFml("TradeSim.Initialize"); { Initialize internal variables }
ExtFml("TradeSim.RecordTrades",
"Rand Entry + Bollinger Bands Exit",
LONG,
EntryTrig,
EntryPrice,
InitialStop,
ExitTrig,
ExitPrice,
START);

Hope this is of some help,
Rob
Reply With Quote
  #5  
Old 27th May 2010, 01:38 AM
FSeppelt FSeppelt is offline
Junior Member
Site Admin
 
Join Date: May 2007
Posts: 5
Default

Thanks Oz,
My translation similar to yours, still no luck, however will play around with exit conditions. Ordinary portfolio simulation test works fine with random walk but Monte Carlo crashes. Ordinary portfolio simulation seems to suggest that if this exit worked in the past, it is not so good today.
Regards,
Frank
Reply With Quote
  #6  
Old 27th May 2010, 02:14 AM
FSeppelt FSeppelt is offline
Junior Member
Site Admin
 
Join Date: May 2007
Posts: 5
Default Enigma

Hi Oz,
Ran the same code through Metastock with no problems with opposite conclusion indicating that the exit is still good. Must be something in the translation of coding between BullCharts and TradeSim.
Regards,
Frank
Reply With Quote
  #7  
Old 27th May 2010, 04:23 AM
FSeppelt FSeppelt is offline
Junior Member
Site Admin
 
Join Date: May 2007
Posts: 5
Default HaHa Inattention to detail

When pulling accross Metastock code the RSI in BullCharts requires rsi(exp,period) for some reason. i.e. rsi(C,14).

For those who would like code that seems to work with BullCharts:-

ETtest1 := abs(13-barssince(hist(C>bbandtop(c,20,s,2),1) AND h<=hist(h,1) AND hist(h,1)>=hist(h,2) AND hist(rsi(C,14)>65,1)))<=7;
ETtest2 := hist(c>bbandtop(c,20,s,1.25),1) AND hist(c<bbandtop(c,20,s,2),1) AND h<=hist(h,1) AND hist(h,1)>=hist(h,2);
ETtest3 := hist(rsi(C,14),1)<valuewhen(1,hist(c>bbandtop(c,20 ,s ,2),1) AND h<=hist(h,1) AND hist(h,1)>=hist(h,2) AND hist(rsi(C,14)>65,1),hist(rsi(C,14),1));
ETtest4 := barssince(c<bbandtop(c,20,s,1.25))<barssince(hist( c>bbandtop(c,20,s,2),1) AND h<=hist(h,1) AND hist(h,1)>=hist(h,2) AND hist(rsi(C,14)>65,1));
ETtest5 := barssince(c>bbandtop(c,20,s,2))>barssince(c<bbandt op(c,20,s,1.25));
ExitTrigger := ETtest1 AND ETtest2 AND ETtest3 AND ETtest4 AND ETtest5;
ExitTrigger;

By the way thanks Oz for the sectioning of the code as it allowed me to narrow down where the problem lay.
Regards,
Frank
Reply With Quote
  #8  
Old 11th June 2010, 06:38 AM
oztrader oztrader is offline
Junior Member
Site Admin
 
Join Date: Sep 2007
Posts: 26
Default

Hi Frank,

Pleased to see that the issue has now been resolved.

My last post was made prior to an eye operation the same day and I have not been able to return since.

With MetaStock when you use RSI(14) it automatically does the calculations based on the closing price, however the formula can also be written RSI(Data Array,14) to allow for Open, High, Low etc.

Out of interest did you happen to run the simulation based on exiting at the Open of the day following the exit being triggered.
I feel that the result would be more realistic than an exit on the trigger day.

Regards,
Rob
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:01 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright Compuvision Australia Pty Ltd, 2000-2009, All Rights Reserved