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

Bollinger Band ZigZag Indicator 4 for Amibroker

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

  1. 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
    Giới thiệu Bollinger Band , code khá hay mình tình cờ sưu tầm được

    ---------------------------------------------------------------------------------------------------------------------------------------
    _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("Bollinger Band ZigZag Indicator");
    function ParamOptimize( description, defaultVal, minv, maxv, step )
    {
    return Optimize(description, Param(description,defaultVal, minv, maxv, step ), minv, maxv, step );
    }

    BlankBars = 10; // Set to the number set in preferences

    Buy = Sell = Short = Cover = Pos = 0;
    Periods = ParamOptimize( "Periods", 3, 3, 30, 1 );
    Width = ParamOptimize( "Width", 1, 0, 5, 0.1 );
    BBTOp = BBandTop( H, Periods, Width ); // Note H is used instead of the tradional C
    BBBot = BBandBot( L, Periods, Width ); // Note L is used instead of the tradional C

    Plot( BBTop, "BBTop", colorBlue, styleLine );
    Plot( BBBOt, "BBBot", colorBlue, styleLine );
    Plot( C, "", 1, 128 );

    BI = BarIndex();
    start = Status( "firstvisiblebarindex" ) - BI[0] - BlankBars;
    end = Status( "lastvisiblebarindex" ) - BI[0] - BlankBars;
    LBI = LastValue( BarIndex() );

    for ( b = LBI; b > Periods; b-- )
    {
    if ( L <= BBBot AND pos <= 0 )
    {
    pos = 1;
    Buy = True;
    BuyPrice = BBBot;
    }
    else
    if ( H >= BBTop AND Pos >= 0 )
    {
    Pos = -1;
    Sell = True;
    SellPrice = BBTop;
    }
    }

    Short = Sell;
    ShortPrice = SellPrice;

    Cover = Buy;
    CoverPrice = BuyPrice;

    Eq = Equity( 1 );

    if ( ParamToggle( "Equity", "HIDE|SHOW", 0 ) )
    Plot( Eq, "", colorYellow, 1 | styleOwnScale );

    ShowTriangles = ParamToggle( "Arrows", "HIDE|SHOW", 1 );

    if ( showTriangles )
    {
    PlotShapes( IIf( Buy, shapeSmallUpTriangle, shapeNone ), 5, 0, BuyPrice, 0 );
    PlotShapes( IIf( Sell, shapeHollowDownTriangle, shapeNone ), 4, 0, SellPrice, 0 );
    PlotShapes( IIf( Cover, shapeHollowUpTriangle, shapeNone ), 5, 0, CoverPrice, 0 );
    PlotShapes( IIf( Short, shapeSmallDownTriangle, shapeNone ), 4, 0, ShortPrice, 0 );
    }

    if ( ParamToggle( "Trade Lines", "HIDE|SHOW", 0 ) )
    {
    Sig = Buy OR Short;
    signum = Cum( Sig );
    y0 = 0;
    y1 = C[0];
    TPrice = C;
    Shortcolor = LongColor = colorWhite;

    for ( b = start ;b < end ;b++ )
    {
    if ( Sig )
    {
    x0 = y0;
    x1 = y1;
    y0 = b;

    if ( Buy )
    {
    y1 = BuyPrice;
    Color = Shortcolor;
    }
    else
    if ( Short )
    {
    y1 = ShortPrice;
    Color = Longcolor;
    }

    if( SigNum > 1 ) Plot( LineArray( x0, x1, y0, y1 ), "", Color, 1 | styleThick );
    }
    }
    }
    _SECTION_END(); Bollinger Band ZigZag Indicator 4 for Amibroker.png
     

Chia sẻ trang này

Đang tải...