PDA

View Full Version : Protective stops


sectorbets
26th June 2003, 09:52 PM
Hi David--

What a great product!!

It has so many things that I always wished I could test, but I'm having trouble implmenting protective stops. I've read the manual, the download, and everything in the forum, but am still coming up short.

My back test has an existing entry trigger and an exit trigger already for both long and short postions, and try as I might, I can't seem to get it right as to how to add a trailing stop in addiiton to the existing exit triggers.

Separately, I also can't get the bands or triggers plotted in MetaStock, so any help there would also be appreciated.

Best wishes,
Rick Martin

David Samborsky
27th June 2003, 03:11 AM
Hello Rick,

Could you please post your formulas here and I will scrutinize them for you.

sectorbets
27th June 2003, 10:42 AM
Here is the original code--I appreciate any help at all to get the trailing stops added to it, and to plot eitehr the triggers or bands. This is just the LONG side of the equation--I have a similar set of code for the short side.

EntryTrigger := Fml( "Coppock Momentum") >Ref(Fml("Coppock Momentum"), -1) AND
((C>Ref(O,-1) AND Ref(Black(),-1)) OR
(C>Ref(C,-1) AND Ref(White(),-1)) OR
(Ref(Doji(), -1) AND C>Ref(C,-1)));


EntryPrice :=(OPEN+CLOSE)/2;

ExitTrigger := Fml( "Coppock Momentum")<Ref(Fml( "Coppock Momentum"), -1) AND
((C<Ref(C,-1) AND Ref(Black(),-1)) OR
(C<Ref(O,-1) AND Ref(White(),-1)) OR
(Ref(Doji(), -1) AND C<Ref(C,-1)));

ExitPrice := (OPEN+CLOSE)/2;

ExtFml( "TradeSim.Initialize");

ExtFml( "TradeSim.RecordTrades",
"CM Test Daily", { Trade Data Filename }
LONG, { Trade Position Type }
EntryTrigger, { Entry Trigger }
EntryPrice, { Entry Price }
0, { Optional Initial Stop }
ExitTrigger, { Exit Trigger }
ExitPrice, { Exit Price }
START); { Recorder Control }

I haven't added in my failed attempts to get the trailing stops to work since they would just add clutter.

Best wishes,
Rick Martin

David Samborsky
27th June 2003, 01:11 PM
You could try this:-


EntryTrigger &#58;= Fml&#40; "Coppock Momentum"&#41; >Ref&#40;Fml&#40;"Coppock Momentum"&#41;, -1&#41; AND
&#40;&#40;C>Ref&#40;O,-1&#41; AND Ref&#40;Black&#40;&#41;,-1&#41;&#41; OR
&#40;C>Ref&#40;C,-1&#41; AND Ref&#40;White&#40;&#41;,-1&#41;&#41; OR
&#40;Ref&#40;Doji&#40;&#41;, -1&#41; AND C>Ref&#40;C,-1&#41;&#41;&#41;;

EntryPrice &#58;=&#40;OPEN+CLOSE&#41;/2;

ExitTrigger1 &#58;= Fml&#40; "Coppock Momentum"&#41;<Ref&#40;Fml&#40; "Coppock Momentum"&#41;, -1&#41; AND
&#40;&#40;C<Ref&#40;C,-1&#41; AND Ref&#40;Black&#40;&#41;,-1&#41;&#41; OR
&#40;C<Ref&#40;O,-1&#41; AND Ref&#40;White&#40;&#41;,-1&#41;&#41; OR
&#40;Ref&#40;Doji&#40;&#41;, -1&#41; AND C<Ref&#40;C,-1&#41;&#41;&#41;;

Period&#58;=10; &#123; ATR period &#125;
ARC&#58;=1.5; &#123; Average Range Constant &#125;
Volatility&#58;=ARC*ATR&#40;Period&#41;;

ExitTrigger2&#58;=ExtFml&#40; "TradeSim.TrailingStop",
TRIGGER,
LONG,
Volatility,
CLOSE,
LOW&#41;;

ExitTrigger&#58;=ExitTrigger1 OR ExitTrigger2;

ExitPrice &#58;= &#40;OPEN+CLOSE&#41;/2;

ExtFml&#40; "TradeSim.Initialize"&#41;;

ExtFml&#40; "TradeSim.RecordTrades",
"CM Test Daily", &#123; Trade Data Filename &#125;
LONG, &#123; Trade Position Type &#125;
EntryTrigger, &#123; Entry Trigger &#125;
EntryPrice, &#123; Entry Price &#125;
0, &#123; Optional Initial Stop &#125;
ExitTrigger, &#123; Exit Trigger &#125;
ExitPrice, &#123; Exit Price &#125;
START&#41;; &#123; Recorder Control &#125;

sectorbets
27th June 2003, 01:36 PM
Thanks David--

I'll give it a shot. One last question: where do I put the ExitLong / ExitShort statements to get the triggers on a MetaStock chart?

Best wishes,
Rick Martin

Metastockuser
29th July 2003, 05:35 PM
David,

That formula showing how to use two Exit triggers was very helpful to me. I'm now able to use both the system signal and trailing stop loss as exit signals. That was my goal for the day and you made it easy. You might want to include a similar entire example in the manual!

As a total non programmer it is MOST helpful when the entire program is completely shown when detailing how to do something. All the entrance and exit material, the Intializing, everything. When the specific code is given but not placed within the CONTEXT of the entire formula, I get lost on how to apply it. I know that a programmer assumes the reader understands where it gets placed in the code...but us non-programmers get totally lost at that point. And I guess that's my only negative on the manual. Some very helpful specifics are there, but for us non programers it would help if all specifics in the manual are placed inside a generic, complete program.

However, Between the manual and some of the material you have produced here on the discussion boards, Ive been able to work it all out.

Trade Sim is working well. I'm particulary pleased with the ability to look at monthly and yearly break outs of the trading to see how consistently the system being tested has performed over time. Something that Metastock did not focus on ( as Trade Sim has). I suspect Metastock will eventually improve their ablity in that area. Of course by then, you guys will have added more features as well! ;-)

David Samborsky
30th July 2003, 01:39 AM
Yes agree that some examples showing how to employ the functions would be a great asset to beginners. Will endeavour to update the manual in this respect.