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

RE: [amibroker] A little help please.



PureBytes Links

Trading Reference Links

Erik,

 

You don’t need all the complication required to make it flexible and robust. Just try this simplified version. I believe this is the minimum needed to test bull and bear funds. You will have to make sure you don’t test earlier dates than you have data for. Also, this code is always in the market.

 

LongFund = “RYVYX”; //or whatever Bull fund you want

ShortFund = “RYVNX”; //or whatever Bear fund you want

 

BuyLong = “your buy conditions”

BuyShort = “Your short conditions”

 

Buy = (BuyLong AND Name() == LongFund)

   OR (BuyShort AND Name() == ShortFund);

 

Sell = (BuyLong AND Name() == ShortFund)

    OR (BuyShort AND (Name() == LongFund);

 

First line beginning with Buy = is for buying the Bull fund.

Second half of this line is for BUYing the Bear fund (essentially Shorting)

Sell = line Sells your Bear fund when you get a new Buy

Second half of Sell line Covers your Bull fund when you get a new Sell/Short

--

Terry

-----Original Message-----
From:
amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Erik Skyba
Sent: Sunday, August 14, 2005 19:38
To:
amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] A little help please.

 

does anyone have a simpler way to do this?

----- Original Message -----

From: Terry

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;

 

 

--

Terry

-----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.

 

hi folks,

 

 

So I have buy and sell signals created.

 

Short=sell;

 

cover=buy;

 

Here is my problem:

 

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?

 

 

Thanks for your help,

 

Erik SKyba

 




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 other support material please check also:
http://www.amibroker.com/support.html





SPONSORED LINKS
Investment management software Investment property software Investment software
Investment tracking software Return on investment software Stock investment software


YAHOO! GROUPS LINKS