Have a look at SetBacktestMode and see if that helps.

http://www.amibroker.com/guide/afl/afl_view.php?id=350

Mike

--- In [email protected], "Paolo Cavatore" <[EMAIL PROTECTED]> 
wrote:
>
> I've got an indicator which is giving buy/sell signals (ie. 0 
> nothing, +1 buy 100 shares, +2 buy 200 shares, -3 sell 300 shares 
and 
> so forth).
>  
> SigScaleIn/SigScaleOut variables don't seem to be able to manage 
> long/short positions properly. Let's say I'm long 400 shares and 
get 
> a -6 from my indicator. I should close the long position and open a 
> new short position for 200 shares.
>  
> The code below is a draft of what I'm trying to achieve but there 
is 
> no way to let it work as it should. Any help is much appreciated.
>  
> p
>  
>  
> SetPositionSize( 100 * abs(Indicator), spsShares);
>  
> DoScaleInBuy = Indicator > 0;
> DoScaleOutBuy = Indicator < 0;
> DoScaleInShort = Indicator < 0;
> DoScaleOutShort = Indicator > 0;
>  
> Buy = DoScaleInBuy * SigScaleIn + DoScaleOutBuy * SigScaleOut;
>  
> Short = DoScaleInShort * SigScaleIn + DoScaleOutShort * SigScaleOut;
>  
> Sell = Cover = 0;
>


Reply via email to