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

DoubleTopBot Function



PureBytes Links

Trading Reference Links


First create a user function called Choose3.(See Below). Then create a user
function DoubleTopBot. (See Below)
These both verified for me you should be able to cut and paste these as is. Then
just create the system.(At the Bottom).

And yes the way the code is presented in Futures is poor, and difficult to
follow, they should put it together like TASC. 

Hope this helps.
{===========User 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;


============================================================



{=================== User Function DoubleTopBot===============}

Inputs: StrnType(Numeric), TopBot(Numeric), Near(Numeric), Win(Numeric);

Vars: Trend(0),ShtTrend(0), LTrend(0), DnTrend(False),
UpTrend(False),CurLo(999999),
    CurHi(-99999), CTLow(0),CtHi(0),Scale(0),CurHDt(0),CurLDt(0);


Arrays: LastH[3](0), LastLo[3](0),DateH[3](0),DateLo[3](0);

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;

If DnTrend = True and Low <= CTLow then begin
 ShtTrend = -1;
End;

If UpTrend = True and High >= CtHi then begin
 ShtTrend = 1;
End;

If ShtTrend = 1 and High > CurHi and High > High[1] then begin
 CtLow = Low;
End;

If ShtTrend = -1 and Low < CurLo and Low < Low[1] then begin
 CTHi = High;
End;

If ShtTrend = -1 and CurLo > Low then begin
 CurLo = Low;
 CurLDt = 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[0];
 LastH[0] = CurHi;
 CurHi = High; 
 DateH[2] = DateH[1];
 DateH[1] = DateH[0];
 DateH[0] = CurHDt;
End;

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);

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 TopBot = 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;
 
==========================================================

{=========DoubleTopBot System=================}

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;






"The darkest hour in any man's life is when he sits down to plan
 how to get money without earning it"

Sentinel Trading
rjbiii@xxxxxxxxx