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

[amibroker] Re: AFL for Dummies



PureBytes Links

Trading Reference Links

Hello Alan,

We meet again.

At the website there is a very good feedback centre for members only.

There is a series of suggestions over there about different ways of 
making Ami more accessable to non-programmers.
I think all bases were covered.
A request for 'AFL for dummies'was one of the suggestions.

Customised features are the strength of AB but they are also it's 
market weakness.

Tomasz is very receptive to 'training' improvements and is planning 
to do some.

In the short term there is no solution except this forum and of 
course support which is very good.

Yes, it makes a nice change to find a forum that has some content 
and some people who know what they are talking about.

Brian.

P.S

I have a  love-hate relationship with AB.
It is the most exciting stockmarket analysis program I have ever 
used and jam packed with features but at the same time I have never 
experienced such frustration when learning a program.



--- In amibroker@xxxxxxxxxxxxxxx, "matrix10014" <allansn@xxx> wrote:
>
> Hi all,
> Very new to Ami,and so far so good...Its a great program with a 
> great users group.I would like to know if I am the only one out 
> there who would deeply appreciate an "AFL coding manual for 
> Dummies"??.As far as I can tell,the only written explainations are 
> on pg 284-307 of the users manual.
> 
> I bring this up as I was attempting to code a simple system that
> backtests a list of Zacks fundamentally backtested stocks that I 
> import into a watchlist.
> 
>    
> The simple test was as automatic long position..(Buy=1;)
> 1)I wanted to have a 8% maximum stop.
> 2)What i wanted to then do is sell 50% of my position up 20%
(profit 
> target)
> 3)On the remaining 50%,I wanted to move my 8% maximum stop 
> to "breakeven",or perhaps an 50% trailing stop on the open 50% 
> position..
> 
> I did find a code in the users manual(shown below) which had  
> similar conditions.The buy filter in the example was a moving 
> average cross which i changed,and there were 2 profit targets as 
> well as an initial trailing stop.I am assuming my simpler example 
> would require similar coding which makes my eyes roll back in my 
> head.
> 
> Is there an easier way to code my example?If not,whats the best 
way 
> to get a grasp on AFL..Its brutal for a non programmer!!!
> 
> Thanks so much
> 
> Allan
> 
> 
> 
> 
> 
> Buy = 1; /* Go long all stocks*/
> 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 = 20; // profit 
> SecondProfitTarget = 40; // in percent 
> TrailingStop = 50; // 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
>