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

(やまだぃちぅ) #1
about 200 percent. But because the time spent in a trade remained approximately
the same, while the number of trades decreased by more than 50 percent, we can
conclude that the changes only made the system make the most of the most favor-
able market situations. In Part 3, we will try to decrease the time spent in a trade
further, to make room for more diversification possibilities.

TradeStation Code


Variables:
{These variables can also be used as inputs for optimization purposes.}
AllowLong(True), AllowShort(False), MeanderLookback(10) {Max: 25},
{Leave these variables alone.}
LookbackPoints(0), SetMeanderArray(0), MeanderArrayPos(0), SumDiff(0),
AverageDiff(0), SumSquareError(0), SumError(0), SquareSumError(0),
MeanderStDev(0), Meander(0), MeanderHigh(0), MeanderHighest(0),
MeanderLow(0), MeanderLowest(0);
Array: PriceDiff[100](0);
{Code for normalizing the number of contracts traded goes here.}
If BarNumber = 1 Then
LookbackPoints = MeanderLookback * 4;
For SetMeanderArray = 0 To (MeanderLookback - 1) Begin
PriceDiff[SetMeanderArray * 4 + 0] = (Open[SetMeanderArray] -
Close[SetMeanderArray + 1]) / Close[SetMeanderArray + 1];
PriceDiff[SetMeanderArray * 4 + 1] = (High[SetMeanderArray] -
Close[SetMeanderArray + 1]) / Close[SetMeanderArray + 1];
PriceDiff[SetMeanderArray * 4 + 2] = (Low[SetMeanderArray] -
Close[SetMeanderArray + 1]) / Close[SetMeanderArray + 1];
PriceDiff[SetMeanderArray * 4 + 3] = (Close[SetMeanderArray] -
Close[SetMeanderArray + 1]) / Close[SetMeanderArray + 1];
End;
SumDiff = 0;
For MeanderArrayPos = 0 To (LookbackPoints - 1) Begin
SumDiff = SumDiff + PriceDiff[MeanderArrayPos];
End;
AverageDiff = SumDiff / (LookbackPoints);
SumSquareError = 0;
SumError = 0;
For MeanderArrayPos = 0 To (LookbackPoints - 1) Begin

120 PART 2 Trading System Development

Free download pdf