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

ATR exit error



PureBytes Links

Trading Reference Links

Between not getting my formatting correctly(using HTML) and having a new
email address I have had one heck of a time getting this posted.



Someone asked a while back about the ATR exit. If you use this then it would
be worthwhile to check the code and version that you are using.

This is the ATR exit code that I have for TS6.

inputs: ATRs( 3 ) ;
variables: PosHigh( 0 ), ATRVal( 0 ) ;

ATRVal = AvgTrueRange( 10 ) * ATRs ;

if BarsSinceEntry = 0 then
 PosHigh = High ;

if MarketPosition = 1 then
 begin
 if High > PosHigh then
  PosHigh = High ;
 Sell ( "ATR" ) next bar at PosHigh - ATRVal stop ;
 end
else
 Sell ( "ATRe" ) next bar at High - ATRVal stop ;


{ ** Copyright (c) 1991-2001 TradeStation Technologies, Inc. All rights
reserved. ** }



The problem with this version is the last line. This line determines the
stop if a new high wasn't reached on the last bar. The way I understand it
this line should be
identical to the one three lines above it. It isn't, obviously. I was always
suspicious of this as what it does is lower your stop if you didn't get to a
new high on the last bar. One of the other ATR versions has it this way.
The condition can then exist where your price erodes insuch a fashion that
you don't get stopped out. Succesively lower highs means lower stops until
the acceleration downward reaches a peak and then you are. This results in a
bad
exit. This just has to be wrong. The one other version on 2000i that has
both
the long and short stops has it done correctly.

Inputs: TrailingATRs(4), ATRLength(10);
Variables: PosHigh(0), PosLow(0), ATRVal(0);

ATRVal = AvgTrueRange(ATRLength) * TrailingATRs;

If MarketPosition = 1 Then Begin
 If BarsSinceEntry = 0 Then
  PosHigh = High;
 If High > PosHigh Then
  PosHigh = High;
 ExitLong Next Bar at PosHigh - ATRVal Stop;
End;

If MarketPosition = -1 Then Begin
 If BarsSinceEntry = 0 Then
  PosLow = Low;
 If Low < PosLow Then
  PosLow = Low;
 ExitShort Next Bar at PosLow + ATRVal Stop;
End;


Once I saw this I was convinced and changed my code. I recommend changing
your code and incorporating it in to your system. That way if you ever have
to reinstall you won't have to remember this change.
Maybe if this has been covered it is worth revisiting. I don't believe that
I have kept alive old versions and think that this is a problem with the
current install.
It's a jungle in there. Watch out!


Jim Bronke
Phoenix, AZ