End;
{***** The Min-move Stop *****}
If TrueMinBarMove > 0 Then Begin
TrueNextBar = BarsSinceEntry + 2;
ExitLong ("L-Min") Next Bar at EntryPrice *
(1 + (TrueMinBarMove * TrueNextBar)) Stop;
ExitShort ("S-Min") Next Bar at EntryPrice *
(1 - (TrueMinBarMove * TrueNextBar)) Stop;
End;
End;
{***** The Max-length Stop *****}
If MaxLength > 0 and BarsSinceEntry >= TrueMaxLength Then Begin
ExitLong ("L-Time") on Close;
ExitShort ("S-Time") on Close;
End;
End;
{***** True-range Stops *****}
Variables:
StopLoss(2), TrailingStop(1), ProfitStop(25), TargetStop(4), SlowBar(3),
MinBarMove(0.25), MaxLength(10), RangePeriod(20), OneRange(0),
StopRange(0), TrailRange(0), TrueLength(0), TrueProfitStop(0), LongProfit(0),
ShortProfit(0), MinTradeMove(0), TargetRange(0), TrueSlowBar(0),
TrueNextBar(0), TrueMaxLength(0);
If BarNumber = 1 Then Begin
TrueProfitStop = 1 – ProfitStop * 0.01;
TrueSlowBar = SlowBar - 1;
TrueMaxLength = MaxLength - 1;
End;
OneRange = AvgTrueRange(RangePeriod);
If EntryPrice > 0 Then Begin
{***** The Stop Loss *****}
If StopLoss > 0 Then Begin
StopRange = StopLoss * OneRange;
ExitLong ("L-Loss") Next Bar at EntryPrice - StopRange Stop;
ExitShort ("S-Loss") Next Bar at EntryPrice + StopRange Stop;
End;
{***** The Trailing Stop *****}
252 PART 3 Stops, Filters, and Exits