Hello all, Thank you so much for the replies. This is absolutely wonderful and I cannot speak any more highly of this. In particular, thank you so much for the detailed response for Howard. Your descriptive comments are very educationl as well. I call this forum to consider both TJ and Howard as treasure .... I can only hope no big sharks will take them over.
Thanks again --- In [email protected], "Howard B" <[EMAIL PROTECTED]> wrote: > > Hi iceboundbug -- > > Here is some afl code that implements the first of the two expressions you > asked about. > > I'll leave the second to you. > > ///////////////////////////////////////////////// > // loopexample.afl > > // From a question posted on Yahoo AmiBroker Forum > // July 2, 2008 > // Howard Bandy > > // This code is intended to be an example of writing > // a loop. It is definitely Not the most efficient code that > // could be written to solve this problem. > > > // The question asked how to create an array, x, > // with this property: > > // x = Sum( MA(C-O,3) ,3) - Ref( Sum( MA(C-O,3) ,3), -1) >0; > > // Here is what one of the terms being compared looks like in afl: > d = Sum(MA(C-O,3),3); > // x will be true when d > ref(d,-1), false otherwise > // d will be plotted later as a reference > > > > > // initialize the first elements of the x array > // to be certain known values have been stored > for (i=0; i<=3; i++) > { > x[i] = 0; > } > > // compute a temporary variable u that contains > // the 3 bar moving average of the past three Close minus Open > for (i=2; i<BarCount; i++) > { > u[i] = ((C[i]-O[i]) + (C[i-1]-O[i-1]) + (C[i-2]-O[i-2]))/3; > } > > // compute a temporary variable w that contains > // the 3 bar sum of u. > for (i=2; i<BarCount; i++) > { > w[i] = u[i] + u[i-1] + u[i-2]; > } > > > // set the value of x to 1 (true) > // if w today minus w yesterday is greater than 0 > for (i=4; i<BarCount; i++) > { > if ((w[i] - w[i-1]) > 0) > { > x[i] = 1; > } > else > { > x[i] = 0; > } > > // Note -- I would probably use the follow construction using IIF, > // but you will be translating into C++, so the if-else above > // has the more straight-forward translation. > // x[i] = IIf((w[i] - w[i-1])>0,1,0); > } > > Plot(C,"C",colorBlack,styleCandle); > > Plot(x,"x",colorRed,styleLine|styleOwnScale); > > Plot(d,"d",colorBlue,styleLine|styleOwnScale); > > /////////////////////////////////////////////////////////////////// > > To create a dll, translate the afl looping code into C++, following the > example on pages 326 to 338. > > Thanks, > Howard > www.quantitativetradingsystems.com > > > > > > On Wed, Jul 2, 2008 at 9:08 AM, Steve Dugas [EMAIL PROTECTED] wrote: > > > Hi - I wrote one DLL a few years ago and I am *definitely* very rusty > > but I > > just took a quick look at my source code to confirm this.... > > > > If it will work for your purposes, you don't necessarily need to calculate > > all that in the DLL, you can use the site interface to import your arrays > > into the DLL - here are a couple of examples from my DLL.. > > > > AmiVar VsjdAutoOptInd(int NumArgs, AmiVar *ArgsTable) > > { > > // user-defined params > > AmiVar TestBars = gSite.GetVariable("TestBars"); > > AmiVar StartDate = gSite.GetVariable("StartDate"); > > AmiVar EndDate = gSite.GetVariable("EndDate"); > > } > > > > If that won't give you what you want, then you will need to to start with > > the innermost arrays and work your way out, walking the arrays on a > > bar-by-bar basis. Here is another example from the DLL showing how to do > > it... > > > > for (Bar = FirstTestBar; Bar <= LastTestBar; ++Bar) > > { > > ePosition.array[Bar] = eShares.array[Bar]; > > eAdjToCash.array[Bar] = 0 - eValOfShares.array[Bar] - eComm.array[Bar]; > > eRemainCash.array[Bar] = eCash.array[Bar] - eValOfShares.array[Bar] - > > eComm.array[Bar]; > > eTheorCash.array[Bar] = eCash.array[Bar] - eValOfShares.array[Bar] - > > eComm.array[Bar]; > > } > > > > Good Luck - Man, this stuff *really* makes you appreciate what TJ has given > > > > us with the AFL language!! 8 - ) > > > > Steve > > > > > > ----- Original Message ----- > > From: "iceboundbug" [EMAIL PROTECTED] <iceboundbug%40yahoo.com.au> > > > > > To: [email protected] <amibroker%40yahoogroups.com>> > > Sent: Wednesday, July 02, 2008 3:31 AM > > Subject: [amibroker] Re: Help to convert afl statement to a loop > > > > > > > > Hello Steve, > > > > > > The reason why I want a loop is to write a DLL - I got few books > > > including Howards book to complete the DLL but I cannot get my head > > > around with a loop. You said it is a quite a job but please tell me at > > > least about how many lines of coading that would be? Thanks > > > > > > > > > > > > > > > --- In [email protected] <amibroker%40yahoogroups.com>, "Steve > > Dugas" sjdugas@ wrote: > > >> > > >> That looks like it would be quite a job. None of my business of course > > > but now that you got my curiousity up....why would you want to write it > > > as a loop? Thanks! > > >> > > >> Steve > > >> ----- Original Message ----- > > >> From: iceboundbug > > >> To: [email protected] <amibroker%40yahoogroups.com> > > >> Sent: Tuesday, July 01, 2008 8:45 PM > > >> Subject: [amibroker] Help to convert afl statement to a loop > > >> > > >> > > >> Hello all, > > >> > > >> Could someone help me to write the following two afl statements using > > > two separate loops please. > > >> > > >> Thanks in advance. > > >> > > >> > > >> > > >> x = Sum( MA(C-O,3) ,3) - Ref( Sum( MA(C-O,3) ,3) , -1) >0 ; > > >> > > >> > > >> > > >> y = MA(C-O, 5) > (-1)*MA(C-O, 7) ; > > >> > > > > > > > > > > > > > > > ------------------------------------ > > > > > > 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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG: > > > http://www.amibroker.com/devlog/ > > > > > > For other support material please check also: > > > http://www.amibroker.com/support.html > > > Yahoo! Groups Links > > > > > > > > > > > > > > > > > > >
