Manual Trade Management — Click & Forget

9. Manual Trade Management — Click & Forget

Inp_Manage_Manual_Trades = true

One of the most practical features of the system. The trader can open a position MANUALLY (Magic Number = 0) and the EA immediately takes full management control:

  • ✅ Virtual Stop Loss (emergency %-based cut)
  • ✅ Profit Lock (aggressive trailing near TP)
  • ✅ TSL Bollinger Bands (trailing SL)
  • ✅ Hard Break-Even (SL moved to BE)
  • ✅ Virtual Negative Break-Even
  • ✅ Dynamic Take Profit (TP extension)
  • ✅ EOD Terminator (end-of-day close)
  • ✅ Equity Trailing Lock

Philosophy: The trader decides on the entry (direction, level) — the EA manages the risk. Perfect for discretionary trading supported by automatic protection.

Account Protection — System Level

8. Account Protection — System Level

Daily Loss Hard Limit

If daily P/L drops below -(Inp_Daily_Loss_HardLimit)% of balance:
  → g_DailyLossReached = true
  → ALL new orders blocked for the rest of the day
  → Existing positions continue to be managed

Default: 4% of balance.

Drawdown Freeze

If current drawdown > Inp_Drawdown_FreezeLimit%:
  → g_DrawdownFreeze = true
  → New orders frozen

Default: 0.5% (very conservative, ideal for prop firm challenges).

Daily Target Profit

If daily P/L > +Inp_Daily_Target_Profit%:
  → g_DailyTargetReached = true
  → Trading stopped — profit is secured

Default: 15% — after reaching the target, the system shuts itself down for the day.

Equity Trailing Lock (Master)

An equity protection mechanism operating at the account level:

If equity rises by >= Inp_Equity_TSL_Trigger%:
  → Sets an "equity high watermark"
  → If equity drops below (high - Inp_Equity_TSL_Buffer%):
     → Closes ALL positions immediately

Default: Trigger 5%, Buffer 0.2%. Protects against losing a large intraday gain.

Position Management — Protection Layers

7. Position Management — Protection Layers

ManageAllPositions() executes on EVERY tick for every open position. Protection layers are applied in a strict priority order.

Layer 0: Virtual Stop Loss (Highest Priority — Emergency Cut)

This is not an SL sent to the broker — it is an internal loss-level monitor:

active_cap = base_capital (depending on mode)
pos_profit = profit + swap + commission
max_loss   = active_cap × Inp_Virtual_SL_Percent / 100

If |pos_profit| >= max_loss → immediate position close

Log: "VIRTUAL SL HIT! Position #123 loss (-45.23) exceeded 4.00% of Active Capital (1132.50). Closing immediately."

This safeguard acts as the last line of defence against a catastrophic loss, regardless of spread, slippage or broker conditions.

Layer 0.5: Profit Lock (Aggressive Trailing Near TP)

Activates when price approaches TP within Inp_E_PL_Trigger_Points (500 pts):

  • Enables an aggressive trailing SL based on Inp_E_PL_TSL_Points (200 pts) from the current price
  • SL only moves in the direction of profit (ratchet — never backwards)
  • Protects accumulated profit just before TP is hit

Log: "Position #123: PROFIT LOCK Activated!"

Layer 1: Physical TSL BB (Bollinger Band Trailing SL)

A two-phase mechanism:

  • Phase 1: Standard Hard SL sent to the broker at the time of opening
  • Phase 2: Activates when profit_in_points >= Inp_E_ProfitToActivateBB (1,500 pts)

Once Phase 2 is active:

  • BUY: SL = MAX(BB_Lower, open_price + floor_dist) — follows the lower BB band (never below open + floor)
  • SELL: SL = MIN(BB_Upper, open_price - floor_dist) — follows the upper BB band

TSL BB has higher priority than Hard BE — once Phase 2 is active, Hard BE is ignored.

Log: "Position #123 entered Phase 2 (TSL BB)."

Layer 2: Hard Break-Even (Classic BE)

Moves the physical SL to (or above) the entry price when profit reaches Inp_HardBE_Trigger_Points (200 pts):

BUY:  new_SL = open_price + (Inp_HardBE_Level_Points × _Point)   // e.g. +100 pts
SELL: new_SL = open_price - (Inp_HardBE_Level_Points × _Point)

SL is only moved in the direction of profit. Once activated, the flag is_breakeven1_set = true — Hard BE is never repeated.

Log: "Position #123: Hard Break-Even set at +100 pts."

Layer 3: Virtual Negative Break-Even

An innovative mechanism that allows a position to „breathe” after achieving a significant profit:

  1. After reaching Inp_NegBE_Trigger_Points (5,000 pts) profit → activates is_breakeven2_set = true
  2. If the position retraces to Inp_NegBE_Level_Points (e.g. −3,000 pts) → position is closed
  3. Active only when Hard BE has NOT yet been set

Rationale: the position achieved a large profit (5,000 pts), so the system „allows” it to retrace to −3,000 pts before closing it. This dramatically reduces the number of prematurely exited trends.

Log: "Position #123: Virtual Negative BE Activated." → "Position #123: Closed by Virtual Negative BE."

Dynamic Take Profit (TP Extension on Strong Trend)

When price approaches TP within Inp_E_PL_Trigger_Points:

  1. Checks the BB (using a separate, wider deviation of Inp_E_BB_TP_Deviation = 3.0)
  2. If price breaches the outer BB band (strong trend confirmed!) → TP is pushed further by Inp_E_TP_Extension_Points (500 pts)
  3. Can be extended multiple times — no limit on the number of extensions

Log: "Position #123: Dynamic TP Extended by 500 points!"

