[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coding MaxLoss and ProfitTarget Stops



PureBytes Links

Trading Reference Links

At 09:48 PM 8/28/01 +1200, you wrote: >Herman > >> Has anybody succeeded handcoding the Maximum Loss and Profit Target Stops such that System Tester Stop results are identical to using the custom coded stops?>>
>Here is a sampling of work-in-progress on profit stops for MS.
Thanks Roy for the nice code and ideas. I tried having the WilliamsBuyStop fml return the entry price at time of entry and zero at other times but it doesn't give me the proper results so I think there is more to it... I look forward to your comments on the William's fml.
>I have yet to check any of these against MS but will do so over the next few days. For the life of me I can't see how MS stops can execute at tradeable steps - see comments on code further down. With Profit Stop I have added some code to convert the stop value to the next higher ASX tradeable step. Similar code could be added to a stop loss or exit stop by those who need it (i.e. have their own stop capable system tester).>
You lost me here, care to explain?
Many thanks for your feedback, I'll be playing with your code for the next few days :-)
Herman.
>I'm going to have a lot more fun with this stuff yet. There are a number of possibilities yet to >explore. I hope there is something here that will help or give you inspiration. > >Roy > >{Profit Exit - entered on Close} >Profit:=Input("Profit target %",1,50, 5)/100; >Entry:=Fml("Williams Buy Stop"); >EntryAmt:=If(PREV<=0,If(Entry>0,CLOSE,0), > If(H>PREV*(1+Profit),-PREV,PREV)); >Target:=Abs(EntryAmt)*(1+Profit); >EntryAmt<0 AND H>Target; {binary exit signal} > >{Profit Exit - entered on Open} >Profit:=Input("Profit target %",1,50, 5)/100; >Entry:=Fml("Williams Buy Stop"); >EntryAmt:=If(PREV<=0,If(Entry>0,OPEN,0), > If(H>PREV*(1+Profit),-PREV,PREV)); >Target:=Abs(EntryAmt)*(1+Profit); >EntryAmt<0 AND H>Target; {binary exit signal} > >{Profit Exit - entered on Stop} >Profit:=Input("Profit target %",1,50, 5)/100; >Entry:=Fml("Williams Buy Stop"); >EntryAmt:=If(PREV<=0,If(Entry>0,Entry,0), > If(H>PREV*(1+Profit),-PREV,PREV)); >Target:=Abs(EntryAmt)*(1+Profit); >EntryAmt<0 AND H>Target; {binary exit signal} > >{Profit Stop - entered on Stop} >Profit:=Input("Profit target %",1,50, 5)/100; >Entry:=Fml("Williams Buy Stop"); >EntryAmt:=If(PREV<=0,If(Entry>0,Entry,0), > If(H>PREV*(1+Profit),-PREV,PREV)); >Target:=Abs(EntryAmt)*(1+Profit); >X:=If(EntryAmt<0 AND H>Target,Target,0); >Stop:=If(X=0,0,If(X>0.1 AND X<=0.5, >If(Int(X*200)=X*200,X+.005, Int((X+.005)*200)/200), If(X<=0.1, >If(Int(X*1000)=X*1000,X+.001, Int((X+.001)*1000)/1000), >If(Int(X*100)=X*100,X+.01, Int((X+.01)*100)/100)))); >Stop; {Value exit signal} > >{Target Exit} >Profit:=Input("Percent profit",1,50, 5)/100; >Loss:=Input("Percent loss" ,1,50,50)/100; >Time:=Input("Maximum trade duration",1,50,2); >Entry:=Fml("Williams Buy Stop"); >Init:=Cum(Entry<>-1)=0; >EntryPrice:=If(PREV<=0,If(Entry>0,Entry,0), > If(H>PREV*(1+Profit) > OR L<=PREV*(1-Loss) > OR BarsSince(PREV=0)>=Time,-PREV,PREV)); >Trade:=Init=0 AND EntryPrice<>0; >ProfitTarget:=Abs(EntryPrice)*(1+Profit); >LossTarget:=Abs(EntryPrice)*(1-Loss); >ProfitExit:=If(EntryPrice<0 AND H> ProfitTarget,ProfitTarget,0); >LossExit:=If(EntryPrice<0 AND L<= LossTarget,LossTarget,0); >ProfitExit:=If(EntryPrice<0 AND ProfitExit=0 AND LossExit=0,O,ProfitExit); >LossTarget; ProfitTarget; > > > >