logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
kitcaptain  
#1 Posted : Friday, October 15, 2010 2:44:58 AM(UTC)
kitcaptain

Rank: Member

Groups: Registered, Registered Users
Joined: 9/9/2010(UTC)
Posts: 10

Dear MS Community, I'd like to reach out for help to correct me on the below system tester coding. During the last week I've tried to absorb as much of the valuable online material courtesy of Wabbit, Patrick and Roy and to get started I've tried to piece together the below test code. Running the simulation works but once plotted on a chart there's clearly something terribly wrong with the way I'm either using the latch and/or abusing Richard Dale's trailing stop. ie Exit signals appearing soon after Entry.. System Editor: {Buy Order Tab} A:= Mov(c,20,E) ; B:=Mov(c,50,E) ; Entry:=cross(A,B); Entry {Entry Size: Number of Units = FML("Share_Quantity) Sizing based from ATR} {Sell Order Tab} A:= Mov(c,20,E) ; B:=Mov(c,50,E) ; Entry:=cross(A,B); Exit:= cross(B,A); I:=Cum(Entry+Exit>-1)=1; If(BarsSince(I OR Entry)
kitcaptain  
#2 Posted : Friday, October 15, 2010 3:04:28 AM(UTC)
kitcaptain

Rank: Member

Groups: Registered, Registered Users
Joined: 9/9/2010(UTC)
Posts: 10

I've noticed my Sell Order tab code was weirdly missing part of the Latch statement.. {Sell Order Tab} A:= Mov(c,20,E) ; B:=Mov(c,50,E) ; Entry:=cross(A,B); Exit:= cross(B,A); I:=Cum(Entry+Exit>-1)=1; If(BarsSince(I OR Entry)
oztrader  
#3 Posted : Friday, October 15, 2010 7:30:48 PM(UTC)
oztrader

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 7/12/2007(UTC)
Posts: 134
Location: Perth Western Australia

Hi kitcaptain, If your Entry and Exit are based on the crossover of two moving averages then you don't need to use a latch. However if the moving average crossover creates an entry trigger and the exit is to be controlled by Richard's trailing stop then you need to change your exit condition accordingly. oz
kitcaptain  
#4 Posted : Sunday, October 17, 2010 9:04:59 PM(UTC)
kitcaptain

Rank: Member

Groups: Registered, Registered Users
Joined: 9/9/2010(UTC)
Posts: 10

Dear Oz, Thank you for this explanation. I see expected results when I enter Buy and Sell Orders using simple MA crossover, however as soon as I include in the system test Sell Order Tab: exit {basic MA cross exit strategy which works} OR ExtFml( "AdvancedStop.StopLong", entry,0,0, C-2*ATR(10),0,0,0,0); No matter what I've tried the Exit, when plotted on a chart is always on the bar following Entry. Where's the trail? What am I missing? Thank you in advance for your kind assistance, Regards, Andrew
kitcaptain  
#5 Posted : Monday, October 18, 2010 6:13:11 AM(UTC)
kitcaptain

Rank: Member

Groups: Registered, Registered Users
Joined: 9/9/2010(UTC)
Posts: 10

My non-programming mind has concluded today that the AdvancedStop function is not a black box that does "everything" for you but simply a useful function that calculates a value/price of an ATR trailing stop (amongst others). The code should then refer to this value for further conditions. Please correct me if I'm wrong.. Thanks,
oztrader  
#6 Posted : Monday, October 18, 2010 6:59:38 PM(UTC)
oztrader

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 7/12/2007(UTC)
Posts: 134
Location: Perth Western Australia

Hi Kitcaptain, Richard Dale's dll and associated formulae are coded to follow a trade on a chart after entry which is why you have to "input' the date of entry and can't be used in the way you are trying to use them. If you want to use an ATR based trailing stop then an example of the code would be:- Exit:=C
kitcaptain  
#7 Posted : Monday, October 18, 2010 8:33:25 PM(UTC)
kitcaptain

Rank: Member

Groups: Registered, Registered Users
Joined: 9/9/2010(UTC)
Posts: 10

Dear Oz, Appreciate your kind feedback once again. Greetings from Hong Kong. Following much research and even more trial and error I've concluded the function included in Richard's dll does offer initial and trailing stop options (amongst others) within the following function which can be called within a back test: ExtFml( "AdvancedStop.StopLong", Entry Condition, Initial Stop at Entry, Transition to breakeven/TPS, TPS, First Pyramid Condition, TPS at First Pyramid, Second Pyramid Condition, TPS at Second Pyramid) I'm a couple of weeks into this so taking baby steps and continued testing, as I still have doubts myself. I'm playing with the exit criteria: Exit:= Exit condition; Stoplong:= C less than ExtFml(AdvancedStop....etc etc; {At first not including "C less than" extfml was my mistake} Exit OR Stoplong Regards, Andrew
oztrader  
#8 Posted : Monday, October 18, 2010 10:40:39 PM(UTC)
oztrader

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 7/12/2007(UTC)
Posts: 134
Location: Perth Western Australia

Hello Andrew, Probably the best way to explain this is to get you to plot, let's say, Richard's "RAD*ChandelierStopLong" indicator on a chart that has data from year 2000 to the currrent date using only the defaults and see what it looks like. Now, given that you can't change the inputs (i.e. date) when back-testing how can the trailing stop possibly operate? Cheers, Rob
kitcaptain  
#9 Posted : Monday, October 18, 2010 10:53:04 PM(UTC)
kitcaptain

Rank: Member

Groups: Registered, Registered Users
Joined: 9/9/2010(UTC)
Posts: 10

Hi Rob, Agreed, I first looked at the RAD* indicators in the Indicator Builder and came to the same conclusion. Within the System tester / System Editor / Functions.. / AdvancedStop there are 6 additional functions including "Stoploss of all long trades" which I'd assumed could be utilised within a system test for my purpose? Please correct me if I'm wrong? Thanks again for your time and trouble, Andrew
oztrader  
#10 Posted : Tuesday, October 19, 2010 12:58:11 AM(UTC)
oztrader

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 7/12/2007(UTC)
Posts: 134
Location: Perth Western Australia

Hi Andrew, The function "Stoploss of all long trades" is the same as "RAD*ChandelierStopLong" and this cannot be used in back-testing. You can however use the example I posted above but use the sign for "less than". Cheers, Rob
kitcaptain  
#11 Posted : Tuesday, October 19, 2010 1:12:40 AM(UTC)
kitcaptain

Rank: Member

Groups: Registered, Registered Users
Joined: 9/9/2010(UTC)
Posts: 10

OK, thanks for the confirmation. At least I'm not completely back to the drawing board.. I appreciate the alternative example which I'll use moving forward. Cheers, Andrew
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.