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

[amibroker] Re: strategy involving 2 scrips (pair)



PureBytes Links

Trading Reference Links

I am not a afl-crack for myown but some time ago I wrote a script for 
pairtrading 2 correlated shares. Maybe the script gives you some 
ideas how you can program your strategy in afl:

Ticker1 = "GE";
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;

Regards
mmike

--- In amibroker@xxxxxxxxxxxxxxx, "drzingaro" <drzingaro@xxx> wrote:
>
> hi,
> 
> some scrips within the same sector show strong corelation in their
> market price over a long period. Their ratio exhibits the 
corelation.
> 1. I need to explore / search for such scrips from a sector
> 2.plot closing prices of 2 such securities on same chart
> 3.plot their price ratio (price of scrip 1 / price of scrip 2)in a
> different pane.
> 4. plot say 60days mean of this ratio on the ratio chart.
> 5.plot bolinger bands for this mean on the same chart.
> 
> strategy - The scrips exhibit a strong correlation and
> have a tendency to revert to the mean and move in a trading band. 
> when price ratio shifts to the upper or lower boundry of the trading
> range. Traders
> may initiate a neutral strategy and go long on scrip A and go short 
on
> Scrip B.
> 
> reverse / square the trade when the ratio shifts to the mean.
> 
> can anyone help me on afl?
> 
> regards
> 
> dr zingaro
>



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

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/