Showing posts with label AFL CODE- DOUBLE TOP & DOUBLE BOTTOM. Show all posts
Showing posts with label AFL CODE- DOUBLE TOP & DOUBLE BOTTOM. Show all posts

Friday, October 11, 2024

AFL CODE- DOUBLE TOP & DOUBLE BOTTOM

_SECTION_BEGIN("DBDT");

GraphXSpace = 5;

SetChartBkColor( colorBlack );

SetChartOptions( 1, chartShowDates, chartGridMiddle, 0, 0, 0 );

SetChartOptions(0,chartShowArrows|chartShowDates);

SetBarFillColor( IIf( C > O, ColorRGB( 0, 75, 0 ), IIf( C <= O, ColorRGB( 75, 0, 0 ), colorLightGrey ) ) );

 

_SECTION_BEGIN("Title");

DODay = TimeFrameGetPrice("O", inDaily);

DHiDay = TimeFrameGetPrice("H", inDaily);

DLoDay = TimeFrameGetPrice("L", inDaily);

Title = EncodeColor(colorWhite)+  Name() + ", " + EncodeColor(colorGold)+ Interval(2) + ", " + EncodeColor(colorAqua)+Date() + EncodeColor(colorWhite)+"  -  " +

EncodeColor(colorYellow)   + "Vol: "+ WriteVal(V) +

EncodeColor(colorBlue)   +  "   Open: " + EncodeColor(colorWhite) + O +

EncodeColor(colorRed)+ "   High: "   +EncodeColor(colorWhite) + H +

EncodeColor(colorBrightGreen)+ "   Low: " +EncodeColor(colorWhite) + L +

EncodeColor(colorTeal) +"   Close: "  + EncodeColor(colorWhite) +C +

EncodeColor(colorBlue)+ "  Day-Open: " +DODay + EncodeColor(colorBrightGreen)+"  Day-High: " +DHiDay +EncodeColor(colorRed)+ "  Day-Low: " + DLoDay;

_SECTION_END();

 

Plot( C, "", IIf( C > O, ColorRGB( 0, 255, 0 ), IIf( C <= O, ColorRGB( 255, 0, 0 ), colorLightGrey ) ), 64, Null, Null, 0, 0, 1 );

 

// Fractal Pivots, E.M.Pottasch 2/2018

bi = BarIndex();

fvb = FirstVisibleValue( bi );

lvb = LastVisibleValue( bi );

 

rightstrength = Param( "Right Strength", 5, 1, 50, 1 );

leftstrength = Param( "Left Strength", 5, 1, 50, 1 );

fact = Param( "Chart Time Frame Factor", 1, 1, 10, 1 );

 

rightStrength = rightStrength * fact;

leftStrength = leftStrength * fact;

 

pk = H == HHV( H, leftstrength ) AND Ref( HHV( H, rightstrength ), rightstrength ) < H;

tr = L == LLV( L, leftstrength ) AND Ref( LLV( L, rightstrength ), rightstrength ) > L;

pkl = H == HHV( H, leftstrength );

trl = L == LLV( L, leftstrength );

 

for( i = 0; i < 3; i++ )

{

    VarSet( "px" + i, ValueWhen( pk, bi, i ) );

    VarSet( "tx" + i, ValueWhen( tr, bi, i ) );

    VarSet( "ph" + i, ValueWhen( pk, H, i ) );

    VarSet( "tl" + i, ValueWhen( tr, L, i ) );

}

 

ll = tr AND tl1 < tl2;

hl = tr AND tl1 > tl2;

hh = pk AND ph1 > ph2;

lh = pk AND ph1 < ph2;

dt = pk AND ph1 == ph2;

db = tr AND tl1 == tl2;

 

PlotShapes( shapeSmallCircle * trl, colorGreen, 0, L, -10 );

PlotShapes( shapeSmallCircle * pkl, colorRed, 0, H, 10 );

PlotShapes( shapeSmallCircle * tr, colorBrightGreen, 0, L, -10 );

PlotShapes( shapeSmallCircle * pk, colorOrange, 0, H, 10 );

 

doubleTopThreshold = 0.75 * Ref( ATR( 20 ), -1 );

