determination of positions' profits

 
Hello. As soon as the sum of my open buying positions reaches $ 100 profit, including all fees, I want to work closeallbuying() void. I was unable to prepare a code that could work for this. I would be very happy if someone could help me.
Reason: