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

RE: [amibroker] Re: EasyLanguage question



PureBytes Links

Trading Reference Links

I tried several variations, but I'm not getting it. It plots, but has a very odd reaction with different periods and does not emulate the chart previously posted and attached again. If any Tradestation person would like to have a look…

 

Here's the code I have so far (with notes).

 

//================= TWITCH FUNCTION ======================

/*

EASYLANGUAGE FUNCTION:

Inputs: price(NumericSeries), initLength(NumericSimple);

variables: length(0), x(0), y(0), y1(0), y2(0), u(0), u1(0), u1_2(0), u_2(0);

 

If initLength <2 then length = 2 else length = initlength;

if CurrentBar = 1 then begin

    x=(1- cosine(360/Length))/0.414213562;

    u=-x + squareroot(x*x+2*x);

    u1= 1.0-u;

    u1_2=u1*u1;

    u_2=u*u;

    y1=price;

    y2=y1;

end;

y=u_2* price+2*u1*y1-u1_2*y2;

y2=y1;

y1=y;

 

TWITCH=Y

 

//From Fred:

 

Subject: [amibroker] Re: EasyLanguage question

 

In the ela/d/s code ...

 

Y = u_2* price+2*u1*y1-u1_2*y2;

y2 = y1;

y1 = y;

 

The next time Y is calculated ( on the next bar ) Y2 will have the

value of Y from two bars ago ... Y1 will have the value of Y from

one bar ago ...

*/

function twitch (tprice, initLength)

{   /*

    Code for this function coded by:  BobR

    Code from Futures magazine Jan 2006, P39

    Adapted to Amibroker by TerryH on 1/31/2006

    */

 

    length = Max( 2, initLength);

    for (t = 1; t < BarCount; t++)

    {

        x[t] = (1 - cos(360 / length)) / 0.414213562;

        u[t] = -x[t] + sqrt(x[t]^2 + 2 * x[t]);

        u1[t] = 1 - u[t];

        //u1_2 = u1 * u1; //Substituted u1^2

        //u_2 = u * u; //Substituted u^2

        y1[t] = tprice[t-1];

        y2[t] = y1[t-1];

    }

    for (t = 1; t < BarCount; t++)

    {

        y[t] = u[t]^2 * tprice[t] + 2 * u1[t] * y1[t] - u1[t]^2 * y2[t];

        y2[t] = y1[t-1];

        y1[t] = y[t-1];

    }

    return y;

}

//================= END FUNCTION ======================

 

Period = Param("Twitch Period",21,2,100,1,5); //number of bars to use in "average"

TwValue = twitch(C,period);

 

Plot(C,Name(),colorBlack,styleLine);

Plot(TwValue,"Twitch",colorRed);

 

--

Terry

 

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Terry
Sent: Tuesday, January 31, 2006 12:50
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Re: EasyLanguage question

 

Thanks Fred. That should let me make this thing work with a loop.

 

--

Terry

 

-----Original Message-----

From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On

Behalf Of Fred

Sent: Tuesday, January 31, 2006 11:43

To: amibroker@xxxxxxxxxxxxxxx

Subject: [amibroker] Re: EasyLanguage question

 

In the ela/d/s code ...

 

Y = u_2* price+2*u1*y1-u1_2*y2;

y2 = y1;

y1 = y;

 

The next time Y is calculated ( on the next bar ) Y2 will have the

value of Y from two bars ago ... Y1 will have the value of Y from

one bar ago ...

 

--- In amibroker@xxxxxxxxxxxxxxx, "Terry" <MagicTH@xxxx> wrote:

>

> I am trying to convert a function called Twitcher from TradeStation

> EasyLanguage. Twitcher concept was published in last month's

FUTURES

> Magazine. Code is from a user's group.

>

> QUESTION: Does the following code for y refer to the next bar and

next 2

> bars or previous bars?

>

> Y = u_2* price+2*u1*y1-u1_2*y2;

> y2 = y1;

> y1 = y;

>

> Here's the entire EasyLanguage code (for the twitcher function)

>

> EASYLANGUAGE FUNCTION:

> Inputs: price(NumericSeries), initLength(NumericSimple);

> variables: length(0), x(0), y(0), y1(0), y2(0), u(0), u1(0), u1_2

(0),

> u_2(0);

>

> If initLength <2 then length = 2 else length = initlength;

> if CurrentBar = 1 then begin

>     x=(1- cosine(360/Length))/0.414213562;

>     u=-x + squareroot(x*x+2*x);

>     u1= 1.0-u;

>     u1_2=u1*u1;

>     u_2=u*u;

>     y1=price;

>     y2=y1;

> end;

> y=u_2* price+2*u1*y1-u1_2*y2;

> y2=y1;

> y1=y;

>

> TWITCH=Y

> --

> Terry

>

 

 

 

 

 

 

 

Please note that this group is for discussion between users only.

 

To get support from AmiBroker please send an e-mail directly to

SUPPORT {at} amibroker.com

 

For other support material please check also:

http://www.amibroker.com/support.html

 

 

Yahoo! Groups Links

 

 

 

 

 

 

 

 

------------------------ Yahoo! Groups Sponsor --------------------~-->

Try Online Currency Trading with GFT. Free 50K Demo. Trade

24 Hours. Commission-Free.

http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM

--------------------------------------------------------------------~->

 

Please note that this group is for discussion between users only.

 

To get support from AmiBroker please send an e-mail directly to

SUPPORT {at} amibroker.com

 

For other support material please check also:

http://www.amibroker.com/support.html

 

 

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:

    http://docs.yahoo.com/info/terms/

 

 



Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





SPONSORED LINKS
Investment management software Real estate investment software Investment property software
Software support Real estate investment analysis software Investment software


YAHOO! GROUPS LINKS




Attachment: Twitcher Emini.gif
Description: GIF image