|
For the SELL, you are testing the PRICE versus the number of BARS since a BUY + a ProfitTarget. This makes no sense because Bars has nothing to do with the price.
What I think you want is to test the PRICE versus the BUYPRICE + ProfitTarget.
Use this code instead. Note I have added some plots and some trouble-shooting code at the bottom. Click EXPLORE to see the output (and use just one symbol). You are also going to want some kind of stop loss in case your stock just goes down after buying!
Buy = Cross(C,MA(C,20)); ProfitTarget = 20; //Bars = BarsSince(Buy==1); Bought = ValueWhen(Buy,BuyPrice,1); Sell = C >= Bought + ProfitTarget;
Plot(C,Name(),1,64); PlotShapes(Buy * shapeUpArrow + Sell * shapeDownArrow,1,0,C);
Filter = 1; AddColumn(Buy,"Buy",1.0,colorGreen); //AddColumn(Bars,"Bars",1.0); AddColumn(Bought,"Bought",1.0); AddColumn(Sell,"Sell",1.0,colorRed); AddColumn(C,"Close",1.0);-- Terry -----Original Message-----
Terry, thanks. I was kind of hoping for a simpler solution. I tried the following but for some reason it does not give the same result av with ApplyStop.
ProfitTarget = 20; Bars = BarsSince(Buy==1); Sell = C >= Ref(C,-Bars) + ProfitTarget;
Any idea to what is wrong? Thanks, /Fredrik --- In [email protected], "Terry" <[EMAIL PROTECTED]> wrote: > > I think you'll have to build a loop and define your own stops. I like to > use temporary variables such as myBuy instead of BUY, then apply the > results using "normal" Buy = myBuy; Sell = mySell; and so on after the > loop is finished. You will need to track whether you are on a Buy or a > Short to know which stop to use. > -- > Terry > -----Original Message----- > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of broman1003 > Sent: Thursday, July 27, 2006 15:25 > To: [email protected] > Subject: [amibroker] Re: Profit target > > --- In [email protected], "broman1003" > <fredrik_broman1003@> wrote: > > > > Hi, > > > > I am trying to build a trading system where I would like to use a > > profit target. I began by using the ApplyStop function but that one > > does not allow you to specify a different target for long resp short > > trades. Is there an easy way around that? > > Kind regards, > > /Fredrik > > > > Anyone? > > > > > > 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 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 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/
<*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
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 other support material please check also: http://www.amibroker.com/support.html
SPONSORED LINKS
YAHOO! GROUPS LINKS
__,_._,___ |
- RE: [amibroker] Re: Profit target Terry
- [amibroker] Re: Profit target broman1003
- RE: [amibroker] Re: Profit target Terry
