Close the order with the largest loss?
-
I want to close the order with the largest loss only if the total profit from profitable trades exceeds that loss. Is there a way to do this?
-
You need a structure calculating that total profit right now and then compare it to each losing one. Both are loops with variables. Are you familiar with variables?
-
I have no knowledge about variables. Could you please give me an example?
-
That is not a trivial thing to do. Do you have any initial project to begin with?
-
@kingvu
For closing the most losable trade, try:

-
-
I want to code an Expert Advisor (EA) based on the following rules:
- If there are no existing positions, open a buy order with a volume of 0.01 lots.
- If there is an existing position and the price decreases by 10 pips, open an additional buy order with a volume of 0.01 lots.
- If there is an existing position and the total account balance is positive by 5 pips, close all open positions.
- If there is an existing position and the total account balance is negative, compare the total profit of positive positions with the largest negative position. If the total profit of positive positions exceeds the largest negative position by 5 pips, close all positive positions and the largest negative position.
My project (I think it's incorrect, but I can't think of an alternative way) : https://fxdreema.com/shared/0kmNYGuFb
-
@kingvu Points 1 and 2 can be achieved this way:
https://fxdreema.com/shared/GlMSZAyE
The total close of trades you designed for point 3 is correct.
