Metastockuser
3rd August 2003, 03:03 AM
I've been able to get a intial stop to function as a protective stop as well as set up trailing standard deviation and volatility stops to work.
But I've got no clue about a plain old Fixed Trailing stop loss.
I have found a formula on the net which goes like thisL
If(cum(1)=1,
{then} Close,
{else} If((C*1.1) <= PREV,
{then}(C*1.1),
{else} PREV));
But no clue as to what it means or how to work it. By way of example I'd be interested in what a 10% trailing stop would look like, how I would set it up.
I'm using the basic indicator as the first stop trigger. A Fixed Trailing stop loss would be my second trigger.
Jose
15th August 2003, 09:18 PM
MetaStock -> Tools -> Indicator Builder -> New
Copy and paste formulae below.
=========================
Trailing Stop - MetaStock
=========================
---8<---------------------------
{Triggers Long (+1) & Short (-1) signals at
crossover of user-defined trailing stops}
{x23 slower than TradeSim's version}
{josesilva22@yahoo.com}
fixed:=Input("fixed % trailing stop",0,100,5);
plot:=Input("plot: trailing stop=1, signals=2",1,2,1);
delay:=Input("signal Entry and Exit delay",
0,3,0);
StLong:=C-C*fixed/100;
StShort:=C+C*fixed/100;
stopLong:=If(C<PREV,StLong,Max(StLong,PREV));
stopShort:=If(C>PREV,StShort,Min(StShort,PREV));
In:=Cross(C,Ref(stopShort,-1));
Out:=Cross(Ref(stopLong,-1),C);
Init:=Cum(In+Out>-1)=1;
InInit:=Cum(In)=1;
Flag:=BarsSince(Init OR In)
< BarsSince(Init OR Out)+InInit;
signals:=Ref((InInit AND Alert(InInit=0,2)
OR Flag AND Alert(Flag=0,2))
+(Flag=0 AND Alert(Flag,2))*-1,-delay);
If(plot=1,Ref(stopLong,-1),signals);
If(plot=1,Ref(stopShort,-1),signals)
---8<---------------------------
========================
Trailing Stop - TradeSim
========================
---8<---------------------------
{Triggers Long (+1) & Short (-1) signals at
crossover of user-defined trailing stops}
{x23 faster than MetaStock's 4-PREV version}
{TradeSim.dll must be in
...\MetaStock\External Function DLLs\ folder}
{josesilva22@yahoo.com}
fixed:=Input("fixed % trailing stop",0,100,5);
plot:=Input("plot: trailing stop=1, signals=2",1,2,1);
delay:=Input("signal Entry and Exit delay",
0,3,0);
Volatility:=C*fixed/100;
stopLong:=ExtFml("TradeSim.TrailingStop",
BAND, {mode: band or trigger}
LONG, {long or short}
Volatility, {user defined see variable above}
CLOSE, {RefPoint for stop calc}
CLOSE); {threshold - stop breached}
stopShort:=ExtFml("TradeSim.TrailingStop",
BAND,SHORT,Volatility,CLOSE,CLOSE);
In:=Cross(C,Ref(stopShort,-1));
Out:=Cross(Ref(stopLong,-1),C);
Init:=Cum(In+Out>-1)=1;
InInit:=Cum(In)=1;
Flag:=BarsSince(Init OR In)
< BarsSince(Init OR Out)+InInit;
signals:=Ref((InInit AND Alert(InInit=0,2)
OR Flag AND Alert(Flag=0,2))
+(Flag=0 AND Alert(Flag,2))*-1,-delay);
If(plot=1,Ref(stopLong,-1),signals);
If(plot=1,Ref(stopShort,-1),signals)
---8<---------------------------
jose '-)
tech/a
31st August 2003, 02:43 AM
M/S user
This is a 10% trailing stop I use in TRADESIM
InitialStop:=If(Ref(C,-1)>0.90*EntryPrice,0.90*EntryPrice,Ref(C,-1));
tech
tech/a
31st August 2003, 02:47 AM
Jose
How do I paste this up for use with Tradesim?
tech
Jose
31st August 2003, 03:36 AM
MetaStock -> Tools -> Indicator Builder -> New
Copy and paste "Trailing Stop - TradeSim" formula.
Entry condition:
---8<----------------------
...
AND c>Fml("Trailing Stop - TradeSim")
---8<----------------------
Exit condition:
---8<----------------------
...
OR c<Fml("Trailing Stop - TradeSim")
---8<----------------------
jose '-)
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.