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

[amibroker] Try to rewrite from JScript to AFL a ZigZag formula.



PureBytes Links

Trading Reference Links

Hi,

I try to rewrite from JScript to AFL a ZigZag formula.

Dont works, where my mistake ?

ALF formula
-------------------------------------------

Reversal = 0.02;
function FillLine( startbar, startval, endbar, endval )
{
for( j = startbar; j <= endbar; j++ )
{
ZigArray[ j ] = startval + (( j - startbar) * (endval-startval)/( endbar -
startbar ));
}
}

ZigArray = Low;
Maximum = High[ 0 ];
Minimum = Low[ 0 ];
MinBar = 0;
MaxBar = 0;
startbar = 0;
if( High[ 1 ] > High[ 0 ] )
{
dir = 1;
Extremum = Low[ 0 ];
}
else
{
dir = -1;
Extremum = High[ 0 ];
}
ExBar = 0;
for( i = 1; i < BarCount-1; i++ )
{
if( High[ i ] > Maximum )
{
Maximum = High[ i ];
MaxBar = i;
}
if( Low[ i ] < Minimum )
{
Minimum = Low[ i ];
MinBar = i;
}
if( (dir == 1) AND ( Minimum < (1- Reversal ) * Maximum ) )
{
FillLine( ExBar, Extremum, MaxBar, Maximum );
Extremum = Maximum;
ExBar = MaxBar;
Maximum = Minimum;
MaxBar = MinBar;
dir = -1;
}
if( (dir == -1) AND ( Maximum > (1+ Reversal ) * Minimum ) )
{
FillLine( ExBar, Extremum, MinBar, Minimum );
Extremum = Minimum;
ExBar = MinBar;
Minimum = Maximum;
MinBar = MaxBar;
dir = 1;
}
}

/*-*-*-*-*-*-*-*-*-* Graphs *-*-*-*-*-*-*-*-*-*/
_SECTION_BEGIN("Close");
SetChartOptions(0,chartShowArrows);
Plot( Close, "Close", ParamColor("Color", colorBlack ), ParamStyle("Style",
styleCandle, maskPrice ) );
_SECTION_END();
_SECTION_BEGIN("ZigArray");
Plot( ZigArray, _DEFAULT_NAME(), colorRed, styleLine);
_SECTION_END();



------------------------ Yahoo! Groups Sponsor --------------------~--> 
$4.98 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/Q7_YsB/neXJAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/