PureBytes Links
Trading Reference Links
|
On Wednesday 31 May 2006 12:35 pm, Phsst wrote:
> I very much like the StaticVariable idea, but I tried the following
> code and AFL does not like my version of "somecalculation"...
>
> if( Status("StockNum") == 0 ) StaticVarSet("GapsUp2Pct", 0 );
> CondGap = O >= Ref(H, -1) * 1.02; // Opening Gap up 2% or more
> StaticVarSet("GapsUp2Pct", Cum(CondGap) +
> StaticVarGet("GapsUp2Pct") ); // Accumulate Total # of Gaps in entire list
>
> It won't accept the Cum(CondGap) where you specified the insertion of
> "somecalculation", so I assume that might be why you were careful to
> state "SINGLE value (numbers)", indicating that normal AFL
> calculations cannot take place within the StaticVarSet operation.
Exactly. Cum results in an array of values, which is the accumulated value at
every bar up until that time. If you really just want the last value of
the array, then try LastValue(Cum(CondGap)). If you are computing the entire
array anyway to do your exploration, there is no extra cost in computing the
LastValue. But you probably don't want to use that in a graphical indicator,
or use it in a way the results in a decision about buying or selling (since
you would be violating the time travel prohibition).
> Anyway TJ, I hope you see why I had hoped for a simple new variable
> type that would persist for the life of an explore AND accept normal
> AFL calculations to be performed on them.
You can't avoid converting between arrays and single (aka scalar) values. It
might be reasonable for AFL to automatically convert an array to a single
value when a single value is required by using the last value, but I'd rather
have that be explicit, partly to avoid accidentally doing the conversion when
I meant to do something else.
> It would really simplify
> quick statistical calculations against entire lists without having to
> use AddToComposite.
AddToComposite is the correct thing to use when you need to store a whole
array of values (several, actually). You could store the Cum result, for
example, if you actually wanted to do that.
> And don't take the above as a criticism... it is just an idea.
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. 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 :)
dan
------------------------ Yahoo! Groups Sponsor --------------------~-->
Get to your groups with one click. Know instantly when new email arrives
http://us.click.yahoo.com/.7bhrC/MGxNAA/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/
|