Hi Keith, Thanks for the input!! I must admit I had given up hope a while back and chimed in as others appeared to have the same difficulty that I had.
I followed your lead and went thru the manual and put together an AFL guide.Hopefully I will nail it this time..Once again,thanks for your assistance Allan --- In [email protected], Keith McCombs <kmcco...@...> wrote: > > Allan -- > I saw your sentence, "How would one .......", and immediately opened my > .pdf copy of "AmiBroker 5.20 User's Guide", meaning to show you how to > get the answers to your question. So, first searched for == (I assumed > that I might find fewer of those than for example { or ,. Well there > are 99 of them in the guide. It took me about a minute to get past > examples that just coincidentally used == until I cam across an > explanation of what they mean on page 331. We really luck out here > because this is in a section called "Language Structure" starting on the > preceding page. It also tells all about the other symbols that AFL uses. > > Hmmm, nothing about 'indent' there though. So, we just do a search for > 'indent'. Oops -- struck out; its not even mentioned in the User's > Guide at all. > > So, here goes, I know this from my experience with the 'C' computer > language. The 'indent' means NOTHING to the computer. It is only a > crutch for us humans, so we can see more easily what is going on. > > If I had not known that though, I might assume that it was very common > to computer languages in general (otherwise it would have been explained > in the User's Manual). So I 'Google' "+computer +language +indent". > And there, the fifth one down, is Wikipedia, my favorite first reference > on everything. And it says, "Indentation is not a requirement of most > programming languages. Rather, programmers indent to better convey the > structure of their program to human readers." > > BTW, here is a very good example. Yahoo seems to blow away all > indention in the code we post, so I will use spaces in it. The > following is from your posting below: > > To the computer, this: > for( i = 0; i < BarCount; i++ ) {if( priceatbuy == 0 AND Buy[ i ] ){ > priceatbuy = BuyPrice[ i ];} > > is exactly this: > for(i = 0; i<BarCount; i++){ > if(priceatbuy == 0 AND Buy[i]){ > priceatbuy = BuyPrice[i]; > } > > But the addition of indentation made it easier for ME to see the > structure. And also, for me to see that the for statement is not yet > complete, because there is no } in line with the f in for. > -- Keith > > matrix10014 wrote: > > > > Hi, > > > > If anyone could direct me to a resource that would explain the code > > below,that would be appreciated.I understand the code,I just have no > > idea of the logic behind it.How would one begin to get an > > understanding of the use of {,==,i++ as well as the indentation of > > various lines of code > > > > Is that standard computer language jargon? > > > > Example of code that exits 50% on first profit target, 50% on next > > profit target and everything at trailing stop: > > > > Buy = Cross( MA( C, 10 ), MA( C, 50 ) ); > > Sell = 0; > > > > // the system will exit > > // 50% of position if FIRST PROFIT TARGET stop is hit > > // 50% of position is SECOND PROFIT TARGET stop is hit > > // 100% of position if TRAILING STOP is hit > > > > FirstProfitTarget = 10; // profit > > SecondProfitTarget = 20; // in percent > > TrailingStop = 10; // also in percent > > > > priceatbuy=0; > > highsincebuy = 0; > > > > exit = 0; > > > > for( i = 0; i < BarCount; i++ ) > > { > > if( priceatbuy == 0 AND Buy[ i ] ) > > { > > priceatbuy = BuyPrice[ i ]; > > } > > > > if( priceatbuy > 0 ) > > { > > highsincebuy = Max( High[ i ], highsincebuy ); > > > > if( exit == 0 AND > > High[ i ] >= ( 1 + FirstProfitTarget * 0.01 ) * priceatbuy ) > > { > > // first profit target hit - scale-out > > exit = 1; > > Buy[ i ] = sigScaleOut; > > } > > > > if( exit == 1 AND > > High[ i ] >= ( 1 + SecondProfitTarget * 0.01 ) * priceatbuy ) > > { > > // second profit target hit - exit > > exit = 2; > > SellPrice[ i ] = Max( Open[ i ], ( 1 + SecondProfitTarget * 0.01 ) * > > priceatbuy ); > > } > > > > if( Low[ i ] <= ( 1 - TrailingStop * 0.01 ) * highsincebuy ) > > { > > // trailing stop hit - exit > > exit = 3; > > SellPrice[ i ] = Min( Open[ i ], ( 1 - TrailingStop * 0.01 ) * > > highsincebuy ); > > } > > > > if( exit >= 2 ) > > { > > Buy[ i ] = 0; > > Sell[ i ] = exit + 1; // mark appropriate exit code > > exit = 0; > > priceatbuy = 0; // reset price > > highsincebuy = 0; > > } > > } > > } > > > > SetPositionSize( 50, spsPercentOfEquity ); > > SetPositionSize( 50, spsPercentOfPosition * ( Buy == sigScaleOut ) ); > > // scale out 50% of position > > > > --- In [email protected] <mailto:amibroker%40yahoogroups.com>, > > Louies <Louies88@> wrote: > > > > > > Hi Allan > > > > > > Another great way for newbies to learn the coding process, that is > > if someone has the will to help, is to go into the Amibroker's member > > area where they store all the monthly codes for the Technical Analysis > > of Stock & Commodity magazine articles and begin shredding those codes > > into "chewable" pieces. I wish someone with strong coding aptitude > > would lend a hand by explaining LINE BY LINE the codes for the monthly > > article. That's a great way to learn. I mean it's great to see Tomasz > > eloquently codes it. It's entirely new experience to see the codes > > explained. Personally, I think it's a great way to learn. After all, > > we don't buy Amibroker software just to manually draw > > support/resistance lines or just to drag indictors to chart. I believe > > most of us who buy this product all wish to learn the coding process. > > What's a better way than to have someone REALLY explains that to us. > > > > > > > > > > > > > > > ________________________________ > > > From: matrix10014 <allansn@> > > > To: [email protected] <mailto:amibroker%40yahoogroups.com> > > > Sent: Monday, March 23, 2009 1:17:47 PM > > > Subject: [amibroker] Re: AFL 101 > > > > > > > > > Hi Louie88, > > > > > > I couldnt agree with you more regarding the need for a book that > > would enable traders with zero to little programming skills to develop > > a foundation and grow from there.I would certainly be the very first > > customer > > > > > > Allan > > > > > > --- In amibro...@yahoogrou ps.com, "louies88" <Louies88@ .> wrote: > > > > > > > > > > > Anyway, what I'm looking for in the market these days is a book > > simple enough to teach traders w/ some trading experience under their > > belt, but lack the coding know-hows to express their ideas in terms of > > a programming language. I can safely say that the majority of traders > > severely lack the programming skills to express their trading ideas, > > and/or testing them ADEQUATELY in a trading platform. My wish is that > > if someone in here or else where who is fluent in AFL to write a book > > about coding AFL in ENGLISH (please) with plenty of examples and lots > > of explanations. The examples illustrated the concept while the > > explanations drive home the points being made. I find out that the > > best learning technique is imitation. If I can follow what's being > > coded and replicated them on my own, I'll remember it longer. I'm sure > > that if somebody comes out w/ a book like that in any scripting > > language whether that is EasyLanguage of TradeStation or AFL of > > Amibroker, it > > > would sell like hot cakes. In today's market, there is no such a > > book exists. > > > > > > > > s, "Introduction to > > > > > Amibroker" or "Quantitative Trading Systems". > > > > > > > > > > "Introduction to Amibroker" is mostly a rehash of the User > > Guide, and > > > > > therefore I personally don't recommend it. I may stand alone > > with this > > > > > opinion -- many others rave about it. I bought this book, was a bit > > > > > disappointed, but am not complaining because the one below is > > worth more > > > > > (to me) than the cost of the two combined. > > > > > > > > > > "Quantitative Trading Systems", is more advanced. But it > > contains many > > > > > more examples and the code for them is available to buyers of > > the book > > > > > on the book's web site. Each of examples focuses on a single > > topic and > > > > > is very well documented. Going through these examples on your > > computer > > > > > (and modifying them as you wish) will keep you focused as well. > > > > > > > > > > Howard is writing a third book and I will order it as soon as he > > lets me. > > > > > -- Keith > > > > > > > > > > > > > > > > >