Obsługa manualna — Click & Forget

9. Obsługa manualna — Click & Forget

Inp_Manage_Manual_Trades = true

To jedna z najbardziej praktycznych funkcji. Trader może otworzyć pozycję RĘCZNIE (Magic Number = 0) i EA natychmiast przejmuje nad nią pełną kontrolę:

  • ✅ Virtual Stop Loss (awaryjne cięcie %-owe)
  • ✅ Profit Lock (agresywne trailing przy TP)
  • ✅ TSL Bollinger Bands (trailing SL)
  • ✅ Hard Break-Even (przeniesienie SL na BE)
  • ✅ Virtual Negative Break-Even
  • ✅ Dynamic Take Profit (rozszerzanie TP)
  • ✅ EOD Terminator (zamknięcie na koniec dnia)
  • ✅ Equity Trailing Lock

Filozofia: Trader decyduje o wejściu (kierunek, poziom) — EA zarządza ryzykiem. Idealny do tradingu dyskrecjonalnego wspieranego automatyczną ochroną.

Zarządzanie pozycjami — warstwy ochrony

7. Zarządzanie pozycjami — warstwy ochrony

ManagePositions() wykonuje się na KAŻDYM ticku dla każdej otwartej pozycji. Warstwy ochrony są stosowane w ściśle określonej kolejności priorytetów.

Warstwa 0: Virtual Stop Loss (najwyższy priorytet — awaryjne cięcie)

Nie jest to SL wysłany do brokera — to wewnętrzna kontrola poziomu straty:

active_cap = base_capital (zależnie od trybu)
pos_profit = zysk + swap + prowizja
max_loss = active_cap × Inp_Virtual_SL_Percent / 100

Jeśli |pos_profit| >= max_loss → natychmiastowe zamknięcie pozycji

Log: "VIRTUAL SL HIT! Position #123 loss (-45.23) exceeded 4.00% of Active Capital (1132.50). Closing immediately."

To zabezpieczenie działa jako ostatnia linia obrony przed katastroficzną stratą, niezależnie od spreadu, poślizgu czy warunków brokera.

Warstwa 0.5: Profit Lock (agresywne trailing bliskie TP)

Aktywuje się gdy cena zbliży się do TP na odległość Inp_E_PL_Trigger_Points (500 pkt):

  • Włącza agresywny trailing SL oparty o Inp_E_PL_TSL_Points (200 pkt) od aktualnej ceny
  • SL przesuwa się tylko w kierunku zysku (ratchet — nigdy wstecz)
  • Chroni wypracowany zysk tuż przed osiągnięciem TP

Log: "Position #123: PROFIT LOCK Activated!"

Warstwa 1: Physical TSL BB (Bollinger Band Trailing SL)

Dwufazowy mechanizm:

  • Faza 1: Standard Hard SL wysłany do brokera przy otwarciu
  • Faza 2: Aktywuje się gdy profit_in_points >= Inp_E_ProfitToActivateBB (1500 pkt)

Po wejściu w Fazę 2:

  • BUY: SL = MAX(BB_Lower, open_price + floor_dist) — podąża za dolnym pasmem BB (nigdy poniżej otwarcia + podłoga)
  • SELL: SL = MIN(BB_Upper, open_price - floor_dist) — podąża za górnym pasmem BB

BB TSL ma wyższy priorytet niż Hard BE — gdy Faza 2 aktywna, Hard BE jest ignorowane.

Log: "Position #123 entered Phase 2 (TSL BB)."

Warstwa 2: Hard Break-Even (klasyczny BE)

Przenosi fizyczny SL do (lub powyżej) ceny otwarcia gdy zysk osiągnie Inp_HardBE_Trigger_Points (200 pkt):

BUY: new_SL = open_price + (Inp_HardBE_Level_Points × _Point)  // np. +100 pkt
SELL: new_SL = open_price - (Inp_HardBE_Level_Points × _Point)

SL jest przesuwany tylko w kierunku zysku. Po jednorazowej aktywacji flaga is_breakeven1_set = true — Hard BE nie jest powtarzany.

Log: "Position #123: Hard Break-Even set at +100 pts."

Warstwa 3: Virtual Negative Break-Even

Innowacyjny mechanizm pozwalający pozycji „oddychać” po osiągnięciu pewnego zysku:

  1. Po osiągnięciu Inp_NegBE_Trigger_Points (5000 pkt) zysku → aktywuje się is_breakeven2_set = true
  2. Jeśli pozycja cofnie się do poziomu Inp_NegBE_Level_Points (np. -3000 pkt) → pozycja jest zamykana
  3. Działa wyłącznie gdy Hard BE NIE jest jeszcze ustawiony

Sens: pozycja osiągnęła duży zysk (5000 pkt), system „pozwala” jej wrócić do -3000 pkt zanim ją zatnie. Drastycznie zmniejsza liczbę przedwcześnie zamkniętych trendów.

Log: "Position #123: Virtual Negative BE Activated." → "Position #123: Closed by Virtual Negative BE."

Dynamic Take Profit (rozszerzanie TP przy silnym trendzie)

Gdy cena zbliży się do TP na Inp_E_PL_Trigger_Points:

  1. Sprawdza BB (z osobnym szerszym odchyleniem Inp_E_BB_TP_Deviation = 3.0)
  2. Jeśli cena przebija zewnętrzne pasmo BB (silny trend!) → TP jest przesuwany dalej o Inp_E_TP_Extension_Points (500 pkt)
  3. Można wielokrotnie rozszerzać — bez limitu liczby rozszerzeń

Log: "Position #123: Dynamic TP Extended by 500 points!"