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

RE: [amibroker] CBT Help



PureBytes Links

Trading Reference Links

Look at the BarsInTrade property of the trade object

d 

> -----Original Message-----
> From: amibroker@xxxxxxxxxxxxxxx 
> [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of tipequity
> Sent: Wednesday, October 10, 2007 9:33 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] CBT Help
> 
> I have written the following CBT code to exit open long position on 
> sell siganls. Now I want to add another cluase that the position must 
> have been open for at least two bars. SetOption("HoldMinBars",2 ) 
> doesn't work for me because it starts counting from the last buy 
> signal. So to achive my objective I need to call BarsInTrade 
> property. What I don't know how do is access this property of the 
> trade method inside a signal loop. Your help would be much 
> appreciated.
> 
> TIA
> Kam
> 
> SetBacktestMode( backtestRegularRaw ); 
> SetCustomBacktestProc(""); 
> if( Status("action") == actionPortfolio )
> { 
> bo = GetBacktesterObject(); 
> bo.PreProcess(); 
> for( i = 0; i < BarCount; i++ ) 
> { 
> for( sig = bo.GetFirstSignal(i); sig; sig = bo.GetNextSignal(i))
> { 
> OpenPos = bo.FindOpenPos( sig.Symbol );
> if( Sig.IsExit() AND OpenPos)		
> {
> bo.ExitTrade( i, OpenPos.symbol, sig.Price, 1); 
> }
> }
> bo.HandleStops(i);
> bo.UpdateStats(i,1);
> bo.UpdateStats(i,2);
> } 
> bo.PostProcess(); 
> }
> 
> 
> 
> 
> 
> Please note that this group is for discussion between users only.
> 
> To get 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
> 
> 
> 
> 



Please note that this group is for discussion between users only.

To get 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/