SumSquareError = SumSquareError +
Square(PriceDiff[MeanderArrayPos] - AverageDiff);
SumError = SumError + (PriceDiff[MeanderArrayPos] - AverageDiff);
End;
SquareSumError = Square(SumError);
MeanderStDev = SquareRoot((LookbackPoints * SumSquareError -
SquareSumError) / (LookbackPoints * (LookbackPoints - 1)));
Meander = Close * (1 + AverageDiff);
MeanderHighest = Close * (1 + AverageDiff + 2 * MeanderStDev);
MeanderHigh = Close * (1 + AverageDiff + MeanderStDev);
MeanderLow = Close * (1 + AverageDiff - MeanderStDev);
MeanderLowest = Close * (1 + AverageDiff - 2 * MeanderStDev);
If MarketPosition = 0 Then Begin
If AllowLong = True and Close < Close[1] and Close < Open Then
Buy ("L-Jan 01") NumCont Contracts Next Bar at MeanderLow Limit;
If AllowShort = True and Close > Close[1] and Close > Open Then
Sell ("S-Jan 01") NumCont Contracts Next Bar at MeanderHigh Limit;
End;
If EntryPrice > 0 Then Begin
ExitLong ("L-Stop") Next Bar at MeanderLowest Stop;
ExitLong ("L-Trgt") Next Bar at MeanderHighest Limit;
ExitShort ("S-Stop") Next Bar at MeanderHighest Stop;
ExitShort ("S-Trgt") Next Bar at MeanderLowest Limit;
End;
{Code for testing stops in Excel goes here (see Part 3 of book), with
Normalize(False). Set SurfaceChartTest(True). Disable original stops in system.}
{Code for initial market export goes here, with Normalize(True). Set
ExportSwitch(True).}
{Code for testing robustness goes here (see Part 3 of book), with Normalize(True).
Set RobustnessSwitch(True).}
{Code for exporting results for money management analysis goes here (see Part 4
of book), with Normalize(False). Set MoneyExport(True).}
CHAPTER 10 Meander System V.1.0 121