Friday, October 11, 2024

AFL CODE-RRG

 _SECTION_BEGIN( "XY-Rotation Chart" );


_N( base = ParamStr( "Base", "VNINDEX" ) );

_N( list = ParamStr( "Symbols", "0500,1300,1700,2300,2700,3500,3700,5300,7500,8300,8500,8600,8780,9500" ) );

tbar = Param( "Trailing Bar", 12, 1, 100, 1 );


color1 = ParamColor("Màu 1:", colorRed);

color2 = ParamColor("Màu 2:", colorOrange);

color3 = ParamColor("Màu 3:", colorYellow);

color4 = ParamColor("Màu 4:", colorDarkGreen);

color5 = ParamColor("Màu 5:", colorBlue);

color6 = ParamColor("Màu 6:", colorCustom10);

color7 = ParamColor("Màu 7:", colorPlum);

color8 = ParamColor("Màu 8:", colorBrown);

color9 = ParamColor("Màu 9:", colorViolet);

color10 = ParamColor("Màu 10:", colorCustom12);

color11 = ParamColor("Màu 11:", colorlightblue);

color12 = ParamColor("Màu 12:", colorLime);

color13P = ParamColor("Màu 13+:", colorcycle);


list = Name()+","+list;


EnableTextOutput( False );

GfxSetOverlayMode( 2 );


pxl = Status( "pxchartleft" );

pxr = Status( "pxchartright" );

pxt = Status( "pxcharttop" );

pxb = Status( "pxchartbottom" );

pxw = ( pxr - pxl ) / 2;

pxh = ( pxb - pxt ) / 2;

xm = pxl + pxw;

ym = pxt + pxh;


GfxFillSolidRect(pxl,pxt, xm, ym, colorLightBlue ); 

GfxFillSolidRect(pxr,pxt, xm, ym, colorGreen ); 

GfxFillSolidRect(pxr,pxb, xm, ym, colorYellow ); 

GfxFillSolidRect(pxl,pxb, xm, ym, colorRed ); 

GfxSetTextColor( colorGreen ); 


GfxTextOut( "CAI THIEN", pxl +5, pxt +5);

GfxTextOut( "DAN DAT", pxr-70, pxt +5);

GfxTextOut( "SUY YEU", pxr-70, pxb-20);

GfxTextOut( "TUT HAU", pxl+5, pxb-20);


GfxMoveTo( pxl, ym ); 

GfxLineTo( pxr, ym );

GfxMoveTo( xm, pxt );

GfxLineTo( xm, pxb );


function getrs ( sc, t )

{

    bc = Foreign( base, "C" );

    sbr = sc / bc;


    rs1 = MA( sbr, 12 );

    rs2 = MA( sbr, 26 );

    rs = 100 * ( ( rs1 - rs2 ) / rs2 + 1 );


    rm1 = MA( rs, 1 );

    rm2 = MA( rs, 9 );

    rm = 100 * ( ( rm1 - rm2 ) / rm2 + 1 );


    return IIf( t, rs , rm ) - 100;

}


function drawpos ( x, y, sym, text, color )

{

    rsl = VarGet( "rsl" );

    rsh = VarGet( "rsh" );

    rml = VarGet( "rml" );

    rmh = VarGet( "rmh" );


    xx = pxl + pxw + x * ( pxw / ( Max( rsh, -rsl ) * 1.10 ) );

    yy = pxb - pxh - y * ( pxh / ( Max( rmh, -rml ) * 1.10 ) );


    xp = Nz( VarGet( "xp" + sym ), xx );

    yp = Nz( VarGet( "yp" + sym ), yy );


    VarSet( "xp" + sym, xx );

    VarSet( "yp" + sym, yy );


    GfxMoveTo( xp, yp );

    GfxLineTo( xx, yy );

    

    GfxSelectPen( color); 

    GfxSelectSolidBrush(color);  

    GfxSetTextColor( color); 


    GfxCircle( xx, yy, IIf( text == "", 2, 4 ) );

    

    check = StrMid( sym, 0, 1);

if (check == "0" OR check == "1" OR check == "2" OR check == "3" OR check == "4" OR check == "5" OR check == "6" OR check == "7" OR check == "8" OR check == "9")

sym = FullName();

else

sym = Name();


    if ( text != "" ) GfxTextOut( sym, xx + 6 , yy - 3 );

}



for ( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )

{

    SetForeign( sym );


    rs = getrs( C, 1 );

    rm = getrs( C, 0 );

    

       switch (i) {

case 0:

color = color1;

break;

case 1:

color = color2;

break;

case 2:

color = color3;

break;

case 3:

color = color4;

break;

case 4:

color = color5;

break;

case 5:

color = color6;

break;

case 6:

color = color7;

break;

case 7:

color = color8;

break;

case 8:

color = color9;

break;

case 9:

color = color10;

break;

case 10:

color = color11;

break;

case 11:

color = color12;

break;

default:

color = color13P;

break;

}


    for ( ii = BarCount - tbar; ii < BarCount; ii++ )

    {

        drawpos( rs[ ii ], rm[ ii ], sym, WriteIf( ii == BarCount - 1, sym, "" ), color );

    }


    RestorePriceArrays( True );


    for ( ii = BarCount - tbar; ii < BarCount; ii++ )

    {

        rs_ = rs[ ii ];

        rm_ = rm[ ii ];


        rsh = Nz( VarGet( "rsh" ), rs_ );

        if ( rs_ >= rsh )

            VarSet( "rsh", rs_ );


        rsl = Nz( VarGet( "rsl" ), rs_ );

        if ( rs_ <= rsl )

            VarSet( "rsl", rs_ );


        rmh = Nz( VarGet( "rmh" ), rm_ );

        if ( rm_ >= rmh )

            VarSet( "rmh", rm_ );


        rml = Nz( VarGet( "rml" ), rm_ );

        if ( rm_ <= rml )

            VarSet( "rml", rm_ );

    }


    RestorePriceArrays( True );

}

_SECTION_END();

👉Tải tại đây

https://drive.google.com/file/d/1BLP-ud7bTs2Zj4lsc6SszaFq6J08KVwS/view?usp=drive_link

Cách sử dụng AFL  cho Amibroker  

Tải xuống tệp Amibroker AFL. 

Bây giờ hãy sao chép tệp afl và dán vào vị trí cài Amibroker  

D:\A KY PC\Win\Amibroker\Formulas\VIP free


1 comment: