You can close the command between ''. added in the comments.

if you write ./mpex.sh 'BUY|S.DICE|40000'
you don't need to escape the "|" character.
One only line of code. four pipes. No more temp files