Variables
-
I Just Realized how helpful the variables could be .
i am trying to get the loss of last closed trade into pips and save it into a variable, but i cant find any block or setting to do that.
i am not using the stoploss to close the trade , trade can be closed after a condition, or it could be closed manually , so what i am trying to do is whenever the trade is closed the loss (in pips) is saved into a variable for further reference .
thanks. -
-
@zackry Here:https://fxdreema.com/shared/Wfvtkbn6e
Note the OnTrade tab
-
@roar thank you very much I am gonna try this, thanks again
-
@roar hello bro
its not working i tried a lot variations as well but still not luck -
Not tested

-
@josecortesllobat thank you bro
this method is working and its holding the loss in pips in a variable
i tried to use the variable in the new trade's takeprofit but the ea is not placing any tp
Take a look:
https://fxdreema.com/shared/zdkeP492b -
Hi @Zackry
As you mentioned, what I suggested works so I guess the variable "los" should be a negative value.

Could you confirm that?
If it is a negative value, I would say that you can´t set a negative value as a Take Profit. It does not make sense. But, if this is the case (trying to set a negative value for TP), you just need to convert the negative value into positive. You can do it by using:
-
a MQL code block with MathAbs function
-
the adjust field with "*(-1)" [without quotes] in the Take Profit pane on the Sell/Buy blocks
-
storing the pips lost directly in positive
....
-
-
@josecortesllobat thanks bro
really appreciate your help -
@josecortesllobat is it possible to keep the loss in variable without using the stoploss?
here is what i mean let say ea open a buy trade and if that trade goes to negative the it should keep updating the variable with the most current amount of loss (in pips) , again i am not talking about the stoploos calculation or the calculation after the trade is closed , i am talking about the trade that is running currently and hasnt been closed . -
This might be a starting point

Each time P/L is below LossPips, LossPips will be updated to the new value.
-
@josecortesllobat thanks bro, I will give it a go