Yes it is described in the User's guide
http://www.amibroker.com/guide/a_custommetrics.html
(see Example 3).
For more help on AFL programming use the forum.amibroker.com