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

Re: [amibroker] Rankings Help



PureBytes Links

Trading Reference Links

Aequalsz,

Thank You for sharing the code: it works perfectly.
I was trying to realize something similar (only considering Hi-Lo, without %
value).
Since I am not a programmer, I didn't know to do, but this code solved my
problems.
I converted the code to a function (...see below), with a unique parameter,
so it can be used in more efficient manner.
As you can see, this function draws the line until the last bar.

Best Regards,
	Antonio


//==========================================================================

function ZigZagHL(prcnt)
{

// -------------------------------------------------------------------------
global ZigArray_HL;

WavePcnt = (1+0.01*prcnt);

End_Val_HL   = Avg[0];
Start_Val_HL = End_Val_HL;

End_Bar_HL   = 0;
Start_Bar_HL = End_Bar_HL;

Switch_HL = 0;

Hs_cnd = (Ref(H,-1) <= Ref(H,0) AND Ref(H,0) >= Ref(H,1));
Ls_cnd = (Ref(L,-1) >= Ref(L,0) AND Ref(L,0) <= Ref(L,1));

Hs_Swing = IsTrue(Hs_cnd)  AND (Ls_cnd==False);
Ls_Swing = (Hs_cnd==False) AND IsTrue(Ls_cnd);

//--------------------------------------------------------------------------

     for (i=0; i < BarCount; i++)
     {
         ZigArray_HL[i] = -1.0E10; 

         // Swing High -----------------------------------------------------

         if ( i > 0 AND i < BarCount AND Hs_Swing[i] )
              SwingHigh_HL = H[i];
         else
              SwingHigh_HL = -1;

         // Swing Low ------------------------------------------------------

         if ( i > 0 AND i < BarCount AND Ls_Swing[i] )
              SwingLow_HL = L[i];
         else
              SwingLow_HL = -1;

         // ZigZag ---------------------------------------------------------

         if ( SwingHigh_HL != -1)
         {     
              if (
                   Switch_HL[i-1] != 1 
                        AND SwingHigh_HL >= (End_Val_HL * WavePcnt) )
              {
                   Start_Bar_HL = End_Bar_HL;
                   Start_Val_HL = End_Val_HL;
                   End_Bar_HL = i;
                   End_Val_HL = SwingHigh_HL;

                   for( j = Start_Bar_HL; j <= End_Bar_HL; j++ )
                   {
                   ZigArray_HL[j] = Start_Val_HL 
                                     + (j - Start_Bar_HL)
                                       * (End_Val_HL - Start_Val_HL)
                                        / (End_Bar_HL - Start_Bar_HL );
                   }
                   Switch_HL = 1;
              }
              else
              if (Switch_HL[i-1] == 1 AND SwingHigh_HL >= End_Val_HL)
              {
                   End_Bar_HL = i;
                   End_Val_HL = SwingHigh_HL;

                   for( j = Start_Bar_HL; j <= End_Bar_HL; j++ )
                   {
                   ZigArray_HL[j] = Start_Val_HL 
                                     + (j - Start_Bar_HL)
                                       * (End_Val_HL - Start_Val_HL)
                                        / (End_Bar_HL - Start_Bar_HL );
                   }

              }
         }
         if ( SwingLow_HL != -1)
         {
              if (
                   Switch_HL[i-1] != -1 
                        AND SwingLow_HL <= (End_Val_HL * WavePcnt) )
              {
                   Start_Bar_HL = End_Bar_HL;
                   Start_Val_HL = End_Val_HL;
                   End_Bar_HL = i;
                   End_Val_HL = SwingLow_HL;

                   for( j = Start_Bar_HL; j <= End_Bar_HL; j++ )
                   {
                   ZigArray_HL[j] = Start_Val_HL 
                                     + (j - Start_Bar_HL)
                                       * (End_Val_HL - Start_Val_HL)
                                        / (End_Bar_HL - Start_Bar_HL );
                   }
                   Switch_HL = -1;
              }
              else
              if (Switch_HL[i-1] == -1 AND SwingLow_HL <= End_Val_HL)
              {
                   End_Bar_HL = i;
                   End_Val_HL = SwingLow_HL;

                   for( j = Start_Bar_HL; j <= End_Bar_HL; j++ )
                   {
                   ZigArray_HL[j] = Start_Val_HL 
                                     + (j - Start_Bar_HL)
                                       * (End_Val_HL - Start_Val_HL)
                                        / (End_Bar_HL - Start_Bar_HL );
                   }
              }
         }
    }

    return ZigArray_HL;
}


//==========================================================================


> -----Original Message-----
> From: aequalsz [mailto:aequalsz@xxxxxxxxx] 
> Sent: Friday, July 23, 2004 8:45 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Re: Reverse engineering eSignal ZigZag code
>
> Dave,
>
> O.K. but haven't really checked the code out thoroughly and will
> probably want to convert it to a .dll before too long.  And lastly, it
> bears a strong resemblance to several other codes floating around so
> hope I don't get too many people mad.
>
...snip... 




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/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/