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

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



PureBytes Links

Trading Reference Links

A few modifications. Easier to assign colors and arrays are plotted within loop.
Current symbol is included in sort.


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


/* Your smooth factor */
smooth_factor = 5;

/* Number of items to sort */
number_of_items = 6;

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

/* Substitute the samples with your own array values */
Perf_T1 = MA( C, 2 ); 
Perf_T2 = MA( C, 5 ); 
Perf_T3 = MA( C, 7 ); 
Perf_T4 = MA( C, 3 ); 
Perf_T5 = MA( C, 10 ); 
Perf_T6 = MA( C, 4 );


/* Assign colors */
VarSet( "Color1", colorBlue );
VarSet( "Color2", colorGreen );
VarSet( "Color3", colorBlack );
VarSet( "Color4", colorYellow );
VarSet( "Color5", colorGold );
VarSet( "Color6", colorRed );


/* Add corresponding industry names here */
StaticVarSetText("Name1", "Electrical Applicance");
StaticVarSetText("Name2", "Banks");
StaticVarSetText("Name3", "Real Estate");
StaticVarSetText("Name4", "Securities");
StaticVarSetText("Name5", "Marine");
StaticVarSetText("Name6", FullName());

for ( i = 1; i < number_of_items + 1; i++ )
{
        best_value = VarGet( "Perf_T" + i );
        best_name = StaticVarGetText( "Name" + i );
        best_color = VarGet( "Color" + i );
        best_j = i;

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

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


        /* Build title string */
        title_string = EncodeColor( best_color ) + " " + best_name + ":" + EncodeColor( colorBlack ) + WriteVal( best_value, 8.2 ) + "%\n" + title_string;

        /* Plot Arrays */
        Plot( best_value , best_name, best_color );
        
}

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





WP> 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/