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

[amibroker] Limit Trade Length by Number of Bars



PureBytes Links

Trading Reference Links


Hello Everyone, 

I am trying to limit the number of bars that my trades can stay open, 
to see if this can make a difference in the profitability of my 
system.  If my trade has been open 50 bars I want to close the 
trade.  In the 'Stops' tab of BackTester Settings I typed 50 in 
the 'Bars' box of the 'N-bar stop' section, and I clicked the 'bars' 
radial button to enable this feature. 

I thought this would limit my trade lengths to 50 (or no more than 
51, assuming sell at next day open), but I am still getting large 
trade lengths, like 320 bars, and so on.  It does not seem to have 
made a difference from my original system.  Below is the basic form 
of my code: 

PosQty = 10; // open positions 
SetOption("MaxOpenPositions", PosQty ); 
PositionSize = -100/PosQty; // invest 100% of portfolio equity 
divided by max. position count 

Cond1 = ................ (various conditions) 
Cond2 = ................ (various conditions) 
Cond3 = ................ (various conditions) 
Cond4 = ................ (various conditions) 

BuyPrice = ValueWhen(Cond4, (High + Low)/2 ); 

Buy      =  (BuyPrice >= Low   AND  BarsSince(Cond4) <= 10  AND  
BarsSince(Cond4) > 0)  AND 
            (BuyPrice >= 0.50  AND  BuyPrice <= 10.00); 

ApplyStop (0, 1, 25, 1);   // uses 25% max loss stop 
ApplyStop (1, 1, 90, 1);   // uses 90% tgt prof stop 

Sell     = Cross( MFI(14), 80); 

My system is a backtest run against all stocks for a 10-year period. 

Any help would be greatly appreciated.  Many thanks. 

Josef 





------------------------ Yahoo! Groups Sponsor --------------------~--> 
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

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