If you want to define, modify and check some variable, there are many examples here and there. The other thing - to control each trade by itself... well, things are going to be creative here.
I was thinking about this problem and I still don't know the best answer. The problem comes from the fact that we can't store much custom information for trades and orders, and this information to be available from everywhere. Let's say that we can use the "Comment" attribute to store some information, but the problem here is that the comment is limited to something like 32 symbols. We can store information in variables, but it's lost when the EA is removed. We can store information in files, but then how will EAs fight for it, and file access is generally slow. We can store information in graphical objects, but such an object exists in a single chart only.