You could try is thisthis, however it seems to me you are looking for Custom transform orientations.
In your situation:
Select the triangle object and enter edit mode (↹ Tab)
Select the edge along which you want the custom Z axis to be aligned and press ⎈ Ctrl⎇ AltSpace
This should create a custom orientation and set it as the current orientation. You can switch orientations in the Header or the properties region (N) of the 3D view. In the properties region you can also delete unwanted orientations.
Note that to clamp a transform operation (translate, rotate, scale) to the axes defined by the custom transform orientation, you must press the axis key twice (e.g. GZZ).