Handlestops work well thanks
I also discovered that applystops do generate exit signals (at least 
in the case of stoptypeloss). I was incorrect in my original post
Try these codes for yourself. Either handlestops or exitTrade 
provides the same result.

if( Status("action") == actionPortfolio )   
{   
        bo.PreProcess() ;     
        for(bar=0 ; bar < BarCount ; bar++)
        { 
                // comment either handlestops or exittrade out.
                bo.HandleStops(bar); 
                for( sig = bo.GetFirstSignal(bar) ; sig ; sig = 
bo.GetNextSignal(bar)) 
                { 
                        if(sig.IsEntry() AND IsNull ( bo.FindOpenPos
( sig.Symbol )) AND sig.PosSize > 0)
                        {
                                bo.enterTrade(bar, sig.symbol, True, 
sig.price, sig.PosSize,sig.PosScore) ;
                        }
                        if( sig.IsExit() AND bo.FindOpenPos
(sig.symbol) ) 
                        {       
                                // comment either handlestops or 
exittrade out.
                                bo.exitTrade(bar, sig.symbol, 
sig.price, sig.Reason) ;
                        }
                }
                bo.UpdateStats(bar, 2) ;
        } 
        bo.ListTrades();
}
Buy = C < EMA(C, 30);
Sell = False;
BuyPrice =SellPrice =C;
ApplyStop(stopTypeLoss, stopModePercent, 3, 1, False, 0);
SetBacktestMode( backtestRegularRaw) ;          
SetOption("InitialEquity", 100000) ;            
SetOption("MaxOpenPositions", 10) ;     
SetOption("CommissionMode", 1) ;                                
SetOption("CommissionAmount", 0.1);     
SetOption("AllowPositionShrinking", False) ;    
//SetOption("UsePrevBarEquityForPosSizing", True) ; 
SetOption("HoldMinBars", 0) ;                                   
Short=Cover=0 ; 

--- In [email protected], "gp_sydney" <[EMAIL PROTECTED]> 
wrote:
>
> Paul,
> 
> I haven't tested it, but I'm not sure that it's supposed to. I 
think
> the signal list is based on your Buy and Sell arrays, while 
ApplyStops
> creates automatic stops that are handled by the HandleStops method.
> 
> In fact, on thinking about it, I don't really see how ApplyStops 
could
> generate signals. The signal list is generated on the first pass, 
but
> the automatic stops are dependent on what you do in the custom
> backtester, which is on the second pass. For example, if your stop 
is
> an N-bar stop and you force Buys outside of what's in the Buy array
> (ie. in the custom backtester), then the N-bar stop wouldn't work
> properly if it had been processed on the first pass to generate 
signals.
> 
> The alternative is to implement your own equivalent to ApplyStops 
for
> the type of stop you want in the custom backtester.
> 
> Regards,
> GP
> 
> 
> --- In [email protected], "Paul Ho" <paul.tsho@> wrote:
> >
> > I've been trying,
> > Cant get applystop to generate a sig.IsExit() signal in the 
custom 
> > backtester when its in the lowest level. Does anybody have the 
same or 
> > different experience?
> > /Paul.
> >
>


Reply via email to