Here, I calculate the maximum allowed loss based on a fixed percentage of the closing price.


Fixed-percentage trailing stop for MetaStock

{SVE_Stop_Trail%_Date: Fixed percentage trailing stop from date}
InpMonth:=Input("Month",1,12,1);
InpDay:=Input("Day",1,31,1);
InpYear:=Input("Year",1800,2050,2009);
LongShort:=Input("1=Long or 2=Short? ",1,2,1);
InitStop:=Input("Initial Stop Price",0.1,10000,10);
Perc:=Input("Trailing Stop Percentage",1,30,12);
Loss:=C*Perc/100;
Entry:= InpYear=Year() AND InpMonth=Month() AND InpDay=DayOfMonth();
StopLong:=ExtFml("AdvancedStop.StopLong", Entry,InitStop,0,C-Loss,0,0,0,0);
StopShort:=ExtFml("AdvancedStop.StopShort",Entry,
Initstop,0,C+Loss,0,0,0,0);
Trail:=If(LongShort=1,Stoplong,Stopshort);
Trail