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

[amibroker] Re: Plot ATR trailing stop which only increases



PureBytes Links

Trading Reference Links

Many people have helped me on this forum, so I am very happy to 
offer my first answer!

You could try something like this.

It draws a non-retreating line 3xATR(30) below daily Close price.
It only retreats if the Close falls through the line.
It shows potential stop loss points with a red downward arrow.



// plot non-retreating 3xATR(30) below daily Close, as an exit line

AT = 3 * ATR(30);
AT2 = 0;

for (i=1;i<BarCount; i++)  // start from 1 because we address [i-1]
{
  // create a line 3xATR below daily Close
  AT2[i] = Close[i] - AT[i];

  // don't retreat
  if (AT2[i] < AT2[i-1])
    AT2[i] = AT2[i-1];

  // but follow Close if necessary
  if (Close[i] <= AT2[i])
    AT2[i] = Close[i];
}

Plot(C, "OHLC", colorBlack, styleBar);
Plot(AT2, "Non-descending 3xATR(30) below Close", colorBlue);
PlotShapes(shapeDownArrow*(Close <= AT2), colorRed);


-Andrew

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

--- In amibroker@xxxxxxxxxxxxxxx, "amickan1958" <amickan@xxx> wrote:
>
> Hi,
> 
> I've been trying to crack this one but can't seem to. What I need 
is a 
> plot of my trailing stop. The stop is based on a multiplier of 
todays 
> ATR(30) value. This stop only ever increase.
> 
> Can anyone help me out with some code please?
> 
> Thanks
> 
> Andrew
>




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/