Compare troughs and peaks through Trade scripts

Dear Frnds, pls help me how to compare two troughs or peaks through the trade scripts in zerodha pi. I am trying to compare the troughs/peaks of my indicator and the troughs/peaks of the price.