The Guppy Darvas code
Hi All found this in one of the BB- but this does not pass the verification test in the easylanguage- Any suggestions are welcome-
inputs:
Periods( 100 ),
ExitNextDay( false ),
GhostBoxExit( false ),
BreakoutEntry (false ),
VolumeEntry( false ),
VolumeAvgLen( 10 ),
VolumeFactor( 1.5 ) ;
variables:
BarsSinceDH( 0 ),
BarsSinceDL( 0 ),
CriticalLow( 0 ),
TempD_Low( 0 ),
SearchForLow ( false ),
D_Low( 0 ),
D_High( 0 ),
BottomLineNum( 0 ),
TopLineNum( 0 ),
LeftSideNum( 0 ),
RightSideNum( 0 ),
CriticalHigh( 0 ),
TempD_High( 0 ),
DHighLowDiff( 0 ),
MyStop( 0 ),
MyTrigger( 0 ),
DownTrend( 0 ) ;
if CurrentBar > Periods then
begin
BarsSinceDH = BarsSinceDH + 1 ;
BarsSinceDL = BarsSinceDL + 1 ;
if Low[3] <= CriticalLow[4] and
Low[3] <= Low[2] and
Low[3] <= Low[1] and
Low[3] < Low
then
begin
TempD_Low = Low[3] ;
BarsSinceDL = 3 ;
end ;
if SearchForLow and BarsSinceDL < 6 and
BarsSinceDL <= BarsSinceDH then
begin
D_Low = Low[BarsSinceDL] ;
D_High = TempD_High ;
SearchForLow = false ;
BottomLineNum = TL_New( Date[BarsSinceDH],
Time[BarsSinceDH], D_Low, Date[3], Time[3],
D_Low ) ;
TopLineNum = TL_New( Date[BarsSinceDH],
Time[BarsSinceDH], D_High, Date[3], Time[3],
D_High ) ;
LeftSideNum = TL_New( Date[BarsSinceDH],
Time[BarsSinceDH], D_High, Date[BarsSinceDH],
Time[BarsSinceDH], D_Low ) ;
RightSideNum = TL_New( Date[3], Time[3], D_High,
Date[3], Time[3], D_Low ) ;
end ;
if High[3] >= CriticalHigh[4]
and High[3] >= High[2]
and High[3] >= High[1]
and High[3] > High
then
begin
BarsSinceDH = 3 ;
TempD_High = High[3] ;
SearchForLow = true ;
end ;
CriticalHigh = Highest( High, Periods ) ;
CriticalLow = Lowest( Low, BarsSinceDH ) ;
end ;
DHighLowDiff = D_High - D_Low ;
if GhostBoxExit and DHighLowDiff > 0 and Close >
D_High + DHighLowDiff then
begin
MyStop = ( IntPortion( ( Close - D_Low ) /
DHighLowdiff ) - 1 ) * DHighLowDiff + D_Low ;
MyTrigger = MyStop + DHighLowDiff ;
end
else
begin
MyStop = D_Low ;
MyTrigger = D_High ;
end ;
if Close crosses under D_Low then
DownTrend = 0
else if BreakoutEntry and Close crosses over D_High then
DownTrend = 1
else if BreakoutEntry and DownTrend = 1 and
BarsSinceDL = 3 then
DownTrend = 2 ;
if ( BreakoutEntry and DownTrend = 2 ) or
BreakoutEntry = false then
begin
if VolumeEntry then
begin
if Close crosses over MyTrigger and Volume >
Average( Volume, VolumeAvgLen ) * VolumeFactor
then
Buy next bar market ;
end
else if Close < MyTrigger then
Buy next bar MyTrigger stop ;
if ExitNextDay then
begin
if Low[1] >= MyStop and Low < MyStop then
Sell next bar at market ;
end
else
Sell next bar at MyStop stop ;
end ;