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

[amibroker] Re: Does Applystop work with custom backtest with the low level approach



PureBytes Links

Trading Reference Links

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 amibroker@xxxxxxxxxxxxxxx, "gp_sydney" <gp.investment@xxx> 
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 amibroker@xxxxxxxxxxxxxxx, "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.
> >
>



------------------------------------

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

*********************************
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/