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

RE: [amibroker] How to COUNT BARS since trade buy in EXPLORATION?



PureBytes Links

Trading Reference Links

Hi Roy,
 
i am not sure if i understood you correctly.
 
Don't you mean:  bars = barssince(buy);  
 
Maybe it is that simple :-)
 
Best regards
 
Thomas
www.tradingbasis.com <http://www.tradingbasis.com/> 
 
 

  _____  

From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of Roy Ewing
Sent: Tuesday, July 18, 2006 12:27 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] How to COUNT BARS since trade buy in EXPLORATION?



I must be overlooking something, but am having trouble with counting
the number of bars since a trade was opened.

Example:

I would like to run exploration and have one of the columns simply
have a number telling me how many bars (trading days) I have held the
stock. I don't need to go back a long way, my "system" is based
shorter term swing-trading, 7-15 days.

I have manually built in arrays for each stock purchased, as in
BDATE[1-20] = DATENUM (20 stocks, with buy date cvtd to valid DATENUM).
BBOOK[1-20] = Purchase price of those 20 stocks
BSYMB1-20 = The text of the SYM. Still can't use strings in
arrays, so have to do it the long way.

Hurdle one is getting how many bars has it been between today (I use
"DATENUM()" to get last bar datenum) , and the "BDATE[n]"?

I can do this:
BDATE[13] = Date_To_Num("13072006") ; BSYMB13 = "XYZ" ; BBOOK[13] =
30.78 ;
Diff = DateNum() - BDATE[13];

That gives me the total (calendar) days, but NOT the # of bars. I
have to manually subtract out weekends, trading holidays, etc.
("Date_To_Num" is a function call. It is in the AFL library)

I have tried:

BS = BARSSINCE(DateNum() = BDATE[13]);

But that only produces a syntax error at the "=" sign.

I don't know enough coding yet to do it, but a function call would be
nice where the "buy" date is sent to it and the # of bars "in trade"
is returned.

Is there something simple I am overlooking?

Thanks.

Roy