MetaStock™ Zone Forum & FAQ Artykuły Linki Elliott Waves EasyLanguage™ Zone

A B C D E F G H I J K L M N O P R S T U V W Y Z #

Trailing Stop - AdvTrailStop plug-in by Jose Silva

--- In equismetastock@xxxxxxxxxxxxxxx, "erc90" 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!

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

{ 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))

 

Trailing Stop - AdvTrailStop plug-in by Jose Silva

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

Source / From: TOP
http://purebytes.com/archives/metastock/  

Equis and MetaStock® and MetaStock Professional® are registered trademarks of Equis International. Achelis Binary Wave®, The DownLoader®,
Expert Advisor®, OptionScope®, Quotecenter® and Smart Charts® are trademarks of Equis International, a Thomson Reuters company.

TradeStation® Pro, TradeStation® 2000i, OptionStation®, SuperCharts®, PowerEditor® and EasyLanguage®
are registered trademarks of TradeStation Technologies, Inc. Other names and marks referred to are the property of their respective owners.

All information provided on this website is for educational purposes only. Trading involves risk, including possible loss of principal and other losses.

Ten i inne materiały na tej stronie zostały zamieszczone zostały jedynie w celach edukacyjnych, nie ponoszę żadnej odpowiedzialno¶ci za ich stosowanie.

Gra na giełdzie i rynkach walutowych (FOREX) niesie ze sob± ryzyko poważnych strat finansowych!