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

Re: [amibroker] Re: SafeZone Stop Implementation



PureBytes Links

Trading Reference Links

If you are having problems it is always a good idea to run an
exploration with the various variables in columns to see if you are
getting error results.

there may be times when you have problems with the safe stop

DnPen=IIf(L<L1,L1-L,0);
DnPenSum=Sum(DnPen,Pd);
DnPenCount=Sum(L<L1,Pd);
AvgDnPen=DnPenSum/DnPenCount;

If DnPenCount is zero you will get an error in the avgdnpen because of
dividing by zero giving infinity.
use
AvgDnPen= nz( DnPenSum/DnPenCount );

--
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://e-wire.net.au/~eb_kavan/ab_write.htm


On 1/28/06, ryan_carstens <contact@xxxxxxxxxxxxxxxx> wrote:
> Thanks for the quick response.  One more question, when I implement
> as follows it seems the stop only gets reset on each subsequent BUY
> signal sporadically.  It is very frustrating.
>
> BuySignal = WeeklyADX < ADXEntry AND DailyRSI14 < RSIEntry;
> Buy = BuySignal;
>
> //Implement Safezone Stop/////
> L1=Ref(L,-1);
> Pd=Param("Period",10,1,50,1);
> DnPen=IIf(L<L1,L1-L,0);
> DnPenSum=Sum(DnPen,Pd);
> DnPenCount=Sum(L<L1,Pd);
> AvgDnPen=DnPenSum/DnPenCount;
> AvgDnPenMult=Param("Multiplier",2,1,4,0.1);
> DaysInTrade=BarsSince(Buy);
> StopLong=L1-(AvgDnPen*AvgDnPenMult);
> SafeZoneStopLong=HHV(StopLong,DaysInTrade);
>
> StopExit = Ref(Low,1) < SafeZoneStopLong;
> SellPrice = StopLong;
> SellSignal = WeeklyADX > ADXExit OR DailyRSI9 > RSIExit OR StopExit;
> Sell = SellSignal;
> Buy = ExRem(Buy,Sell);
> Sell = ExRem(Sell,Buy);
>
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@xxxx> wrote:
> >
> > Applystop works off the value of the retracement below the highest
> > high after the buy signal (highest (H-stop amount) since buy)
> > Your applystop statement
> > ApplyStop(stopTypeTrailing,stopModePoint,Ref(Low,-1)-
> SafeZoneStopLong,1);
> > changes the retracemet to be the Low-retracement,so the plot does
> not
> > show the true stop values
> >
> > If you want to use the highest (Low-retracement) then you sould
> code it in AFL
> > This would often require a loop, but in this case you cannot get a
> new
> > buy until after a norma sellsignal occurs, so you could just code
> > something along these lines
> >
> > Sell = Sell OR Cross( hhighestsince(buy, Ref(Low,-1)-
> SafeZoneStopLong), C );
> >
> > --
> > Cheers
> > Graham
> > AB-Write >< Professional AFL Writing Service
> > Yes, I write AFL code to your requirements
> > http://e-wire.net.au/~eb_kavan/ab_write.htm
> >
> >
> > On 1/28/06, ryan_carstens <contact@xxxx> wrote:
> > > I'm trying to implement a SafeZone Stop.  I'm certain the stop
> logic
> > > is coded correctly, but I find the directions for ApplyStop to be
> > > very confusing.  This stop graphs correctly, but when backtested,
> > > the stop doesn't behave correctly.  I'm entering on close and
> would
> > > like to have the stop placed the next day and when hit the trade
> > > should be exited at the stop price.  I have "Activate Stops
> > > Immediately" although I don't fully understand the affect this
> has.
> > > I think I'm just a little foggy on the scope of when things
> happen.
> > >
> > > Any help would be very much appreciated as I've gotten to the
> point
> > > where I've exhausted all resources and am just getting
> frustrated.
> > >
> > >
> > > BuySignal = close > ema(close,20);
> > > Buy = BuySignal;
> > > SellSignal = close < ema(close,20);
> > > Sell = SellSignal;
> > >
> > > Buy = ExRem(Buy,Sell);
> > > Sell = ExRem(Sell,Buy);
> > >
> > > //Implement Safezone Stop/////
> > > L1=Ref(L,-1);
> > > Pd=Param("Period",10,1,50,1);
> > > DnPen=IIf(L<L1,L1-L,0);
> > > DnPenSum=Sum(DnPen,Pd);
> > > DnPenCount=Sum(L<L1,Pd);
> > > AvgDnPen=DnPenSum/DnPenCount;
> > > AvgDnPenMult=Param("Multiplier",2,1,4,0.1);
> > > DaysInTrade=BarsSince(Buy);
> > > StopLong=L-(AvgDnPen*AvgDnPenMult);
> > > SafeZoneStopLong=HHV(StopLong,DaysInTrade);
> > >
> > > ApplyStop(stopTypeTrailing,stopModePoint,Ref(Low,-1)-
> > > SafeZoneStopLong,1);
> > >
> > > Plot(Close,"Close",colorBlack,styleBar);
> > > Plot( SafeZoneStopLong, "Trailing stop", colorBrown, styleThick |
> > > styleLine  );
> > > PositionSize = -15;
> > >
> > >
> > >
> > >
> > >
> > >
> > > 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
>
>
>
>
>
>
>
>


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/