doubleTop = pk && abs( ph1 - ph2 ) < doubleTopThreshold;

 

doubleBottomThreshold = 0.75 * Ref( ATR( 20 ), -1 );

doubleBottom = tr && abs( tl1 - tl2 ) < doubleBottomThreshold;

 

for( i = lvb; i > fvb; i-- )

{

    sz = 8;

 

    // troughs

    if( ll[i] )

    {

        str = "LL";

        PlotTextSetFont( str, "Arial Black", sz, i, L[i], ColorRGB( 0, 250, 0 ), colorDefault, -30 );

    }

 

    if( hl[i] )

    {

        str = "HL";

        PlotTextSetFont( str, "Arial Black", sz, i, L[i], ColorRGB( 0, 250, 0 ), colorDefault, -30 );

    }

 

    if( db[i] )

    {

        str = "DB";

        PlotTextSetFont( str, "Arial Black", sz, i, L[i], ColorRGB( 0, 250, 0 ), colorDefault, -30 );

    }

 

    //peaks

    if( hh[i] )

    {

        str = "HH";

        PlotTextSetFont( str, "Arial Black", sz, i, H[i], ColorRGB( 250, 0, 0 ), colorDefault, 20 );

    }

 

    if( lh[i] )

    {

        str = "LH";

        PlotTextSetFont( str, "Arial Black", sz, i, H[i], ColorRGB( 250, 0, 0 ), colorDefault, 20 );

    }

 

    if( dt[i] )

    {

        str = "DT";

        PlotTextSetFont( str, "Arial Black", sz, i, H[i], ColorRGB( 250, 0, 0 ), colorDefault, 20 );

    }

 

    if( doubleTop[i] )

    {

        str = "Double Top";

        PlotTextSetFont( str, "Arial Black", sz, i, H[i], ColorRGB( 250, 125, 0 ), colorDefault, 40 );

    }

     

     if( doubleBottom[i] )

    {

        str = "Double Bottom";

        PlotTextSetFont( str, "Arial Black", sz, i, L[i], ColorRGB( 250, 125, 0 ), colorDefault, -40 );

    }

     

}


Buy = tr;

Sell = pk;

 

PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), colorGreen, layer = 0, L); 

PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), colorRed, layer = 0, H);

 

writeif( highest( doubleTop ) == 1, "\nAmiBroker has detected some possible Double Top patterns for " + name() + "\n\nLook for TAG on the price chart.", "\n\nThere are no double top patterns for " + name() );

writeif( highest( doubleBottom ) == 1, "\n\nAmiBroker has detected some possible Double Bottom patterns for " + name() + "\n\nLook for TAG on the price chart.", "\nThere are no double top patterns for " + name() );


Filter = doubleTop OR doubleBottom OR HH OR HL OR LH OR LL; 

SetOption( "NoDefaultColumns", True );

AddColumn( DateTimeConvert(2,DateNum(),Null), "NGAY LOC CP", formatDateTime );

AddtextColumn(MarketID(1),"SAN GD"); AddtextColumn(Name(),"Ma CP",1.2); 


AddColumn( Close, "Close" );

AddColumn( ROC(Close,1), "%Change",1.2,IIf(ROC(Close,1)>0,colorBrightGreen,IIf(ROC(Close,1)<0,colorRed,colorBlack)));

AddColumn(V,"Volume",1.0,IIf(V>=Ref(V,-1),colorGreen,colorred));

AddColumn(V*Aux1,"Value",1.0,IIf(Aux1*V >= Ref(Aux1,-1)*Ref(V,-1),colorGreen,colorred));

AddTextColumn(WriteIf(doubleTop,"Double Top",WriteIf(doubleBottom,"Double Bottom",WriteIf(HH,"HH",WriteIf(LH,"LH",WriteIf(HL,"HL",WriteIf(LL,"LL","")))))),

"Top / Bottom",1.0, IIf(doubleTop,colorRed,IIf(doubleBottom,colorGreen,colorBlack)));

SetSortColumns(-6);

_SECTION_END();

👉Tải tại đây

https://drive.google.com/file/d/1TxtXvm22H_rhhvWYC8F8C9V7U1KbkJaw/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