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

[amibroker] Re: Scalling out help file code



PureBytes Links

Trading Reference Links

Why yes, I would be glad to help. From Marcin...

In the AA>backtester settings>portfolio tab you need to set the 
Limit trade size as % of entry bar volume to zero. Thanks Marcin!


--- In amibroker@xxxxxxxxxxxxxxx, "orionsturtle" <orionsturtle@xxx> 
wrote:
>
> Does anyone know why this help file code for scaling out will not 
> buy into 50% of availabe equity when it is used on a one minute 
> chart as opposed to a daily? It uses 50% of the equity on the 
Daily 
> chart buy signal, but only about 5% on the one Min chart. the only 
> parameter I changed was the Periodocity in the AA > backtester 
> settings> general tab.
> 
> Thanks fo any advice...heres the help file code...
> ------------------------------------------------------
> Example 4: partial exit (scaling out) on profit target stops
> 
> 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
>