PureBytes Links
Trading Reference Links
|
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 amibroker@xxxxxxxxxxxxxxx, Louies <Louies88@xxx> 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@xxx>
> To: amibroker@xxxxxxxxxxxxxxx
> 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 amibroker@xxxxxxxxx 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
> > >
> >
>
------------------------------------
**** 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/
|