our initial assumptions and the findings from Table 15.5. However, as opposed to
Table 15.4 in relation to Table 15.1, Table 15.7 shows both a lower average profit
per trade and a lower risk–reward relationship than Table 15.5, which suggests that
the trailing-stop version should be traded in a normal fashion on the first signal
only. One way to do it might be to trade the trailing-stop version as you’d do with
any system, and then add a trade every so often, which you monitor according to
the stop-loss rules.
TradeStation Code
Variables:
{These variables can also be used as inputs for optimization purposes.}
AllowLong(True), AllowShort(True), RandomEntry(False), TrailingStop(False),
BarsInTrade(8), ProfitExit(4.5){4}, LossExit(1){1.6},
{Leave these variables alone.}
RandomTrigger(0), LongStop(0), ShortStop(0), LongTarget(0), ShortTarget(0),
Top(0), Bottom(0);
RandomTrigger = IntPortion(Random(2));
{Code for normalizing the number of contracts traded goes here.}
If BarNumber = 1 Then Begin
ProfitExit = ProfitExit / 100;
LossExit = LossExit / 100;
LongStop = 1 - LossExit;
LongTarget = 1 + ProfitExit;
ShortStop = 1 + LossExit;
ShortTarget = 1 - ProfitExit;
End;
Top = High;
Bottom = Low;
If (RandomEntry = False or RandomTrigger = 1) and MarketPosition = 0 Then
Begin
If AllowLong = True and High < High[2] and Close < Open and Open Next Bar
< High Then
Buy ("L-June 02") NumCont Contracts Next Bar at High Stop;
If AllowShort = True and Low > Low[2] and Close > Open and Open Next Bar
> Low Then
Sell ("S-June 02") NumCont Contracts Next Bar at Low Stop;
End;
182 PART 2 Trading System Development