PureBytes Links
Trading Reference Links
|
Hi,
I answer to myself, because I found the answer ( Very proud of it ;-D ).
Just put
ZigArray = Low;
before the function FillLine, so the function see the ZigArray variable
like a globale variable, not a local one like before, and it works.
Thanks Tintin92 ;-D
Merry Christmas and a Happy New year Everyone.
>
> Hi,
>
> I try to rewrite from JScript to AFL a ZigZag formula.
>
> Dont works, where my mistake ?
>
> ALF formula
> -------------------------------------------
>
> Reversal = 0.02;
ZigArray = Low; <--------- Here
> function FillLine( startbar, startval, endbar, endval )
> {
> for( j = startbar; j <= endbar; j++ )
> {
> ZigArray[ j ] = startval + (( j - startbar) * (endval-startval)/( endbar -
> startbar ));
> }
> }
>
> 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();
>
>
>
>
> 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
>
>
>
>
>
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/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/
|