----- Original Message -----
Sent: Sunday,
August 14, 2005 8:26 PM
Subject: RE:
[amibroker] A little help please.
Erik,
You have to
Buy the Bear funds on a
Short signal. Here is some
code that allows you to enter the funds you want to trade. It allows two
Long funds and two Bear funds. You can set the date of inception for the
Long and Bear funds and it will trade “myTicker” prior to those dates. For
example you can trade the Rydex funds and trade QQQQ or ^NDX before they
started. This code is probably more than you were looking for, but it
works:
function
Date_To_Num(mmddaaaa)
{
mm_ = StrToNum(StrLeft(mmddaaaa,2));
dd_ = StrToNum(StrMid(mmddaaaa,3,2));
aa_ = StrToNum(StrRight(mmddaaaa,4));
RESULT = (10000 * (aa_ -
1900)) +
(100 * mm_) +
dd_;
return
RESULT;
}
LongDate
= IIf(DateNum() >=
Date_To_Num(LongInception),1,0);
//Set to
inception date of Long fund
ShortDate =
IIf(DateNum() >=
Date_To_Num(ShortInception),1,0);
//Set to
inception date of Bear fund
"Long
Trades:";
myTicker +
" before
" +
LongInception + " then
" +
LongFund;
"\nShort
Trades:";
myTicker +
" before
" +
ShortInception + " then
" +
ShortFund;
//Your trading
system goes here
//Ultimately you
must create BuyLong and BuyShort as your Buy and Sell
conditions
//This one also
allows BuyDoubleLong and BuyDoubleShort such as Rydex Venture and
Velocity
Buy = (BuyLong
AND Name() ==
LongFund AND
LongDate)
OR (BuyDoubleLong AND Name() ==
DoubleLong AND
LongDate)
OR (BuyShort AND Name() ==
ShortFund AND
ShortDate)
OR (BuyDoubleShort AND Name() ==
DoubleShort AND
ShortDate)
OR (LSC >
0 AND (BuyLong OR BuyDoubleLong OR netSignal >= 0) AND NOT LongDate AND Name() ==
myTicker);
Sell = (BuyLong
AND (Name() ==
DoubleLong OR
Name() ==
ShortFund OR
Name() ==
DoubleShort))
OR (BuyDoubleLong AND (Name() ==
LongFund OR
Name() ==
ShortFund OR
Name() ==
DoubleShort))
OR (BuyShort AND (Name() ==
LongFund OR
Name() ==
DoubleLong OR
Name() ==
DoubleShort))
OR (BuyDoubleShort AND (Name() ==
LongFund OR
Name() ==
DoubleLong OR
Name() ==
ShortFund))
OR ((LSC <
0 OR netSignal <= 0) AND NOT ShortDate AND Name() ==
myTicker);
//When
before ShortDate, Short the Index to simulate. Can never Short a Fund. Must
Buy Inverse funds to effect a short.
Short = Name() ==
myTicker AND NOT ShortDate AND LSC == -1 AND (BuyShort OR BuyDoubleShort OR netSignal <= 0);
Cover = LSC !=
-1 OR netSignal >= 0;
-----Original
Message-----
From:
amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Erik Skyba
Sent: Sunday, August 14, 2005
18:05
To:
amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] A little help
please.
So I have buy and
sell signals created.
If I have two
funds, one fund I want to go long when there is a buy and another (inverse
fund) fund I want to go long when there is a sell or short.
I thought this would
involve using the name() function and an iff statement but I can't seem
to make the trades hit up correctly.
How would I go
about doing this?