Advanced TP SL Control
- Utilità
- SERGUEI PROKHOROV
- Versione: 1.0
- Attivazioni: 20
Overview
This expert advisor (EA) monitors open positions and closes them based on the total floating profit or loss per symbol. It allows both global and symbol-specific configurations to control risk or lock in profits automatically.
Core Functionality
-
Tracks total floating P/L (profit or loss) per symbol in account currency.
-
Automatically closes positions if a defined threshold is reached.
-
Fully customizable per symbol via the CustomizedSettings string.
Input Parameters
-
GlobalTakeLoss (double)
Defines a global profit/loss threshold in account currency.
Positive values → Close when total profit reaches this amount.
Negative values → Close when total loss exceeds this amount.
Set to 0 to use per-symbol settings from CustomizedSettings . -
GlobalOrderDirection (enum)
Filters which direction of trades are counted:-
Buy
-
Sell
-
BuyAndSell (default)
-
-
ProfitLossAllOrders (enum)
Filters which trades are counted:-
OnlyProfitPositions
-
OnlyLossPositions
-
ProfitAndLossPositions (default)
-
-
ConcernedMode (enum)
Defines what to close when the threshold is reached:-
AllOrders : closes all trades for the symbol
-
ConcernedOrders : closes only those trades that were used in the calculation
-
-
CustomizedSettings (string)
Format: "SYMBOL,DIRECTION,PL_FILTER,CONCERNED_FLAG,THRESHOLD;"
Example: "EURUSD,B,L,C,-50.0;XAUUSD,S,P,A,100.0;"-
DIRECTION : B = Buy, S = Sell, A = BuyAndSell
-
PL_FILTER : P = OnlyProfit, L = OnlyLoss, X = ProfitAndLoss
-
CONCERNED_FLAG : C = ConcernedOrders, A = AllOrders
-
THRESHOLD : Profit/loss threshold in account currency
-
-
Ping (int)
Interval in seconds to refresh and evaluate orders.
How It Works
-
Every Ping seconds, EA evaluates orders.
-
Calculates total P/L for each symbol based on filters.
-
If threshold is reached, it closes the defined trades (all or concerned).
-
On chart, current P/L is shown in green (profit) or red (loss).
