MetaStock™ Zone Tworzenie Sytemów Trader Shop 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 & Signals by Jose Silva
Long/Short price trailing stop & signals - MetaStock, TradeSim & AdvTrailingStop plug-in versions.

Trailing Stop - MetaStock by Jose Silva

{ Triggers: Long (+1) & Short (-1) signals at crossover of user-defined trailing stops }
{ x23 slower than TradeSim's version }
{ (c)Copyright 2003-2004 Jose Silva }
{ http://www.metastocktools.com }

buffer:=Input("buffer % trailing stop",0,100,8);
plot:=Input("plot: trailing stop=1, Long+Short=2, signals=3",1,3,1);
adv:=Input("plot: today's trailing stop=0, tomorrow's stop=1",0,1,0);
delay:=Input("Entry and Exit signal delay",
0,5,0);

StLong:=C-C*buffer/100;
StShort:=C+C*buffer/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)),-delay);
stop:=Ref(If(flag=1,stopLong,stopShort),-1+adv);

If(plot=1,stop,
If(plot=2,Ref(stopLong,-1+adv),0));
If(plot=1,stop,
If(plot=2,Ref(stopShort,-1+adv),signals))

 

 

 

Trailing Stop - AdvTrailStop (Plug-In)

{ Plot on price chart }
{ Triggers: Long (+1) & Short (-1) signals at
crossover of user-defined trailing stops }
{ Much faster than MetaStock's 4-PREV version }
{ ©Copyright 2004 Jose Silva }
{ http://www.metastocktools.com }

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

buffer1:=
Input("initial stop % buffer",0,100,5)/100;
buffer2:=
Input("trailing stop % buffer",0,100,8)/100;
plot:=Input("plot: trailing stop=1, Long+Short=2, signals=3",1,3,1);
adv:=Input("plot: today's trailing stop=0, tomorrow's stop=1",0,1,0);
delay:=Input("Entry and Exit signal delay",
0,5,0);

entrySignal:=C=C;
initialStopLong:=C*(1-buffer1);
trailStopLong:=C*(1-buffer2);
stopLong:=ExtFml("AdvancedStop.StopLong",
entrySignal,initialStopLong,0,trailStopLong,
0,0,0,0);

exitSignal:=Cross(stopLong,C);
initialStopShort:=C*(1+buffer1);
trailStopShort:=C*(1+buffer2);
stopShort:=ExtFml("AdvancedStop.StopShort",
exitSignal,initialStopShort,0,trailStopShort,
0,0,0,0);

entrySignal:=Cross(C,stopShort);
stopLong:=ExtFml("AdvancedStop.StopLong",
entrySignal,initialStopLong,0,trailStopLong,
0,0,0,0);

In:=Cross(C,Ref(stopShort,-1));
Out:=Cross(Ref(stopLong,-1),C);
Init:=Cum(In+Out>-1)=1;
flag:=BarsSince(Init OR In)
< BarsSince(Init OR Out)+(Cum(In)=1);
signals:=Ref(((Cum(In)=1)
AND Alert((Cum(In)=1)=0,2)
OR flag AND Alert(flag=0,2))
-(flag=0 AND Alert(flag,2)),-delay);
stop:=Ref(If(flag=1,stopLong,stopShort),-1+adv);

If(plot=1,stop,
If(plot=2,Ref(stopLong,-1+adv),0));
If(plot=1,stop,
If(plot=2,Ref(stopShort,-1+adv),signals))

 

Source / From: TOP
http://www.metastocktools.com

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!