U Trail and Close Part
U Trail and Close Part™ is a fully automated Expert Advisor for managing trades. The following functions are used in the Expert Advisor:
Calculation of risk in a position
- StopLoss - used for calculation of risk in a trade.
- LotFixedUse - only a fixed lot is used.
- LotFixed - fixed lot size.
- RiskMM - percentage of risk in the position. The function is active if the fixed lot is disabled.
Partial profit taking
- PartialOn - enable partial closure (true) by take profit.
- Levels_Part - closure levels (points), each level is set as the number of points from the trade opening price.
- Percents_Part - closure percentage (%), calculated as a percentage of the position volume for each part of the partial closure.
Consider the function of partial position closure on the example of a BUY order (Lot=1.0):
- Levels_Part = "05/10/15/20";
- Percents_Part = "20/40/30/10".
At each Levels_Part level, a part of position specified in Percents_Part is closed:
- The price passed 05 points up - 20% of position volume was closed (Lot=0.20).
- The price passed 10 points up - 40% of position volume was closed (Lot=0.40).
- The price passed 15 points up - 30% of position volume was closed (Lot=0.30).
- The price passed 20 points up - 10% of position volume was closed (Lot=0.10).
Break Even Point
- UseBreakeven - enable transferring positions to breakeven (true).
- BreakevenStep - value of profit to move the Stop Loss to breakeven (points).
- BreakevenPoint - the number of breakeven points from the position opening price (points).
- UseTrailingSimple - enable simple trailing (true).
- TrailingSimpleStop - simple trailing start (points).
- TrailingSimpleStep - simple trailing step (points).
- UseTrailingVirtual - allow virtual trailing.
- Levels_Virtual - position closure levels (points).
- Percents_Virtual - order closure percentage (%).
- TrailingVirtualStep - the minimum trailing step (points).
- UseDelayVirtual - allow the delay of virtual trailing.
- DistDelayVirtual - delay for the virtual trailing (points).
Virtual trailing - each movement of the levels, responsible for a certain part of the position, does not modify the stop loss value of the position itself (function for managing the first BUY and the first SELL orders simultaneously).
Consider the process of virtual order management with partial closure on the example of a BUY order.
- Levels_Virtual = "15/25/45";
- Percents_Virtual = "40/30/30".
When opening the position, the levels are plotted below the order's Open price at the distances set in Levels_Virtual. At each level, a part of position specified in Percents_Virtual is closed.
- An order is opened.
- The levels arrange below the order Open price at the distance: level (1) - 15 points, (2) - 25 points, (3) - 45 points.
- The price moves up and all levels follow the price. The price reverses and starts moving down. The levels remain in place.
- The price crosses the first level. 40% of the position is closed (1).
- If the price moves further down and breaks the level (2), 30% of the position is closed.
- The price moves up again and the remaining level follows it. If the price reverses, starts moving down and crosses the third level (3) - 30% of the position is closed.
- Thus, all 100% of the position volume are closed.
Trailing based on the ZigZag indicator
- UseTrailingZigZag - trailing of stop loss for the structure (ZigZag).
- xExtDepthL - period of the ZigZag of the structure.
- xExtDeviationL - the number of points between extremes (in %).
- xExtBackstepL - the minimum number of candles between all extremes.
- Magic - magic number of positions.
- Slippage - slippage.
- Language (English/Russian) - language to display the messages.
- Comment_EA - display information on the screen (true).
- UseSound - enable sounds.
- clModifyBuy - color of modification of Buy positions.
- clModifySell - color of modification of Sell positions.