Hi,

I am new to amibroker and trying to code up and backtest a simple pair trading 
system where I go Long Sec1 and Short Sec2 in equal dollar amounts based on a 
normalized ratio. For example using SPY and QQQQ as Sec1 and Sec2 to 
illustrate,  I define:

Sec1=Foreign("SPY", "Close");
Sec2=Foreign("QQQQ", "Close");
Ratio=Sec1/Sec2;
Norm=(Ratio-MA(Ratio,10))/StDev(Ratio,10);

I want to be able to test the system where I buy Sec1 and short Sec2 in equal 
dollar amounts when Norm < -1.50 and unwind when Norm > -0.50

and do the opposite-
Short Sec1 and Buy Sec2 when Norm > 1.50 and unwind when Norm <0.50

Stuck on how to make sure the correct arrays are recognized and execute both a 
buy and a short.

Any help is much appreciated. Thx.

Reply via email to