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

[EquisMetaStock Group] Initial/Trailing stop %



PureBytes Links

Trading Reference Links

Erc90, it's best to code stops separately and then reference them into 
TradeSim explorations - this way one can see how they actually work on 
charts.

>From http://www.metastocktools.com/#metastock :

====================================
Trailing Stop - AdvTrailStop plug-in
====================================
---8<----------------------------------------

{ Initial/Trailing Stop Long v2.0

  Note: Stop will not "see" entry signals
   on neither the exit or the next signal bar.

  AdvancedStop.dll must be in the
  ...\MetaStock\External Function DLLs\ folder.
  AdvancedStop.dll by Richard Dale, free from:
http://www.tradernexus.com/advancedstop/advancedstop.html

 ©Copyright 2004-2007 Jose Silva.
  The grant of this license is for personal use
   only - no resale or repackaging allowed.
  All code remains the property of Jose Silva.
  http://www.metastocktools.com }

{ User inputs }
per1:=Input("Initial Stop buffer %",0,100,7);
per2:=Input("Trailing Stop buffer %",0,100,7);
pr:=Input("Stop reference: [1]Open, [2]High, [3]Low, [4]Close",1,4,4);
stopCh:=Input("Stop resets at:  [1]Close,  [2]Intraday",1,2,1);
plot:=Input("plot:  [1]Stop,  [2]Signals,  [3]Trade flag",1,3,1);

{ Entry/Exit Long signals reference }
entry:=Cross(C,Mov(C,21,E)); {<- Example}
exit:=0; {<- Optional}

{ Stop price reference }
x:=If(pr=1,O,If(pr=2,H,If(pr=3,L,C)));

{ Long Initial/Trailing Stop }
StopLong:=ExtFml("AdvancedStop.StopLong",
 entry,x*(1-per1/100),0,x*(1-per2/100),0,0,0,0);
InitLong:=If(StopLong>=L AND stopCh=2 OR exit,
 C,x*(1-per1/100));
TrailLong:=If(StopLong>=L AND stopCh=2 OR exit,
 C,x*(1-per2/100));
StopLong:=ExtFml("AdvancedStop.StopLong",
 entry,InitLong,0,TrailLong,0,0,0,0);

{ Long trade flag / signals }
flag:=ExtFml("AdvancedStop.StageLong",
 entry,InitLong,0,TrailLong,0,0,0,0)>0;
entry:=flag AND Alert(flag=0,2);
exit:=flag=0 AND Alert(flag,2);
signals:=entry-exit;

{ Plot stop on price chart }
If(plot=1,StopLong,If(plot=2,signals,flag))

---8<----------------------------------------

This stop references custom entry signals.  These can be hard-coded into 
the stop indicator or referenced from an external signals indicator.  Exit 
signals for the stop are optional but strongly recommended.


jose '-)
http://www.metastocktools.com




--- In equismetastock@xxxxxxxxxxxxxxx, "erc90" <erc90@xxx> wrote:
>
> Does anyone know how to set a protective stop-loss at 7% of equity, 
> i.e., if one's entire account drops by 7% from the initial capital then 
> sell everything?
> 
> thanks!





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/equismetastock/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/equismetastock/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:equismetastock-digest@xxxxxxxxxxxxxxx 
    mailto:equismetastock-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    equismetastock-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/