How to execute code on both sides of trade?


Here is the query:
Suppose I want to create Supertrend Algo for NIFTY F&O for both sides LONG as well as SHORT, then how to do that ?
If I create two different Algos with One as LONG and other as SHORT, how it will work ?
I mean when LONG Trade executed, and after sometime if SHORT Conditions also get matched and if I SHORT that trade as well, will it be squared off with my PREVIOUS NIFTY LONG ? Or it will just throw the DIFFERENT ORDER ?

Please explain anyone about this TWO SIDE ALOGS ,



You might want to backtest this idea thoroughly. If you enter into self trades (by employing different brokers for the two legs of your strategy or by using trading accounts in separate names with your broker) then that will land you into largely avoidable regulatory trouble.