PureBytes Links
Trading Reference Links
|
<It is a good idea, but already implemented, at least if you can live
with the StaticVarSet and Get notation combined with testing
Status("StockNum") == 0, which is obscure at best.>
Dan,
I got the above OK. And yes, after years of working with AB, my brain
got tangled up on the arrays when I tried to combine them with scalers.
Thank you for the 'eye opening' LastValue(Cum(CondGap)) comment...
that did the trick.
I'll post the code that worked as a one-pass statistics calculator at
the end of this message. But onto your other comment:
<I'd rather see some kind of qualifier on variable declarations to
indicate the lifetime of the variable, and I'd rather be able to store
arrays or single values using the same notation rather than using two
very different obscure notations. But I am not complaining either :)>
You just said the same thing I was trying to say, perhaps wording it
better.
Thanks for your comments & critique.
Here is the sample 'one-pass' code for calculating statistics or
ratios on an entire watchlist or other defined group of issues: (It
does give a 'running' report with each issue that is processed).
//GapStats one pass Sample Code
// Initialize pseudo-RUN variables that will persist ONLY for life of
each Exploration execution
if( Status("StockNum") == 0 ) StaticVarSet("GapsUp2Pct", 0 );
if( Status("StockNum") == 0 ) StaticVarSet("GapsFilled", 0 );
if( Status("StockNum") == 0 ) StaticVarSet("ClosedLower", 0 );
CondGap = O >= Ref(H, -1) * 1.02; // Opening Gap up 2% or more
StaticVarSet("GapsUp2Pct", LastValue(Cum(CondGap)) +
StaticVarGet("GapsUp2Pct") );
CondGapFilled = CondGap AND L <= Ref(H, -1); // Gap filled same day
StaticVarSet("GapsFilled", LastValue(Cum(CondGapFilled)) +
StaticVarGet("GapsFilled") );
CondClosedLower = CondGap AND C < O;
StaticVarSet("ClosedLower", LastValue(Cum(CondClosedLower)) +
StaticVarGet("ClosedLower") );
PctFilled = StaticVarGet("GapsFilled") / StaticVarGet("GapsUp2Pct") * 100;
PctLower = StaticVarGet("ClosedLower") / StaticVarGet("GapsUp2Pct") * 100;
lastbar = BarIndex() == BarCount - 1;
SetOption("NoDefaultColumns",1);
Filter = lastbar;
AddColumn(Status("StockNum") + 1,"ListCount",1.0); // StockNum is zero
based
AddColumn(StaticVarGet("GapsUp2Pct"),"# 2% UpGaps", 1.0);
AddColumn(StaticVarGet("GapsFilled"),"# Filled",1.0);
AddColumn(PctFilled,"% Filled", 1.2);
AddColumn(StaticVarGet("ClosedLower"),"# Lower",1.0);
AddColumn(PctLower,"% Lower", 1.2);
------------------------ Yahoo! Groups Sponsor --------------------~-->
Protect your PC from spy ware with award winning anti spy technology. It's free.
http://us.click.yahoo.com/97bhrC/LGxNAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~->
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
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|