CHIA SẺ CODE AFL AMIBROKER CHƠI THEO XU HƯỚNG BIỂU ĐỒ RRG

_SECTION_BEGIN( "XY-Rotation Chart" );

_N( base = ParamStr( "Base", "VNINDEX" ) );
_N( list = ParamStr( "Symbols", "SSI,HCM,VND,APG,AGR,ART,BSI,BVS,CTS,FTS,MBS,SBS,SHS,TVB,TVS,VCI,VDS,VIX,ORS,AAS,APS,PHS,CSI,BMS" ) );
tbar = Param( "Trailing Bar", 12, 1, 100, 1 );

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( "Improving", 9, 19);
GfxTextOut( "Leading", 1739, 19);
GfxTextOut( "Weakening", 1719, 869);
GfxTextOut( "Lagging", 9, 869);

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 )
{
    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 );

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

    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 );

    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 );
}

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

    rs = getrs( C, 1 );
    rm = getrs( C, 0 );

    for ( ii = BarCount - tbar; ii < BarCount; ii++ )
    {
        drawpos( rs[ ii ], rm[ ii ], sym, WriteIf( ii == BarCount - 1, sym, "" ) );
    }

    RestorePriceArrays( True );
}

_SECTION_END();
// T?i xu?ng t? https://www.nguoilamvuon.net _SECTION_BEGIN ("Bi?u d? xoay XY"); _N (base = ParamStr ("Co s?", "IHSG")); _N (list = ParamStr ("Symbols", "IDXBASIC, IDXCYCLIC, IDXENERGY, IDXFINANCE, IDXHEALTH, IDXINDUST, IDXINFRA, IDXNONCYC, IDXPROPERT, IDXTECHNO, IDXTRANS"); tbar = Param ("Thanh Trailing", 12, 1, 100, 1); EnableTextOutput (Sai); GfxSetOverlayMode (2); pxl = Tr?ng thái ("pxchartleft"); pxr = Tr?ng thái ("pxchartright"); pxt = Tr?ng thái ("pxcharttop"); pxb = Tr?ng thái ("pxchartbottom"); pxw = (pxr - pxl) / 2; pxh = (pxb - pxt) / 2; xm = pxl + pxw; ym = pxt + pxh; GfxMoveTo (pxl, ym); GfxLineTo (pxr, ym); GfxMoveTo (xm, pxt); GfxLineTo (xm, pxb); hàm 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; } hàm drawpos (x, y, sym, text) { 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); GfxCircle (xx, yy, IIf (text == "", 2, 4)); 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); for (ii = BarCount - tbar; ii <BarCount; ii ++) { rs_ = rs [ii]; rm_ = rm [ii]; rsh = Nz (VarGet ("rsh"), rs_); n?u (rs_> = rsh) VarSet ("rsh", rs_); rsl = Nz (VarGet ("rsl"), rs_); n?u (rs_ <= rsl) VarSet ("rsl", rs_); rmh = Nz (VarGet ("rmh"), rm_); n?u (rm_> = rmh) VarSet ("rmh", rm_); rml = Nz (VarGet ("rml"), rm_); n?u (rm_ <= rml) VarSet ("rml", rm_); } RestorePriceArrays (Đúng); } for (i = 0; (sym = StrExtract (list, i))! = ""; i ++) { SetForeign (sym); rs = getrs (C, 1); rm = getrs (C, 0); for (ii = BarCount - tbar; ii <BarCount; ii ++) { drawpos (rs [ii], rm [ii], sym, WriteIf (ii == BarCount - 1, sym, "")); } RestorePriceArrays (Đúng); } _SECTION_END ();

Đăng ký và liên hệ

Hãy để lại thông tin liên hệ của bạn để nhận thông tin miễn phí từ chúng tôi !

Hotline : 097.925.0696 - 097.544.1818