Code cho amibroker Miễn phí

Discussion in 'Thị trường chứng khoán' started by cp2011, Jun 7, 2021.

7069 người đang online, trong đó có 74 thành viên. 06:41 (UTC+07:00) Bangkok, Hanoi, Jakarta
  1. 1 người đang xem box này(Thành viên: 0, Khách: 1)
thread_has_x_view_and_y_reply
  1. no1no2no3

    no1no2no3 Thành viên gắn bó với f319.com

    Joined:
    Apr 22, 2009
    Likes Received:
    1,390
    Bạn nói đúng lắm, nhưng cũng nên xem code đó viết như thế nào
    4season likes this.
  2. MrPeace1982

    MrPeace1982 Thành viên rất tích cực

    Joined:
    Jun 9, 2016
    Likes Received:
    209
    Anh em làm cách nào tạo thêm 1 chart volume VNIndex vào chung sheet chart volume và giá DIG ko. Giúp mình với.

    [​IMG] [​IMG]
  3. cp2011

    cp2011 Thành viên gắn bó với f319.com

    Joined:
    Apr 12, 2010
    Likes Received:
    1,822
    Cái này do Google Chrome nó không hỗ trợ Flash từ 2021 nên không úp ảnh lên F319 này như trước đây bạn ah. Nếu bạn biết cách nào để khắc phục lỗi này thì chỉ giúp mình. mình đang cần đến đó.
    --- Gộp bài viết, Aug 1, 2021, Bài cũ: Aug 1, 2021 ---
    Bạn mở Code nào đó ra rồi thêm phần Volume vào trong đó là được mà. không cần dùng đến chart Volume riêng như kia...
    Tặng các bạn 1 Code mình đang dùng...
    //-------------------------------- Fibnacci Inter & Exter Retracements_14-180_31.0.2021 PS-------------------------------------

    #pragma nocache
    #include_once
    //#include_once "C:\Program Files (x86)\AmiBroker\Formulas\PatternExplorer\#Defaults & Mods\PE - Defaults.afl"
    //#include_once "C:\Program Files (x86)\AmiBroker\Formulas\PatternExplorer\#Defaults & Mods\PE - Mods.afl"
    #include_once "C:\Program Files\AmiBroker\Formulas\PatternExplorer\#Defaults & Mods\PE - Defaults.afl"
    #include_once "C:\Program Files\AmiBroker\Formulas\PatternExplorer\#Defaults & Mods\PE - Mods.afl"
    GraphZOrder = 0;

    //-------------- Start Ve Chart ---------------
    Vert = Param("Vertical Chart Zoom", 15, - 15, 50, 1);//Co gian Chart theo chieu doc (Vertical)
    GraphXSpace = Vert;
    SetChartOptions(0,chartShowDates);// 0= Dat Date duoi Chart
    Plot(C, "", IIf(O>=C, colorCustom16, colorCustom6), ParamStyle("Price Style",styleLine+styleDots+styleThick+styleCandle,maskPrice)); // Chart = Candlde.
    //-------------- End Ve Chart ---------------


    _SECTION_BEGIN( "Volume" );

    PlotVolume = ParamToggle( "Plot Volume", "Off|On", 0 );
    Type = ParamList( "Color Mode", "Simple,Standard,Extended", def_VolumeType );
    UpColor = ParamColor( "Up Color", def_VolumeUpColor );
    DnColor = ParamColor( "Down Color", def_VolumeDnColor );
    NeutralColor = ParamColor( "Neutral Color", def_VolumeNeutralColor );
    style = ParamStyle( "Style", styleHistogram | styleOwnScale | styleNoTitle | styleNoLabel, maskHistogram );
    VolumeHeight = 7.1 - Param( "Volume Height", 0.1, 0, 7.1, 0.1 );

    /*******************************************************************************************/
    if ( Type == "Simple" AND PlotVolume )
    Plot( Volume, _DEFAULT_NAME(), NeutralColor, style, VolumeHeight );

    /*******************************************************************************************/
    if ( Type == "Standard" AND PlotVolume )
    Plot( Volume, _DEFAULT_NAME(), IIf( C > O, UpColor, DnColor ), style, VolumeHeight );

    /*******************************************************************************************/
    if ( Type == "Extended" AND PlotVolume )
    Plot( Volume, _DEFAULT_NAME(), IIf( C > Ref( C, -1 ) AND V > Ref( V, -1 ), UpColor, IIf( C Ref( V, -1 ), DnColor, NeutralColor ) ), style, VolumeHeight );

    _SECTION_END();


    //////////////////////////////////////////////////////////////////
    _SECTION_BEGIN("Fib Retracements");
    fibs = ParamToggle("Plot Fibs","Off|On",0);
    text = ParamToggle("Plot Text","Off|On",0);
    pctH = Param ("Pivot Hi %", 0.325,0.001,2.0,0.002);
    HiLB = Param ("Hi LookBack",1,1,BarCount-1,1);
    pctL = Param ("Pivot Lo %", 0.325,0.001,2.0,0.002);
    LoLB = Param ("Lo LookBack",1,1,BarCount-1,1);
    Back = Param ("Extend Left = 2",1,1,500,1);
    Fwd = Param("Plot Forward", 0, 0, 500, 1);
    hts = Param ("Text Shift", -33.5,-50,50,0.10);
    style =ParamStyle("Line Style",styleLine,styleNoLabel|styleNoTitle);
    x = BarIndex();
    pRp = PeakBars( H, pctH, 1) == 0;
    yRp0 = SelectedValue(ValueWhen( pRp, H, HiLB));
    xRp0 = SelectedValue(ValueWhen( pRp, x, HiLB));
    pSp = TroughBars( L, pctL, 1) == 0;
    ySp0 = SelectedValue(ValueWhen( pSp, L, LoLB));
    xSp0 = SelectedValue(ValueWhen( pSp, x, LoLB));
    Delta = yRp0 - ySp0;

    function fib(ret)
    {
    retval = (Delta * ret);
    Fibval = IIf(ret xRp0, ySp0 + retval,IIf(ret > 1.0
    AND xSp0 1.0
    AND xSp0 > xRp0, ySp0 + retval, Null))));
    return FibVal;
    }

    x0 = Min(xSp0,xRp0)-Back;
    x1 = (BarCount -1);
    //////////////////////////////////////////////////////////////////
    r236 = fib(0.236); r236I = LastValue (r236,1);
    r382 = fib(0.382); r382I = LastValue (r382,1);
    r050 = fib(0.50); r050I = LastValue (r050,1);
    r618 = fib(0.618); r618I = LastValue (r618,1);
    r786 = fib(0.786); r786I = LastValue (r786,1);
    e127 = fib(1.27); e127I = LastValue (e127,1);
    e162 = fib(1.62); e162I = LastValue (e162,1);
    e200 = fib(2.00); e200I = LastValue (e200,1);
    e262 = fib(2.62); e262I = LastValue (e262,1);
    e424 = fib(4.24); e424I = LastValue (e424,1);
    //////////////////////////////////////////////////////////////////
    p00 = IIf(xSp0 > xRp0,ySp0,yRp0); p00I = LastValue (p00,1);
    p100 = IIf(xSp0 xRp0,colorLime,colorRed);
    color100 =IIf(xSp0 Ref(C,-1),EncodeColor(colorCustom6),EncodeColor(colorRed))+ WriteVal( Open, 1.2 ) +" ("+WriteVal(Open- Ref(C,-1) ,1.2)+")"
    +EncodeColor(colorWhite) + "_High : " +WriteIf(H>Ref(C,-1),EncodeColor(colorCustom6),EncodeColor(colorRed))+ WriteVal( H , 1.2 ) +" ("+WriteVal(High- Ref(C,-1) ,1.2)+")"
    +EncodeColor(colorWhite) + "_Low : " +WriteIf(L>Ref(C,-1),EncodeColor(colorCustom6),EncodeColor(colorRed))+ WriteVal( L, 1.2 ) +" ("+WriteVal(Low- Ref(C,-1) ,1.2)+")"
    +EncodeColor(colorWhite) + "_Close : " +WriteIf(C>Ref(C,-1),EncodeColor(colorCustom6),EncodeColor(colorRed))+ WriteVal( C, 1.2 ) +" ("+WriteVal(C- Ref(C,-1) ,1.2)+")"
    +EncodeColor(colorWhite) + "_Vol : " +WriteIf(V>Ref(V,-1),EncodeColor(colorCustom6),EncodeColor(colorRed))+ WriteVal( V, 1.0 )+" ("+WriteVal(V- Ref(V,-1) ,1.0)+")"
    +"\n" +"**" + "{{VALUES}}" ;
    }
    //-------------------------------- Title 26.03.2020 PS-------------------------------------

    range = Param("Periods", 7, 2, 200, 1 );
    Bull_Trend=(Trix(range) >= Ref(Trix(range),-1)); //(Trix(range) >= Ref(Trix(range),-1)) AND (Ref(Trix(range),-1) >= Ref(Trix(range),-2));
    Bear_Trend=(Trix(range-1) = Ref(Trix(range),-1)); //(Trix(range) >= Ref(Trix(range),-1)) AND (Ref(Trix(range),-1) >= Ref(Trix(range),-2));
    Bear_Trend=(Trix(range-1) x1;
    dn = Cross(L1, L)AND Cum(1) > x1;
    //------End Ve duong Line Kháng cu/Ho Tro-----
    }

    //--------------- Ve Thanh Bar Báo TOP/BOTTOM ---------------

    _SECTION_BEGIN("Trendlines Multitimeframe");// Ve Thanh bar ÐINH/ÐÁY

    Version(5.21);
    xx=BarIndex();x=xx;Lx=LastValue(x);
    nbar=Param("N Pivot Bars",14,2,50,1);
    tf=Param("Time Frame (min)",180,1,100000,1);tfrm=in1Minute*tf;// Ve so thanh bar tai vi tri TOP/Bottom
    CleanPivots=ParamToggle("Use Clean Pivots","On|Off",0);
    PivotSymmetry=ParamToggle("Use Symmetric Pivots","On|Off",1);

    TimeFrameSet(tfrm);
    if (PivotSymmetry)
    {
    fc=1;
    pk=H>Ref(HHV(H,nbar*fc),-1) AND Ref(HHV(H,nbar),nbar)=L;
    }
    else
    {
    fc=2;
    pk=H>Ref(HHV(H,nbar*fc),-1) AND Ref(HHV(H,nbar),nbar)=L;
    }
    px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
    px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
    px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
    ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
    ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
    ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);
    if (CleanPivots)
    {
    tr=IIf(pk AND tr AND ph1>ph2 AND tl1>tl2,False,tr);
    pk=IIf(pk AND tr AND ph1ph1,False,tr);
    pk=IIf(pk AND px0ph1,False,pk);
    tr=IIf(tr AND px0>tx0 AND tl0tx1 AND ph1px1 AND tl1>=tl2,False,tr);
    pk=IIf(pk AND px0>px1 AND px1>tx1 AND px1>tx0 AND ph0>ph1,False,pk);
    tr=IIf(tr AND tx0>tx1 AND tx1>px1 AND tx1>px0 AND tl0tx1 AND ph1px1 AND tl1>ph1,False,tr);
    pk=IIf(pk AND px0ph1,False,pk);
    tr=IIf(tr AND px0>tx0 AND tl0tx1 AND ph1px1 AND tl1>=tl2,False,tr);
    pk=IIf(pk AND px0>px1 AND px1>tx1 AND px1>tx0 AND ph0>ph1,False,pk);
    tr=IIf(tr AND tx0>tx1 AND tx1>px1 AND tx1>px0 AND tl0tx1 AND px2>tx1 AND ph1px1 AND tx2>px1 AND tl1>tl2,False,tr);
    }
    pkh=IIf(pk,H,Null);
    trl=IIf(tr,L,Null);
    TimeFrameRestore();
    fact=Max(tfrm/60,Interval()/60)/(Interval()/60);
    Lkbk=tfrm/Interval();

    if(Lkbk>1)
    {
    pk=TimeFrameExpand(pk,tfrm,expandFirst);
    pkh=TimeFrameExpand(pkh,tfrm,expandFirst);
    pkhs=IIf(!IsEmpty(pkh),1,0);pkhs=pkhs-Ref(pkhs,-1);
    pk=pk AND H==pkh;
    cond1=Sum(pk,BarsSince(pkhs==1)+1)==1 AND pk;
    pk=pk AND cond1;

    tr=TimeFrameExpand(tr,tfrm,expandFirst);
    trl=TimeFrameExpand(trl,tfrm,expandFirst);
    trls=IIf(!IsEmpty(trl),1,0);trls=trls-Ref(trls,-1);
    tr=tr AND L==trl;
    cond1=Sum(tr,BarsSince(trls==1)+1)==1 AND tr;
    tr=tr AND cond1;

    px0=ValueWhen(pk,x,0); tx0=ValueWhen(tr,x,0);
    px1=ValueWhen(pk,x,1); tx1=ValueWhen(tr,x,1);
    px2=ValueWhen(pk,x,2); tx2=ValueWhen(tr,x,2);
    ph0=ValueWhen(pk,H,0); tl0=ValueWhen(tr,L,0);
    ph1=ValueWhen(pk,H,1); tl1=ValueWhen(tr,L,1);
    ph2=ValueWhen(pk,H,2); tl2=ValueWhen(tr,L,2);
    }

    y0=ValueWhen(tr,trl,0);
    y1=ValueWhen(tr,trl,1);
    y2=ValueWhen(tr,trl,2);
    y3=ValueWhen(tr,trl,3);
    x0=ValueWhen(tr,xx,0);
    x1=ValueWhen(tr,xx,1);
    x2=ValueWhen(tr,xx,2);
    x3=ValueWhen(tr,xx,3);
    aa=(Y0-Y1)/(X0-X1);
    ls1=aa*(xx-X1)+Y1;
    dls1=ls1-Ref(ls1,-1);
    aa=(Y1-Y2)/(X1-X2);
    ls2=aa*(xx-X1)+Y1;
    dls2=ls2-Ref(ls2,-1);
    dls2=IIf(tr,Ref(dls1,-1),dls2);
    aa=(Y2-Y3)/(X2-X3);
    ls3=aa*(xx-X2)+Y2;
    dls3=ls3-Ref(ls3,-1);
    dls3=IIf(tr,Ref(dls2,-1),dls3);
    y0=ValueWhen(pk,pkh,0);
    y1=ValueWhen(pk,pkh,1);
    y2=ValueWhen(pk,pkh,2);
    y3=ValueWhen(pk,pkh,3);
    x0=ValueWhen(pk,xx,0);
    x1=ValueWhen(pk,xx,1);
    x2=ValueWhen(pk,xx,2);
    x3=ValueWhen(pk,xx,3);
    aa=(Y0-Y1)/(X0-X1);
    hs1=aa*(xx-X1)+Y1;
    dhs1=hs1-Ref(hs1,-1);
    aa=(Y1-Y2)/(X1-X2);
    hs2=aa*(xx-X1)+Y1;
    dhs2=hs2-Ref(hs2,-1);
    dhs2=IIf(pk,Ref(dhs1,-1),dhs2);
    aa=(Y2-Y3)/(X2-X3);
    hs3=aa*(xx-X2)+Y2;
    dhs3=hs3-Ref(hs3,-1);
    dhs3=IIf(pk,Ref(dhs2,-1),dhs3);

    _SECTION_BEGIN("Multi_nBar");

    fse=Param("Font Size",12,11,100,1);
    GfxSelectFont("Times New Roman", fse, 700,False );
    GfxSetBkMode( colorGold );

    GfxSetTextColor( ParamColor("Color",colorGold) );
    Hora1=Param("n(bar)Horizontal",2,1,1200,1);
    Vera1=Param("n(bar)Vertical",97,1,830,1);
    //GfxTextOut("Bar :"+nbar, Hora1 , Vera1 );
    //---------ON-OFF bien Bar----------
    Barr = ParamToggle( "Barr", "Show|Hide", 1 );
    if (Barr == 1 )
    {
    GfxTextOut("Bar :"+nbar, Hora1 , Vera1 );
    }
    //---------ON-OFF bien Bar----------
    _SECTION_END();
    //=====
    _SECTION_BEGIN("Multi_TFR(min)");
    fse=Param("Font Size",12,11,100,1);
    GfxSelectFont("Times New Roman", fse, 700,False );
    GfxSetBkMode( colorGold );

    GfxSetTextColor( ParamColor("Color",colorGold) );
    Hora2=Param("TimeFR Horizontal",2,1,1200,1);
    Vera2=Param("TimeFR Vertical",115,1,830,1);
    //GfxTextOut("Min:"+tf, Hora2 , Vera2 );
    //---------ON-OFF bien Time----------
    Minut = ParamToggle( "Min:", "Show|Hide", 0 );
    if (Minut == 1 )
    {
    GfxTextOut("Min:"+tf, Hora2 , Vera2 );
    }
    //---------ON-OFF bien Time----------
    _SECTION_END();

    _SECTION_END();

    //--------------- Start Ve thanh Bar báo ÐINH/ÐÁY (TOP/Bottom) ---------------
    DinhDay = ParamToggle( "Dinh Day", "Show|Hide", 1 );
    if ( DinhDay == 1 )
    {
    _SECTION_BEGIN("Dinh Day");

    Plot(pkh,"",colorCustom11,styleThick,0,0,0,-1); // Ve thanh Bar mau Non Chuoi bao ÐINH (TOP)
    Plot(trl,"",colorCustom12,styleThick,0,0,0,-1); // Ve thanh Bar mau Tím bao ÐÁY (Bottom )
    PlotShapes(shapeSmallCircle*pk,IIf(Lx-ValueWhen(pk,x)>nbar*fact,colorCustom11,colorWhite),0,H,10); // Ve Cham tròn trên Ðinh màu Non Chuoi bao TOP
    PlotShapes(shapeSmallCircle*tr,IIf(Lx-ValueWhen(tr,x)>nbar*fact,colorCustom12,colorWhite),0,L,-10); // Ve Cham tròn duoi Ðay màu Tím bao Bottom
    PlotShapes(shapeHollowCircle*pk,colorCustom12,0,H,10);// Ve vòng tròn trên Ðinh
    PlotShapes(shapeHollowCircle*tr,colorCustom7,0,L,-10);// Ve vòng tròn Duoi ÐÁY

    _SECTION_END();
    }
    //--------------- End Ve thanh Bar báo ÐINH/ÐÁY (TOP/Bottom) ---------------

    //--------------- Start Viet gia tri HH,HL,LL,... ---------------
    _SECTION_BEGIN("Label");
    disp=ParamToggle("Display labels","Off|On",1);

    dxhm=Param("Shift X Highs (Margin)",14,-100,100,1);
    dxlm=Param("Shift X Lows (Margin)",10,-100,100,1);
    dxh=Param("Shift X Highs",0,-100,100,1);
    dxl=Param("Shift X Lows",0,-100,100,1);
    dyhm=Param("Shift Y Highs (Margin)",5,-100,100,1);
    dylm=Param("Shift Y Lows (Margin)",3,-100,100,1);
    dyh=Param("Shift Y Highs",18,-100,100,1);
    dyl=Param("Shift Y Lows",29,-100,100,1);
    hm=Param("Marging High",30,-100,100,1);
    lm=Param("Margin Low",30,-100,100,1);

    function GetVisibleBarCount()
    {
    lvb=Status("lastvisiblebar");
    fvb=Status("firstvisiblebar");
    return Min(lvb-fvb,BarCount-fvb);
    }
    function GfxConvertPixelsToBarX(Pixels)
    {
    lvb=Status("lastvisiblebar");
    fvb=Status("firstvisiblebar");
    pxchartleft=Status("pxchartleft");
    pxchartwidth=Status("pxchartwidth");
    fac=pxchartwidth/Pixels;
    bar=(lvb-fvb)/fac;
    return bar;
    }
    function GfxConvertPixelToValueY(Pixels)
    {
    local Miny,Maxy,pxchartbottom,pxchartheight;
    Miny=Status("axisminy");
    Maxy=Status("axismaxy");
    pxchartbottom=Status("pxchartbottom");
    pxchartheight=Status("pxchartheight");
    fac=pxchartheight/Pixels;
    Value=(Maxy-Miny)/fac;
    return Value;
    }

    if(disp)
    {
    ll=tr AND tl1tl2;

    hh=pk AND ph1>ph2;
    lh=pk AND ph1LowMargin) PlotText("LL",i+fvb+dxll,L[i+fvb]-dyll,colorWhite,colorBlack);
    if(ll[i+fvb] AND L[i+fvb]LowMargin) PlotText("HL",i+fvb+dxll,L[i+fvb]-dyll,colorWhite,colorBlack);
    if(hl[i+fvb] AND L[i+fvb]LowMargin) PlotText("DB",i+fvb+dxll,L[i+fvb]-dyll,colorWhite,colorBlack);
    if(db[i+fvb] AND L[i+fvb]=HighMargin) PlotText("HH",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorWhite,colorBlack);
    if(lh[i+fvb] AND H[i+fvb]=HighMargin) PlotText("LH",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorWhite,colorBlack);
    if(dt[i+fvb] AND H[i+fvb]=HighMargin) PlotText("DT",i+fvb+dxhh+dxhhm,H[i+fvb]+dyhhm,colorWhite,colorBlack);
    }
    }

    _SECTION_END();
    //--------------- End Viet gia tri HH,HL,LL,... ---------------

    //----------------- Ve 2 duong trend dao dong bao chu ky SÓNG tren chart ----------------------------------
    _SECTION_BEGIN("Sin Lines");
    SinLine = ParamToggle( "SinLine", "Show|Hide", 0 );
    if ( SinLine == 1 )
    {

    p1 = Param("TL 1 Periods", 20, 5, 50, 1);
    p2 = Param("TL 2 Periods", 5, 3, 25, 1);
    TL1 = LinearReg(C, p1);
    TL2 = EMA(TL1, p2);
    Col1 = IIf(TL1 > TL2, ParamColor("TL Up Colour", colorCustom12), ParamColor("TL Dn Colour", colorCustom11));

    Plot(Prec(TL1,3),"\n" + "Line 1", Col1, styleLine|styleNoLabel);
    Plot(Prec(TL2,3),"\n" + "Line 2", Col1, styleLine|styleNoLabel);
    }
    _SECTION_END();
    //-----------------End Ve 2 duong trend dao dong bao chu ky SÓNG tren chart ----------------------------------

    // --------------- EMA có Prec Chuan 31.05.21------------------
    _SECTION_BEGIN("EMA Prec");
    //---------------Bat Dau EMA 50,58.65,200----------------------
    EMAPrec = ParamToggle( "EMA Prec", "Show|Hide", 0 );
    if ( EMAPrec == 1 )
    {
    _SECTION_BEGIN("EMA20");
    EMA20 = ParamToggle( "EMA20", "Show|Hide", 0 );
    if ( EMA20 == 1 )
    {
    P = ParamField("Price field",3);
    Periods = Param("Periods", 20, 2, 100, 1 );
    Plot(Prec(EMA( P, Periods ),3),_DEFAULT_NAME(), ParamColor( "Color", colorOrange), ParamStyle("Style", styleLine ) | styleNoRescale );
    }
    _SECTION_END();

    _SECTION_BEGIN("EMA50");
    EMA50 = ParamToggle( "EMA50", "Show|Hide", 1 );
    if ( EMA50 == 1 )
    {
    P = ParamField("Price field",3);
    Periods = Param("Periods", 50, 2, 200, 1 );
    Plot(Prec(EMA( P, Periods ),3), _DEFAULT_NAME(), ParamColor( "Color", colorCustom7 ), ParamStyle("Style", styleLine | styleThick) | styleNoRescale );
    }
    _SECTION_END();

    _SECTION_BEGIN("EMA58");
    EMA58 = ParamToggle( "EMA58", "Show|Hide", 1 );
    if ( EMA58 == 1 )
    {
    P = ParamField("Price field",3);
    Periods = Param("Periods", 58, 2, 300, 1 );
    Plot(Prec(EMA( P, Periods ),3), _DEFAULT_NAME(), ParamColor( "Color", colorCustom11), ParamStyle("Style", styleLine | styleThick)| styleNoRescale );
    }
    _SECTION_END();

    _SECTION_BEGIN("EMA65");
    EMA65 = ParamToggle( "EMA65", "Show|Hide", 1 );
    if ( EMA65 == 1 )
    {
    P = ParamField("Price field",3);
    Periods = Param("Periods", 65, 2, 400, 1 );
    Plot(Prec(EMA( P, Periods ),3), _DEFAULT_NAME(), ParamColor( "Color", colorCustom12), ParamStyle("Style", styleLine | styleThick)| styleNoRescale );
    }
    _SECTION_END();

    _SECTION_BEGIN("EMA200");
    EMA200 = ParamToggle( "EMA200", "Show|Hide", 1 );
    if ( EMA200 == 1 )
    {
    P = ParamField("Price field",3);
    Periods = Param("Periods", 200, 2, 500, 1 );
    Plot(Prec(EMA( P, Periods ),3), _DEFAULT_NAME(), ParamColor( "Color", colorPink), ParamStyle("Style", styleLine | styleThick | styleNoTitle)| styleNoRescale );
    }
    _SECTION_END();
    //---------------End EMA 50,58,65,200--------------------------

    //---------------Start EMA 20_50,20_65, 50_65) Cross-----------
    UP1=Cross(EMA(C,20),EMA(C,50)); // MA20 Cat len 50 = UPTrend.
    DOWN1=Cross(EMA(C,50),EMA(C,20)); // MA20 Cat Xuong 50 = DOWNTrend.

    UP2=Cross(EMA(C,20),EMA(C,65)); // MA20 Cat len 65 = UPTrend.
    DOWN2=Cross(EMA(C,65),EMA(C,50)); // MA20 Cat Xuong 65 = DOWNTrend.

    UP3=Cross(EMA(C,50),EMA(C,65)); // MA50 Cat len 65 = UPTrend.
    DOWN3=Cross(EMA(C,65),EMA(C,50)); // MA50 Cat Xuong 65 = DOWNTrend.

    UP4=Cross(EMA(C,100),EMA(C,200)); // MA100 Cat len 200 = UPTrend.
    DOWN4=Cross(EMA(C,200),EMA(C,100)); // MA200 Cat Xuong 100 = DOWNTrend.

    PlotShapes( shapeUpArrow * up1 ,7,0,EMA(C,50)); //Ve Mui ten khi MA20 Cat len MA50. (Yellow=7 =Vàng =Có tín hieu)
    PlotShapes( shapeDownArrow *DOWN1 ,7,0,EMA(C,50)); //Ve Mui ten khi MA20 Cat Xuong MA50. (Yellow=7 =Vàng =Có tín hieu)

    PlotShapes( shapeUpArrow * up2 ,5,0,EMA(C,65)); //Ve Mui ten khi MA20 Cat len MA65. (5=Custom6 =XanhL=Tín hieu Tang)
    PlotShapes( shapeDownArrow *DOWN2 ,4,0,EMA(C,65)); //Ve Mui ten khi MA20 Cat Xuong MA65. (4=Red =Ðo =Tín hieu Giam)

    PlotShapes( shapeUpArrow * up3 ,11,0,EMA(C,65)); //Ve Mui ten khi MA20 Cat len MA65. (11=Custom11=Tím =Xác nhan TANG)
    PlotShapes( shapeDownArrow *DOWN3 ,10,0,EMA(C,65)); //Ve Mui ten khi MA20 Cat Xuong MA65. (10=Custom10=Aqua =Xác nhan GIAM)

    PlotShapes( shapeUpArrow * up4 ,12,0,EMA(C,200)); //Ve Mui ten khi MA100 Cat len MA200. (12=Custom??=... =Xác nhan TANG Dai han)
    PlotShapes( shapeDownArrow *DOWN4 ,13,0,EMA(C,200));//Ve Mui ten khi MA200 Cat Xuong MA100. (13=Custom??=... =Xác nhan GIAM Dai han)

    }
    //---------------End EMA 20_50,20_65, 50_65) Cross-------------
    // --------------End EMA có Prec Chuan 31.05.21----------------

    // --------------- EMA có Prec Chuan 31.05.21------------------
    _SECTION_BEGIN("EMA5 Prec");
    //---------------Bat Dau MA5,13,17,20,50,100-----------------
    EMAPrec = ParamToggle( "EMA Prec", "Show|Hide", 1 );
    if ( EMAPrec == 1 )
    {
    _SECTION_BEGIN("EMA5");
    EMA5 = ParamToggle( "EMA5", "Show|Hide", 1 );
    if ( EMA5 == 1 )
    {
    P = ParamField("Price field",3);
    Periods = Param("Periods", 5, 2, 100, 1 );
    Plot(Prec(EMA( P, Periods ),3),_DEFAULT_NAME(), ParamColor( "Color", colorYellow), ParamStyle("Style", styleLine ) | styleNoRescale );
    }
    _SECTION_END();

    _SECTION_BEGIN("EMA13");
    EMA13 = ParamToggle( "EMA13", "Show|Hide", 1 );
    if ( EMA13 == 1 )
    {
    P = ParamField("Price field",3);
    Periods = Param("Periods", 13, 2, 200, 1 );
    Plot(Prec(EMA( P, Periods ),3), _DEFAULT_NAME(), ParamColor( "Color", colorCustom7 ), ParamStyle("Style", styleLine | styleThick) | styleNoRescale );
    }
    _SECTION_END();

    _SECTION_BEGIN("EMA17");
    EMA17 = ParamToggle( "EMA17", "Show|Hide", 1 );
    if ( EMA17 == 1 )
    {
    P = ParamField("Price field",3);
    Periods = Param("Periods", 17, 2, 300, 1 );
    Plot(Prec(EMA( P, Periods ),3), _DEFAULT_NAME(), ParamColor( "Color", colorCustom11), ParamStyle("Style", styleLine | styleThick)| styleNoRescale );
    }
    _SECTION_END();

    _SECTION_BEGIN("EMA20");
    EMA20 = ParamToggle( "EMA20", "Show|Hide", 1 );
    if ( EMA20 == 1 )
    {
    P = ParamField("Price field",3);
    Periods = Param("Periods", 20, 2, 400, 1 );
    Plot(Prec(EMA( P, Periods ),3), _DEFAULT_NAME(), ParamColor( "Color", colorCustom12), ParamStyle("Style", styleLine | styleThick)| styleNoRescale );
    }
    _SECTION_END();

    _SECTION_BEGIN("EMA100");
    EMA100 = ParamToggle( "EMA100", "Show|Hide", 1 );
    if ( EMA100 == 1 )
    {
    P = ParamField("Price field",3);
    Periods = Param("Periods", 100, 2, 500, 1 );
    Plot(Prec(EMA( P, Periods ),3), _DEFAULT_NAME(), ParamColor( "Color", colorBrown), ParamStyle("Style", styleLine | styleThick | styleNoTitle)| styleNoRescale );
    }
    _SECTION_END();

    _SECTION_BEGIN("EMA200");
    EMA200 = ParamToggle( "EMA200", "Show|Hide", 1 );
    if ( EMA200 == 1 )
    {
    P = ParamField("Price field",3);
    Periods = Param("Periods", 200, 2, 500, 1 );
    Plot(Prec(EMA( P, Periods ),3), _DEFAULT_NAME(), ParamColor( "Color", colorPink), ParamStyle("Style", styleLine | styleThick | styleNoTitle)| styleNoRescale );
    }
    _SECTION_END();

    //---------------End EMA5,13,17,20,100 ------------------------

    //---------------Start EMA 5_13, 5_17, 17_20 Cross-------------
    UP1=Cross(EMA(C,5),EMA(C,13)); // MA5 Cat len 13 = UPTrend.
    DOWN1=Cross(EMA(C,13),EMA(C,5)); // MA5 Cat Xuong 13 = DOWNTrend.

    UP2=Cross(EMA(C,5),EMA(C,17)); // MA5 Cat len 17 = UPTrend.
    DOWN2=Cross(EMA(C,17),EMA(C,5)); // MA5 Cat Xuong 17 = DOWNTrend.

    UP3=Cross(EMA(C,17),EMA(C,20)); // MA17 Cat len 20 = UPTrend.
    DOWN3=Cross(EMA(C,20),EMA(C,17)); // MA17 Cat Xuong 20 = DOWNTrend.

    UP4=Cross(EMA(C,100),EMA(C,200)); // MA100 Cat len 200 = UPTrend.
    DOWN4=Cross(EMA(C,200),EMA(C,100)); // MA200 Cat Xuong 100 = DOWNTrend.

    PlotShapes( shapeUpArrow * up1 ,7,0,MA(C,13)); //Ve Mui ten khi MA5 Cat len MA13. (Yellow=7 =Vàng =Có tín hieu)
    PlotShapes( shapeDownArrow *DOWN1 ,7,0,MA(C,13)); //Ve Mui ten khi MA5 Cat Xuong MA13. (Yellow=7 =Vàng =Có tín hieu)

    PlotShapes( shapeUpArrow * up2 ,5,0,MA(C,20)); //Ve Mui ten khi MA5 Cat len MA17. (5=Custom6 =XanhL=Tín hieu Tang)
    PlotShapes( shapeDownArrow *DOWN2 ,4,0,MA(C,20)); //Ve Mui ten khi MA5 Cat Xuong MA17. (4=Red =Ðo =Tín hieu Giam)

    PlotShapes( shapeUpArrow * up3 ,11,0,MA(C,20)); //Ve Mui ten khi MA17 Cat len MA20. (11=Custom12=Tím =Xác nhan TANG)
    PlotShapes( shapeDownArrow *DOWN3 ,10,0,MA(C,20)); //Ve Mui ten khi MA17 Cat Xuong MA20. (10=Custom11=Aqua =Xác nhan GIAM)

    PlotShapes( shapeUpArrow * up4 ,12,0,EMA(C,200)); //Ve Mui ten khi MA100 Cat len MA200. (12=Custom??=... =Xác nhan TANG Dai han)
    PlotShapes( shapeDownArrow *DOWN4 ,13,0,EMA(C,200));//Ve Mui ten khi MA200 Cat Xuong MA100. (13=Custom??=... =Xác nhan GIAM Dai han)

    }
    //---------------End EMA 5_13, 5_17, 17_20 Cross-------------
    // --------------End EMA có Prec Chuan 31.05.21----------------


    // --------- BollingerBand 02_11.03.20 ---------
    _SECTION_BEGIN("BBands Fill");// Có màu BackGround.
    BOLLINGER = ParamToggle( "Bollinger Fill", "Show|Hide", 1 );
    if ( BOLLINGER == 1 )
    {
    P = ParamField("Price field",-1);
    Periods = Param("Periods", 20, 2, 300, 1 );
    Width = Param("Width", 2, 0, 10, 0.05 );
    Color = ParamColor("Color", colorLightGrey );
    Color = ColorBlend( Color, GetChartBkColor(), 0.5 );
    Style = ParamStyle("Style", styleLine | styleNoTitle ) | styleNoRescale;

    Plot(Prec(bbt = BBandTop( P, Periods, Width ),3), "BBTop" + _PARAM_VALUES(), Color, Style );
    Plot(Prec(bbb = BBandBot( P, Periods, Width ),3), "BBBot" + _PARAM_VALUES(), Color, Style );
    Plot(Prec(MA( P,20),3), "BB Mid" + _PARAM_VALUES(), colorLightOrange, styleNoTitle );
    PlotOHLC( bbt, bbt, bbb, bbb, "", ColorBlend( Color, GetChartBkColor(), 0.7 ), styleNoLabel | styleCloud | styleNoRescale, Null, Null, Null, -1 );
    _SECTION_END(); // Có màu BackGround.
    }
    // --------- End BollingerBand 02_11.03.20 ---------

    //----- Start Viet muc gia dong cua tai vi tri nen Close-----
    _SECTION_BEGIN("Price Line");
    PriceLine = ParamToggle( "Price Line", "Show|Hide", 1 );
    if ( PriceLine == 1 )
    {
    PriceLineColor=ParamColor("PriceLineColor",colorCustom12);
    PriceLevel = ParamField("PriceField", field = 3 );
    Daysback = Param("Bars Back",300,10,500,1);
    FirstBar = BarCount - DaysBack;
    YY = IIf(BarIndex() >= Firstbar,EndValue(PriceLevel),Null);

    Plot(YY,"Current Price",PriceLineColor,ParamStyle("LineStyle",styleLine|styleDashed|styleNoTitle|styleNoLabel,maskAll));

    side = Param("side",1,0,1000,1);
    dist = 0.5;

    for( i = 0; i < BarCount; i++ )
    {
    if(i+side== BarCount) PlotText( "\n << " + PriceLevel[ i ], i, YY[ i ]+dist, colorCustom12 );
    }
    }
    _SECTION_END();
    //----- End Viet muc gia dong cua tai vi tri nen Close-----

    //--------------- Ðem nguoc thoi gian ---------------
    _SECTION_BEGIN("Time Left");
    function GetSecondNum()
    {
    Time = Now( 4 );
    Seconds = int( Time % 100 );
    Minutes = int( Time / 100 % 100 );
    Hours = int( Time / 10000 % 100 );
    SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
    return SecondNum;
    }
    RequestTimedRefresh( 1 );
    TimeFrame = Interval();
    SecNumber = GetSecondNum();
    Newperiod = SecNumber % TimeFrame == 0;
    SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
    SecsToGo = TimeFrame - SecsLeft;

    x=Param("xposn",2,0,1000,1);
    y=Param("yposn",32,0,1000,1);
    MM = ParamToggle( "Time Left", "Show|Hide", 0 );
    if ( MM == 1 )
    {
    if ( NewPeriod )
    GfxRoundRect( x+45, y+17, x-3, y-2, 0, 0 );
    GfxSetBkMode(1);
    GfxSelectFont( "Arial", 12, 700, False );
    GfxSetTextColor( colorWhite );
    GfxTextOut( ""+SecsToGo+" / "+NumToStr( TimeFrame, 1.0 ), x, y );
    }
    _SECTION_END();
    //--------------- Ðem nguoc thoi gian ---------------

    //--------------- Delta = Vn30-Vn30F ---------------
    _SECTION_BEGIN( "Delta Vn30-Vn30F1M" );
    Delta = ParamToggle( "Delta", "Show|Hide", 0 );
    if ( Delta == 1 )
    {

    stck1=C; // Gia Vn30F1M
    symbol2="Vn30";
    stck2=Foreign(symbol2,"C");
    Delta=stck1-stck2;

    FS=Param("font Size",12,11,100,1);
    GfxSelectFont( "Arial", 12, 700, False );

    GfxSetBkMode( colorWhite );
    GfxSetTextColor(ParamColor( "Color",colorWhite));
    Hor = Param( "Horizontal Position", 2, 1, 1200, 1 );
    Ver = Param( "Vertical Position", 50 , 1, 830, 1 );
    DD=Prec(delta,2) ;

    GfxTextOut( "D: " + DD, Hor , Ver );
    }
    _SECTION_END();

    //--------------- Delta = Vn30-Vn30F ---------------

    //--------------- Hien thi Giá trên Chart_15.07.19 ---------------
    _SECTION_BEGIN( "Magnified Market Price" );
    Market = ParamToggle( "Market", "Show|Hide", 1 );
    if ( Market == 1 )
    {

    FS = Param( "Font Size", 14, 11, 100, 1 );
    GfxSelectFont( "Arial", FS, 700, italic = False, underline = False, True );
    GfxSetBkMode( colorWhite );
    GfxSetTextColor( ParamColor( "Color", colorCustom11) );
    Hor = Param( "Horizontal Position", 2, 1, 1200, 1 );
    Ver = Param( "Vertical Position", 63, 1, 1, 1 );
    GfxTextOut( "" + C, Hor , Ver );
    YC = TimeFrameGetPrice( "C", inDaily, -1 );
    DD = Prec( C - YC, 2 );
    xx = Prec( ( DD / YC ) * 100, 1 );
    GfxSelectFont( "Arial", 10, 700, italic = False, underline = False, True );
    GfxSetBkMode( colorWhite );
    GfxSetTextColor( ParamColor( "Color", colorViolet ) );
    GfxTextOut( "" + DD + " (" + xx + "%)", Hor + 0, Ver + 20 );
    }
    _SECTION_END();
    //--------------- Hien thi Giá trên Chart_15.07.19 ---------------
    --- Gộp bài viết, Aug 1, 2021 ---
    Chỉ cần Code này đủ các bạn tìm đủ thứ trên tt.
    Lưu ý Đang dùng trên bản A 6.20.3, phải cài thêm phần phụ trợ PatternExplorer thì mới chạy Code này hoàn chỉnh được
  4. haisactigon

    haisactigon Thành viên gắn bó với f319.com

    Joined:
    Sep 10, 2004
    Likes Received:
    20,826
    Cảm ơn bác chủ. Mình xin để chọn lọc những cái hay hoàn thiện bộ lọc của mình
  5. MrPeace1982

    MrPeace1982 Thành viên rất tích cực

    Joined:
    Jun 9, 2016
    Likes Received:
    209
    Là sao bạn? Ý mình là thêm chart volume VNIndex vào chung 1 sheet với chart cổ phiếu bất kỳ thí dự như DGC như hình này đó bạn. Thấy người ta làm, mình hỏi họ mà họ ko nói. Bạn giúp mình với.
    [​IMG]
  6. wildboar

    wildboar Thành viên gắn bó với f319.com

    Joined:
    Jun 21, 2015
    Likes Received:
    9,315
    bác viết code từ chục năm trước bây h họ dùng công nghệ AI rùi chắc code của bác không hợp thời trang 2021:))
    cp2011 likes this.
  7. cp2011

    cp2011 Thành viên gắn bó với f319.com

    Joined:
    Apr 12, 2010
    Likes Received:
    1,822
    Vừa chỉnh sửa 03/2021....
    Rõ ràng, từng phần một. ai cần phần nào thì lấy phần đó mà chế riêng cho mình.
    Hoặc dùng nguyên như vậy, cần phần nào bật phần đó lên OK, OK chứ!
    Những ai đang dung Amibroker thì đang cần đến nó và không bị lỗi mốt nhé......
    gamoi2020 and wildboar like this.
  8. cp2011

    cp2011 Thành viên gắn bó với f319.com

    Joined:
    Apr 12, 2010
    Likes Received:
    1,822
    Bạn vẫn chưa hiểu à, Gửi code bạn đang dùng để up ảnh lên đay mình sửa cho nhanh Hoặc tự làm như sau:
    1/ Mở bộ lọc trong ami (Nút dấu chấm than(!) trên thanh công cụ
    Một bảng nhỏ hiện ra,
    2/ Nhấn nút Pick để tìm file AFL của bạn đang dùng
    3/ nhấn nút Edit để chỉnh sửa Code đã chọn
    4/ cần thêm phần Volum thì : Coppy đọn Code của Volum rồi dán vào File AFL đang cần thêm Volum (Đã chọn ở bước 2
    5/ Lưu File sau khi thêm đoạn code Volume
    6/ Kiểm tra test lại File AFL đã chỉnh sửa ....
    7/ ...Chi tiết chưa....Cụ thể chưa? Chưa rõ thì add riêng
  9. MrPeace1982

    MrPeace1982 Thành viên rất tích cực

    Joined:
    Jun 9, 2016
    Likes Received:
    209
    Mình làm như bạn hướng dẫn nhưng nó không hiện ra chart volume VNIndex và đồ thị chỉ số VNindex mà hiện chart volume cổ phiếu DGC.
    [​IMG]

    Đoạn code của mình đây :
    _SECTION_BEGIN("Price");
    Ticker = ParamStr("Symbol", Name() );
    PlotForeign( Ticker, Ticker, ParamColor("Color", colorCycle ), ParamStyle("Style") | GetPriceStyle() );
    _SECTION_END();

    _SECTION_BEGIN("Volume");
    Plot( Volume, _DEFAULT_NAME(), IIf( C > O, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ) ), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram ) );
    _SECTION_END();
    -----------
    Sửa như thế nào để add thêm chart volume chỉ số VNIndex vào chart volume, chart giá bất kỳ cổ phiếu nào mình muốn. Bạn giúp mình với
  10. wildboar

    wildboar Thành viên gắn bó với f319.com

    Joined:
    Jun 21, 2015
    Likes Received:
    9,315
    Bác cho hỏi cai dode cũ của tui phần BB như sau:

    P = ParamField("Price field",-1);
    Periods = Param("Periods", 15, 2, 100, 1 );
    Width = Param("Width", 2, 0, 10, 0.05 );
    Color = ParamColor("Color", colorLightGrey );
    Style = ParamStyle("Style", styleLine | styleNoLabel ) | styleNoLabel;
    Plot( bbt = BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
    Plot( bbb = BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );
    PlotOHLC( bbt, bbt, bbb, bbb, "", ColorBlend( Color, GetChartBkColor(), 0.8 ), styleNoLabel | styleCloud | styleNoRescale, Null, Null, Null, -1 );


    đoạn này của bác thì cắt đoan nào dán vào
    // --------- BollingerBand 02_11.03.20 ---------
    _SECTION_BEGIN("BBands Fill");// Có màu BackGround.
    BOLLINGER = ParamToggle( "Bollinger Fill", "Show|Hide", 1 );
    if ( BOLLINGER == 1 )
    {
    P = ParamField("Price field",-1);
    Periods = Param("Periods", 20, 2, 300, 1 );
    Width = Param("Width", 2, 0, 10, 0.05 );
    Color = ParamColor("Color", colorLightGrey );
    Color = ColorBlend( Color, GetChartBkColor(), 0.5 );
    Style = ParamStyle("Style", styleLine | styleNoTitle ) | styleNoRescale;

    Plot(Prec(bbt = BBandTop( P, Periods, Width ),3), "BBTop" + _PARAM_VALUES(), Color, Style );
    Plot(Prec(bbb = BBandBot( P, Periods, Width ),3), "BBBot" + _PARAM_VALUES(), Color, Style );
    Plot(Prec(MA( P,20),3), "BB Mid" + _PARAM_VALUES(), colorLightOrange, styleNoTitle );
    PlotOHLC( bbt, bbt, bbb, bbb, "", ColorBlend( Color, GetChartBkColor(), 0.7 ), styleNoLabel | styleCloud | styleNoRescale, Null, Null, Null, -1 );
    _SECTION_END(); // Có màu BackGround.
    cp2011 likes this.

Share This Page