diff --git a/.vscode/vscode-kanban.json b/.vscode/vscode-kanban.json index ca94494d..d92e381a 100644 --- a/.vscode/vscode-kanban.json +++ b/.vscode/vscode-kanban.json @@ -1,6 +1,25 @@ { - "todo": [], + "todo": [ + { + "assignedTo": { + "name": "Hadi Khazaee Asl" + }, + "creation_time": "2025-05-08T10:58:12.985Z", + "id": "7", + "references": [], + "title": "add support for Swings on Block Detection ..." + } + ], "in-progress": [ + { + "assignedTo": { + "name": "Hadi Khazaee Asl" + }, + "creation_time": "2025-05-09T02:09:15.086Z", + "id": "8", + "references": [], + "title": "add support for Multi Time Frame and Multi Symbol" + }, { "assignedTo": { "name": "Hadi Khazaee Asl" @@ -14,19 +33,10 @@ "assignedTo": { "name": "Hadi Khazaee Asl" }, - "creation_time": "2025-05-08T10:58:12.985Z", - "id": "7", + "creation_time": "2025-05-09T02:16:34.743Z", + "id": "9", "references": [], - "title": "add support for Swings on Block Detection ..." - }, - { - "assignedTo": { - "name": "Hadi Khazaee Asl" - }, - "creation_time": "2025-05-08T10:51:12.522Z", - "id": "5", - "references": [], - "title": "add Trade Session Support and Multi Symbol Structure" + "title": "add support for Closing All Trades at Specified Time ..." } ], "testing": [ @@ -72,6 +82,15 @@ "references": [], "title": "Add Support for Daily Max Volume and Ticks Box in XCAEA POI Detector ..." }, + { + "assignedTo": { + "name": "Hadi Khazaee Asl" + }, + "creation_time": "2025-05-08T10:51:12.522Z", + "id": "5", + "references": [], + "title": "add Trade Session Support and Multi Symbol Structure" + }, { "assignedTo": { "name": "Hadi Khazaee Asl" diff --git a/Experts/x-saherelm.xcaea.ea.mq5 b/Experts/x-saherelm.xcaea.ea.mq5 index 67b18e09..a631acc9 100644 --- a/Experts/x-saherelm.xcaea.ea.mq5 +++ b/Experts/x-saherelm.xcaea.ea.mq5 @@ -159,7 +159,7 @@ void OnDeinit(const int reason) // REASON_CLOSE 9 Terminal closed // - // eaSignaller.DeInit(); + eaSignaller.DeInit(); // ZeroMemory(eaAlert); @@ -678,8 +678,15 @@ void InitRequirements() eaTradeManager .SetTradeSession( _Symbol, - "03:00", // Start ... - "20:00", // End ... + "01:30", // Start ... + "14:25", // End ... + "XSaherSession" // Name ... + ); + eaTradeManager + .SetTradeSession( + _Symbol, + "19:30", // Start ... + "11:30", // End ... "XSaherSession" // Name ... ); @@ -687,7 +694,8 @@ void InitRequirements() // EA Signaller ... eaSignaller = new XCXCAEASignaller( _Symbol, - _Period // + _Period, + PERIOD_H1 // Analysing Period ... ); // diff --git a/XCAEA/Classes/xcaea.x-trade.manager.class.mq5 b/XCAEA/Classes/xcaea.x-trade.manager.class.mq5 index 695c21b0..dbe69d0c 100644 --- a/XCAEA/Classes/xcaea.x-trade.manager.class.mq5 +++ b/XCAEA/Classes/xcaea.x-trade.manager.class.mq5 @@ -613,6 +613,10 @@ class XCXCAEATradeManager : public XCBaseAlert allowLongs = true; allowShorts = true; + // + forceCloseAt = NULL; + isForceCloseAtTime = false; + // maxAllowedTPs = 0; maxAllowedSLs = 0; @@ -671,6 +675,14 @@ class XCXCAEATradeManager : public XCBaseAlert mSaveTrades = value; } + // + void SetForceCloseTradesAt( + string _forceCloseAt // + ) + { + forceCloseAt = _forceCloseAt; + } + // void SetTradeSession( string symbol, @@ -955,7 +967,28 @@ class XCXCAEATradeManager : public XCBaseAlert // // Do Collection Protectiong ... - // TODO: Implement this ... + + // + // Check Force Close ... + if (IsValid(forceCloseAt)) + { + // + datetime forceCloseTime = ParseDateTimeFromTimeString(forceCloseAt); + bool canForceClose = IsTimeInRange( + TimeCurrent(), + forceCloseTime // + ) && + !isForceCloseAtTime; + if (canForceClose) + { + // + isForceCloseAtTime = HandleForceCloseTrades(ownPosition); + + // + // Prevent Moving Forward ... + return; + } + } // // Do Signle Protections ... @@ -1224,10 +1257,12 @@ class XCXCAEATradeManager : public XCBaseAlert // // Chack Trade Session Validating ... - if (isSymbolSessionExists) { + if (isSymbolSessionExists) + { // result = sessions[symbolSessionIDX].CanTrade(); - if (!result) { + if (!result) + { // executionResult = X_SIGNAL_EXECUTION_FAILED_DELAY_NOT_PASSED; @@ -1620,6 +1655,44 @@ class XCXCAEATradeManager : public XCBaseAlert RemoveTrade(idx); } + /** + * Handle Force Close Trades ... + */ + bool HandleForceCloseTrades( + XPosition &positions[] // + ) + { + // + bool result = false; + + // + result = HasChild(positions); + if (!result) + { + return result; + } + + // + string prefix = "Protector: "; + string comment = "Force Close ..."; + + // + int closedsCount = trader.Close( + positions, + comment // + ); + result = IsValidSize(closedsCount); + if (result) + { + // + string message = prefix + "Force Close (" + ToString(closedsCount) + ") Trades at Specified Time ..."; + HandleReportProtector(message); + } + + // + return result; + } + // // TODO: Complete this ... void HandleGuard() @@ -2040,6 +2113,13 @@ class XCXCAEATradeManager : public XCBaseAlert bool isNewWeek = timeTracker.IsNewWeek(); bool isNewMonth = timeTracker.IsNewMonth(); + // + // Reset Force Closed Flag on new Day Starts ... + if (isNewDay) + { + isForceCloseAtTime = false; + } + // bool canResetRestrictions = ( @@ -2174,6 +2254,10 @@ class XCXCAEATradeManager : public XCBaseAlert bool allowLongs; bool allowShorts; + // + string forceCloseAt; + bool isForceCloseAtTime; + // int maxAllowedTPs; int maxAllowedSLs; diff --git a/XCAEA/Signals/xcaea.signaller.class.mq5 b/XCAEA/Signals/xcaea.signaller.class.mq5 index fdb9cb61..113df6e8 100644 --- a/XCAEA/Signals/xcaea.signaller.class.mq5 +++ b/XCAEA/Signals/xcaea.signaller.class.mq5 @@ -48,6 +48,7 @@ class XCXCAEASignaller : XCBase XCXCAEAPOIDrawer *drawer; bool continuesRFTillTarget; XBoxZone unAvailableBoxes[]; + XCXCAEAHelper *analyseHelper; XCXCAEAPOIDetector *detector; XCAEAStrategyConditions mConditions; XCAEAStrategyConditions mConditionsCollection[]; @@ -56,12 +57,14 @@ class XCXCAEASignaller : XCBase // Constructor ... XCXCAEASignaller( string _symbol, - ENUM_TIMEFRAMES _period // + ENUM_TIMEFRAMES _period, + ENUM_TIMEFRAMES _analysePeriod // ) { // symbol = _symbol; period = _period; + analysePeriod = _analysePeriod; // Init(); @@ -175,6 +178,15 @@ class XCXCAEASignaller : XCBase inputs // ); + // + // XCAEA Analyse Helper ... + analyseHelper = new XCXCAEAHelper(); + analyseHelper.Init( + symbol, + analysePeriod, + inputs // + ); + // // Initialize and Configure Detector ... detector = new XCXCAEAPOIDetector(helper); @@ -347,6 +359,7 @@ class XCXCAEASignaller : XCBase ZeroMemory(drawer); ZeroMemory(helper); ZeroMemory(detector); + ZeroMemory(analyseHelper); // mConditions.Clean(); @@ -461,6 +474,7 @@ class XCXCAEASignaller : XCBase // // Checking Signal's Decision Zone ... + // On Trigger Time Frame ... hasDecisionZone = DetectDecisionZone( helper, drawer, @@ -471,6 +485,19 @@ class XCXCAEASignaller : XCBase loopback // ); + // + // Checking Signal's Decision Zone ... + // On Analyse Time Frame ... + // hasDecisionZone = DetectDecisionZone( + // helper, + // drawer, + // decisionZone, + // decisionZoneDir, + // conditions, + // zIndex, + // loopback // + // ); + // // Make Signal Box UnAvailable ... if (hasDecisionZone) @@ -891,6 +918,9 @@ class XCXCAEASignaller : XCBase // Props ... string symbol; ENUM_TIMEFRAMES period; + ENUM_TIMEFRAMES analysePeriod; + + // CArrayObj mObjects; CArrayObj mBarObjects;