Question on CNC intraday

After @nithin pointed out the use of showing positions of sold CNC demat trade i tried today. But one main question

Let us say i have 0 balance in my account to start with morning. Now i sold TCS at 2085 x 10 quantities.

Later using that 20850 full margin i bought mphasis trade

What happened then was TCS was going down and it showed profit in my positions
And emphasis was going down and it was shown as loss in my position

But TCS profit was more as it reached 2075 . now as i used entire TCS sold value to buy emphasis first i had to square off emphasis and book loss. Get back my margin and then buy back TCS to book profit

Is this the only way if a person uses his morning sold value to enter another position? Someone pls clarify