Trading Systems and Money Management : A Guide to Trading and Profiting in Any Market

(やまだぃちぅ) #1
End
Else If TrailStopVar > 0 Then Begin
SCT.TRLoss = AvgTrueRange(MaxBarsVar) * StopLossVar;
SCT.TRTrailing = AvgTrueRange(MaxBarsVar) * TrailStopVar;
SCT.TRTarget = AvgTrueRange(MaxBarsVar) * ProfTargVar;
End;
If EntryPrice > 0 Then Begin
If MaxBarsVar > 0 and BarsSinceEntry + 1 >= MaxBarsVar Then
SetExitOnClose;
If StopLossVar > 0 Then Begin
ExitLong ("SCT.L-Loss(TR)") Next Bar at EntryPrice - SCT.TRLoss
Stop;
ExitShort ("SCT.S-Loss(TR)") Next Bar at EntryPrice + SCT.TRLoss
Stop;
End;
If TrailStopVar > 0 Then Begin
SCT.TrueLength = BarsSinceEntry + 1;
ExitLong ("SCT.L-Trail(TR)") Next Bar at
Highest(High, SCT.TrueLength) - SCT.TRTrailing Stop;
ExitShort ("SCT.S-Trail(TR)") Next Bar at
Lowest(Low, SCT.TrueLength) + SCT.TRTrailing Stop;
End;
If ProfTargVar > 0 Then Begin
ExitLong ("SCT.L-Trgt(TR)") Next Bar at EntryPrice + SCT.TRTarget
Limit;
ExitShort ("SCT.S-Trgt(TR)") Next Bar at EntryPrice - SCT.TRTarget
Limit;
End;
End;
End;

Comments on the Code



  1. The variable SurfaceChartTest(True) needs to be placed on top of the code
    or even as an input. The other variables will only become active when
    SurfaceChartTest is set to True. To speed up the computing time, the program
    will not run through the rest of the code, as long as SurfaceChartTest is set
    to False.


224 PART 3 Stops, Filters, and Exits

Free download pdf