{"id":172,"date":"2026-04-23T08:09:10","date_gmt":"2026-04-23T06:09:10","guid":{"rendered":"https:\/\/strony.info\/AdaptiveHybridSystem\/?p=172"},"modified":"2026-04-26T11:28:09","modified_gmt":"2026-04-26T09:28:09","slug":"position-management-protection-layers","status":"publish","type":"post","link":"https:\/\/strony.info\/AdaptiveHybridSystem\/2026\/04\/23\/position-management-protection-layers\/","title":{"rendered":"Position Management \u2014 Protection Layers"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"management\">7. Position Management \u2014 Protection Layers<\/h2>\n\n\n\n<p><code>ManageAllPositions()<\/code>&nbsp;executes on EVERY tick for every open position. Protection layers are applied in a strict priority order.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Layer 0: Virtual Stop Loss (Highest Priority \u2014 Emergency Cut)<\/h3>\n\n\n\n<p>This is not an SL sent to the broker \u2014 it is an internal loss-level monitor:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>active_cap = base_capital (depending on mode)\npos_profit = profit + swap + commission\nmax_loss   = active_cap \u00d7 Inp_Virtual_SL_Percent \/ 100\n\nIf |pos_profit| &gt;= max_loss \u2192 immediate position close<\/code><\/pre>\n\n\n\n<p><strong>Log:<\/strong>&nbsp;<code>\"VIRTUAL SL HIT! Position #123 loss (-45.23) exceeded 4.00% of Active Capital (1132.50). Closing immediately.\"<\/code><\/p>\n\n\n\n<p>This safeguard acts as the last line of defence against a catastrophic loss, regardless of spread, slippage or broker conditions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Layer 0.5: Profit Lock (Aggressive Trailing Near TP)<\/h3>\n\n\n\n<p>Activates when price approaches TP within&nbsp;<code>Inp_E_PL_Trigger_Points<\/code>&nbsp;(500 pts):<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Enables an aggressive trailing SL based on\u00a0<code>Inp_E_PL_TSL_Points<\/code>\u00a0(200 pts) from the current price<\/li>\n\n\n\n<li>SL only moves in the direction of profit (ratchet \u2014 never backwards)<\/li>\n\n\n\n<li>Protects accumulated profit just before TP is hit<\/li>\n<\/ul>\n\n\n\n<p><strong>Log:<\/strong>&nbsp;<code>\"Position #123: PROFIT LOCK Activated!\"<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Layer 1: Physical TSL BB (Bollinger Band Trailing SL)<\/h3>\n\n\n\n<p>A two-phase mechanism:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Phase 1:<\/strong>\u00a0Standard Hard SL sent to the broker at the time of opening<\/li>\n\n\n\n<li><strong>Phase 2:<\/strong>\u00a0Activates when\u00a0<code>profit_in_points >= Inp_E_ProfitToActivateBB<\/code>\u00a0(1,500 pts)<\/li>\n<\/ul>\n\n\n\n<p>Once Phase 2 is active:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>BUY: SL =\u00a0<code>MAX(BB_Lower, open_price + floor_dist)<\/code>\u00a0\u2014 follows the lower BB band (never below open + floor)<\/li>\n\n\n\n<li>SELL: SL =\u00a0<code>MIN(BB_Upper, open_price - floor_dist)<\/code>\u00a0\u2014 follows the upper BB band<\/li>\n<\/ul>\n\n\n\n<p>TSL BB has higher priority than Hard BE \u2014 once Phase 2 is active, Hard BE is ignored.<\/p>\n\n\n\n<p><strong>Log:<\/strong>&nbsp;<code>\"Position #123 entered Phase 2 (TSL BB).\"<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Layer 2: Hard Break-Even (Classic BE)<\/h3>\n\n\n\n<p>Moves the physical SL to (or above) the entry price when profit reaches&nbsp;<code>Inp_HardBE_Trigger_Points<\/code>&nbsp;(200 pts):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>BUY:  new_SL = open_price + (Inp_HardBE_Level_Points \u00d7 _Point)   \/\/ e.g. +100 pts\nSELL: new_SL = open_price - (Inp_HardBE_Level_Points \u00d7 _Point)<\/code><\/pre>\n\n\n\n<p>SL is only moved in the direction of profit. Once activated, the flag&nbsp;<code>is_breakeven1_set = true<\/code>&nbsp;\u2014 Hard BE is never repeated.<\/p>\n\n\n\n<p><strong>Log:<\/strong>&nbsp;<code>\"Position #123: Hard Break-Even set at +100 pts.\"<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Layer 3: Virtual Negative Break-Even<\/h3>\n\n\n\n<p>An innovative mechanism that allows a position to \u201ebreathe\u201d after achieving a significant profit:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>After reaching\u00a0<code>Inp_NegBE_Trigger_Points<\/code>\u00a0(5,000 pts) profit \u2192 activates\u00a0<code>is_breakeven2_set = true<\/code><\/li>\n\n\n\n<li><strong>If the position retraces to\u00a0<code>Inp_NegBE_Level_Points<\/code>\u00a0(e.g. \u22123,000 pts)<\/strong>\u00a0\u2192 position is closed<\/li>\n\n\n\n<li>Active only when Hard BE has NOT yet been set<\/li>\n<\/ol>\n\n\n\n<p>Rationale: the position achieved a large profit (5,000 pts), so the system \u201eallows\u201d it to retrace to \u22123,000 pts before closing it. This dramatically reduces the number of prematurely exited trends.<\/p>\n\n\n\n<p><strong>Log:<\/strong>&nbsp;<code>\"Position #123: Virtual Negative BE Activated.\"<\/code>&nbsp;\u2192&nbsp;<code>\"Position #123: Closed by Virtual Negative BE.\"<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Dynamic Take Profit (TP Extension on Strong Trend)<\/h3>\n\n\n\n<p>When price approaches TP within&nbsp;<code>Inp_E_PL_Trigger_Points<\/code>:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Checks the BB (using a separate, wider deviation of\u00a0<code>Inp_E_BB_TP_Deviation = 3.0<\/code>)<\/li>\n\n\n\n<li>If price breaches the outer BB band (strong trend confirmed!) \u2192 TP is\u00a0<strong>pushed further<\/strong>\u00a0by\u00a0<code>Inp_E_TP_Extension_Points<\/code>\u00a0(500 pts)<\/li>\n\n\n\n<li>Can be extended multiple times \u2014 no limit on the number of extensions<\/li>\n<\/ol>\n\n\n\n<p><strong>Log:<\/strong>&nbsp;<code>\"Position #123: Dynamic TP Extended by 500 points!\"<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>7. Position Management \u2014 Protection Layers ManageAllPositions()&nbsp;executes on EVERY tick for every open position. Protection layers are applied in a strict priority order. Layer 0: Virtual Stop Loss (Highest Priority \u2014 Emergency Cut) This is not an SL sent to the broker \u2014 it is an internal loss-level monitor: Log:&nbsp;&#8220;VIRTUAL SL HIT! Position #123 loss &hellip; <a href=\"https:\/\/strony.info\/AdaptiveHybridSystem\/2026\/04\/23\/position-management-protection-layers\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Position Management \u2014 Protection Layers<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[7,292,124,120,343,123,275,119,11,12,344,267,117,346,342,345,341,340,116,122,114],"class_list":["post-172","post","type-post","status-publish","format-standard","hentry","category-en","tag-adaptivehybridsystem","tag-algorithmictrading","tag-bollingerbandstsl","tag-breakeven","tag-capitalprotection","tag-dynamictakeprofit","tag-en","tag-hardbreakeven","tag-metatrader5","tag-mql5","tag-ordermanagement","tag-positionmanagement","tag-profitlock","tag-riskcontrolsystem","tag-risklayers","tag-tickbasedexecution","tag-tpexpansion","tag-tradeprotection","tag-trailingstop","tag-virtualnegativebreakeven","tag-virtualstoploss"],"_links":{"self":[{"href":"https:\/\/strony.info\/AdaptiveHybridSystem\/wp-json\/wp\/v2\/posts\/172","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/strony.info\/AdaptiveHybridSystem\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/strony.info\/AdaptiveHybridSystem\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/strony.info\/AdaptiveHybridSystem\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/strony.info\/AdaptiveHybridSystem\/wp-json\/wp\/v2\/comments?post=172"}],"version-history":[{"count":1,"href":"https:\/\/strony.info\/AdaptiveHybridSystem\/wp-json\/wp\/v2\/posts\/172\/revisions"}],"predecessor-version":[{"id":286,"href":"https:\/\/strony.info\/AdaptiveHybridSystem\/wp-json\/wp\/v2\/posts\/172\/revisions\/286"}],"wp:attachment":[{"href":"https:\/\/strony.info\/AdaptiveHybridSystem\/wp-json\/wp\/v2\/media?parent=172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/strony.info\/AdaptiveHybridSystem\/wp-json\/wp\/v2\/categories?post=172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/strony.info\/AdaptiveHybridSystem\/wp-json\/wp\/v2\/tags?post=172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}