How can I store the profit of any current open trade in variables?
-
I need to store the profit of a trade in a variable, but I have multiple trades. I give an example: I have 5 open buy trades, and I need to take the profits (or loss) of the oldest trade and the most recent trade, and store those values in two different variables. In my example, if I have 5 buy trades, I want to store in variables the profits of trade number 1 (the oldest) and trade number 5 (the most recent). I can't figure out how to do it. Can somebody help me?
-
@guille4 not sure why you want to store the values of profit with open trades. If your trying to get profit/loss of current trades. You can use the unrealized block.
If not sure if this is what your trying to do but if your trying to close positions when it reaches a certain amount while already having positions that had closed due to sl/tp. In that case you cant use the above block. This is what i use and works well for me.
-
@guille4 Do you only need the oldest and the most recent or there can be other combinations?
-
I need store just the oldest and just the newest profit (or loss) of a group of trades (buy or sells).
-
@l-andorrà I need store just the oldest and just the newest profit (or loss) of a group of trades (buy or sells).
-
@guille4 You can do it this way:

-
@l-andorrà muchas gracias andorrano, funcionó perfecto !!
-
@guille4 No hay de qué. Fué un placer.
