1. Welcome to the international stock forum - forex forum ! Chào mừng đến với diễn đàn quốc tế chứng khoán - forex ! www.Traders.vn
    Dismiss Notice

Thảo luận, chia sẻ Amibroker code dùng trong Phân tích kỹ thuật

Thảo luận trong 'Amibroker' bắt đầu bởi chart123, 25/8/17.

  1. chart123

    chart123 Member

    Tham gia ngày:
    1/5/17
    Bài viết:
    32
    Đã được thích:
    1
    Điểm thành tích:
    8
    Giới tính:
    Nam
    Mình lập Topic này với mong muốn anh em diễn đàn cùng nhau chia sẻ, trao đổi phần mềm Amibroker dùng trong phân tích kỹ thuật.
    Mình xin giói thiệu một số code do mình sưu tầm được hoặc tự sửa để các bạn tham khảo ( mình vẫn sử dụng các code này trong PTKT )

    Dưới đây là code sưa tầm, không phải của mình
    Code :
    -------------------------------------------------------------------------------------------------------------------------------------------
    _SECTION_BEGIN("Price");
    SetChartOptions(0,chartShowArrows|chartShowDates);
    _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
    Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
    _SECTION_END();

    _N(Title = StrFormat(EncodeColor( colorGold) + "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
    SetChartOptions(0,chartShowArrows|chartShowDates);


    SetChartBkColor(ColorRGB(23,23,23));


    priceStyle = IIf( (Interval(0) == -900), styleLine, styleBar);


    if (BeginValue(BarIndex()) != 0 AND EndValue(BarIndex()) != BarCount-1) {
    range = EndValue(BarIndex())-BeginValue(BarIndex());
    Title += StrFormat("\nRange Bars: %g", range);
    }

    CandleBorder = ParamColor("Candle Border Color", colorBlack );
    UpCandleColor = ParamColor("Up Candle Color", colorGreen );
    DownCandleColor = ParamColor("Down Candle Color", colorRed );


    Graph0BarColor = IIf( C > O,UpCandleColor ,DownCandleColor);

    Plot( C, "Close", CandleBorder, styleNoTitle | ParamStyle("Style") | priceStyle );





    x = TEMA(Close,12);
    y = TEMA(Close,20);
    Z= TEMA(Close,50);
    Buy=Cross(x,y );
    Sell=Cross(y, x);

    SUPERBUY=Cross(Y,Z);
    SUPERSELL=Cross(Z,Y);
    PlotShapes( SUPERBUY * shapeHollowCircle, colorWhite, 0);
    PlotShapes( SUPERSELL * shapeHollowCircle, colorBlue, 0);
    PlotShapes( Buy * shapeUpTriangle, colorBrightGreen, 0);
    PlotShapes( Sell * shapeDownTriangle, colorRed, 0);



    dist = 1.9*ATR(10);

    for( i = 0; i < BarCount; i++ )
    {
    if( Buy ) PlotText( "Buy\n@" + C[ i ], i, L[ i ]-dist, colorGreen );
    if( Sell ) PlotText( "Sell\n@" + C[ i ], i, H[ i ]+dist, colorRed, colorYellow );
    if( SUPERBUY ) PlotText( "SUPERSELL\n@" + C[ i ], i, L[ i ]-dist, colorWhite );
    if( SUPERSELL ) PlotText( "SUPERBUY\n@" + C[ i ], i, H[ i ]+dist, colorBlue, colorYellow );

    }
    _SECTION_BEGIN("AuthorName");
    k = (GetPerformanceCounter()/100)%100;
    printf("GetPerformance Counter %g",k);
    GfxSelectFont("Century Gothic", 14,800);
    GfxSetBkMode(3);
    GfxSetTextColor(colorSkyblue);
    GfxTextOut("TradersZone(Neil)50 50 System",-10+k,20);

    RequestTimedRefresh(10);
    _SECTION_END();
    -----------------------------------------------------------------------------------------------------------------------------------
    traderszon 50 50 system.png
     
  2. chart123

    chart123 Member

    Tham gia ngày:
    1/5/17
    Bài viết:
    32
    Đã được thích:
    1
    Điểm thành tích:
    8
    Giới tính:
    Nam
    indi.png code super trend

    ----------------------------------------------------------------------------------------------------------------------

    _SECTION_BEGIN("SuperTrend");
    SetBarsRequired(100000,0);
    GraphXSpace = 15;
    SetChartOptions(0,chartShowArrows|chartShowDates);

    Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle |
    ParamStyle("Style") | GetPriceStyle() );

    PositionSize = 100000;

    Factor=Optimize("Factor",2,2,10,1);
    Pd=Optimize("ATR Periods",11,1,20,1);
    Up=(H+L)/2+(Factor*ATR(Pd));
    Dn=(H+L)/2-(Factor*ATR(Pd));
    iATR=ATR(Pd);
    TrendUp=TrendDown=Null;
    trend[0]=1;
    changeOfTrend=0;
    flag=flagh=0;

    for (i = 1; i <BarCount-1; i++) {
    TrendUp = Null;
    TrendDown = Null;

    trend=1;


    if (Close>Up[i-1]) {
    trend=1;
    if (trend[i-1] == -1) changeOfTrend = 1;

    }
    else if (Close<Dn[i-1]) {
    trend=-1;
    if (trend[i-1] == 1) changeOfTrend = 1;
    }
    else if (trend[i-1]==1) {
    trend=1;
    changeOfTrend = 0;
    }
    else if (trend[i-1]==-1) {
    trend=-1;
    changeOfTrend = 0;
    }

    if (trend<0 && trend[i-1]>0) {
    flag=1;
    }
    else {
    flag=0;
    }

    if (trend>0 && trend[i-1]<0) {
    flagh=1;
    }
    else {
    flagh=0;
    }

    if (trend>0 && Dn<Dn[i-1]){
    Dn=Dn[i-1];
    }

    if (trend<0 && Up>Up[i-1])
    { Up=Up[i-1];
    }

    if (flag==1)
    { Up=(H+L)/2+(Factor*iATR[i]);;
    }
    if (flagh==1)
    { Dn[i]=(H[i]+L[i])/2-(Factor*iATR[i]);;
    }
    if (trend[i]==1) {
    TrendUp[i]=Dn[i];
    if (changeOfTrend == 1) {
    TrendUp[i-1] = TrendDown[i-1];
    changeOfTrend = 0;
    }
    }
    else if (trend[i]==-1) {
    TrendDown[i]=Up[i];
    if (changeOfTrend == 1) {
    TrendDown[i-1] = TrendUp[i-1];
    changeOfTrend = 0;
    }
    }
    }

    Plot(TrendUp,"Trend",colorGreen);
    Plot(TrendDown,"Down",colorRed);

    Buy = trend==1;
    Sell=trend==-1;

    Buy=ExRem(Buy,Sell);
    Sell=ExRem(Sell,Buy);
    Short=Sell;
    Cover=Buy;

    BuyPrice=ValueWhen(Buy,C);
    SellPrice=ValueWhen(Sell,C);
    ShortPrice=ValueWhen(Short,C);
    CoverPrice=ValueWhen(Cover,C);

    PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
    PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);

    PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
    PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
    PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);

    PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

    _SECTION_END();

    _SECTION_BEGIN("MA");
    P = ParamField("Price field",-1);
    Periods = Param("Periods", 15, 2, 300, 1, 10 );
    Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
    _SECTION_END();

    _SECTION_BEGIN("Label");

    //Magfied Market Price
    GfxSetTextAlign( 6 );// left alignment
    FS=Param("Font Size",16);
    GfxSelectFont("Arial", FS, 700, True );
    GfxSetBkMode(0); // transparent
    GfxSetTextColor( colorLightOrange );
    Hor=Param("Horizonta Position",1000);
    Ver=Param("Vertica Position",18);
    GfxTextOut(""+C, Hor , Ver );
    YC=TimeFrameGetPrice("C",inDaily,-1);
    DD=Prec(C-YC,2);
    xx=Prec((DD/YC)*100,2);
    FS2=Param("Font Size2",11);
    GfxSelectFont("Arial", FS2,11, 700, True );
    GfxSetBkMode( colorGreen );
    Hor1=Param("Horizontal Position",1000);
    Ver1=Param("Vertical Position",1);
    GfxSetTextColor( colorLightOrange );
    GfxTextOut(""+DD+" ("+xx+"%)", Hor1 , Ver1+45 );

    dec = (Param("Decimals",2,0,7,1)/10)+1;

    Title =EncodeColor(255)+ Name() + " " + EncodeColor(30) + Date() +
    " " + EncodeColor(5) + "{{INTERVAL}} " +
    EncodeColor(255)+ " Open = "+ EncodeColor(30)+ WriteVal(O,dec) +
    EncodeColor(255)+ " High = "+ EncodeColor(30)+ WriteVal(H,dec) +
    EncodeColor(255)+ " Low = "+ EncodeColor(30)+ WriteVal(L,dec) +
    EncodeColor(255)+ " Close = "+ EncodeColor(35)+ WriteVal(C,dec)+
    EncodeColor(255)+ " Volume = "+ EncodeColor(30)+ WriteVal(V,1) ;

    _SECTION_END();

    _SECTION_BEGIN("Advance Trenlines with Candle Pivots");
    farback = Param("How Far back to go", 100, 50, 5000, 10);
    nBars = Param("Number of bars", 12, 5, 40);
    aHPivs = H - H;
    aLPivs = L - L;
    aHPivHighs = H - H;
    aLPivLows = L - L;
    aHPivIdxs = H - H;
    aLPivIdxs = L - L;
    nHPivs = 0;
    nLPivs = 0;
    lastHPIdx = 0;
    lastLPIdx = 0;
    lastHPH = 0;
    lastLPL = 0;
    curPivBarIdx = 0;
    aHHVBars = HHVBars(H, nBars);
    aLLVBars = LLVBars(L, nBars);
    aHHV = HHV(H, nBars);
    aLLV = LLV(L, nBars);
    aVisBars = Status("barvisible");
    nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));
    _TRACE("Last visible bar: " + nLastVisBar);
    curBar = (BarCount - 1);
    curTrend = "";
    if (aLLVBars[curBar] < aHHVBars[curBar])
    {
    curTrend = "D";
    }

    else
    {
    curTrend = "U";
    }

    for (i = 0; i < farback; i++)
    {
    curBar = (BarCount - 1) - i;
    if (aLLVBars[curBar] < aHHVBars[curBar])
    {
    if (curTrend == "U")
    {
    curTrend = "D";
    curPivBarIdx = curBar - aLLVBars[curBar];
    aLPivs[curPivBarIdx] = 1;
    aLPivLows[nLPivs] = L[curPivBarIdx];
    aLPivIdxs[nLPivs] = curPivBarIdx;
    nLPivs++;
    }
    }
    else
    {
    if (curTrend == "D")
    {
    curTrend = "U";
    curPivBarIdx = curBar - aHHVBars[curBar];
    aHPivs[curPivBarIdx] = 1;
    aHPivHighs[nHPivs] = H[curPivBarIdx];
    aHPivIdxs[nHPivs] = curPivBarIdx;
    nHPivs++;
    }
    }
    }

    curBar = (BarCount - 1);
    candIdx = 0;
    candPrc = 0;
    lastLPIdx = aLPivIdxs[0];
    lastLPL = aLPivLows[0];
    lastHPIdx = aHPivIdxs[0];
    lastHPH = aHPivHighs[0];
    if (lastLPIdx > lastHPIdx)
    {
    candIdx = curBar - aHHVBars[curBar];
    candPrc = aHHV[curBar];
    if (lastHPH < candPrc AND candIdx > lastLPIdx AND candIdx < curBar)
    {
    aHPivs[candIdx] = 1;
    for (j = 0; j < nHPivs; j++)
    {
    aHPivHighs[nHPivs - j] = aHPivHighs[nHPivs - (j + 1)];
    aHPivIdxs[nHPivs - j] = aHPivIdxs[nHPivs - (j + 1)];
    }
    aHPivHighs[0] = candPrc;
    aHPivIdxs[0] = candIdx;
    nHPivs++;
    }
    }

    else
    {
    candIdx = curBar - aLLVBars[curBar];
    candPrc = aLLV[curBar];
    if (lastLPL > candPrc AND candIdx > lastHPIdx AND candIdx < curBar)
    {
    aLPivs[candIdx] = 1;
    for (j = 0; j < nLPivs; j++)
    {
    aLPivLows[nLPivs - j] = aLPivLows[nLPivs - (j + 1)];
    aLPivIdxs[nLPivs - j] = aLPivIdxs[nLPivs - (j + 1)];
    }
    aLPivLows[0] = candPrc;
    aLPivIdxs[0] = candIdx;
    nLPivs++;
    }
    }

    for (k = 0; k < nHPivs; k++)
    {
    _TRACE("High pivot no. " + k + " at barindex: " + aHPivIdxs[k] + ", " + WriteVal(ValueWhen(BarIndex() == aHPivIdxs[k], DateTime(), 1), formatDateTime) + ", " + aHPivHighs[k]);
    }

    a1 = ahpivs == 1;
    a2 = alpivs == 1;
    PlotShapes(a1 *shapeSmallCircle, colorLightOrange, 0, H, Offset = 5);
    PlotShapes(a2 *shapeSmallCircle, colorLightOrange, 0, L, Offset = -5);
    //////////////////////////////////////////////////////

    Para = ParamToggle("Plot Parallel Lines","Off,On");
    ColorS= ParamColor("Support",colorLightOrange);
    ColorR= ParamColor("Resistance",colorLightOrange);
    x = Cum(1);
    s1 = L;
    s11 = H;
    pS = a2 == 1;


    endt = LastValue(ValueWhen(ps,x,1));
    startt = LastValue(ValueWhen(ps,x,2));
    ends = LastValue(ValueWhen(ps,S1,1));
    starts = LastValue(ValueWhen(ps,S1,2));
    dtS = endt - startt;
    aS = (endS - startS) / dtS;
    bS = endS;
    trendlineS = aS *(x - endt) + bS;
    g3 = IIf(x > startt - 10, trendlineS, Null);
    Plot(g3, "", colors );
    pR = a1 == 1;
    endt1 = LastValue(ValueWhen(pr,x,1));
    startt1 = LastValue(ValueWhen(pr,x,2));
    endr = LastValue(ValueWhen(pr,S11,1));
    startr = LastValue(ValueWhen(pr,S11,2));
    dtR = endt1 - startt1;
    aR = (endR - startR) / dtR;
    bR = endR;
    trendlineR = aR *(x - endt1) + bR;
    g4 = IIf(x > startT1 - 10, trendlineR, Null);
    Plot(g4, "", colorr );

    acd = log(endr/startr)/(endt1-startt1);
    res1 = exp((x-endt1)*acd)*endr;
    RRL = ROC(res1,1);
    bcd = log(ends/starts)/(endt-startt);
    sup1= exp((x-endt)*bcd)*ends;
    RSL = ROC(sup1,1);

    Low_Value = LastValue(Ref(LLV(L,endt1-startt1),-(x-endt1)));
    x2 = LastValue(ValueWhen(L==Low_Value & x>startt1 & x<endt1,x));
    PLL = IIf(LastValue(x)-x2>5,exp((x-x2)*acd)*Low_Value,Null);
    Hi_Value = LastValue(Ref(HHV(H,endt-startt),-(x-endt)));
    x3 = LastValue(ValueWhen(H==Hi_Value & x>startt & x<endt,x));
    PHL = IIf(LastValue(x)-x3>5,exp((x-x3)*bcd)*Hi_Value,Null);
    SLabs = sup1-Ref(sup1,-1); RLabs = res1-Ref(res1,-1);
    ROC2SL = (SLabs/C)*100; ROC2RL = (RLabs/C)*100;
    PLLd = abs((LastValue(C)/LastValue(PLL))-1)<0.01*100;
    PHLd = abs((LastValue(C)/LastValue(PHL))-1)<0.01*100;
    barvisible = Status("barvisible");
    firstvisiblebar = barvisible & NOT
    Ref(barvisible,-1);
    HHvisible = LastValue(HighestSince(firstvisiblebar,High));
    LLvisible = LastValue(LowestSince(firstvisiblebar,Low));
    RaH = HHvisible *1.05; RaL = LLVisible *0.95;
    AnZ= starts==0 OR ends==0 OR startr==0 OR endr==0;
    PLplot = IIf(x-x2>=0 & abs(LastValue(L/PLL)-1) <abs(LastValue((100/1000)*ATR(14))) & PLL>RaL & PLL<RaH & NOT AnZ,PLL,IIf(x-x2>=0 & RaL==0 & PLLd & abs(LastValue(L/PLL)-1) <abs(LastValue((100/1000)*ATR(14)))& NOT AnZ,PLL,Null));
    PHplot = IIf(x-x3>=0 & abs(LastValue(H/PHL)-1) <abs(LastValue((100/1000)*ATR(14))) & PHL>RaL & PHL<RaH & NOT AnZ,PHL,IIf(x-x3>=0 & RaL==0 & PHLd & abs(LastValue(H/PHL)-1) <abs(LastValue((100/1000)*ATR(14)))& NOT AnZ,PHL,Null));
    Plot(IIf(Para,PLplot,Null)," ",colorr,styleDashed,maskDefault+styleNoRescale);
    Plot(IIf(Para,PHplot,Null)," ",colors,styleDashed,maskDefault+styleNoRescale);
    _SECTION_END();


    _SECTION_BEGIN("Fibonacci");

    //AA - Fibonacci Retracements AND Goals"

    Period = Param("Period", 5, 1, 50);
    ShowExt = ParamToggle("Show Extension ?", "No|Yes");


    Period = Period*(13*.618);

    Hhb = LastValue(Ref(HHVBars(H, Period), -1))+1;
    Llb = LastValue(Ref(LLVBars(L, Period), -1))+1;
    Hv = LastValue(Ref(HHV(H, Period), -1));
    Lv = LastValue(Ref(LLV(L, Period), -1));

    Range = (Hv - Lv);
    LText = " 0 %, 23.6 %, 38.2 %, 50 %, 61.8 %, 78.6 %, 100 %,127 % ,161.8 %, 200 %";
    if(Hhb > Llb)
    {
    Levels[0] = Lv;
    Levels[1]= (Range *.236)+Levels[0];
    Levels[2]= (Range *.382)+Levels[0];
    Levels[3]= (Range *.5)+Levels[0];
    Levels[4]= (Range *.618)+Levels[0];
    Levels[5]= (Range *.786)+Levels[0];
    Levels[6]= Hv;
    Levels[7]= (Range *.270)+Levels[6];
    Levels[8]= (Range *.618)+Levels[6];
    Levels[9]= (Range )+Levels[6];
    x0 = BarCount - 1 - Llb;
    x1 = BarCount - 1 - Hhb;
    }
    else
    {
    Levels[0]= Hv;
    Levels[1]= Levels[0]- (Range *.236);
    Levels[2]= Levels[0]- (Range *.382);
    Levels[3]= Levels[0]- (Range *.5);
    Levels[4]= Levels[0]- (Range *.618);
    Levels[5]= Levels[0]- (Range *.786);
    Levels[6]= Lv;
    Levels[7]= Levels[6]- (Range *.270);
    Levels[8]= Levels[6]- (Range *.618);
    Levels[9]= Levels[6]- (Range );
    x0 = BarCount - 1 - Hhb;
    x1 = BarCount - 1 - Llb;
    }

    //////////////////////////////////////////////////////////////////////////////////////
    /// **************************** Plotting Area ********************************
    //

    for(i=0; i<10; i++)
    {
    if(i!=6)
    x = x0;
    else
    x = x1;
    if(i<7 OR ShowExt)
    {
    Plot(LineArray(x, Levels[i], BarCount, Levels[i]), "", i+2, styleDashed);
    PlotText(StrExtract(LText, i), BarCount, Levels[i], i+2);
    }
    }




    _SECTION_END();


    ----------------------------------------------------------------------------------------------------------
    [ATTACH=full]50[/ATTACH][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i]
     
  3. traders

    traders Administrator Thành viên BQT

    Tham gia ngày:
    29/4/17
    Bài viết:
    110
    Đã được thích:
    1
    Điểm thành tích:
    18
    Code cho MACD khá hay để các bạn tham khảo

    ---------------------------------------------------------------------------
    _SECTION_BEGIN("Chart Display");
    GraphXSpace = 10;
    SetBarsRequired(1,1);

    SetChartOptions(0,chartShowArrows|chartShowDates|chartWrapTitle);
    Plot( C, "Close", ParamColor("Candle Outline Color?", colorWhite), styleCandle|styleNoTitle);
    _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H,

    L, C, SelectedValue( ROC( C, 1 )) ));
    _SECTION_END();

    _SECTION_BEGIN("Volume");
    Plot(Volume, _DEFAULT_NAME(), ParamColor("Color", colorGrey50), ParamStyle( "Style", styleHistogram | styleOwnScale,

    maskHistogram), 2 );
    _SECTION_END();

    VBS=0;
    VSS=0;
    VBM = "";
    VSM = "";

    _SECTION_BEGIN("Parameter Settings");
    ap = Param("Aroon Periods", 14, 1, 100, 1 );
    ParamStr("--------------- ------------------","-");
    bp = Param("Bollinger Bands Periods", 15, 2, 300, 1 );
    bw = Param("Bollinger Bands Width", 2, 0, 10, 0.05 );
    ParamStr("--------------------------------","-");
    r1 = Param( "MACD Fast Average", 12, 2, 200, 1 );
    r2 = Param( "MACD Slow Average", 26, 2, 200, 1 );
    r3 = Param( "MACD Signal Average", 9, 2, 200, 1 );
    ParamStr("---------------------------------","-");
    mp = Param( "MFI Periods", 14, 2, 200, 1 );
    ParamStr("--------------- -----------------","-");
    rp = Param( "RSI Periods", 15, 1, 200, 1 );
    ParamStr("---------------- -----------------","-");
    P1 = Param("Fast MA Period?",3,1,100);
    P2 = Param("Medium MA Period?",5,1,300);
    P3 = Param("Short MA Period?",8,1,300);

    HHVBS = HHVBars(H,ap+1);
    LLVBS = LLVBars(L,ap+1);

    Aroon_Up = ((ap-HHVBS)/ap)*100;
    Aroon_Down = ((ap-LLVBS)/ap)*100;
    Aroon_Buy = Aroon_Up>70 AND Aroon_Down<30;
    Aroon_Sell = Aroon_Up<30 AND Aroon_Down>70;

    VBS = IIf(Aroon_Buy,VBS+1,VBS);
    VSS = IIf(Aroon_Sell,VSS+1,VSS);
    VBM = WriteIf(Aroon_Buy,VBM + "Aroon ",VBM);
    VSM = WriteIf(Aroon_Sell,VSM + "Aroon ",VSM);

    BB_Buy = C<BBandBot(C,bp,bw);
    BB_Sell = C>BBandTop(C,bp,bw);

    VBS = IIf(BB_Buy,VBS+1,VBS);
    VSS = IIf(BB_Sell,VSS+1,VSS);
    VBM = WriteIf(BB_Buy,VBM + "Bollinger Bands ",VBM);
    VSM = WriteIf(BB_Sell,VSM + "Bollinger Bands ",VSM);

    ml = MACD(r1, r2);
    sl = Signal(r1,r2,r3);
    MACD_Hist = ml-sl;

    MACD_Buy = ml>0 OR ml>sl;
    MACD_Hist_Buy = MACD_Hist<0 AND MACD_Hist>Ref(MACD_Hist,-1);
    MACD_Sell = ml<0 OR ml<sl;
    MACD_Hist_Sell = MACD_Hist>0 AND MACD_Hist<Ref(MACD_Hist,-1);

    VBS = IIf(MACD_Buy,VBS+1,VBS);
    VSS = IIf(MACD_Sell,VSS+1,VSS);
    VBS = IIf(MACD_Hist_Buy,VBS+1,VBS);
    VSS = IIf(MACD_Hist_Sell,VSS+1,VSS);

    VBM = WriteIf(MACD_Buy,VBM + "MACD ",VBM);
    VSM = WriteIf(MACD_Sell,VSM + "MACD ",VSM);
    VBM = WriteIf(MACD_Hist_Buy,VBM + "MACD-Histogram ",VBM);
    VSM = WriteIf(MACD_Hist_Sell,VSM + "MACD-Histogram ",VSM);

    MFI_Buy = MFI(mp)<20;
    MFI_Sell = MFI(mp)>80;

    VBS = IIf(MFI_Buy,VBS+1,VBS);
    VSS = IIf(MFI_Sell,VSS+1,VSS);

    VBM = WriteIf(MFI_Buy,VBM + "MFI ",VBM);
    VSM = WriteIf(MFI_Sell,VSM + "MFI ",VSM);

    RSI_Value = RSI(rp);
    RSI_Buy = RSI_Value>30 AND Ref(RSI_Value,-1)<=30;
    RSI_Sell = RSI_Value<70 AND Ref(RSI_Value,-1)>=70;

    RSI_Price_Buy = RSI_Value>Ref(RSI_Value,-1) AND C>Ref(C,-1) AND RSI_Value>50;
    RSI_Price_Sell = RSI_Value<Ref(RSI_Value,-1) AND C<Ref(C,-1) AND RSI_Value<50;

    VBS = IIf(RSI_Buy,VBS+1,VBS);
    VSS = IIf(RSI_Sell,VSS+1,VSS);

    VBS = IIf(RSI_Price_Buy,VBS+1,VBS);
    VSS = IIf(RSI_Price_Sell,VSS+1,VSS);

    VBM = WriteIf(RSI_Buy,VBM + "RSI ",VBM);
    VSM = WriteIf(RSI_Sell,VSM + "RSI ",VSM);
    VBM = WriteIf(RSI_Price_Buy,VBM + "RSI&Price ",VBM);
    VSM = WriteIf(RSI_Price_Sell,VSM + "RSI&Price ",VSM);

    Fast_MA = MA(C,P1);
    Medium_MA = MA(C,P2);
    Slow_MA = MA(C,P3);

    MA_Buy = Fast_MA>Medium_MA AND Medium_MA>Slow_MA;
    MA_Sell = Fast_MA<Medium_MA AND Medium_MA<Slow_MA;

    VBS = IIf(MA_Buy,VBS+1,VBS);
    VSS = IIf(MA_Sell,VSS+1,VSS);
    VBM = WriteIf(MA_Buy,VBM + "MA ",VBM);
    VSM = WriteIf(MA_Sell,VSM + "MA ",VSM);

    _SECTION_END();

    _SECTION_BEGIN("Trading System");

    Count = Param("Trading System based on how many parameters?",3,1,8);

    Buy = VBS>=Count;
    Sell = VSS>=Count;

    Buy = ExRem(Buy,Sell);
    Sell = ExRem(Sell,Buy);

    PlotShapes(IIf(Buy,shapeUpArrow,shapeNone), colorBrightGreen, 0, L, Offset=-15);
    PlotShapes(IIf(Sell,shapeDownArrow,shapeNone), colorRed, 0, H, Offset=-15);

    AlertIf(Buy, "SOUND C:\\program files\\amibroker\\tada.wav", "Buy alert : "+C,1);
    AlertIf(Sell, "SOUND C:\\program files\\amibroker\\notify.wav", "Sell alert : "+C,2);

    MessageBg = ParamColor("Message Background Color?",colorBlack);
    GfxSetBkColor(MessageBg);
    GfxSelectFont("Arial",10,600);
    GfxSetTextColor(colorGreen);
    GfxTextOut("Buy Signal Count : "+VBS,15,25);
    GfxTextOut(VBM,15,40);
    GfxSetTextColor(colorRed);
    GfxTextOut("Sell Signal Count : "+VSS,15,55);
    GfxTextOut(VSM,15,70);

    _SECTION_END();

    MACD.png
     
  4. chart123

    chart123 Member

    Tham gia ngày:
    1/5/17
    Bài viết:
    32
    Đã được thích:
    1
    Điểm thành tích:
    8
    Giới tính:
    Nam
    Code về RSI


    ----------------------------------------------
    _SECTION_BEGIN("Price");
    SetChartOptions(0,chartShowArrows|chartShowDates);
    _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
    Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
    _SECTION_END();

    _SECTION_BEGIN("RSI TRENDLINE ");
    // RSI TRENDLINE formula ver 1.0

    SetBarsRequired(sbrAll, sbrAll);
    TP = Param("Trend Per", 300,2,1000);
    per_RSI= Param("RSI Per", 9, 7, 35,1);
    IND = RSI(per_RSI);
    Center = 50 ;

    Plot( RSI(per_RSI), "", 4, 4);
    Plot(50,"",1,1) ;

    // CALCULATE UPTREND

    startvalue = LastValue( LLV( IND, TP ) );
    startbar = LastValue( ValueWhen( IND == startvalue, BarIndex(), 1) );
    BP = BarCount - Startbar;

    secondvalue = LastValue( LLV( IND, BP - 5 ) );
    secondbar = LastValue( ValueWhen( IND == secondvalue, BarIndex(), 1) );
    BP2 = BarCount - secondbar;

    thirdvalue = LastValue( LLV( IND, BP2 - 5 ) );
    thirdbar = LastValue( ValueWhen( IND == thirdvalue, BarIndex(), 1) );
    BP3 = BarCount - thirdbar;

    fourthvalue = LastValue( LLV( IND, BP3 - 5 ) );
    fourthbar = LastValue( ValueWhen( IND ==fourthvalue, BarIndex(), 1) );
    BP4 = BarCount - fourthbar;

    fifthvalue = LastValue( LLV( IND, BP4 - 5 ) );
    fifthbar = LastValue( ValueWhen( IND ==fifthvalue, BarIndex(), 1) );
    BP5 = BarCount - fifthbar;

    sixthvalue = LastValue( LLV( IND, BP5 - 5 ) );
    sixthbar = LastValue( ValueWhen( IND ==sixthvalue, BarIndex(), 1) );

    Low_1= IIf( BarIndex() == startbar, 80, Null);
    Low_2= IIf( BarIndex() == secondbar, 80, Null);
    Low_3= IIf( BarIndex() == thirdbar, 80, Null);
    Low_4= IIf( BarIndex() == fourthbar, 80, Null);
    Low_5= IIf( BarIndex() == fifthbar, 80, Null);
    Low_6= IIf( BarIndex() == sixthbar, 80, Null);

    b = startvalue ;
    FirstSlope = (secondvalue - b) / (secondbar - startbar) ;
    FirstTrendline = FirstSlope * ( BarIndex() - startbar ) + b;
    // Plot( IIf( BarIndex() >= startbar AND FirstTrendline <= 90 , FirstTrendline, Null ) , "FirstTrendline", colorGreen, styleThick +2048 );

    SecondSlope = (thirdvalue - b) / (thirdbar - startbar) ;
    SecondTrendline = SecondSlope * ( BarIndex() - startbar ) + b;

    ThirdSlope = (fourthvalue - b) / (fourthbar - startbar) ;
    ThirdTrendline = ThirdSlope * ( BarIndex() - startbar ) + b;

    FourthSlope = (fifthvalue - b) / (fifthbar - startbar) ;
    FourthTrendline = FourthSlope * ( BarIndex() - startbar ) + b;

    FifthSlope = (sixthvalue - b) / (sixthbar - startbar) ;
    FifthTrendline = FifthSlope * ( BarIndex() - startbar ) + b;

    MainSlope = IIf( FirstSlope > SecondSlope, IIf( SecondSlope > ThirdSlope, IIf( ThirdSlope > FourthSlope,
    IIf( FourthSlope > FifthSlope, FifthSlope, FourthSlope),ThirdSlope), SecondSlope), FirstSlope) ;

    MainLine = MainSlope * ( BarIndex() - startbar ) + b;
    Plot( IIf( BarIndex() >= startbar, MainLine, Null ) , "MainLine", colorDarkGreen, styleThick ) ;


    IND_Diff = IIf( BarIndex() >= startbar, abs( IND - MainLine), Null) ;
    MainTrendLine_Diff = Param("Difference IND from MainTrendLine", 2.5, 0.5,5, 0.5);

    Cond_Buy = IIf( BarIndex() >= Thirdbar AND IND_Diff <= MainTrendLine_Diff, IND, 0) AND MainLine < 55 ;

    PlotShapes( IIf( Cond_Buy, shapeUpArrow , shapeNone ), colorGreen );



    /////////////////////////////////////////////

    // CALCULATE DOWNTREND

    starthigh = LastValue( HHV( IND, TP ) );
    starthighbar = LastValue( ValueWhen( IND == starthigh, BarIndex(), 1) );
    HBP = BarCount - starthighbar;

    secondhigh = LastValue( HHV( IND, HBP - 5 ) );
    secondhighbar = LastValue( ValueWhen( IND == secondhigh, BarIndex(), 1) );
    HBP2 = BarCount - secondhighbar;

    thirdhigh = LastValue( HHV( IND, HBP2 - 5 ) );
    thirdhighbar = LastValue( ValueWhen( IND == thirdhigh, BarIndex(), 1) );
    HBP3 = BarCount - thirdhighbar;

    fourthhigh = LastValue( HHV( IND, HBP3 - 5 ) );
    fourthhighbar = LastValue( ValueWhen( IND ==fourthhigh, BarIndex(), 1) );
    HBP4 = BarCount - fourthhighbar;

    fifthhigh = LastValue( HHV( IND, HBP4 - 5 ) );
    fifthhighbar = LastValue( ValueWhen( IND ==fifthhigh, BarIndex(), 1) );
    HBP5 = BarCount - fifthhighbar;

    sixthhigh = LastValue( HHV( IND, HBP5 - 5 ) );
    sixthhighbar = LastValue( ValueWhen( IND ==sixthhigh, BarIndex(), 1) );

    High_1= IIf( BarIndex() == starthighbar, 90, Null);
    High_2= IIf( BarIndex() == secondhighbar, 90, Null);
    High_3= IIf( BarIndex() == thirdhighbar, 90, Null);
    High_4= IIf( BarIndex() == fourthhighbar, 90, Null);
    High_5= IIf( BarIndex() == fifthhighbar, 90, Null);
    High_6= IIf( BarIndex() == sixthhighbar, 90, Null);

    MainTrendLine_Diff = Param("Difference IND from MainTrendLine", 2.5, 0.5,7, 0.5);

    d = starthigh ;
    FirstDownSlope = (secondhigh - d) / (secondhighbar - starthighbar) ;
    FirstDownTrendline = FirstDownSlope * ( BarIndex() - starthighbar ) + d;

    SecondDownSlope = (thirdhigh - d) / (thirdhighbar - starthighbar) ;
    SecondDownTrendline = SecondDownSlope * ( BarIndex() - starthighbar ) + d;

    ThirdDownSlope = (fourthhigh - d) / (fourthhighbar - starthighbar) ;
    ThirdDownTrendline = ThirdDownSlope * ( BarIndex() - starthighbar ) + d;

    FourthDownSlope = (fifthhigh - d) / (fifthhighbar - starthighbar) ;
    FourthDownTrendline = FourthDownSlope * ( BarIndex() - starthighbar ) + d;

    FifthDownSlope = (sixthhigh - d) / (sixthhighbar - starthighbar) ;
    FifthDownTrendline = FifthDownSlope * ( BarIndex() - starthighbar ) + d;

    MainDownSlope = IIf( FirstDownSlope < SecondDownSlope, IIf( SecondDownSlope < ThirdDownSlope,
    IIf( ThirdDownSlope < FourthDownSlope, IIf( FourthDownSlope < FifthDownSlope, FifthDownSlope, FourthDownSlope),ThirdDownSlope), SecondDownSlope), FirstDownSlope) ;

    MainDownLine = IIf( MainDownSlope == 0, Null, MainDownSlope * ( BarIndex() - starthighbar ) + d ) ;
    Plot( IIf( BarIndex() >= starthighbar, MainDownLine, Null ) , "Main_DOWN_Line", colorViolet, styleThick ) ;

    IND_Diff = IIf( BarIndex() >= starthighbar, abs( IND - MainDownLine), Null) ;

    Cond_Sell = IIf( BarIndex() >= Thirdbar AND IND_Diff <= MainTrendLine_Diff, IND, 0) AND MainDownLine > 45 ;

    PlotShapes( IIf( Cond_Sell, shapeDownArrow , shapeNone ), colorRed );


    Title = Name() + "\\c17" + " " +"\\c12" + "RSI" + " " + per_RSI ;
    _SECTION_END();

    rsi.png
     
  5. chart123

    chart123 Member

    Tham gia ngày:
    1/5/17
    Bài viết:
    32
    Đã được thích:
    1
    Điểm thành tích:
    8
    Giới tính:
    Nam
    Mẫu đẹp
    STOCHASTIC - EMA

    --------------------------------------------------------

    _SECTION_BEGIN("Price");
    SetChartOptions(0,chartShowArrows|chartShowDates);
    _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
    Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
    _SECTION_END();

    _SECTION_BEGIN("EMA_STOCHASTIC");
    /*optimizing factor*/
    OPT1 = Optimize( "OPT1", 15, 10, 30, 2 );
    OPT2= Optimize("OPT2", 30, 20, 60, 5 );
    OPT3 = Optimize( "OPT3", 50, 40, 120, 10 );
    OPT4= Optimize("OPT4", 10, 1, 20, 1 );
    OPT5 = Optimize( "OPT5", 20, 1, 50, 1 );
    OPT6= Optimize("OPT6", 9, 4, 20, 2 );
    OPT7 = Optimize( "OPT7", 1, 1, 10, 2 );
    OPT8= Optimize("OPT8", 2, 1, 10, 2 );




    /*Buy/Sell Conditions (In Example, Long trade only)*/
    Buy = ((EMA(C,OPT1)>EMA(C,OPT2)AND EMA(C,OPT2)>EMA(C,OPT3))AND(Cross(EMA(C,OPT4),EMA(C,OPT5))))
    OR
    ((EMA(C,OPT2)>EMA(C,OPT1)AND EMA(C,OPT1)>EMA(C,OPT3))AND(Cross(StochK(OPT6,OPT7),StochD(OPT6,OPT7,OPT8))))
    OR
    Cross(EMA(C,OPT2),EMA(C,OPT3));

    Sell = Cross(EMA(C,OPT5),EMA(C,OPT4))
    OR
    (Cross(StochD(OPT6,OPT7,OPT8),StochK(OPT6,OPT7))AND(EMA(C,OPT2)>EMA(C,OPT1)AND EMA(C,OPT1)>EMA(C,OPT3)));

    Short = 0;
    Cover = 0;



    /*Display Buy/Sell signal*/
    shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
    PlotShapes( shape, IIf( Buy, colorGreen, colorRed ),0, IIf( Buy, Low, High ) );



    /*Display Buy/Sell price*/
    GraphXSpace = 5;
    dist = 1.5*ATR(10);

    for( i = 0; i < BarCount; i++ )
    {
    if( Buy ) PlotText( "Buy\n@" + C[ i ], i, L[ i ]-dist, colorGreen );
    if( Sell ) PlotText( "Sell\n@" + C[ i ], i, H[ i ]+dist, colorRed);
    }



    /*Display indicators*/
    Plot(EMA(C,10),"EMA short", colorGreen );
    Plot(EMA(C,20),"EMA long", colorRed );

    /*Trying to insert Bullish/Bearish Ribbon*/
    Plot( 1,"Ribbon",
    IIf( EMA( Close , 15 )> EMA( Close , 30)AND EMA( Close , 30 )> EMA( Close , 50), colorGreen, IIf( (EMA( Close , 15 )< EMA( Close , 30)AND EMA( Close , 30 )> EMA( Close , 50)), colorGold, colorRed )),
    styleOwnScale|styleArea|styleNoLabel,0, 50 );
    _SECTION_END(); EMA.png
     
  6. stock

    stock Member

    Tham gia ngày:
    1/5/17
    Bài viết:
    73
    Đã được thích:
    0
    Điểm thành tích:
    6
    Giới tính:
    Nam
    code : auto buy
    -----------------------------------------------------------------------

    _SECTION_BEGIN("Price");
    SetChartOptions(0,chartShowArrows|chartShowDates);
    _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
    Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
    _SECTION_END();

    _SECTION_BEGIN("ADXbuy");
    /*ADX system
    goldfreaz - 18 April 2002

    Buy: slope ADX > slope ADX threshold and
    ADX > ADX threshold + ADX histeresis and
    PDI > ADX + DI histeresis and
    slope PDI - slope MDI > slope DI threshold and
    PDI > ADX

    Sell: {ADX > ADX threshold - ADX histeresis and
    PDI < ADX - DI histeresis} or
    MDI > PDI + DI histeresis

    with optimization */



    // ADX and PDI/MDI have different smoothing constants
    // smoothing defined as a exponential daily average, not Wilder's nonsense
    Aperiod=11;
    Bperiod=13;
    ADXthreshold=18;
    dadxthr=0.5;
    slpadxD=18;
    slpadxthr=0.35;
    dPM=3.5;
    slppmD=3;
    slpPMthr=-0.65;
    //Aperiod=Optimize("Aperiod",13,11,15,1);
    //Bperiod=Optimize("Bperiod",14,13,17,1);
    //ADXthreshold=Optimize("ADXthreshold",17,16,18,0.25);
    //dadxthr=Optimize("dADXthr",0.25,0,1.5,0.25);
    //slpadxD=Optimize("slpadxD",12,18,22,1);
    //slpadxthr=Optimize("slpadxthr",0.35,0.2,0.5,0.05);
    //dPM=Optimize("dPM",1,3.5,4,0.2);
    //slppmD=Optimize("slppmD",3,2,4,1);
    //slpPMthr=Optimize("slpPMthr",-0.65,-1,-0.5,0.05);
    Ppdi=PDI(Bperiod);
    Mmdi=MDI(Bperiod);
    dx=100*abs(Ppdi-Mmdi)/(Ppdi+Mmdi);
    Aadx=EMA(dx,Aperiod);
    slpadx=(Aadx-Ref(MA(Aadx,slpadxD),-1))/slpadxD;
    slpPM=(Ppdi-Ref(EMA(Ppdi,slppmD),-1)-Mmdi+Ref(EMA(Mmdi,slppmD),-1))/slppmD;

    Buy =slpadx>slpadxthr AND Aadx>ADXthreshold+dadxthr AND Ppdi>Mmdi+dPM AND
    slpPM>slpPMthr AND Ppdi>Aadx;

    Sell=(Aadx>ADXthreshold-dadxthr AND Ppdi<Aadx-dPM) OR Mmdi>Ppdi+dPM;

    Filter=Buy OR Sell;
    Sell=ExRem(Sell,Buy); Buy=ExRem(Buy,Sell);

    AddColumn(Buy,"Buy");
    AddColumn(Sell,"sell");
    AddColumn(Aadx,"Aadx");
    AddColumn(slpPM,"slpPM");
    AddColumn(BuyPrice,"BuyPrice");
    AddColumn(SellPrice,"SellPrice");
    _SECTION_END();

    _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));Graph0BarColor= IIf( C > O,colorGreen,colorRed);
    Plot( C, "Close", ParamColor("Color", colorLavender ), styleBar | ParamStyle("StyleThick") | GetPriceStyle() );
    if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
    {
    ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 )));
    }


    _SECTION_BEGIN("Ravi");
    Col = IIf(C > O,colorBrightGreen,colorRed);
    Plot(C,"",col,styleBar+styleThick);
    _SECTION_BEGIN("Magnified Market Price");
    //by mcxnsetips.com//
    FS=Param("Font Size",30,11,100,1);
    GfxSelectFont("Times New Roman", FS, 700, True );
    GfxSetBkMode( colorWhite );
    GfxSetTextColor( ParamColor("Color",colorWhite) );
    Hor=Param("Horizontal Position",990,1,1200,1);
    Ver=Param("Vertical Position",12,1,830,1);
    GfxTextOut(""+C, Hor , Ver );
    YC=TimeFrameGetPrice("C",inDaily,-1);
    DD=Prec(C-YC,2);
    xx=Prec((DD/YC)*100,2);
    GfxSelectFont("Times New Roman", 11, 700, True );
    GfxSetBkMode( colorBlack );
    GfxSetTextColor(ParamColor("Color",colorYellow) );
    GfxTextOut(""+DD+" ("+xx+"%)", Hor , Ver+45 );
    _SECTION_END();


    _SECTION_BEGIN(" EMA's");
    EMA1 = EMA(H,34);
    EMA2 = EMA(L,34);
    EMA3 = EMA(C,34);

    Plot( EMA1, "EMA1" ,ParamColor( "Color1", colorRed ), ParamStyle("Style", styleDashed|styleThick) | styleNoRescale );
    Plot( EMA2, "EMA2" ,ParamColor( "Color2", colorGreen ), ParamStyle("Style", styleDashed|styleThick) | styleNoRescale );
    Plot( EMA3, "EMA3" ,ParamColor( "Color3", colorBlue ), ParamStyle("Style", styleDashed|styleThick) | styleNoRescale );
    _SECTION_END();


    TimeFrameSet(inDaily);
    DayHigh = LastValue(H);
    DayLow = LastValue(L);
    TimeFrameRestore();

    Title = Date() + ", Op=" + Open + ", Hi=" + High + ", Lo=" + Low + ", LTP=" + Close + ", Change= " + SelectedValue( ROC( C, 1 ) ) + "%" + "\n Today`s High=" + DayHigh + ", Today`s Low=" + DayLow + " © " ;


    prev=AMA2(C,1,0);
    d=IIf(C>Ref(Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),-1),Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),
    IIf(C<Ref(Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),-1),Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),PREV));
    a=Cross(Close,d);
    b=Cross(d,Close);
    state=IIf(BarsSince(a)<BarsSince(b),1,0);
    s=state>Ref(state,-1);
    ss=state<Ref(state,-1);
    sss=state==Ref(state,-1);
    col=IIf(state == 1 ,51,IIf(state ==0,4,1));
    //Plot(C,"",Col,64);
    Buy = s;
    Sell = ss;
    ///shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
    ///PlotShapes(shape, IIf(Buy,colorGreen,colorRed), 0, IIf(Buy,Low,High));
    ///PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-5);
    ///PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-10);
    ///PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-7.5);
    ///PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=10);
    ///PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=15);
    //PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-12.5);
    ///WriteIf(s,"EXIT all Short positions\nif trading long positions, enter long Now-\nOR at the market price on tomorrow's Open with stop="+EncodeColor(4)+WriteVal(L+.75*ATR(5),1.4)+" ,","");
    ////WriteIf(ss,"exit all long positions today with a Market On Close (MOC) order\nOR at the market price on tomorrow's Open with stop="+EncodeColor(4)+WriteVal(Ref(H+.75*ATR(5), -1),1.4)+",","");
    ///WriteIf( sss ,"No trading signals today.","") ;


    dist = 2*ATR(5);
    dist1 = 5*ATR(5);
    for( i = 0; i < BarCount; i++ )
    {
    if( Buy )
    {
    PlotText( "\nBuy:" + L[ i ] + "\nT= " + (L*1.005) + "\nSL= " + (L*0.9975), i, L[ i ]-dist, colorGreen, colorWhite );
    }
    if( Sell )
    {
    PlotText( "Sell:" + H[ i ] + "\nT= " + (H*0.995) + "\nSL= " + (H*1.0025), i, H[ i ]+dist1, colorRed, colorWhite );
    }
    }


    Filter = s OR sss OR sss ;
    AddColumn(C,"close",1.2);
    AddColumn( IIf( s, 66,1 ), "buy", formatChar, 1, bkcolor =IIf (s,colorYellow, colorPink ));
    AddColumn( IIf( Ss, 83,1 ), "sell", formatChar, 1, bkcolor =IIf (Ss,colorPink, colorWhite ));
    AddColumn( IIf( sss, 87,1 ), "wait", formatChar, 1, bkcolor =IIf (sss,colorYellow, colorRed ));


    _SECTION_BEGIN("trend");
    uptrend=PDI(20)>MDI(10)AND Signal(29)<MACD(13);
    downtrend=MDI(10)>PDI(20)AND Signal(29)>MACD(13);
    Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon",
    IIf( uptrend, colorGreen, IIf( downtrend, colorRed, 0 )), /* choose color */
    styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
    _SECTION_END();

    Buy = s AND a AND uptrend ;
    Short = ss AND b AND downtrend ;
    Sell = ss AND b AND downtrend ;
    Cover = s AND a AND uptrend ;

    Buy=ExRem(Buy,Sell);
    Sell=ExRem(Sell,Buy);
    Cover=ExRem(Cover,Short);
    Short=ExRem(Short,Cover);

    Filter=Buy OR Sell;
    Filter= Cover OR Short;

    AddColumn( Buy, "Buy", 1);
    AddColumn(Sell, "Sell", 1);
    AddColumn(Close,"Close",1.2);
    AddColumn(Volume,"Volume",1.0);


    // Plot the Buy and Sell arrows.
    //shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
    //PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-10);
    ///PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-20);
    ///PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-15);
    ///PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=20);
    //PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=30);
    //PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25);

    auto buy.png

     

Chia sẻ trang này

Đang tải...