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 [email protected], "amickan1958" <[EMAIL PROTECTED]> 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
>


Reply via email to