PureBytes Links
Trading Reference Links
|
{***************************************************************************
******
Zero Lag S&P Daytrading System
Copyright (c) 2000 MESA Software
Notes: 1. Uses 45 minute bars of the S&P 500 Futures contract.
2. Always exit trades at the end of the day.
3. Money management stops are set to $1500.
4. Trades about 1.5 times per week.
5. Uses a Hilbert Transform and a dominant cycle estimate. DOES NOT use
the MESA algorithm.
6. R-MESA uses the MESA algorithm and is a proven robust trading system.
****************************************************************************
*****}
Inputs: Price((H+L)/2),
alpha(.22);
Vars: Imult (.635),
Qmult (.338),
InPhase(0),
Quadrature(0),
Phase(0),
DeltaPhase(0),
count(0),
InstPeriod(0),
Period(0),
Trendline(0),
ZeroLag(0),
Ht(0),
Lt(0),
Yh(0),
Yl(0);
{Set yesterday's high and low}
If Date <> Date[1] then begin
Ht = H;
Lt = L;
Yh = Ht[1];
Yl = Lt[1];
end;
{Establish today's high and low}
If H > Ht then Ht = H;
If L < Lt then Lt = L;
{Initialize ZeroLag}
If CurrentBar = 5 then begin
ZeroLag = (H+L)/2;
end;
If CurrentBar > 5 then begin
{Compute zero lag Kalman filter}
ZeroLag = alpha*(Price + .4*(Price - Price[1])) + (1 - alpha)*ZeroLag[1];
{Detrend Price}
Value3 = Price - Price[7];
{Compute InPhase and Quadrature components}
Inphase = 1.25*(Value3[4] - Imult*Value3[2]) + Imult*InPhase[3];
Quadrature = Value3[2] - Qmult*Value3 + Qmult*Quadrature[2];
{Use ArcTangent to compute the current phase}
If AbsValue(InPhase +InPhase[1]) > 0 then Phase =
ArcTangent(AbsValue((Quadrature+Quadrature[1]) / (InPhase+InPhase[1])));
{Resolve the ArcTangent ambiguity}
If InPhase < 0 and Quadrature > 0 then Phase = 180 - Phase;
If InPhase < 0 and Quadrature < 0 then Phase = 180 + Phase;
If InPhase > 0 and Quadrature < 0 then Phase = 360 - Phase;
{Compute a differential phase, resolve phase wraparound, and limit delta
phase errors}
DeltaPhase = Phase[1] - Phase;
If Phase[1] < 90 and Phase > 270 then DeltaPhase = 360 + Phase[1] - Phase;
If DeltaPhase < 1 then DeltaPhase = 1;
If DeltaPhase > 60 then Deltaphase = 60;
{Sum DeltaPhases to reach 360 degrees. The sum is the instantaneous
period.}
InstPeriod = 0;
Value4 = 0;
For count = 0 to 40 begin
Value4 = Value4 + DeltaPhase[count];
If Value4 > 360 and InstPeriod = 0 then begin
InstPeriod = count;
end;
end;
{Resolve Instantaneous Period errors and smooth}
If InstPeriod = 0 then InstPeriod = InstPeriod[1];
Value5 = .25*(InstPeriod) + .75*Period[1];
{Compute Trendline as simple average over the measured dominant cycle
period}
Period = IntPortion(Value5);
Trendline = 0;
For count = 0 to Period - 1 begin
Trendline = Trendline + Price[count];
end;
If Period > 0 then Trendline = Trendline / Period;
{Demand an outside day to trade}
If Date >= 0 and (Ht >= Yh or Lt <= Yl) then begin
{New positions are entered at the end of the second bar of the day}
If Date = Date[1] and Date > Date[2] and MarketPosition = 0 then begin
If ZeroLag > Trendline and Open > Open[1] and High > High[1] and Close[1]
> Low[1] + (High[1] - Low[1])/ 3 then buy;
If ZeroLag < Trendline and Open < Open[1] and Low < Low[1] and Close[1] <
High[1] - (High[1] - Low[1])/ 3 then sell;
end;
If ZeroLag Crosses Over Trendline and High < High[1] and C>L+(H-L)/2 then
buy;
If ZeroLag Crosses Under Trendline and Low > Low[1] and C<H-(H-L)/2 then
sell;
end;
end;
-----Original Message-----
From: Vince and Jonathan Castelli [mailto:vcastell@xxxxxxxxx]
Sent: Saturday, February 26, 2000 12:18
To: omega-list@xxxxxxxxxx
Subject: ELA to Text - John Ehler's Free ZEROLAG S&P Daytrading system
Could someone please translate the attached .ela file to text for me?
Thanks!
|