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

[amibroker] Re: Coding N-bar stops



PureBytes Links

Trading Reference Links


Ralph,

There may be better ways but this should work:

out=0;
in=True;//your buy here

s=Optimize("S",1,1,10,1)*.01;
n=Optimize("N",1,1,10,1);

Buy=ExRem(in,out);

out=BarsSince(Buy)>N AND (C-BuyPrice)/BuyPrice < S;

Sell=ExRem(out,in);

Walt

You should also take a look at the "equity" statement notes in the 
help files. And try fiddleing with the "activate stops immediately" 
in the settings (if you want to try using the buit-in stops)...


--- In amibroker@xxxxxxxxxxxxxxx, "rkp1" <rkp1@xxxx> wrote:
> 
> I am currently trading a counter-trend system on select stocks. 
> Profitable trades average ~5 bars, losers are usually > ~10 bars. I 
> would like to test various N-bar stops to see if they can improve 
> drawdown and/or returns. Specifically as a first cut I would like 
to 
> try this pseudo-code, optimizing on N(bars) and S(%):
> 
> if (Trade_Length > N) and (Position_Profit < S) then SELL
> 
> What would be the simplest way to code this?
> 
> My reasoning on this is that I've tried the built in N-bar stop in 
> settings, which makes results worse, because by the time you stop 
> out sometimes you hit the peak loss, whereas if you let it ride to 
> the normal exit the loss shrinks. I thought maybe it could work 
with 
> a set loss percentage below which you ride the trade out, otherwise 
> stop out.
> 
> Thanks in advance,
> 
> Ralph





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