【Pennant】
[code]inputs:Len( numericsimple ),
MaxConsolIndex( numericsimple ),
BarsPast( numericsimple ),
oTLHiStartPr( numericref ),
oTLHiEndPr( numericref ),
oTLLoStartPr( numericref ),
oTLLoEndPr( numericref ) ;
variables:
var0( Len - 1 ),
var1( 0 ),
var2( 0 ),
var3( 0 ),
var4( 0 ),
var5( 0 ),
var6( 0 ),
var7( 0 ),
var8( 0 ),
var9( 0 ),
var10( 0 ),
var11( 0 ),
var12( 0 ),
var13( 0 ),
var14( 0 ),
var15( 0 ),
var16( 0 ),
var17( 0 ),
var18( 0 ),
var19( 0 ),
var20( 1000000 ),
var21( false ) ;
var1 = -1 ;
var2 = AvgTrueRange( Len ) ;
if var2 > 0 then
var3 = ( HighestFC( TrueHigh, Len ) - LowestFC( TrueLow, Len ) ) /
AvgTrueRange( Len )
else
var3 = MaxConsolIndex + 1 ;
if var3 <= MaxConsolIndex then
begin
Value1 = LinearReg( High, Len, 0, var4, var5, var6,
var7 ) ;
Value1 = LinearReg( Low, Len, 0, var8, var9, var10,
var11 ) ;
var18 = var8 - var4 ;
if var18 >= 0 then
begin
var13 = 0 ;
var15 = 0 ;
for Value1 = 0 to var0
begin
var12 = High[Value1] - ( var6 + var4 * ( var0 -
Value1 ) ) ;
var14 = -( Low[Value1] - ( var10 + var8 * ( var0 -
Value1 ) ) ) ;
if var12 > var13 then
var13 = var12 ;
if var14 > var15 then
var15 = var14 ;
end ;
oTLHiStartPr = var6 + var13 ;
oTLHiEndPr = var7 + var13 ;
oTLLoStartPr = var10 - var15 ;
oTLLoEndPr = var11 - var15 ;
var16 = var4 ;
var17 = var8 ;
if var18 > 0 then
var19 = MinList( BarsPast, ( oTLHiEndPr - oTLLoEndPr ) / var18 )
else
var19 = BarsPast ;
var1 = 1 ;
end ;
end ;
if var1 = 1 then
begin
var20 = 0 ;
var21 = false ;
end
else
begin
var20 = var20 + 1 ;
if var20 <= var19 then
begin
oTLHiEndPr = oTLHiStartPr + var16 * ( var0 + var20 ) ;
oTLLoEndPr = oTLLoStartPr + var17 * ( var0 + var20 ) ;
if var21 = false then
begin
condition1 = High > oTLHiEndPr and Low > oTLLoEndPr ;
if condition1 then
begin
var21 = true ;
var1 = 2 ;
end
else
begin
condition1 = Low < oTLLoEndPr and High < oTLHiEndPr ;
if condition1 then
begin
var21 = true ;
var1 = 3 ;
end ;
end ;
end;
end
else
begin
oTLHiEndPr = 0 ;
oTLLoEndPr = 0 ;
end ;
end ;
Value1 = Pennant[1] ;
Pennant = var1 ;
[/code]
页:
[1]