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

RE: [amibroker] Re: CMS Trailing Stop System in AFL



PureBytes Links

Trading Reference Links




Hello,
 
I am not sure to have done a correct interpretation 
of Prev but it is a begin
 
Stephane
 

 
TrStop[0<FONT 
size=1>]=Null;
nP=0.<FONT face="Courier New" 
color=#ff00ff size=1>1;<FONT color=#800000 
size=1>
for(i=1<FONT 
size=1>;i<BarCount;i++)
{
if<FONT 
size=1>(C[i]==TrStop[i-1<FONT 
size=1>])
{
TrStop[i]=TrStop[i-1<FONT 
size=1>];
}
else
{
if<FONT 
size=1>(C[i-1<FONT 
size=1>]<TrStop[i-1] 
&& C[i]<TrStop[i-<FONT color=#ff00ff 
size=1>1])
{
TrStop[i]=Min<FONT 
size=1>(TrStop[i-1<FONT 
size=1>],C[i]*(1<FONT 
size=1>+nP));
}
else
{
if<FONT 
size=1>(C[i-1<FONT 
size=1>]>TrStop[i-1] 
&& C[i]>TrStop[i-<FONT color=#ff00ff 
size=1>1])
{
TrStop[i]=Max<FONT 
size=1>(TrStop[i-1<FONT 
size=1>],C[i]*(1<FONT 
size=1>-nP));
}
else
{
if<FONT 
size=1>(C[i]>TrStop[i-1<FONT 
size=1>])
{
TrStop[i]=C[i]*(1<FONT 
size=1>-nP);
}
else
{
TrStop[i]=C[i]*(1<FONT 
size=1>+nP);
}
}
}
}
}
 
 
Up= Cross<FONT 
size=1>(Close,TrStop);
Down= Cross<FONT 
size=1>(TrStop,C);
 
/*
if(C=PREV, PREV, if(((Ref(C,-1)<PREV)
AND (C<PREV)), Min(PREV,C*(1+nPips)), if((Ref(C,-1)>PREV) 
AND (C>PREV), Max(PREV,C*(1-nPips)), if(C>PREV,C*(1-nPips),C*
(1+nPips)))));
*/
Plot(C,<FONT color=#ff00ff 
size=1>"",1<FONT 
size=1>,64<FONT 
size=1>);
Plot(TrStop,<FONT color=#ff00ff 
size=1>"TrStop",<FONT color=#ff00ff 
size=1>2,1<FONT 
size=1>);
PlotShapes(<FONT color=#0000ff 
size=1>IIf(<FONT face="Courier New" 
size=1>up,
shapeUpArrow,shapeNone),colorGreen,<FONT 
color=#ff00ff size=1>0,L,-<FONT color=#ff00ff 
size=1>10); 
PlotShapes(<FONT color=#0000ff 
size=1>IIf(<FONT face="Courier New" 
size=1>down,
shapeDownArrow,shapeNone),colorRed,<FONT 
color=#ff00ff size=1>0,H,-<FONT color=#ff00ff 
size=1>10); 
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  rocou 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Friday, April 23, 2004 8:47 
AM
  Subject: [amibroker] CMS Trailing Stop 
  System in AFL
  Dear Traders, may I please ask for your help - how 
  do I have to program the following "trailing stop system" of my broker 
  CMS in AFL, to backtest/optimize the "n pips" stop values ?Thank 
  you for your help in advance.Kind regardsRobert{Trailing 
  Stop Loss}TrStopLevel:=If(C=PREV, PREV, If(((Ref(C,-1)<PREV)AND 
  (C<PREV)), Min(PREV,C*(1+nPips)), If((Ref(C,-1)>PREV) AND 
  (C>PREV), Max(PREV,C*(1-nPips)), 
  If(C>PREV,C*(1-nPips),C*(1+nPips)))));{Signal Up and 
  Down}Up:= Cross(Close,TrStopLevel);Down:= 
  Cross(TrStopLevel,C);{OpenBuy, CloseBuy, OpenSell, 
  CloseSell}OpenBuy:= Up and (eventCount('OpenBuy')= 
  eventCount('CloseBuy'));CloseBuy:= Down and 
  (eventCount('OpenBuy')>eventCount('CloseBuy'));OpenSell:=  Down 
  and (eventCount('OpenSell')= 
  eventCount('CloseSell'));CloseSell:=  Up and 
  (eventCount('OpenSell')>eventCount('CloseSell'));Send 
  BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  __________ 
  NOD32 1.732 (20040422) Information __________This message was checked 
  by NOD32 antivirus system.<A 
  href="">http://www.nod32.com


Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html








Yahoo! Groups Sponsor


  ADVERTISEMENT 












Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.