PureBytes Links
Trading Reference Links
|
G'day,
Below is some AFL code I've written to scan for stocks
starting to meet the criteria as set out in Stan Weinstein's book 'The Secrets
of Profiting in Bull or Bear Markets'.
To use it you must have your industries, sectors and indices
set up correctly in Ami.
The code picks stocks to go long on - not stocks to
short.
Also it picks stocks as they enter Stage 1 not as they enter
Stage 2. So it's intended to create a watch list not to be a system. I've not
included volume as a criteria - I need to understand how OBV works.
If you just want stocks as they enter Stage 2 the line marked
/* Modify */ would need to be changed to
cond2 = close > ma(close,maLong)
AND close > open;
maLong and maShort can be modified
to suit. The lower the maShort value the more aggressive the Trade. maLong is
probably best left at 150 - but could be changed according to the market being
traded.
dollars is the size of the trade and is to ensure sufficient
liquidity - this is a personal criteria.
Now I have a couple of questions to those
interested.
1. This code checks that the stock is out performing its
sector but does not check the sector is outperforming the market. Can AFL cater
to this also ? If so how ?
2. If the exrem statement is uncommented less stocks are
reported as buys than with it removed. exrem appears to remove <FONT
color=#000000>more than just duplicate buy signals. I'm obviously missing
something.
<FONT color=#000000
size=2>3. How does on balance volume work ? I'd just like to add a check that
white candle days are of higher volume than black candle days over the pastweek
for example.
Any ideas appreciated,
Geoff
/* Stan Weinstein Buy Criteria - Afl
implementation by Geoff Mulhall 18/4/2001 */
dollars = 5000;
maLong = 150;maShort = 13;maRelStr =
2;
/* sufficient liquidity ie share purchased less
than 2% of weekly volume*/
cond1 = dollars/close < 0.02 *
sum(volume,maLong)/(maLong/5);
/*close above MA and a Stage 4 stock
*/
cond2 = close > ma(close,maShort) AND close
> open AND close < ma(close,maLong); /* Modify */
/* gradient of the moving average is increasing
or has levelled */
cond3 = (ma(close,maShort) -
ref(ma(close,maShort), -1)) >= 0;
/* beginning to trend over the last 2 days
*/
cond4 = low > ref(low,-1) AND ref(low,-1)
>= ref(low,-2);
/* gradient of the relative strength is
increasing */
cond5 = ma(relstrength(""),maRelStr)
>= ref(ma(relstrength(""),maRelStr), -1 * maRelStr);
buy = cond1 AND cond2 AND cond3 AND cond4 AND
cond5;
sell = 0;
/* buy = exrem(buy,sell); */ /* sell =
exrem(sell,buy); */
|