2026-02-15 05:13:55 +00:00 | | | #ifndef TRADE_EXECUTION_MQH
|
| | | #define TRADE_EXECUTION_MQH
|
| | |
|
| | | #include "AISignalConfirmation.mqh"
|
2026-02-27 21:49:28 -06:00 | | | #include "NNDataLogger.mqh"
|
2026-02-15 05:13:55 +00:00 | | |
|
| | | void UpdateLastTradeInfo(const string direction);
|
| | |
|
| | | bool IsInCooldown()
|
| | | {
|
EA: sync live build (Jul-Nov 2026) — trade report direction/setup fix, VZ indicators, risk modules
- AIGateway/profitgtx: report_trade takes direction and setup from the position's
opening deal ("dir_src":"entry"); the closing deal inverted every direction and
restarts lost the setup (99% "auto")
- add MATheory, RiskGuards, RiskSizing, TradePolicy (setup blocklist, strict AI gate)
- add VZ_Core + VZ_Features/MFIB/Regime/Setups/Sessions indicators, VZ_FeaturesExport
service, VZ_DumpMA, VZ_TogglePause
- margin-aware sizing, news, labels and session updates since 2026-07-14
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:48:22 -06:00 | | | if(g_reentry_attempt && ReEntry_Bypass_Cooldown)
|
| | | return false; // re-entries pace themselves with ReEntry_Cooldown
|
2026-02-15 05:13:55 +00:00 | | | datetime now = TimeCurrent();
|
| | | return (now - Last_Trade_Time < Trade_Cooldown_Seconds);
|
| | | }
|
| | |
|
EA: sync live build (Jul-Nov 2026) — trade report direction/setup fix, VZ indicators, risk modules
- AIGateway/profitgtx: report_trade takes direction and setup from the position's
opening deal ("dir_src":"entry"); the closing deal inverted every direction and
restarts lost the setup (99% "auto")
- add MATheory, RiskGuards, RiskSizing, TradePolicy (setup blocklist, strict AI gate)
- add VZ_Core + VZ_Features/MFIB/Regime/Setups/Sessions indicators, VZ_FeaturesExport
service, VZ_DumpMA, VZ_TogglePause
- margin-aware sizing, news, labels and session updates since 2026-07-14
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:48:22 -06:00 | | | // ATR(14) expressed in points, for volatility-scaled stops. 0 if ATR not ready.
|
| | | double ATRPoints()
|
| | | {
|
| | | if(Current_ATR <= 0.0 || _Point <= 0.0) return 0.0;
|
| | | return Current_ATR / _Point;
|
| | | }
|
| | |
|
2026-02-15 05:13:55 +00:00 | | | int CountOpenTradesForSymbol()
|
| | | {
|
| | | int count = 0;
|
| | | for(int i = PositionsTotal() - 1; i >= 0; --i)
|
| | | {
|
| | | ulong ticket = PositionGetTicket(i);
|
| | | if(ticket == 0 || !PositionSelectByTicket(ticket))
|
| | | continue;
|
| | |
|
| | | if(PositionGetString(POSITION_SYMBOL) == _Symbol && PositionGetInteger(POSITION_MAGIC) == MagicNumber)
|
| | | count++;
|
| | | }
|
| | | return count;
|
| | | }
|
| | |
|
2026-02-27 21:49:28 -06:00 | | | // ── Base gate: cooldown + position cap ──────────────────────────────────────
|
| | | // News direction checks live in OpenBuy / OpenSell so each side can be gated
|
| | | // independently (e.g., news is bullish → OpenBuy passes, OpenSell blocked).
|
2026-02-15 05:13:55 +00:00 | | | bool CanOpenNewTrade()
|
| | | {
|
EA: sync live build (Jul-Nov 2026) — trade report direction/setup fix, VZ indicators, risk modules
- AIGateway/profitgtx: report_trade takes direction and setup from the position's
opening deal ("dir_src":"entry"); the closing deal inverted every direction and
restarts lost the setup (99% "auto")
- add MATheory, RiskGuards, RiskSizing, TradePolicy (setup blocklist, strict AI gate)
- add VZ_Core + VZ_Features/MFIB/Regime/Setups/Sessions indicators, VZ_FeaturesExport
service, VZ_DumpMA, VZ_TogglePause
- margin-aware sizing, news, labels and session updates since 2026-07-14
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:48:22 -06:00 | | | if(!RiskGuardsAllowEntry()) // hours / ADX / daily loss / daily cap (RiskGuards.mqh)
|
| | | return false;
|
| | |
|
2026-02-15 05:13:55 +00:00 | | | if(IsInCooldown())
|
| | | return false;
|
| | |
|
| | | if(CountOpenTradesForSymbol() >= Max_Open_Trades)
|
| | | return false;
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
2026-07-14 16:19:12 -05:00 | | | // Broker's minimum SL/TP distance in points. SL of a buy is measured against
|
| | | // Bid while entry is Ask (and vice versa for sells), so the spread has to be
|
| | | // added on top of SYMBOL_TRADE_STOPS_LEVEL or tight stops still bounce with
|
| | | // "invalid stops".
|
| | | int MinStopPoints()
|
| | | {
|
| | | int stops_level = (int)SymbolInfoInteger(_Symbol, SYMBOL_TRADE_STOPS_LEVEL);
|
| | | int spread = (int)SymbolInfoInteger(_Symbol, SYMBOL_SPREAD);
|
| | | return stops_level + spread + 1;
|
| | | }
|
| | |
|
2026-02-15 05:13:55 +00:00 | | | int GetSLPoints(const bool continuation)
|
| | | {
|
2026-07-14 16:19:12 -05:00 | | | int pts;
|
EA: sync live build (Jul-Nov 2026) — trade report direction/setup fix, VZ indicators, risk modules
- AIGateway/profitgtx: report_trade takes direction and setup from the position's
opening deal ("dir_src":"entry"); the closing deal inverted every direction and
restarts lost the setup (99% "auto")
- add MATheory, RiskGuards, RiskSizing, TradePolicy (setup blocklist, strict AI gate)
- add VZ_Core + VZ_Features/MFIB/Regime/Setups/Sessions indicators, VZ_FeaturesExport
service, VZ_DumpMA, VZ_TogglePause
- margin-aware sizing, news, labels and session updates since 2026-07-14
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:48:22 -06:00 | | | if(Use_ATR_Exits && ATRPoints() > 0.0)
|
| | | return MathMax((int)(ATRPoints() * SL_ATR_Mult), MinStopPoints());
|
2026-02-15 05:13:55 +00:00 | | | if(Symbol_Profile_Initialized)
|
2026-07-14 16:19:12 -05:00 | | | pts = continuation ? Symbol_SL_Points : MathMax(20, Symbol_SL_Points / 2);
|
| | | else
|
| | | pts = continuation ? Continuation_SL_Points : Counter_SL_Points;
|
| | | return MathMax(pts, MinStopPoints());
|
2026-02-15 05:13:55 +00:00 | | | }
|
| | |
|
| | | int GetTPPoints(const bool continuation)
|
| | | {
|
2026-07-14 16:19:12 -05:00 | | | int pts;
|
EA: sync live build (Jul-Nov 2026) — trade report direction/setup fix, VZ indicators, risk modules
- AIGateway/profitgtx: report_trade takes direction and setup from the position's
opening deal ("dir_src":"entry"); the closing deal inverted every direction and
restarts lost the setup (99% "auto")
- add MATheory, RiskGuards, RiskSizing, TradePolicy (setup blocklist, strict AI gate)
- add VZ_Core + VZ_Features/MFIB/Regime/Setups/Sessions indicators, VZ_FeaturesExport
service, VZ_DumpMA, VZ_TogglePause
- margin-aware sizing, news, labels and session updates since 2026-07-14
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:48:22 -06:00 | | | if(Use_ATR_Exits && ATRPoints() > 0.0)
|
| | | return MathMax((int)(ATRPoints() * TP_ATR_Mult), MinStopPoints());
|
2026-02-15 05:13:55 +00:00 | | | if(Symbol_Profile_Initialized)
|
2026-07-14 16:19:12 -05:00 | | | pts = continuation ? Symbol_TP_Points : MathMax(80, (int)((double)Symbol_TP_Points * 0.85));
|
| | | else
|
| | | pts = continuation ? Continuation_TP_Points : Counter_TP_Points;
|
| | | return MathMax(pts, MinStopPoints());
|
2026-02-15 05:13:55 +00:00 | | | }
|
| | |
|
EA: sync live build (Jul-Nov 2026) — trade report direction/setup fix, VZ indicators, risk modules
- AIGateway/profitgtx: report_trade takes direction and setup from the position's
opening deal ("dir_src":"entry"); the closing deal inverted every direction and
restarts lost the setup (99% "auto")
- add MATheory, RiskGuards, RiskSizing, TradePolicy (setup blocklist, strict AI gate)
- add VZ_Core + VZ_Features/MFIB/Regime/Setups/Sessions indicators, VZ_FeaturesExport
service, VZ_DumpMA, VZ_TogglePause
- margin-aware sizing, news, labels and session updates since 2026-07-14
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:48:22 -06:00 | | | double MAT_SizeMult(); // MATheory.mqh
|
| | |
|
2026-02-15 05:13:55 +00:00 | | | double BuildLotMultiplier()
|
| | | {
|
| | | double mult = 1.0;
|
| | |
|
EA: sync live build (Jul-Nov 2026) — trade report direction/setup fix, VZ indicators, risk modules
- AIGateway/profitgtx: report_trade takes direction and setup from the position's
opening deal ("dir_src":"entry"); the closing deal inverted every direction and
restarts lost the setup (99% "auto")
- add MATheory, RiskGuards, RiskSizing, TradePolicy (setup blocklist, strict AI gate)
- add VZ_Core + VZ_Features/MFIB/Regime/Setups/Sessions indicators, VZ_FeaturesExport
service, VZ_DumpMA, VZ_TogglePause
- margin-aware sizing, news, labels and session updates since 2026-07-14
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:48:22 -06:00 | | | // Under the MA theory size follows the momentum score, not praise counts / War_Survivor.
|
| | | if(Use_MA_Theory)
|
| | | {
|
| | | mult = MAT_SizeMult();
|
| | | if(Use_Signal_Coordinator) mult *= Coordinator_Lot_Multiplier;
|
| | | return mult;
|
| | | }
|
| | |
|
2026-02-15 05:13:55 +00:00 | | | if(Active_Praise_Signals >= 4)
|
| | | mult *= 2.0;
|
| | | else if(Active_Praise_Signals == 3)
|
| | | mult *= 1.5;
|
| | |
|
| | | if(Active_Warnings >= 3)
|
| | | mult *= 0.5;
|
| | |
|
| | | if(Current_State == STATE_CONTINUATION)
|
| | | mult *= War_Survivor_Lot_Multiplier;
|
| | |
|
| | | if(Use_Signal_Coordinator)
|
| | | mult *= Coordinator_Lot_Multiplier;
|
| | |
|
| | | return mult;
|
| | | }
|
| | |
|
| | | bool OpenBuy(const string reason, double lot_multiplier = 1.0)
|
| | | {
|
| | | if(!CanOpenNewTrade())
|
| | | return false;
|
| | |
|
EA: sync live build (Jul-Nov 2026) — trade report direction/setup fix, VZ indicators, risk modules
- AIGateway/profitgtx: report_trade takes direction and setup from the position's
opening deal ("dir_src":"entry"); the closing deal inverted every direction and
restarts lost the setup (99% "auto")
- add MATheory, RiskGuards, RiskSizing, TradePolicy (setup blocklist, strict AI gate)
- add VZ_Core + VZ_Features/MFIB/Regime/Setups/Sessions indicators, VZ_FeaturesExport
service, VZ_DumpMA, VZ_TogglePause
- margin-aware sizing, news, labels and session updates since 2026-07-14
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:48:22 -06:00 | | | // Trade policy: only setups the trade log shows an edge for (see TradePolicy.mqh)
|
| | | if(!SetupAllowedByPolicy(reason, true))
|
| | | return false;
|
2026-11-09 02:30:20 -06:00 | | | if(!RG_SideAllowed(true, reason)) // v7.20 stacking guards (RiskGuards.mqh)
|
| | | return false;
|
| | | lot_multiplier *= SetupProbationMult(reason); // v7.20 probation (TradePolicy.mqh)
|
EA: sync live build (Jul-Nov 2026) — trade report direction/setup fix, VZ indicators, risk modules
- AIGateway/profitgtx: report_trade takes direction and setup from the position's
opening deal ("dir_src":"entry"); the closing deal inverted every direction and
restarts lost the setup (99% "auto")
- add MATheory, RiskGuards, RiskSizing, TradePolicy (setup blocklist, strict AI gate)
- add VZ_Core + VZ_Features/MFIB/Regime/Setups/Sessions indicators, VZ_FeaturesExport
service, VZ_DumpMA, VZ_TogglePause
- margin-aware sizing, news, labels and session updates since 2026-07-14
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:48:22 -06:00 | | |
|
2026-02-27 21:49:28 -06:00 | | | // Hard news block (no clear directional bias)
|
| | | if(News_Trade_Block_Active)
|
| | | return false;
|
| | |
|
| | | // News directional gate — only sell-only sessions block buys
|
| | | if(News_Trade_Allowed_Direction == -1)
|
| | | return false;
|
| | |
|
2026-02-15 05:13:55 +00:00 | | | bool continuation = (Current_Mode == MODE_TRENDING && Current_State == STATE_CONTINUATION);
|
| | | double entry = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
|
| | | int sl_pts = GetSLPoints(continuation);
|
| | | int tp_pts = GetTPPoints(continuation);
|
| | |
|
EA: sync live build (Jul-Nov 2026) — trade report direction/setup fix, VZ indicators, risk modules
- AIGateway/profitgtx: report_trade takes direction and setup from the position's
opening deal ("dir_src":"entry"); the closing deal inverted every direction and
restarts lost the setup (99% "auto")
- add MATheory, RiskGuards, RiskSizing, TradePolicy (setup blocklist, strict AI gate)
- add VZ_Core + VZ_Features/MFIB/Regime/Setups/Sessions indicators, VZ_FeaturesExport
service, VZ_DumpMA, VZ_TogglePause
- margin-aware sizing, news, labels and session updates since 2026-07-14
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:48:22 -06:00 | | | // Size and margin-check BEFORE asking the AI: an entry we cannot afford must not cost a gateway
|
| | | // call per tick (2026-09-17: 240 accepted verdicts in 11 min all died on margin).
|
| | | double base_mult = lot_multiplier * BuildLotMultiplier();
|
| | | if(!RiskFitStop(true, entry, sl_pts, tp_pts, reason)) return false; // tighten the stop to the cap if the min lot is too big
|
| | | double pre_lots = (Lot_Sizing_Mode == LOTS_RISK_PERCENT) ? RiskSizedLots(true, entry, sl_pts, base_mult, reason)
|
| | | : NormalizeLots(BaseLotSize * base_mult);
|
| | | if(pre_lots <= 0.0) return false; // RiskSizedLots journaled why
|
| | | if(FitLotsToMargin(true, pre_lots, entry) <= 0.0)
|
| | | {
|
| | | static datetime last_margin_note = 0;
|
| | | if(TimeCurrent() - last_margin_note >= 60)
|
| | | {
|
| | | Print("OpenBuy skipped: free margin ", DoubleToString(AccountInfoDouble(ACCOUNT_MARGIN_FREE), 2),
|
| | | " cannot cover the minimum lot for ", _Symbol, " (", reason, ")");
|
| | | last_margin_note = TimeCurrent();
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | double ai_mult = 1.0;
|
| | | if(!AIApproveTrade(true, reason, ai_mult))
|
| | | return false;
|
| | |
|
| | | double lots = pre_lots;
|
| | | if(MathAbs(ai_mult - 1.0) > 0.001)
|
| | | {
|
| | | double mult = base_mult * ai_mult;
|
| | | lots = (Lot_Sizing_Mode == LOTS_RISK_PERCENT) ? RiskSizedLots(true, entry, sl_pts, mult, reason)
|
| | | : NormalizeLots(BaseLotSize * mult);
|
| | | if(lots <= 0.0) return false;
|
| | | }
|
2026-07-14 16:19:12 -05:00 | | | lots = FitLotsToMargin(true, lots, entry);
|
| | | if(lots <= 0.0)
|
| | | {
|
| | | Print("OpenBuy skipped: free margin cannot cover the minimum lot for ", _Symbol);
|
| | | return false;
|
| | | }
|
| | |
|
2026-02-27 21:49:28 -06:00 | | | double sl = NormalizePrice(entry - (sl_pts * _Point));
|
| | | double tp = NormalizePrice(entry + (tp_pts * _Point));
|
2026-02-15 05:13:55 +00:00 | | |
|
| | | bool ok = Trade.Buy(lots, _Symbol, 0.0, sl, tp, reason);
|
| | | if(ok)
|
| | | {
|
| | | Last_Trade_Time = TimeCurrent();
|
| | | UpdateLastTradeInfo("bullish");
|
| | | TodayTrades++;
|
| | | BuyTrades++;
|
2026-02-27 21:49:28 -06:00 | | |
|
| | | // Capture feature snapshot for NN training (labeled when trade closes via NN_LabelFromDeal)
|
| | | if(NN_LogData)
|
| | | {
|
| | | ulong d = Trade.ResultDeal();
|
| | | if(d > 0 && HistoryDealSelect(d))
|
| | | {
|
| | | ulong pos_id = (ulong)HistoryDealGetInteger(d, DEAL_POSITION_ID);
|
| | | int cat = (Current_State == STATE_CONTINUATION) ? 0 : 1;
|
| | | NN_CaptureEntry(pos_id, true, reason,
|
| | | Coordinator_Cluster_Strength, Coordinator_Conflict_Score, cat);
|
| | | }
|
| | | }
|
2026-02-15 05:13:55 +00:00 | | | }
|
| | | return ok;
|
| | | }
|
| | |
|
| | | bool OpenSell(const string reason, double lot_multiplier = 1.0)
|
| | | {
|
| | | if(!CanOpenNewTrade())
|
| | | return false;
|
| | |
|
EA: sync live build (Jul-Nov 2026) — trade report direction/setup fix, VZ indicators, risk modules
- AIGateway/profitgtx: report_trade takes direction and setup from the position's
opening deal ("dir_src":"entry"); the closing deal inverted every direction and
restarts lost the setup (99% "auto")
- add MATheory, RiskGuards, RiskSizing, TradePolicy (setup blocklist, strict AI gate)
- add VZ_Core + VZ_Features/MFIB/Regime/Setups/Sessions indicators, VZ_FeaturesExport
service, VZ_DumpMA, VZ_TogglePause
- margin-aware sizing, news, labels and session updates since 2026-07-14
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:48:22 -06:00 | | | // Trade policy: only setups the trade log shows an edge for (see TradePolicy.mqh)
|
| | | if(!SetupAllowedByPolicy(reason, false))
|
| | | return false;
|
2026-11-09 02:30:20 -06:00 | | | if(!RG_SideAllowed(false, reason)) // v7.20 stacking guards (RiskGuards.mqh)
|
| | | return false;
|
| | | lot_multiplier *= SetupProbationMult(reason); // v7.20 probation (TradePolicy.mqh)
|
EA: sync live build (Jul-Nov 2026) — trade report direction/setup fix, VZ indicators, risk modules
- AIGateway/profitgtx: report_trade takes direction and setup from the position's
opening deal ("dir_src":"entry"); the closing deal inverted every direction and
restarts lost the setup (99% "auto")
- add MATheory, RiskGuards, RiskSizing, TradePolicy (setup blocklist, strict AI gate)
- add VZ_Core + VZ_Features/MFIB/Regime/Setups/Sessions indicators, VZ_FeaturesExport
service, VZ_DumpMA, VZ_TogglePause
- margin-aware sizing, news, labels and session updates since 2026-07-14
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:48:22 -06:00 | | |
|
2026-02-27 21:49:28 -06:00 | | | // Hard news block (no clear directional bias)
|
| | | if(News_Trade_Block_Active)
|
| | | return false;
|
| | |
|
| | | // News directional gate — only buy-only sessions block sells
|
| | | if(News_Trade_Allowed_Direction == 1)
|
| | | return false;
|
| | |
|
2026-02-15 05:13:55 +00:00 | | | bool continuation = (Current_Mode == MODE_TRENDING && Current_State == STATE_CONTINUATION);
|
| | | double entry = SymbolInfoDouble(_Symbol, SYMBOL_BID);
|
| | | int sl_pts = GetSLPoints(continuation);
|
| | | int tp_pts = GetTPPoints(continuation);
|
| | |
|
EA: sync live build (Jul-Nov 2026) — trade report direction/setup fix, VZ indicators, risk modules
- AIGateway/profitgtx: report_trade takes direction and setup from the position's
opening deal ("dir_src":"entry"); the closing deal inverted every direction and
restarts lost the setup (99% "auto")
- add MATheory, RiskGuards, RiskSizing, TradePolicy (setup blocklist, strict AI gate)
- add VZ_Core + VZ_Features/MFIB/Regime/Setups/Sessions indicators, VZ_FeaturesExport
service, VZ_DumpMA, VZ_TogglePause
- margin-aware sizing, news, labels and session updates since 2026-07-14
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 13:48:22 -06:00 | | | // Size and margin-check BEFORE asking the AI: an entry we cannot afford must not cost a gateway
|
| | | // call per tick (2026-09-17: 240 accepted verdicts in 11 min all died on margin).
|
| | | double base_mult = lot_multiplier * BuildLotMultiplier();
|
| | | if(!RiskFitStop(false, entry, sl_pts, tp_pts, reason)) return false; // tighten the stop to the cap if the min lot is too big
|
| | | double pre_lots = (Lot_Sizing_Mode == LOTS_RISK_PERCENT) ? RiskSizedLots(false, entry, sl_pts, base_mult, reason)
|
| | | : NormalizeLots(BaseLotSize * base_mult);
|
| | | if(pre_lots <= 0.0) return false; // RiskSizedLots journaled why
|
| | | if(FitLotsToMargin(false, pre_lots, entry) <= 0.0)
|
| | | {
|
| | | static datetime last_margin_note = 0;
|
| | | if(TimeCurrent() - last_margin_note >= 60)
|
| | | {
|
| | | Print("OpenSell skipped: free margin ", DoubleToString(AccountInfoDouble(ACCOUNT_MARGIN_FREE), 2),
|
| | | " cannot cover the minimum lot for ", _Symbol, " (", reason, ")");
|
| | | last_margin_note = TimeCurrent();
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | double ai_mult = 1.0;
|
| | | if(!AIApproveTrade(false, reason, ai_mult))
|
| | | return false;
|
| | |
|
| | | double lots = pre_lots;
|
| | | if(MathAbs(ai_mult - 1.0) > 0.001)
|
| | | {
|
| | | double mult = base_mult * ai_mult;
|
| | | lots = (Lot_Sizing_Mode == LOTS_RISK_PERCENT) ? RiskSizedLots(false, entry, sl_pts, mult, reason)
|
| | | : NormalizeLots(BaseLotSize * mult);
|
| | | if(lots <= 0.0) return false;
|
| | | }
|
2026-07-14 16:19:12 -05:00 | | | lots = FitLotsToMargin(false, lots, entry);
|
| | | if(lots <= 0.0)
|
| | | {
|
| | | Print("OpenSell skipped: free margin cannot cover the minimum lot for ", _Symbol);
|
| | | return false;
|
| | | }
|
| | |
|
2026-02-27 21:49:28 -06:00 | | | double sl = NormalizePrice(entry + (sl_pts * _Point));
|
| | | double tp = NormalizePrice(entry - (tp_pts * _Point));
|
2026-02-15 05:13:55 +00:00 | | |
|
| | | bool ok = Trade.Sell(lots, _Symbol, 0.0, sl, tp, reason);
|
| | | if(ok)
|
| | | {
|
| | | Last_Trade_Time = TimeCurrent();
|
| | | UpdateLastTradeInfo("bearish");
|
| | | TodayTrades++;
|
| | | SellTrades++;
|
2026-02-27 21:49:28 -06:00 | | |
|
| | | // Capture feature snapshot for NN training (labeled when trade closes via NN_LabelFromDeal)
|
| | | if(NN_LogData)
|
| | | {
|
| | | ulong d = Trade.ResultDeal();
|
| | | if(d > 0 && HistoryDealSelect(d))
|
| | | {
|
| | | ulong pos_id = (ulong)HistoryDealGetInteger(d, DEAL_POSITION_ID);
|
| | | int cat = (Current_State == STATE_CONTINUATION) ? 0 : 1;
|
| | | NN_CaptureEntry(pos_id, false, reason,
|
| | | Coordinator_Cluster_Strength, Coordinator_Conflict_Score, cat);
|
| | | }
|
| | | }
|
2026-02-15 05:13:55 +00:00 | | | }
|
| | | return ok;
|
| | | }
|
| | |
|
| | | #endif
|