Getting all SL values
-
I am trying to get the combined SL value of all running trades into a variable, I have an indicator that will display values on the line, unfortunately though the value(s) aren't in a buffer, also I cannot upload it here at the moment.
@roar do you have a way of inserting this into custom code?
-
Is the SL in points, money or level? Average level?
In any case, I would loop through the trades and sum the SLs
-
@roar Money looping through seems right, how would I get this value to loop through and add?
-
@jstap getting the sum of pips would be easy, but money amounts requires conversion from pips to money using the lot size and tick value data...
https://fxdreema.com/shared/V105Q7kPd
Something like this, I didn't test it. I just tried to reverse the "risk % of equity" SL calculations in the Buy Now block.

-
@roar Thank you, Ill test this and see what happens.
-
@roar Well I have to say you are a genius, I have tried to do this myself, but never quite managed it...and in 3 blocks:)
The result did need *100 to be correct value, all good though.
-
@roar Could you help me? I have added code to what you have done, it now uses - numbers and + numbers, for some reason though it only works correctly for sells, have a look and see if I have done something wrong. I have tried many different combination's but the result is the same.
-
@jstap why use negative values? I'm not sure how the sum of all values now behaves
-
@roar Negative values so when cost of hitting SL is a loss, but the 1st trade is positive, the total value is the actual sum, so if in multiple trades, you could switch all off but know that regardless total trades are in a positive state, or switch off and on trail knowing all is good.
When I have a minute I'll convert to MT5.
-
@roar As I am sure you are aware, this uses market info, so converting to m5 is not simple
(probably the main reason why I don't use).In here is the completed project: https://fxdreema.com/shared/3rOqOH3ve, I had to strip back and create separate for buys and sells, before adding the values together.
Hope people find this useful.