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

[amibroker] Pairstrading a Portfolio



PureBytes Links

Trading Reference Links

Hi, 

as a relative newbie on Amibroke I´d like to do some tests on
pairstrading and market neutral strategies.
Therfore I have writte the following code to define a pair of 2 stocks
or a pair of stock/index to be traded. I want to go long in the one
and on the same time go short in the other stock.
The following code seems to work properly on a predefined pair. 
But now I want to backtest a portfolio of pairs maybe 10-30 different
pairs! The pairs shoud be created dynamically by analysing
correlations etc.
I have no idea how to start this on portfolio level, so I hope
somebody here can help!

Regards 
mmike

My pairstrading code:

Ticker1 = "GM";
Ticker2 = "F";

spread = Foreign( Ticker1, "C") - Foreign( Ticker2, "C");
Plot( spread, "spread", colorRed, styleOwnScale); 

LongCond=Cross(spread, EMA(spread, 10) );
ShortCond=Cross( EMA(spread, 10), spread );

if (Name()== Ticker1)
{
Buy=LongCond;
Sell=ShortCond;
Short=Sell; Cover=Buy;

}
else if (Name()==Ticker2)
{
Buy=ShortCond;
Sell=LongCond;
Short=Sell; Cover=Buy;

}

PositionSize = -25; 



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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/

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