Yes, AB is written in C++. I am only up to AFL101 but I have been around the AB environment for 4 years.
The ABDevelopmentKit might be the place to find out more about what is under the bonnet. > I'm keener on your suggestion regarding using the arithmetic > now that I now that MA(array, array) works! And yes, > I'd prefer the faster option every time! If you are used to programming but not used to AB's array processing it might take a bit of a mental adjustment .. a lot of programmers seem to find that.... it is all done at the machine level in AB speed ... there is a post from Tomasz at the KB about the technical details of part of the process (it went over my head but I get the concept). It's a piece of cake except that StDev is limited to a constant number also so you will have to calc your own StDev (also note that StDev in AB is StDevP by default)..... I started on the AFL for Skew until I hit the StDev wall and I had to leave it for a while ... I'll be back on it later or tomorrow.... the first problem I found is that you will need to run a lot of datapoints before you get a meaningful distribution (pseudo dist in this case) i.e. I used GF and they are all different at the default number of decimal points .. I used Prec() to round down to 2 integers to to test the code I started to write ... in the real world you will need N to be very big to start to find the meaningful mode ... I could use Prec(tradeseries,3) and that would be the equivalent of 1000 bins so you need quite a few N to get a decent bin count ... if you round down to 2 decimal places perhaps the end result won't be that meaningful. <snip>But I also like to think that I'll find other, and perhaps more meaningful "profile attributes" which have nothing to do with the old distributions! That's why I've been looking for a generic solution<snip> That's the way to go ... I never fail to learn something when I dig in. Our analytical approach seems to be synched to some degree ... now that you have raised the subject I am trying to relate Skew etc to my BinomialModels ... I expect a few new metrics to come out of that but they are a fair way away. It is always hard to say, in advance, if the new 'profile attributes' will be useful on a day to day basis but I find the understanding gained from thrashing it all out is worth the effort .. somewhere in the back of my mind I use it all at some stage. Once I got that far I started to wonder if the progressive Skew, Median etc would be that meaningful ... a rolling period might be just as effective ... still if you are like me you need to do it and look at it to see if it meaningful or not. > The following construct works - but it is very, very > slow..... Yep! --- In [email protected], i cs <ics4...@...> wrote: > > Hi Brian, > > Hmmmm... could be a typo in the manual > I certainly had no idea that MA() could do this. > > myX = MA(C, 1); // AFL happy > myX = Median(C, 1); // AFL happy > myX = MA(C, Cum(1)); // AFL happy > myY = Median(C, Cum(1)); // "Argument has incorrect type" > > > You must have a huge amout of hands on with AFL! > Some of the functions in AFL take either arrays, or > numbers, and a few seem to be able to take both: > Not sure what language AB is written in suspect its > probably C++ which allows you to do this sort of > thing. > > Looking at the entry for "int()" > > INT > â' integer part > SYNTAX int( NUMBER ) > int( ARRAY) > > I suspect the manual entry for MA() should be the > same! > > I'm currently looking at the "_TRACE()" command to try > and garner some insight into the execution process. > > I'm keener on your suggestion regarding using the arithmetic > now that I now that MA(array, array) works! And yes, > I'd prefer the faster option every time! But I also like to > think that I'll find other, and perhaps more meaningful > "profile attributes" which have nothing to do with the > old distributions! That's why I've been looking for a > generic solution > > The R package looks intriging too. But I still have to > learn how AB works in it's basic mode before I > unduly complicate my life with other packages etc... > > The following construct works - but it is very, very > slow..... > > function myMedian( array, i ) > { > x = array[i]; > return x; > } > > mp2 = 1; > for( i = 1; i < BarCount; i++ ) > { > mp2[ i ] = myMedian(Median(C,i),i); > } > > > Thanks for your help once again! > > Robert Z > > > > > ________________________________ > From: brian_z111 <brian_z...@...> > To: [email protected] > Sent: Friday, 5 June, 2009 5:00:41 PM > Subject: [amibroker] Re: Newbie Array / Looping Question > > > > > > <snip>Median( ) wants a number as its second argument. (The manual is > clear!)<snip> > > To help me understand next time ... how did you decide that Median)array, > period) wants a number from what is written in the manual? > > MA(array,periods) ; accepts an array and the only differential in the manual > is plurality of the periods (do you think Tomasz intended the plurality to be > significant? ) > > MA(C,Cum(1)) ;//this is OK? > > <snip> When are the "for" loops executed in the block of code? Knowing some > more about the AFL execution order might be helpful.<snip> > > Sorry, don't know anything about execution. > > Recently Siddhartha said that learning the AFL execution was the best thing > we can ever do ... I don't know where to find it though. > > You are not keen on my suggestion that calcs for the moments are arithmetic > and so should fly in AFL without looping? > I am a lay programmer but my instinct is to start there - looping will slow > you down in RT indicators?? ? > > Plan C - use the RMath Plugin ... advanced stats available there. > > --- In amibro...@yahoogrou ps.com, i cs <ics4mer@ > wrote: > > > > Hi Brian, > > > > Thanks for getting back to me. > > > > Unfortunately, Cum() returns array, Median() wants a number as its > > second argument. (The manual is clear!) > > > > I used median as an example because it's relatively easy to understand, > > and I will be using it, but I will also be plotting the growth factor in > > the same > > way - as well as the other moments of distribution - just one step at a > > time. > > > > Its possible to derive a lot of the moments of distribution from other the > > parts, but it comes back to the same problem - I'd have to write functions > > to derive kurtosis, mode etc. > > > > Some of the historic emails in the group included the following solutions: > > - code the functions myself - which I'm trying to avoid. > > - create a dynamic set of variables using VarSet - this seems a bit > > brutish > > especially if you are playing with a number of "profile attributes". > > > > When are the "for" loops executed in the block of code? Knowing some more > > about the AFL execution order might be helpful. Might go down that track for > > a while....and check out the other 1500 references to "loop" in the email > > group. > > > > Thanks again... > > Robert Z > > > > > > > > > > > > ____________ _________ _________ __ > > From: brian_z111 <brian_z111@ ...> > > To: amibro...@yahoogrou ps.com > > Sent: Friday, 5 June, 2009 2:57:43 PM > > Subject: [amibroker] Re: Newbie Array / Looping Question > > > > > > > > > > > > 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 amibro...@yahoogrou ps.com, "brian_z111" <brian_z111@ ...> 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 amibro...@yahoogrou ps.com, "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 > > > > > > > > > > > > > > > > > > > Need a Holiday? Win a $10,000 Holiday of your choice. Enter > > now.http://us. lrd.yahoo. com/_ylc= X3oDMTJxN2x2ZmNp BF9zAzIwMjM2MTY2 > > MTMEdG1fZG1lY2gD VGV4dCBMaW5rBHRt X2xuawNVMTEwMzk3 NwR0bV9uZXQDWWFo > > b28hBHRtX3BvcwN0 YWdsaW5lBHRtX3Bw dHkDYXVueg- -/SIG=14600t3ni/ **http%3A/ > > /au.rd.yahoo. com/mail/ tagline/creative holidays/ *http%3A/ /au.docs. > > yahoo.com/ homepageset/ %3Fp1=other% 26p2=au%26p3= mailtagline > > > > > > > > Need a Holiday? Win a $10,000 Holiday of your choice. Enter > now.http://us.lrd.yahoo.com/_ylc=X3oDMTJxN2x2ZmNpBF9zAzIwMjM2MTY2MTMEdG1fZG1lY2gDVGV4dCBMaW5rBHRtX2xuawNVMTEwMzk3NwR0bV9uZXQDWWFob28hBHRtX3BvcwN0YWdsaW5lBHRtX3BwdHkDYXVueg--/SIG=14600t3ni/**http%3A//au.rd.yahoo.com/mail/tagline/creativeholidays/*http%3A//au.docs.yahoo.com/homepageset/%3Fp1=other%26p2=au%26p3=mailtagline >
