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

[amibroker] Re: need some debugging help on this one



PureBytes Links

Trading Reference Links




Try:
 
//Ehlers ITrend 
(Cybernetic Analysis for Stocks and Futures 
p.24)
<FONT color=#0000ff 
size=2>SetBarsRequired<FONT color=#0000ff 
size=2>(1000000,1000000);
Y=(H<FONT 
size=2>+L)/2; 
<FONT 
size=2>//Price
alpha=Param<FONT 
size=2>("alpha",0.07,0.01<FONT 
size=2>,1,0.01<FONT 
size=1>);
Smooth=0<FONT 
size=2>;ITrend=0;Trigger=0<FONT 
size=2>;
for<FONT 
color=#0000ff size=2>(i=2;i<BarCount;i++)<FONT 
size=1>
{
<FONT 
size=2>ITrend[i]=(alpha-alpha*alpha/4)*Y[i]+0.5<FONT 
size=2>*alpha*alpha*Y[i-1<FONT 
size=2>]-(alpha-0.75*alpha*alpha)*Y[i-2<FONT 
size=2>]+2*(1<FONT 
size=2>-alpha)*ITrend[i-1]-(1<FONT 
size=2>-alpha)*(1<FONT 
size=2>-alpha)*ITrend[i-2<FONT color=#0000ff 
size=2>];
if<FONT 
size=2>(i<7) 
ITrend[i]=(Y[i]+2*Y[i-1<FONT 
size=2>]+Y[i-2<FONT 
size=2>])/4<FONT color=#0000ff 
size=2>;
<FONT 
color=#0000ff>Trigger[i]=2<FONT color=#0000ff 
size=2>*Itrend[i]-ITrend[i-2<FONT color=#0000ff 
size=2>];
}
Clr=<FONT 
color=#0000ff><FONT 
size=2>IIf(Trigger>Y,colorGreen,IIf(Trigger<Y,colorRed,colorYellow));<FONT 
size=1>
Plot<FONT 
color=#0000ff size=2>(ITrend, "ITrend",1,8);<FONT 
size=1>
Plot<FONT 
color=#0000ff size=2>(Trigger, "Trigger",Clr,8);<FONT 
size=1>
Plot<FONT 
color=#0000ff size=2>(Y,"Prices",2,8);<FONT 
size=1>
<FONT color=#0000ff 
size=2>GraphXSpace<FONT color=#0000ff 
size=2>=5;
<FONT color=#0000ff 
size=2>Title=" 
\\c03Ehlers ITrend (Cyber) \\c01ITrend \\c00Trigger \\c-1alpha "+alpha+" 
";
 
-CS
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  <A title=bmwmcrider@xxxxxxxxxxxxx 
  href="">bmwmcrider 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Friday, April 30, 2004 6:00 
AM
  Subject: [amibroker] X-lation of Ehler's 
  EasyLanguage code int afl
  Hello,I just started reading Ehler's Cybernetic 
  Analysis For Stocks And Futures.  On page 24 he presents an 
  indicator, ITrend, in EasyLanguage script as 
  follows:    Inputs:     
  Price((H+L)/2),                
  Alpha(.07);               
      Vars:       
  Smooth(0),                
  ITrend(0),                
  Trigger(0);               
      ITrend = (alpha - 
  alpha*alpha/4)*Price             
  + .5*alpha*alpha*Price[1] - 
  (alpha             
  - .75*alpha*alpha)*Price[2] + 
  2             
  *(1 - alpha)*ITrend[1] - (1 - 
  alpha)             
  *(1- alpha)*ITrend[2];    If currentbar < 7 then ITrend 
  = (Price + 
  2*Price[1]             
  + Price[2])/4;    Trigger = 2*ITrend - 
  ITrend[2];        Plot1(ITrend, 
  "ITrend");    Plot2(Trigger, "Trig");    
  I am not knowledgeable on EasyLanguage script.  Anxious to see his 
  code in operation I attempted a literal translation of the above into 
  afl script as follows:    price = 
  (H+L)/2;    alpha = .07;    iTrend = 
  0;    iTrend = IIf(BarIndex()<7,(price + 
  2*Ref(price,-1) + 
                   
  Ref(price,-2))/4, ((alpha - alpha*alpha/4) * 
                   
  price + .5*alpha*alpha*Ref(price,-1) 
  -                 
  (alpha - .75*alpha*alpha)*Ref(price,-2) + 
                   
  2*(1 -alpha)*Ref(iTrend,-1) 
  -                 
  (1 - alpha)*(1 - alpha)*Ref(iTrend,-2)));    trigger = 
  2*iTrend - Ref(iTrend,-2);    
  Plot(iTrend,"iTrend",colorGreen,styleLine);    
  Plot(trigger,"Trigger", colorRed,styleLine);    Upon 
  placing the above in IB and plotting the results I got a set of bizarre 
  looking traces.  I expected a set of traces similar to, say, moving 
  averages.If anyone out there knowledgeable on EasyLanguage could look 
  at my implementation of Ehler's script and point out any errors that I 
  might have made I would be 
  grateful.MikeSend 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 
  


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.