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

[amibroker] Re: Regression between two price series?



PureBytes Links

Trading Reference Links

I suspect that you can do it by taking hints from the Portfolio script found in the the Equity folder of the Charts window.

Here's an idea:

// Use foreign to get the 'other' price

otherPrice = Foreign( "AA", "C" );

// Create a difference array 

difference = Close - otherPrice;

// The following is adapted from Portfolio.afl
// substituting the difference array in place of equity

islastbar = Status( "lastbarintest" );
isfirstbar = Status( "firstbarintest" );
bar = BarIndex();
firstbar = LastValue( ValueWhen( isfirstbar, bar ) );
lastbar = LastValue( ValueWhen( islastbar, bar ) );
al = LastValue( ValueWhen( islastbar, LinRegSlope( difference, lastbar - firstbar + 1 ) ) );
bl = LastValue( ValueWhen( islastbar, LinRegIntercept( difference, lastbar - firstbar + 1 ) ) );
lr = al * ( BarIndex() - firstbar ) + bl;
lr = IIf( bar >= firstbar AND bar <= lastbar , lr, Null );

Plot( Close, "Close", colorGreen );
Plot( otherPrice, "Other", colorBlue );
Plot( lr , "Linear Reg", colorRed, styleThick );

Mike

--- In amibroker@xxxxxxxxxxxxxxx, "ezbentley" <ezbentley@xxx> wrote:
>
> Is there a convenient way to plot the regression line of one price against another price?
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> 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/