There are several ways to generate a triangle wave in EJS.

I would suggest you draw a triangle wave in a piece of paper.
Then draw similar segments with java code.

If you want to do it in EJS:
You can define x,y array to represent (x,y) coordinate for triangle wave.
Use a loop to assign correct value for triangle wave (several segment of line)
then assign x,y to polygon GUI element to draw it.