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

[amibroker] Re: Limit Trade Length by Number of Bars



PureBytes Links

Trading Reference Links


Terry,

Thank you for the suggestion.  I used this line of code in my 
backtest: 

ApplyStop (3, 1, 50, 0, 0);  // uses n-bar stop = 50 

There was no change in my result.  I still have many 
trades closing with #Bars much greater than 50, e.g., 320, 241, 90, 
87, etc.  I also tried using ApplyStop (3, 2, 50, 0, 0) because it 
seems to me that '1' in the 2nd parameter position means some kind of 
percentage, whereas I am aiming at a number of bars.  There is still 
no difference.  

Any other ideas?

Thanks again!

Joe

--- In amibroker@xxxxxxxxxxxxxxx, Terry <MagicTH@xxxx> wrote:
> Since you're already using ApplyStop why not try
> 
> ApplyStop(3,1,30,0,0); //Type=nBarStop
> -- 
> Terry
> 
> 
> From: "kanowna2000" <kanowna@xxxx>
> Reply-To: amibroker@xxxxxxxxxxxxxxx
> Date: Sun, 07 Nov 2004 19:24:43 -0000
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Limit Trade Length by Number of Bars
> 
> 
> 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 --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/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/