PureBytes Links
Trading Reference Links
|
I am not sure about this one now ... I think we need some help from the code/maths experts.
Median() doesn't appear to accept an array as input (the manual doesn't say one way or another?) ... it might be demanding a constant (that wouldn't surprize me since mean/mode/median are moments of a distribution so massive calcs might be required to find them for skewed dists without having the distriution at hand) ... AB doesn't do that distributions off the shelf ... not AFAIK.
I think you can calc Skewness from N, StDev, arithmetic mean etc ... once you have S you can back calc the Median or the Mode from the Mean and the StDev.
Another brute method might be an algorithmic trial and error test for the Mode (loops required)... I forget what it is called in programming but if the value to the right of the mean has a higher frequency than the mean value the mode is somewhere to the right .. by halving the range between the freq test you will zero in on the mode and then you can calc the median by using the mean and mode values..... AFAIK array processing will always be more timely than looping though.
--- In amibroker@xxxxxxxxxxxxxxx, "brian_z111" <brian_z111@xxx> wrote:
>
> Median(array, periods)
>
> I assume you are measuring, say ROC(C,1) or similar for % price change.
> I guess you just need to get a progressive count, of the number of ROC datapoints, to make the function work.
>
> Things to look out for (if the AB function is going to work for you):
>
> - every element in the array you are measuring needs a value (nulls or zeros might trip up the math e.g. STDev, mean) ... I guess if you are interested in daily bars you will first create a daily ROC(C,1) or ROC of some other point of interest from within the bar HL range
> - the number of periods, in your array count, is range dependent i.e. in AB it can vary with mode ... QuickAFL can be used to change the range (in AA) and QickAFL will autoset the range in charts (or might ... I am not the full bottle on QuickAFL but there is an article by Tomasz in the AB KnowledgeBase)
> - BarsSince type functions might count one less period than you expect ... depending if the function is a zerobased count and how you want to use the count.... sometimes I have to add 1 to make the adjustment manually
> - BarIndex() is the bar by bar count since the start of the range, where range == the range of the database ... AB gets a bit tricky with when and where it uses the complete database range as the default .... probably to do with fast array processing etc ...sometimes I prefer to use Cum(1) as my count ... I seem to get more visually stable indicators in the charts because it doesn't reference the chart range it references from the start of the database.
>
> - so, making a few assumptions, and if Median works for you as required, Median(ROC(C,1),Cum(1)); // because Cum(1) is progressive and counts bars from the beginning
>
> - mathematically I find ROC is not as stable as GrowthFactor where ROC == 3% is expressed as 1.03
>
> Haven't done it though.
>
> If that doesn't work maybe someone else in the forum knows more.
>
> In case of emergency RVince book two has the maths for median, mode, mean interelationships (possibly for advanced, or custom use, you could calculate the median from other values).... mean == median == mode for normal distributions (you should be so lucky!)
>
>
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, "ics4mer" <ics4mer@> wrote:
> >
> > Hi all,
> >
> > I'm after a general form for doing a particular type of algorithm
> > in AFL - and I'm happy to admit that I might be going about it
> > the totally wrong way...
> >
> > I am attempting to extract an evolving "profile" of a stock over
> > time.
> >
> > Using "median" as an example, lets say I want calculate the median
> > percentage price change for the life of the stock. To give an
> > example:
> >
> > The 1st trading day - do nothing.
> > The 2nd trading day - calc median for 2 days
> > The 3rd trading day - calc median for 3 days
> > Last traded day - calc median for n days.
> >
> > For simple functions, I have used a construct similar to;
> > for ( i=0; i < BarCount; i++ ){
> > myArray[ i ] = simpleFunc( i );
> > .....
> > }
> >
> > However, in this case, I would have to write a new median function,
> > and this is irritating, since there is a perfectly good one
> > taunting me from the users manual! That's why I suspect that I
> > might be doing something in the wrong way.
> >
> > Any help or pointers would be much appreciated. A pointer to
> > a message in the user group would be fine too! ( Yes I am still
> > trawling through the email group as I write this....)
> >
> > TIA
> >
> > Robert Z
> >
>
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> 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/
|