Version 1.1 2025.10.14
Update Report – EA “Auto SL TP By Risk”

1. Fixed Hide/Show Lines Button

Issue: HIDE / SHOW LINES button was not functioning correctly; SL/TP lines remained visible even after hiding.

Update:

ToggleLinesVisibility() function updated to delete SL/TP lines and texts when hidden.

Lines are recreated when the button is toggled to show.

SL/TP texts (SL_Text_Name & TP_Text_Name) are also removed when hiding.

Added LinesVisible variable to track visibility status.

2. Chart Event Button Handling Fix

Issue: Button clicks were sometimes ignored or processed multiple times.

Update:

OnChartEvent() refined to handle clicks for all buttons (BUY, SELL, CLOSE ALL, HIDE/SHOW LINES, LOCK) reliably.

LOCK button now toggles status correctly and updates its text to “LOCKED” when active.

3. SL/TP Line Logic Improvement

Issue: TP line did not always update correctly based on SL.

Update:

UpdateTPLine() ensures TP is calculated correctly using SL_FrozenPrice and RiskRewardRatio.

RefreshSLTP() improved to create SL/TP lines initially using either frozen price or ATR if SL is not yet set.

4. Modify Open Positions

Issue: Open positions’ SL/TP were not updated accurately.

Update:

ModifyOpenPositionsSLTP() now:

Skips positions opened before EA started (RobotStartTime).

Calculates new SL/TP based on RiskPerTrade and RiskRewardRatio.

Sends TRADE_ACTION_SLTP request only if the difference is significant.

5. Locking Positions Feature

Issue: Lock sometimes failed; SL/TP not removed after locking.

Update:

LockPositions() opens counter positions with the correct lot size.

RemoveSLTPFromPositions() runs after locking to remove all SL/TP from open positions.

EA automatically stops after locking (ExpertRemove()).

6. OnDeinit / Object Clean-up

Issue: Removing the EA only deleted SL/TP lines; buttons, labels, and edit boxes remained on chart.

Update:

OnDeinit() updated to remove all EA-created objects:

SL/TP lines and texts

Buttons (BUY, SELL, CLOSE ALL, HIDE/SHOW, LOCK)

Labels and edit boxes (Risk & RR)

Timer is stopped (EventKillTimer()).

7. Minor Fixes

Added validation for SL too close to entry price.

Adjusted button and label positions for a cleaner UI.

Alerts and notifications improved for clarity.


Final Result:

- All buttons function correctly.

- Hide/Show SL/TP lines works perfectly.

- SL/TP lines always update according to risk management.

- Lock positions feature is safe and clears SL/TP.

- All EA objects are automatically removed when the EA is removed from the chart.