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

Re: [amibroker] File Reading/Writing



PureBytes Links

Trading Reference Links




HERE 
YOU GO...
 
Regards, 
Jayson 
 <FONT 
color=#282828 size=2>
<FONT face=Arial 
color=#0000ff>/*
Instantaneous Trendline
TASC V. 18:5 (18-27): Adaptive Trends and 
Oscillators by Ehlers
AFL conversion by Corey Saxe
*/<FONT color=#282828 
size=2>
<FONT face=Arial 
color=#0000ff>//SetBarsRequired(10000,10000);<FONT 
color=#282828 size=2>
Y=(<FONT 
face=Arial color=#0000ff>H<FONT 
color=#0000ff>+<FONT 
size=2>L<FONT 
size=2>)/2<FONT color=#282828 
size=2>;
pi = <FONT 
color=#0000ff>4 * <FONT 
size=2>atan(1) ; 
<FONT face=Arial 
color=#0000ff>//Pi
RTD = <FONT 
color=#0000ff>180/pi;<FONT 
color=#008000 size=2>//radians to 
degrees
DTR = pi/<FONT 
face=Arial>180<FONT 
size=2>;<FONT face=Arial 
color=#0000ff>//degrees to radians<FONT color=#282828 
size=2>
//InPhase & Quad 
components---------------------------------------<FONT 
color=#282828 size=2>
V1=Y-<FONT 
color=#0000ff>Ref(Y,-<FONT 
size=2>6<FONT face=Arial 
color=#0000ff>);
V2=<FONT 
color=#0000ff>Ref(V1,-<FONT 
size=2>3<FONT face=Arial 
color=#0000ff>);
V3 =<FONT 
color=#0000ff>0.75*(V1 - <FONT 
size=2>Ref(V1,-6)) + 
0.25*(<FONT 
size=2>Ref(V1,-2)- 
Ref(V1,-<FONT 
size=2>4<FONT face=Arial 
color=#0000ff>));
IP = <FONT 
color=#0000ff>AMA(V2,<FONT 
size=2>0.33<FONT face=Arial 
color=#0000ff>);
Quad = <FONT 
color=#0000ff>AMA(V3,<FONT 
size=2>0.2<FONT face=Arial 
color=#0000ff>);
//Use ArcTan to compute the current 
phase--------------------------
Phase=<FONT 
color=#0000ff>IIf (<FONT 
size=2>abs(IP + Ref<FONT 
size=2>(IP,-1)) > <FONT 
size=2>0<FONT face=Arial 
color=#0000ff>,
atan<FONT 
size=2>(abs( (Quad+<FONT 
size=2>Ref(Quad,-1)) 
/ ( IP + Ref(IP,-<FONT 
size=2>1) ))) * RTD, <FONT 
size=2>0<FONT face=Arial 
color=#0000ff>);
Phase=<FONT 
color=#0000ff>IIf (IP < <FONT 
size=2>0 <FONT 
size=2>AND<FONT 
size=2> Quad > 0, <FONT 
size=2>180<FONT face=Arial 
color=#0000ff> - Phase, 
IIf<FONT 
size=2> (IP < 0 <FONT 
size=2>AND<FONT 
size=2> Quad < 0, <FONT 
size=2>180<FONT face=Arial 
color=#0000ff> + Phase, 
IIf<FONT 
size=2> (IP > 0 <FONT 
size=2>AND<FONT 
size=2> Quad < 0, <FONT 
size=2>360<FONT face=Arial 
color=#0000ff> - Phase, Phase)));
//Compute differential 
phase------------------------------------------<FONT 
color=#282828 size=2>
DP = <FONT 
color=#0000ff>Ref(Phase,-<FONT 
size=2>1) - Phase;<FONT color=#008000 
size=2>//DeltaPhase<FONT 
color=#282828 size=2>
DP = <FONT 
color=#0000ff>IIf ( <FONT 
size=2>Ref(Phase,-1) 
< 90 <FONT 
size=2>AND<FONT 
size=2> Phase > 270, <FONT 
size=2>360 + Ref<FONT 
size=2>(Phase,-1<FONT color=#282828 
size=2>) - Phase, DP);
DP = <FONT 
color=#0000ff>IIf (DP < <FONT 
size=2>1 , 1, 
IIf (DP > <FONT 
size=2>60, 60<FONT 
color=#282828 size=2>, 
DP));
//Sum deltaphases, sum is Instantaneous 
Period-----------------------
instper=<FONT face=Arial 
color=#0000ff size=2>0<FONT face=Arial 
color=#0000ff>;
V4=<FONT face=Arial 
color=#0000ff size=2>0<FONT face=Arial 
color=#0000ff>;
for<FONT 
color=#0000ff>(i=40<FONT 
size=2>;i<BarCount<FONT 
color=#282828 size=2>;i++)
{<FONT color=#800000 
size=2>
for<FONT 
color=#0000ff>(j=0<FONT 
size=2>;j<40<FONT color=#282828 
size=2>;j++)
{
V4[i]=V4[i] + 
DP[i-j];
if<FONT 
color=#0000ff>(V4[i]>360 
AND InstPer[i]==<FONT 
size=2>0<FONT face=Arial 
color=#0000ff>) InstPer[i]=j;
}
}<FONT color=#008000 
size=2>
//Resolve Instantaneous Period errors & 
smooth----------------------
instper=<FONT 
color=#0000ff>IIf(instper==<FONT 
size=2>0,40<FONT 
color=#282828 size=2>,instper);
V5=<FONT 
color=#0000ff>AMA(InstPer,<FONT 
size=2>0.25<FONT face=Arial 
color=#0000ff>);
period=<FONT face=Arial 
color=#0000ff size=2>int<FONT face=Arial 
color=#0000ff>(V5);
Adj=<FONT 
color=#0000ff>Param("MS 
Adj",2,<FONT 
size=2>0,3<FONT 
size=2>,1<FONT color=#282828 
size=2>);
TL=<FONT 
color=#0000ff>Sum<FONT 
size=2>(Y,period+Adj)/(period+Adj);<FONT color=#008000 
size=2>//Trendline<FONT 
color=#282828 size=2>
V11=<FONT 
color=#0000ff>AMA(Y+<FONT 
size=2>0.5*(Y-Ref<FONT 
size=2>(Y,-3)),<FONT 
size=2>0.33<FONT face=Arial 
color=#0000ff>);
Plot<FONT color=#282828 
size=2>(V11, "Sig"<FONT color=#282828 
size=2>,3<FONT color=#282828 
size=2>,1<FONT color=#282828 
size=2>);
Plot<FONT color=#282828 
size=2>(TL, "Trendline"<FONT 
color=#282828 size=2>,0<FONT 
color=#282828 size=2>,1<FONT 
color=#282828 size=2>);<FONT color=#0000ff 
size=2>
Plot<FONT color=#282828 
size=2>(C<FONT 
color=#282828 size=2>,"Prices"<FONT 
color=#282828 size=2>,2<FONT 
color=#282828 size=2>,128<FONT 
color=#282828 size=2>);<FONT color=#008000 
size=2>
<FONT face=Arial 
color=#0000ff>//Plot(V11-TL,"Diff",IIf((V11-TL)<0,4,5),1|styleOwnScale);<FONT 
color=#282828 size=2>
dir1 =TL><FONT 
face=Arial>Ref<FONT 
size=2>(TL,-1<FONT color=#282828 
size=2>);
dir2 =V11>TL;<FONT 
color=#0000ff size=2>
Plot<FONT color=#282828 
size=2>( 2.5<FONT color=#282828 
size=2>,"TL>Ref(TL,-1)"<FONT 
color=#282828 size=2>,IIf<FONT 
color=#282828 size=2>( dir1, <FONT 
size=2>colorGreen, 
colorRed<FONT 
color=#282828 size=2> ),<FONT 
size=2>styleOwnScale<FONT color=#282828 
size=2>|styleArea<FONT 
color=#282828 size=2>|styleNoLabel<FONT 
face=Arial>, <FONT color=#ff00ff 
size=2>0, <FONT color=#ff00ff 
size=2>100<FONT 
face=Arial>);
Plot<FONT color=#282828 
size=2>(3<FONT color=#282828 
size=2>,"black"<FONT color=#282828 
size=2>,colorBlack<FONT 
face=Arial>,<FONT 
size=2>styleOwnScale<FONT color=#282828 
size=2>|styleArea<FONT 
color=#282828 size=2>|styleNoLabel<FONT 
face=Arial>,<FONT color=#ff00ff 
size=2>0, <FONT color=#ff00ff 
size=2>100 );<FONT color=#008000 
size=2>//black line<FONT color=#0000ff 
size=2>
Plot<FONT color=#282828 
size=2>( 5.5<FONT color=#282828 
size=2>,"TL>Sig"<FONT color=#282828 
size=2>,IIf( 
dir2, colorGreen<FONT 
color=#282828 size=2>, colorRed<FONT 
face=Arial> ),<FONT 
size=2>styleOwnScale<FONT color=#282828 
size=2>|styleArea<FONT 
color=#282828 size=2>|styleNoLabel<FONT 
face=Arial>, <FONT color=#ff00ff 
size=2>0, <FONT color=#ff00ff 
size=2>100<FONT 
face=Arial>);
GraphXSpace<FONT 
face=Arial>=<FONT 
size=2>5<FONT face=Arial 
color=#0000ff>;
Title<FONT 
color=#0000ff>=" Ehlers Instantaneous Trendline 
";
<FONT face=Tahoma 
size=2>-----Original Message-----From: Bob Jagow 
[mailto:bjagow@xxxxxxxxxxxxx]Sent: Monday, February 23, 2004 4:45 
PMTo: amibroker@xxxxxxxxxxxxxxxSubject: RE: [amibroker] 
AFL - Translatin TS code
<FONT face=Arial color=#0000ff 
size=2>Outlook says it can't find your attachment, Corey.
Could 
you please resend it?
<FONT face=Arial color=#0000ff 
size=2>TX,
<FONT face=Arial color=#0000ff 
size=2>Bob

  <FONT face=Tahoma 
  size=2>-----Original Message-----From: Corey Saxe 
  [mailto:res1wgwl@xxxxxxxxxxx]Sent: Monday, February 23, 2004 1:02 
  PMTo: amibroker@xxxxxxxxxxxxxxxSubject: Re: [amibroker] 
  AFL - Translatin TS code
  Instantaneous Trendline? (Attachment)
  Seems that TJ did this one first, can't 
  remember...
   
  -CS
  <BLOCKQUOTE 
  >
    ----- Original Message ----- 
    <DIV 
    >From: 
    Ara Kaloustian 
    
    To: <A title=amibroker@xxxxxxxxxxxxxxx 
    href="">Ami-Main 
    Sent: Monday, February 23, 2004 12:04 
    PM
    Subject: [amibroker] AFL - Translatin 
    TS code
    
    The code below gives me an error 
    of:
    Error 3.Condition in IF, WHILE, FOR 
    statementshas to be Numeric or Boolean type
     
    Problem area highlighted below.
     
    Anyone see the problem?
     
    Thanks
     
    Ara
     
    PS: Does anyone have this code already (John 
    Ehler's Trendline). Trying to convert from Trade Station
     
     
    
    //File: DEV - Ehler Trendline
    Price =(H+L)/<FONT color=#ff00ff 
    size=1>2;
    Imult =0.635;
    Qmult =0.338;
    InPhase =0;
    Quadrature =0;
    Phase =0;
    DeltaPhase =0;
    count =0;
    InstPeriod =0;
    Period =0;
    Trendline =0;
     
    if (<FONT color=#0000ff 
    size=1>LastValue(<FONT color=#0000ff 
    size=1>BarIndex()) > <FONT color=#ff00ff 
    size=1>5)
    //Detrend Price
    {Value3 = Price - Ref<FONT 
    size=1>(Price,-7<FONT 
size=1>);}
     
    //Compute InPhase AND Quadrature components
    Inphase = 1.25<FONT 
    size=1>*(Ref<FONT 
    size=1>(Value3,-4) - 
    Imult*Ref<FONT 
    size=1>(Value3,-2)) + 
    Imult*Ref<FONT 
    size=1>(InPhase,-3<FONT 
    size=1>);
    Quadrature = Ref<FONT 
    size=1>(Value3,-2) - 
    Qmult*Value3 + Qmult*Ref<FONT 
    size=1>(Quadrature,-2<FONT 
    size=1>);
    //Use ArcTangent to compute the current phase
    LastInPhase = LastValue<FONT 
    size=1>(InPhase);
    if (<FONT color=#0000ff 
    size=1>abs(LastInPhase + <FONT color=#0000ff 
    size=1>Ref(LastInPhase,-<FONT color=#ff00ff 
    size=1>1<FONT 
    size=1>)))                 <FONT 
    size=2> // <==== Problem in Ref(LastInPhase,-1)<FONT 
    color=#008000>
    {<FONT 
    color=#008000 size=1>
    //Phase = atan(abs((Quadrature+Ref(Quadrature,-1)) / 
    (InPhase+Ref(InPhase,-1))));
    a=0;
    }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 
    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 
    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 



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




Click Here















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.