[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help with .ela code



PureBytes Links

Trading Reference Links

Here is the code for a system published in the 11/98 Futures magazine by
Murrary Ruggiero. Trouble is thefirst function, DoubleTopBot, won’t verify
(the error is bracketed 3rd paragraph from bottom). Any help on this would be
greatly appreciated. If you know how to correct the code.. could you e-mail it
to me? Thanx.

{TopBot 0 Is a bottom and 1 is a top. }
 Inputs: STrnType(Numeric), TopBot(Numeric), Near(Numeric), Win(Numeric);
Vars:	Trend(0), ShtTrend(0), LTTrend(0);
Vars:	DnTrend(False), UpTrend(False);
Vars:	CurLo(999999),CurHi(999999), CTLow(O), CTHi(O), Scale(O);
Vars:	CUrHDt(0),CUrLDt(0);
Arrays:	LastH[3](0), LastLo[3](0);
Arrays:	DateH[3](0), DateLo[3](0);

{ When the market sets both lower highs and lows, we define a downtrend. An
uptrend is when we have
both higher highs and lows.}
If	STrnType = 0 then begin DnTrend = High < High[1] and Low
< Low[1];
UpTrend = High > High[1] and Low
> Low[1];
End;
If	STrnType = 1 then begin DnTrend = High < High[1] and Low <
Low[1]and High[1] < High[2] and Low[1] < Low[2];
UpTrend = High> High[1] and Low
>	Low[1]and High[1] > High[2] and Low[1] > Low[2];
End;

{Define a short-term downtrend as when the market makes lower highs and lows,
confirmed when the
market takes out the low of the current uptrend.}

 If DnTrend = True and Low <  CTLow

then Begin
ShtTrend = -1; End;

{Define short-term uptrend as when the market makes lower highs and lows,
confirmed when the market
takes out the high of the current downtrend.}
 If UpTrend =  True and High >  CTHi
then begin
ShtTrend= 1;
End;

{Keep track of current counter low in short-term uptrend.}
If	ShtTrend =1 and High > CurHi and High > High[1] then begin CTLow = Low;
End;

{Keep track of current countertrend high in short-term downtrend.}
If	ShtTrend = - 1 and Low < Curlo and Low < Low[1] then begin
CTHi = High;
End;

{ Reset current high or low in the direction of the short-term trend when the
trend changes. }
If	ShtTrend = -1 and CurLo > Low then begin
CurLo = Low; CurLDt = DateTojulian(Date);
End;
If	ShtTrend = 1 and CurHi < High then begin
CurHi = High; CurHDt = DateTojulian(Date); End;
If	ShtTrend = 1 and ShtTrend[1] 1
then begin
Lastlo[2] = LastLo[1];
Lastlo[1] = LastLo[0];
LastLo[0] = CurLo;
CurLo = Low;
DateLo[2] = DateLo[1];
DateLo[1] = DateLo[0];
DateLo[0] = CurLDt; End;
If	ShtTrend = -1 and ShtTrend[1] <
-1	then begin
LastH[2] = LastH[1];
LastH[1] = LastH[O];
LastH[O] = CurHi;
CurHi = High;
DateH[2] = DateH[1];
DateH[1] = DateH[1];
DateH[0] = CurHDt; End;

{ Keep track of current high and low of the short-term trend move.}

DoubleTopBot = 0;


if TopBot = 0 then value1 = Choose3(LastLo[0], LastLo[1], LastLo[2], Low);

If TopBot = 1 then value1 = Choose3(LastH[0], LastH[1], LastH[2], High);

{This is where the error message appears stating: CANNOT IMPLICITLY CONVERT
NUMERICAL
TO TRUEFALSE}

if TopBot=0 then begin
if MinList(Absvalue(Low- LastLo[0]),
Absvalue(Low- LastLo[1])), Absvalue(Low - LastLo[2]))) < Near
*	Average(TrueRange,3) and DateTojulian(Date) - DateLo [value1]
Win and Low > Low[1] then
DoubleTopBot = 1;
End;

If DoubleTopBot = 1 then begin If MinList(Absvalue(High - LastH[0]),
Absvalue(High - LastH[1]), Absvalue(High - LastH[2])) < Near
*	Average(TrueRange,3) and DateTojulian(Date) - DateH[value1]
>	Win and High < High[1] then DoubleTopBot = 1;
End;

==================================================
{ User Function DunnTrend}
Inputs: STrnType(Numeric);
Vars:	Trend(O),ShtTrend(O),LTTrend(O);
Vars:	DnTrend(FALSE),UpTrend(FALSE);
Vars:	CurLo(999999),CurHi(-99999),CTLow(O), CTHI(O), Scale(O);
{When the market sets both lower highs and lows we define a downtrend. An
uptrend is when we have both higher highs and lows.}
If STrnType = 0 then begin
DnTrend = High <High[1] and Low < Low[1];
UpTrend = High > High[1]and Low> Low[1];
End;
If STrnType = 1 then begin
DnTrend = High < High[1] and Low < Low[1]and High[1] < High[2] and

Low[1] < Low[2];
UpTrend= High > High[1] and Low > Low[1] and High[1] > High[2] and Low[1] >
Low[2];
End;

{ Define a short-term downtrend as when the market makes lower highs and lows,
confirmed when the
market takes out the low of the current uptrend. }
 If DnTrend = True and Low <= CTLow then begin
ShtTrend=-1;
 End;

{ Define a short-term uptrend as when the market makes higher highs and lows,
confirmed when the
market takes out the high of the current downtrend. }
 If UpTrend = True and High >= CTHi
then begin
ShtTrend= 1; end;

{Keep track of current countertrend low in short-term uptrend.}
If	ShtTrend = 1 and High > CurHi and High> High[1] then begin CTLow= Low;
End;

{Keep track of current countertrend high in short-term downtrend.}
If	ShtTrend = -1 and Low < Curlo and Low < Low[1] then begin CTHi = High;
End;

{Reset current high or low in the direction of the short-term trend when the
trend changes.}
If	ShtTrend = 1 and ShtTrend[1] = -1 then CurHi = High;
If	ShtTrend = -1 and ShtTrend[1]
=	1 then CurLo = Low;

{Keep track of current high and low of the short-term trend move.}
 If ShtTrend = - 1 and CurLo > Low
then CurLo = Low;
If	ShtTrend = 1 and CurHi < High then CurHi = High;
DunnTrend = ShtTrend;
======================================
{function: choose3}
Inputs: val1(numeric), val2(numeric),val3(numeric),REF(NUMERIC);

If minlist(absvalue(ref-val1), absvalue(ref-val2),absvalue(ref-
val3))=absvalue(ref-val1) then
choose3 = 0;

If minlist(absvalue(ref-val1), absvalue(ref-val2),absvalue(ref-
val3))=absvalue(ref-val2) then
choose3 = 1;

If minlist(absvalue(ref-val1), absvalue(ref-val2),absvalue(ref-
val3))=absvalue(ref-val3) then
choose3 = 2;
====================================
{system: Dunnigan}

Inputs: near(0.45),dist(6);

if (doubletopbot(0,0,near,dist)=1 or

doubletopbot(0,0,near,dist)[1]=1)

and close < open then buy at open;

if barssinceentry > 3 then exitlong at open;