[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [amibroker] Re: I am lostII



PureBytes Links

Trading Reference Links

Hello Steve,

I understood what Grant meant in an earlier post when he said 'we' 
have to write the book ourselves and I think the forum does do that.
The forum is the book.

Thanks for your excellent contribution.
I printed a copy and added it to the AFL reference manual.
There were at least 3-4 looping concepts that were new to me.

I like it simple.
There's time for me to try to be clever later, after I learn the 
basics.

BrianB2.

--- In amibroker@xxxxxxxxxxxxxxx, "Steve Dugas" <sjdugas@xxx> wrote:
>
> Hi Allen - Here are the basics of a simple loop, hope it is 
helpful to someone...
> 
> In "regular" AFL, all elements of the data arrays are 
automatically processed at once. So for example
> 
> Close = 0;
> 
> will automatically initialize the entire Close array ( all dates ) 
by setting all of its elements to zero ( or more precisely, a 
working copy of Close, since actual database is not overwritten ). 
In general, it is quicker and easier to use this regular AFL - loops 
are really only necessary when you need to access individual array 
elements for some reason. A simple loop "template" would be
> 
> for ( beginning counter value; test for condition(s) to break out 
of loop; increment counter )
> {
>     code to do whatever you want to current array element
> }
> 
> Now we will turn the template into a real loop.  "i" is simply a 
variable that accepts a numeric value and acts as a counter. We will 
increment it with each pass through the loop to keep track of where 
we are. The letter "i" is commonly used for this because, I beleive, 
it stands for "integer", but we can actually use any variable name 
we want, such as "count", etc
> 
> for( count = 0; count < BarCount; count++ )
> {
>     Close[count] = 0;
> }
> 
> This also initializes the count array to zero, but one element at 
a time. As you can see, using regular AFL is easier   8 - )   Now we 
will "pick apart" the loop a bit...
> 
> for ( count = 0
> 
> Since we want to start with the first array element ( element # 
0 ), we initialize the counter at 0. The loop reads this code just 
once at the beginning to see where to start, it will not be 
rechecked after the loop starts running.
> 
> count < Barcount
> 
> BarCount is the number of data bars for any given ticker. Lets say 
it is 1000, so the actual elements of the Close array would be 
numbered 0 - 999.
> "count < Barcount" tests to see if it is time to stop looping yet. 
It means "continue doing loops while count is less than Barcount." 
Since we have just set "count" to 0, it is less than 1000 so the 
loop will be entered.
> 
> {
>     Close[count] = 0;
> }
> 
> This is the "body" of the loop - it contains the instructions to 
be performed on each pass through the loop. Here we are just 
initializing a single element of the Close array to 0. On this pass, 
the variable "count" is set to 0, so Count[0]  ( first element ) 
will be set to 0.
> 
> count++ ) // back up to the header now
> 
> This is just a short way of writing "count = count + 1". We are 
just incrementing the count by one. When we are incrementing by 1, 
we are allowed to use this "shorthand". If we were incrementing by 
anything else, like 2 or 3, we would have to write "count = count + 
2", etc. So next, count is incremented from 0 to 1.
> 
> Now, the first pass is done, and subsequent passes will continue 
repeating the same above steps until the end of the array is 
reached -
> 1. Is count still < Barcount? If so, do another pass through loop, 
if not, time to exit the loop.
> 2. If doing another pass, set Close[count] ( next element ) to 0
> 3. increment counter again so next elent is accessed on next pass
> 
> If this sounds too simplstic or condescending, I apologize. Or, if 
you have any questions, feel free to ask...
> 
> Steve
> 
>   ----- Original Message ----- 
>   From: allansn@xxx 
>   To: amibroker@xxxxxxxxxxxxxxx 
>   Sent: Sunday, July 23, 2006 10:52 PM
>   Subject: Re: RE: RE: [amibroker] Re: I am lostII
> 
> 
> 
> 
>   Hi Dingo,
> 
>   I have no problem doing anything along the lines of powerscan 
and writing code.Ami is excellent and intuitive as far as that...
> 
>   The problem for a complete non programmer is when i get 
to "looping",the manuals tend to leave out thebasic steps....its 
little things like the "i" and "{ " and " = = " and "buy=0" that are 
difficult to figure out.I get the intended logic,its just tought to 
build on having no foundation...
> 
>   Appreciate it
> 
> 
> 
>   Allan
> 
> 
> 
>   ----- Original Message -----
> 
> 
>   From: dingo <dingo@xxx> 
> 
>   Date: Sunday, July 23, 2006 10:44 pm 
> 
>   Subject: RE: RE: [amibroker] Re: I am lostII 
> 
> 
>   > Its Powerscan:  http://www.amitools.com/ 
>   > 
>   > d 
>   > 
>   > 
>   >  _____  
>   > 
>   > From: amibroker@xxxxxxxxxxxxxxx 
[mailto:amibroker@xxxxxxxxxxxxxxx] 
>   > On Behalf 
>   > Of Terry 
>   > Sent: Sunday, July 23, 2006 8:47 PM 
>   > To: amibroker@xxxxxxxxxxxxxxx 
>   > Subject: RE: RE: [amibroker] Re: I am lostII 
>   > 
>   > 
>   > 
>   > See Steve's reply because the big difference in AFL is the 
array 
>   > processingas Steve explained. 
>   > 
>   > 
>   > 
>   > The books were for Excel VBA programming (macros) because 
that's 
>   > what you 
>   > asked for. VBA is, in a way, quite similar to AB when using 
loops. 
>   > They are 
>   > just constructed a little different. I learned Basic 
programming 
>   > first, then 
>   > VBA (which is also a variation of BASIC). I picked up AFL from 
>   > there with a 
>   > little intro by an experienced trader and then just doing it, 
>   > reading help 
>   > files and asking a few questions along the way. 
>   > 
>   > 
>   > 
>   > Just look at some of the basic formulas you find in AB charts 
or the 
>   > library. Take the ones that don't look too complicated and 
>   > understand them. 
>   > Change a few things. You'll be surprised at what you can 
learn. 
>   > There is 
>   > also (someone please help here) an automated AFL code writer. 
You 
>   > tell it 
>   > your rules and it writes code. You can then see what it did. 
>   > 
>   > -- 
>   > 
>   > Terry 
>   > 
>   > -----Original Message----- 
>   > From: amibroker@xxxxxxxxxxxxxxx 
[mailto:amibroker@xxxxxxxxxxxxxxx] 
>   > On Behalf 
>   > Of allansn@xxx 
>   > Sent: Sunday, July 23, 2006 13:35 
>   > To: amibroker@xxxxxxxxxxxxxxx 
>   > Subject: Re: RE: [amibroker] Re: I am lostII 
>   > 
>   > 
>   > 
>   > Hi Terry, 
>   > 
>   > Noticed you reccomended these 2 books...I have absolutely no 
>   > problem coding 
>   > in Amibroker,but I do run into problems with coding such as 
this.. 
>   > 
>   > for( i = 0; i < *BarCount*; i++ ) 
>   > { 
>   > if( priceatbuy == 0 *AND* *Buy*[ i ] ) 
>   > 
>   >   { 
>   >      priceatbuy = *BuyPrice*[ i ]; 
>   > 
>   > 
>   > 
>   > How would one become proficient/knowledgable in writing code 
such 
>   > as this??? 
>   > 
>   > Is this AFL???  or 
>   > 
>   > Is this sort of language inherent in every language? 
>   > 
>   > Would either of the 2 books you reccomended assist me in this 
task? 
>   > 
>   > If you or anyone could point me in the direction of 
a "Dummies " 
>   > book,thatwould be great.I would just like to be proficient at 
>   > writing/understandingcode such as the snippet above 
>   > 
>   > 
>   > 
>   > Someone reccomended Beggining Programming for Dummies by 
Wang... 
>   > 
>   > 
>   > 
>   > Any thoughts deeply appreciated 
>   > 
>   > 
>   > 
>   > Allan 
>   > 
>   > 
>   > 
>   > 
>   > 
>   > 
>   > 
>   > 
>   > 
>   > 
>   > 
>   > ----- Original Message ----- 
>   > 
>   > From: Terry <MagicTH@xxx> 
>   > 
>   > Date: Sunday, July 16, 2006 9:34 pm 
>   > 
>   > Subject: RE: [amibroker] Re: I am lost 
>   > 
>   > > Great book for macro and function coding: 
>   > > http://www.wrox.com/WileyCDA/WroxTitle/productCd-
0764543717.html 
>   > > 
>   > > Excel for Dummies: 
>   > > http://www.amazon.com/gp/product/1568840500/sr=1- 
>   > > 1/qid=1153099963/ref=sr_1_1/104-1895807-1075905?
ie=UTF8&s=books 
>   > > 
>   > > 
>   > > 
>   > > -- 
>   > > 
>   > > Terry 
>   > > 
>   > > -----Original Message----- 
>   > > From: amibroker@xxxxxxxxxxxxxxx 
>   > [mailto:amibroker@xxxxxxxxxxxxxxx] On 
>   > > Behalf Of MillowenaJuno 
>   > > Sent: Sunday, July 16, 2006 08:36 
>   > > To: amibroker@xxxxxxxxxxxxxxx 
>   > > Subject: Re: [amibroker] Re: I am lost 
>   > > 
>   > > 
>   > > 
>   > > Hi Ton! 
>   > > 
>   > > 
>   > > 
>   > > Is there a Programming Excel for Dummies? 
>   > > 
>   > > 
>   > > 
>   > > Thanks! 
>   > > 
>   > > 
>   > > 
>   > > Millowena 
>   > > 
>   > > 
>   > > 
>   > > 
>   > 
>   > 
>   > 
>   >
>