![]() |
|
#1
|
|||
|
|||
|
Hi all,
Has anybody managed to port over the Metastock code for this System with any success. Thanks in advance. Regards, Frank S. |
|
#2
|
|||
|
|||
|
Hi Frank,
What is the MetaStock code for the Bollinger Bands exit to which you are referring? Cheers, oz |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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 |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
|||
|
|||
|
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 |
|
#7
|
|||
|
|||
|
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 |
|
#8
|
|||
|
|||
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
|
|