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

