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

Re: [amibroker] Drawing Stop Loss Line



PureBytes Links

Trading Reference Links

rpc

Here is a second attempt.

_SECTION_BEGIN("Stop Calculator");
// Stop Calculator
bi = BarIndex()+1;
Buydate = ValueWhen(Buy,bi,1);
Priordate = Buydate -1;

BuydateLow   = ValueWhen(bi == Buydate   ,L,1);
PriordateLow = ValueWhen(bi == Priordate ,L,1);

slpoint = Min(BuydateLow ,PriordateLow )*0.95; 
y2 = LastValue(slpoint);
x2 = BarCount -8;
x3 = BarCount -1;
Line = LineArray( x2, y2, x3, y2, 0 ); 
Plot( Line, "Trend line", colorPaleTurquoise); 
_SECTION_END();

The only problem is that the line

<PriordateLow = ValueWhen(bi == Priordate ,L,1);>

returns {EMPTY} value which makes the calculation of
the line zero.

I am recovering from major surgery and don't have the
energy to figure out what is wrong.

Perhaps the true programmers out there can help


--- rpc200512 <rpc200512@xxxxxxxxx> wrote:

> Hi Rick
> Thanks for the code.I want to draw the horizontal
> line depending on the Buy signal generated by
> afl.While doing so only the last Buy signal should
> be taken into account.
> In fact I am unable to find at which BarCount the
> last buy occured.Pls guide in this respect.After
> finding that I will have to get the Low of that bar
> and Low of the previous bar.
> rpc
>   ----- Original Message ----- 
>   From: Rick Osborn 
>   To: amibroker@xxxxxxxxxxxxxxx 
>   Sent: Wednesday, May 02, 2007 4:56 PM
>   Subject: Re: [amibroker] Drawing Stop Loss Line
> 
> 
>   This should get you started.
>   It assumes the buy happened on the current bar -
> which
>   at least will give you the sell stop limit.
> 
>   It could be refined by getting the BarCount value
> when
>   the buy occurred. 
>   Hope it helps
> 
>   Rick
> 
>   _SECTION_BEGIN("Stop Calculator");
>   // Stop Calculator
>   slpoint = Min(L,Ref(L,-1))*0.95; // 5% below lower
> of
>   current day or yesterday
>   y2 = LastValue(slpoint);
>   x2 = BarCount -8; // no. bars back to start the
> line
>   plot
>   x3 = BarCount -1;
>   Line = LineArray( x2, y2, x3, y2, 0 ); 
>   Plot( Line, "Trend line", colorWhite); 
>   _SECTION_END();
> 
>   --- rpc20060610 <rpc200512@xxxxxxxxx> wrote:
> 
>   > Hi 
>   > I want to draw a Stop Loss line (Horizontal) at
> 5 %
>   > below the the 
>   > lower of current bar(where Buy is triggered) or
>   > earlier bar whichever 
>   > is lower.I am finding difficult to determine how
> to
>   > find where did last 
>   > buy occur on the chart from within the AFL.
>   > Any help in this regard will be greatly
> appreciated
>   > rpc20060610
>   > 
>   > 
> 
>   Rick Osborn & Associates
>   885 Sorrento Ave.
>   Oshawa, Ontario L1J 6V6
>   (905) 728-8543 fax 728-0815
> 
> 
> 
>    


Rick Osborn & Associates
885 Sorrento Ave.
Oshawa, Ontario L1J 6V6
(905) 728-8543  fax 728-0815



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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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/

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