How to get stoploss signal?

After I increase my position, I want to close all positions when the first order stops losing. How to obtain a stop loss signal?
Please show your attempt if you want coding help.