TTI (trend intensity index) indicator

How can I define or implement a TTI (trend intensity index) indicator inside the algo?