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

[amibroker] Re: Two trailing stops possible - 7% and ATR(10)?



PureBytes Links

Trading Reference Links

Ok. I tried that, but I ran into a problem.

I tried to find the buy price based on the criteria. 
Buy = 
C > 5.0 AND 
ROC(C,10) > 0 AND
PDI(10) > MDI(10) AND 
ADX(10)>25  AND
C > EMA(C,10) AND
C > TrailStop AND
Open > TrailStop;  
 
Buycriteriaprice = IIf(Buy = 1, C, 0);

The last line placed buy arrows for buys one after the other on the chart and in the backtest table.  That didn't work.
I had defined TrailStop earlier too.  That seemed okay.

I have not been able to find the way to obtain the buy price (closing price) for the day the buy is made and ignore immediately subsequent days when the criteria is met. That is, I don't want purchases of the same security for days in a row.   

Can you help me with identifying and obtaining the buy price? 

Thanks.


--- In amibroker@xxxxxxxxxxxxxxx, Ara Kaloustian <ara1@xxx> wrote:
>
> You might consider combining the critria formulas and use one ApplyStop
> 
> Criteron1 = your formula1
> criterion2 = your formula2
> criterion  = smaller of (or larger of or whatever ) critrion1 and criterion2
> 
> ApplyStop(.....,criterion,...);
> 
> ----- Original Message ----- 
> From: "srengret" <lechols@xxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Saturday, April 04, 2009 5:13 PM
> Subject: [amibroker] Two trailing stops possible - 7% and ATR(10)?
> 
> 
> > Does Amibroker allow two trailing stops?
> >
> > I've been trying to code two trailing stops with different criteria in 
> > Amibroker 5.10.
> > Why do this:  Some, but not all, of the ATR-based trailing stops allow too 
> > big of a loss when the 7% stop seems to catch them earlier.
> >
> > Here is what I've tried:
> > The first criterion is for a 7% trailing stop.
> > The second criterion is for an ATR-based trailing stop.
> > They are in this order in the code.
> > When running the code, it displays on a chart the two trailing stops as 
> > expected.  However, when I look at the resulting table in the Automatic 
> > Analysis window, it doesn't show the 7% trailing stop data.  However, the 
> > ATR-based stop does show in the table.
> >
> > From the settings button and then the Backtester window, and then the 
> > Stops tab, I disabled the trailing stops.  I did this because the software 
> > code by the user overrides the backtester settings as I understand it.
> >
> > My backtest mode:
> > SetBacktestMode(backtestRegular);
> > Here is the 7% trailing stop code:
> >
> > ApplyStop(2,1,7,1,False,1);
> > Equity(1,0);  //ThIS EVALUATES STOPS.
> > Plot(Sell==4,"7% Loss",colorBlue,styleArea|styleOwnScale);//4 is for 
> > trailing stops
> >
> > For the ATR-based trailing stop:
> >
> > TrailStop = 0;
> > TrailStop = HHV( C - 3* ATR(10),15);
> > Sell = C < TrailStop OR Open < TrailStop OR Low < TrailStop; //must tell 
> > it when to sell
> > ApplyStop(2, 2, TrailStop, 1, False, 1) ;
> > Equity(1,0);  //ThIS EVALUATES STOPS
> > Plot(Sell,"Trlng Stop 3*atr(10)",colorOrange,styleArea|styleOwnScale);
> >
> > So, either the application won't recognize two trailing stops criteria or 
> > I have overlooked something. I think it is the latter, but I just don't 
> > know where.
> >
> > My test cases were Powershares ETFs from 1 Sep 08 through 4 Apr 09.
> >
> > Will anyone point me to a solution?
> >
> > Regards
> >
> >
> >
> >
> >
> >
> >
> >
> > ------------------------------------
> >
> > **** IMPORTANT PLEASE READ ****
> > This group is for the discussion between users only.
> > This is *NOT* technical support channel.
> >
> > TO GET TECHNICAL SUPPORT send an e-mail directly to
> > SUPPORT {at} amibroker.com
> >
> > TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> > http://www.amibroker.com/feedback/
> > (submissions sent via other channels won't be considered)
> >
> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > http://www.amibroker.com/devlog/
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/