Đây là loạt bài Simple and Useful Codes về phần mềm phân tích kỹ thuật AmiBroker

Please post in this thread simple codes which enhance default charts.

As a start, attaching afl which marks the values at highs/lows.

Code:
_SECTION_BEGIN("Show Values at H&L");

n=Param("Values back",20,1,200,1);
p=Param("zig %",5,1,100,1);
dist = 0.8*ATR(15);

for( i = 1; i < n; i++ )
**
PlotText(""+LastValue(Peak(H,p,i),True),BarCount-3-LastValue(PeakBars(H,p,i)),LastValue(dist,True)+La stValue(Peak(H,p,i),False),colorblue,ColorRGB(225, 225,225));
PlotText(""+LastValue(Trough(L,p,i),True),BarCount-3-LastValue(TroughBars(L,p,i)),LastValue(Trough(L,p, i),False)-LastValue(dist,True),colorblue,ColorRGB(225,225,22 5));
}

_SECTION_END();


This code could be useful for scalpers, gives the time left in completion of the current bar (in seconds).
Code:
_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",918,0,1000,1);
y=Param("yposn",586,0,1000,1);

GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
if ( NewPeriod )
**
GfxSelectSolidBrush( colorYellow );
GfxSelectPen( colorYellow, 2 );
Say( "New period" );
}
GfxRoundRect( x+55, y+17, x-4, y-2, 0, 0 );
GfxSetBkMode(1);
GfxSelectFont( "Arial", 9, 700, False );
GfxSetTextColor( colorBlack );
GfxTextOut( ""+SecsToGo+" / "+NumToStr( TimeFrame, 1.0 ), x, y );
_SECTION_END();