Typ : Signal, Name : Hilbert Channel
{************************************************************
Hilbert_Channel (Signal)
This is the signal for the Hilbert Channel Breakout System.
If "EntryVal" or "ExitVal" have values greater than 0, then
those values will be used for the entry / exit lookback
periods. If either input "EntryVal" or "ExitVal" is 0, then
the entry or exit lookback period will be the product of a
fractional constant times the cycle period, "EntryK*Period"
or "ExitK*Period."
Optimize for highest Total Net Profit / Return on Account:
1. Optimize EntryVal, and then ExitVal. (Optimum values are
often between 10 and 45.)
2. Change ExitVal to 0 and optimize ExitK. (Optimum value
is often between 1.5 and 4.5.)
3. Change EntryVal to 0 and optimize EntryK. (Optimum value
is often between .1 and 1.)
4. Repeat steps 2 and 3 until results of optimizing are
stable.
*********************************************************** }
inputs: Price((H + L)/2),
EntryVal(15),
EntryK(0),
ExitVal(15),
ExitK(0);
vars: Period(0),
count(0),
EntryLookBack(0),
ExitLookBack(0),
EntryChannel(0),
ExitChannel(0);
Period = HilbertPeriod(Price);
If EntryVal <> 0 then EntryLookBack = EntryVal else EntryLookBack = EntryK*Period;
if EntryLookBack < 1 then EntryLookBack = 1;
If ExitVal <> 0 then ExitLookBack = ExitVal else ExitLookBack = ExitK*Period;
if ExitLookBack < 1 then ExitLookBack = 1;
EntryChannel = 0;
for count = 1 to EntryLookBack begin
if EntryChannel < High[count] then EntryChannel = High[count];
end;
ExitChannel = 100000;
for count = 1 to ExitLookBack begin
if ExitChannel > Low[count] then ExitChannel = Low[count];
end;
If MarketPosition = 0 and High > EntryChannel then Buy;
If MarketPosition = 1 and Low < ExitChannel then ExitLong;
#BeginCmtry
var: textString(" flat.");
If CheckCommentary then BEGIN
if MarketPosition = 1 then textString = " long.";
if MarketPosition = 0 then textString = " flat.";
commentary("Market position is", textString, NewLine);
commentary("High is", high, ", channel", EntryChannel, ", lookback",
ceiling(EntryLookBack), " bars.", NewLine);
commentary("Low is", low, ", channel", ExitChannel, ", lookback",
ceiling(ExitLookBack), " bars.", NewLine);
End;
#End;
|