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

Re: [amibroker] can AFL really do *anything*?



PureBytes Links

Trading Reference Links

Johsun has done a nice job. Since i'd already written the
code here is another version with a few variations.

Regards,
William Peters
http://www.amitools.com


/* Your smooth factor */
smooth_factor = 5;

/* Number of values to sort */
NumberOfValues = 6;

/* Initalize string variables */
title_string = "";
best_name = "";

/* Substitute and add your values as necessary */
Perf_T1 = 10;
Perf_T2 = 50;
Perf_T3 = 20;
Perf_T4 = 40;
Perf_T5 = 30;
Perf_T6 = 60;

/* Add corresponding industry names here, make sure the last one is ticker name */
StaticVarSetText("Name1", "Electrical Applicance");
StaticVarSetText("Name2", "Banks");
StaticVarSetText("Name3", "Real Estate");
StaticVarSetText("Name4", "Securities");
StaticVarSetText("Name5", "Marine");
StaticVarSetText("Name6", Name());

for ( i = 1; i < NumberOfValues + 1; i++ )
{
        best_value = VarGet( "Perf_T" + i );
        best_name = StaticVarGetText( "Name" + i );
        best_j = i;
        for ( j = i + 1; j < NumberOfValues; j++ )
        {
                if ( VarGet( "Perf_T" + j ) < best_value )
                {
                        best_value = VarGet( "Perf_T" + j );
                        best_name = StaticVarGetText( "Name" + j );
                        best_j = j;
                }
        }

        VarSet( "Perf_T" + best_j, VarGet( "Perf_T" + i ) );
        StaticVarSetText( "Name" + best_j, StaticVarGetText( "Name" + i ) );

        /* Auto coloring here */
        title_string = "\\c" + (i + 20) + best_name + ":" + WriteVal( best_value, 8.2 ) + "%\n" + title_string;
        
}

Title = "TSE Industry Performance Overview: Smooth-factor: " + smooth_factor + "\n" + title_string;





Sunday, October 2, 2005, 4:50:01 AM, you wrote:
YT>    I have shamelessly poached, and modified to suit, some code from the
YT>  AB site originally written by Thomas Zmuch.  Very nice code, sir.
YT>  This shows from any beginning point the relative performance of a
YT>  group of foreign symbols versus the currently selected symbol.

YT>  It now produces the chart attached, and I'd like to know if it's
YT>  possible to incorporate one other little trick here.

YT>  All the on-chart text is produced via the title statement below.  And
YT>  as I plan on adding a bunch of extra industry groups to this chart, I
YT>  want to run them all down the left side, as opposed to across the
YT>  top, as Thomas had originally set it up.  No problem there of course.

YT>  But can AFL do this: Can AFL order the industry group indices written
YT>  on the left side of the chart via the title statement according to
YT>  their values (as happens automatically in the right margin with the
YT>  values themselves)?  That would be one heck of a neat thing if I
YT>  could do that.

YT>  Yuki

YT>  Title statement section from chart: (chart attached, and as you can
YT>  see, we've been having a bit of a party over here in the past 8 weeks
YT>  or so -- these are not even the best performers you see on the chart,
YT>  others are in the 60 percentile range)

YT>  Title= "TSE Industry Performance Overview: Smooth-Factor: "+WriteVal(pds,1.0)+"\n"
YT>  +EncodeColor(colorBlue)+"Electrical Appliances
YT> "+EncodeColor(colorBlack)+WriteVal(Perf_T1,1.2)+" %"+"\n"
YT>  +EncodeColor(colorDarkGreen)+"Banks
YT> "+EncodeColor(colorBlack)+WriteVal(Perf_T2,1.2)+" %  "+"\n"
YT>  +EncodeColor(colorBlack)+"Real Estate
YT> "+WriteVal(Perf_T3,1.2)+" % "+"\n"
YT>  +EncodeColor(colorYellow)+"Securities
YT> "+EncodeColor(colorBlack)+WriteVal(Perf_T4,1.2)+" %"+"\n"
YT>  +EncodeColor(colorGold)+"Marine Trans
YT> "+EncodeColor(colorBlack)+WriteVal(Perf_T5,1.2)+" %"+"\n"
YT>  +EncodeColor(colorRed)+FullName()+"
YT> "+EncodeColor(colorBlack)+WriteVal(Perf_T6,1.2)+" %";


  


    
  




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.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/