diff --git a/Classes/x-saherelm.x-alert.class.mq5 b/Classes/x-saherelm.x-alert.class.mq5 index 4c06900e..c918a562 100644 --- a/Classes/x-saherelm.x-alert.class.mq5 +++ b/Classes/x-saherelm.x-alert.class.mq5 @@ -86,9 +86,7 @@ class XCAlert : public XCBase return GetSpecificToken(this); } - // - // Properties Getter(s) / Setter(s) ... - + // #region Properties Getter(s) / Setter(s) ... // string GetPrefix() { @@ -174,16 +172,16 @@ class XCAlert : public XCBase { mTerminalAlerts = value; } + // #endregion - // - // Tools Funtions ... + // #region Tools Funtions ... // // Alerts ... // // Logging an Alert ... - void LogAlert(string message) + void LogAlert(string message, bool save = true) { // // Validate Args ... @@ -194,15 +192,20 @@ class XCAlert : public XCBase // message = PrepareMessage(message); - + // Log(message); - Save(message); + + // + if (save) + { + Save(message); + } } // // Terminal Alert ... - void TerminalAlert(string message) + void TerminalAlert(string message, bool save = true) { // // Validate Args ... @@ -217,12 +220,17 @@ class XCAlert : public XCBase // Send Terminal Alert ... Alert(message); - Save(message); + + // + if (save) + { + Save(message); + } } // // Mail Alert ... - void MailAlert(string message) + void MailAlert(string message, bool save = true) { // // Validate Args ... @@ -234,12 +242,17 @@ class XCAlert : public XCBase // // Send Mail Alert ... SendMail(GetPrefix(), message); - Save(message); + + // + if (save) + { + Save(message); + } } // // Send Push Notification ... - void PushAlert(string message) + void PushAlert(string message, bool save = true) { // // Validate Args ... @@ -255,7 +268,12 @@ class XCAlert : public XCBase // // Send Push Notification Alert ... SendNotification(message); - Save(message); + + // + if (save) + { + Save(message); + } } // @@ -265,19 +283,25 @@ class XCAlert : public XCBase { // // Handle Log, if Enabled ... - LogAlert(message); + LogAlert(message, false); // // Handle Mail if Enabled ... - MailAlert(message); + MailAlert(message, false); // // Handle Push if Enabled ... - PushAlert(message); + PushAlert(message, false); // // Handle Terminal if Enabled ... - TerminalAlert(message); + TerminalAlert(message, false); + + // + if (GetEnableAlerts()) + { + Save(message); + } } // @@ -1314,6 +1338,7 @@ class XCAlert : public XCBase // return result; } + // #endregion // // Protected ... @@ -1380,7 +1405,8 @@ class XCAlert : public XCBase } // - string filePath = collector.GetFilePath("XLogs"); + string fileName = mPrefix + "." + "XLogs"; + string filePath = collector.GetFilePath(fileName); if (!IsValid(filePath)) { return; diff --git a/Documents/Boards/common.kanban b/Documents/Boards/common.kanban index dc803bb5..69aaf323 100644 --- a/Documents/Boards/common.kanban +++ b/Documents/Boards/common.kanban @@ -38,7 +38,7 @@ { "id": "2f40c757-baa3-40b1-a804-853c78fae93e", "title": "XCAlert", - "checked": false + "checked": true }, { "id": "03287c82-52da-4084-be05-9ddead05f3c2", @@ -63,7 +63,7 @@ { "id": "f618df8d-5d6c-4b4d-a6e1-b2f550a77509", "title": "XCDataCollector", - "checked": false + "checked": true }, { "id": "9aea1e42-e9c9-4efd-85a8-3930335011b4", @@ -89,23 +89,21 @@ "comments": [] }, { - "id": "05e10aba-f8b4-485c-9c79-bcfb4a58e80b", + "id": "1d9c0541-80fe-4acf-856b-285236628756", "listId": "43249367-151b-4e78-bea5-b3c3f41b60ab", - "title": "Document XCAlert", - "description": "XCAlert is a Module for Alerting Tools Enabling.\nin this task we have to complete it's Documentations and then also we have to complete XCDataCollector and make it Usable.", + "title": "Document XCTrade", + "description": "Document XTrade Class and it's Implementations and also do Refactoring if required.", "labels": [], - "checkboxes": [ - { - "id": "888d7a95-44c3-4388-9446-8e5d78a0a0d1", - "title": "add Log Saving Methods", - "checked": false - }, - { - "id": "38bfd420-21fb-436a-abc6-7239da6559ae", - "title": "add Support for Per File Logging", - "checked": false - } - ], + "checkboxes": [], + "comments": [] + }, + { + "id": "bbe1f927-0744-4f27-a960-89078338ae2b", + "listId": "43249367-151b-4e78-bea5-b3c3f41b60ab", + "title": "Document XCVolume", + "description": "Document XCVolume as a Base Modules which works Stand alone.\n", + "labels": [], + "checkboxes": [], "comments": [] } ] @@ -114,6 +112,15 @@ "id": "0c9df632-b6cd-4d3f-9c08-fbe7010ecc4e", "title": "Test", "cards": [ + { + "id": "e1e98f40-ac5f-495a-ac8e-eccff3a204e7", + "listId": "0c9df632-b6cd-4d3f-9c08-fbe7010ecc4e", + "title": "Document XCAccount", + "description": "Since XCAccount is a Base Class which used in other Modules, we have to Document.\n", + "labels": [], + "checkboxes": [], + "comments": [] + }, { "id": "e487c35e-b69d-41b4-bdae-ef8502ecc1dc", "listId": "0c9df632-b6cd-4d3f-9c08-fbe7010ecc4e", @@ -134,6 +141,31 @@ } ] }, + { + "id": "05e10aba-f8b4-485c-9c79-bcfb4a58e80b", + "listId": "0c9df632-b6cd-4d3f-9c08-fbe7010ecc4e", + "title": "Document XCAlert", + "description": "XCAlert is a Module for Alerting Tools Enabling.\nin this task we have to complete it's Documentations and then also we have to complete XCDataCollector and make it Usable.", + "labels": [], + "checkboxes": [ + { + "id": "888d7a95-44c3-4388-9446-8e5d78a0a0d1", + "title": "add Log Saving Methods", + "checked": true + }, + { + "id": "38bfd420-21fb-436a-abc6-7239da6559ae", + "title": "add Support for Per File Logging", + "checked": true + } + ], + "comments": [ + { + "id": "6c821cac-1457-4df7-af20-61fa00f6bb55", + "comment": "apply some fix and Prevent Double Saving Log Messages, and also add Prefix as XLog file name instancing ..." + } + ] + }, { "id": "5549ff02-ce37-476f-9d91-ed190ca15e90", "listId": "0c9df632-b6cd-4d3f-9c08-fbe7010ecc4e", diff --git a/Documents/Diagrams/TradeModules.drawio b/Documents/Diagrams/TradeModules.drawio index ee7a19d1..fc473edc 100644 --- a/Documents/Diagrams/TradeModules.drawio +++ b/Documents/Diagrams/TradeModules.drawio @@ -1,6 +1,6 @@ - + @@ -19,6 +19,23 @@ + + + + + + + + + + + + + + + + + @@ -240,6 +257,324 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Documents/Docs/XCAccount.md b/Documents/Docs/XCAccount.md index e69de29b..e7c18763 100644 --- a/Documents/Docs/XCAccount.md +++ b/Documents/Docs/XCAccount.md @@ -0,0 +1,136 @@ +# XCAccount + +it is a module which used for Accoess Trading Account Data in SaherElm's XTrade Framework. + +## Dependencies + +there is no Dependencies on this modules. + +## Instancing + +there is not any args in Constructor. + +## Instructions + +use provided Actions for Access Account informations in where you need. + +## Actions + +### long GetUserAccount() + +retrieve Current User Identifier. + +### long GetLeverage() + +retrieve Current Account Leverage. + +### bool CanExpertTrade() + +retrieve Flag which Specified Trading using Experts or Manual. + +### ENUM_ACCOUNT_TRADE_MODE GetTradeMode() + +retrieve Current Account Trading Mode. + +- ACCOUNT_TRADE_MODE_DEMO; +- ACCOUNT_TRADE_MODE_CONTEST; +- ACCOUNT_TRADE_MODE_REAL; + +### double GetBalance() + +retrieve Current Account Balance. + +### double GetCredit() + +retrieve Current Account Credit. + +### double GetProfit() + +retrieve Current Account's Amount of Profits. + +### double GetEquity() + +retrieve Current Account's Amount of Equity. + +### double GetMargin() + +retrieve Current Account's Amount of Margin. + +### double GetFreeMargin() + +retrieve Current Account's Amount of Free Margin. + +### double GetMarginLevel() + +retrieve Current Account's Margin Level. + +### double GetMarginCall() + +retrieve Current Account's Margin Call Level. + +### double GetMarginStopOut() + +retrieve Current Account's Margin Stopout Level. + +### string GetName() + +retrieve Current Account's User Name. + +### string GetServerName() + +retrieve Current Account's Server Name. + +### string GetCurrency() + +retrieve Current Account's Currency. + +### string GetCompany() + +retrieve Current Account's Market Name. + +### double CalculateTradeProfit(const string symbol, ENUM_ORDER_TYPE type, double volume, double entry, double exit) + +Calculate and Retrieved Trade Profit based on Account Currency. + +### double CalculateMarging(const string symbol, ENUM_ORDER_TYPE type, double volume, double entry) + +Calculate and Retrieved Specified Trades used Marigin. + +### double CalculateFreeMarging(const string symbol, ENUM_ORDER_TYPE type, double volume, double entry) + +Calculate and Retrieved Specified Trades Free Marigin. + +### double CalculateMaxVolume(const string symbol, ENUM_ORDER_TYPE type, double entry, double percent = 100) + +Calculate Max Allowed Specified Trade's Volume for Entry. + +### double GetPointValue(string symbol) + +Retrieve Specified Symbol's Point Value. + +### double CalculateRiskAmount(string symbol, double points, double volume) + +Calculate How many Risk Currency in a Trade when risk Points and Trade Volume is Specified. +used when we have to know how many risk in $ Currency, for a Trade when we risk 100 Point, by Providing 0.01 Lot as Volume. + +### double CalculateRiskPoints(string symbol, double volume, double amount) + +Calculate Risk Points in a Trade when Volume and Curreny Amount is Specified. +used when we want to know How many points risk in a Trade when we have to risk 5$ in a Trade by 0.01 Lot as Volume. + +### double CalculateVolume(string symbol, double amount, double points) + +Calculate Trade Volume when Risk Amount in Currency and Risk Amount in Points Specified. +used when we want to know Open a Trade by how Size of Volume when we have to risk 5$ in a Trade when 100 points risking. + +### string GetBalanceReportMessage() + +Prepare and Retrieve Balance Report Message for Current Account. + +## Maintainer + +Hadi Khazaee asl + +[https://www.saherelm.ir](https://www.saherelm.ir) + +[hadi_khazaee_asl@yahoo.com](mailto:hadi_khazaee_asl@yahoo.com) diff --git a/Documents/Docs/XCAlert.md b/Documents/Docs/XCAlert.md index d9fa75fa..6b7316f2 100644 --- a/Documents/Docs/XCAlert.md +++ b/Documents/Docs/XCAlert.md @@ -2,6 +2,138 @@ it is a module which used for Providing Logs in SaherElm's XTrade Framework. +## Dependencies + +this Module used XCDataCollector for Saving Logs in Files. + +## Instancing + +using this syntax for instancing : + +```mql5 +XCAlert( + string prefix = "X-Alert", // Alerts Prefixe + bool enableAlerts = true, // Enable Alerts + bool logAlerts = true, // Log Alerts + bool terminalAlerts = false, // Terminal Alerts + bool mailAlerts = false, // Mail Alerts + bool pushAlerts = false, // Push Alerts + bool saveAlerts = false // Save Alerts +) {} +``` + +all of Constructor Input args is Optional, means have default values. +you can set them after instancing using Properties Setter/Getter (s). + +## Instructions + +- Prefix: string, Specified Logger Prefix. this for Separate Different Logger Instances. +- EnableAlerts: boolean, Specified Logging is Enabled or not. +- SaveAlerts: boolean, Specified Saving Log(s) or not. +- LogAlerts: boolean, Specified Can Print Logs on Console or not. +- TerminalAlerts: boolean, Specified Send Logs in Terminal or not. +- MailAlerts: boolean, Specified Send Logs as Mail or not. +- PushAlerts: boolean, Specified Send Logs as Push or not. + +## Actions + +### LogAlert(string message) + +do specified type of Logs. +do log by Print in Console. + +### TerminalAlert(string message) + +do specified type of Logs. +do log by sending Terminal Alert. + +### MailAlert(string message) + +do specified type of Logs. +do log by sending Mail Alert. + +### PushAlert(string message) + +do specified type of Logs. +do log by sending Push Notification Alert. + +### SendAlert(string message) + +do sending log by configuration. +retrieve log and based on configuration send each specified enabled logs separately. + +### Log(string message) + +Checking Log Flag and Print Message. + +### Log(string tag, string message) + +Checking Log Flag and Print Specified Tag & Message. + +### LogEmpty() + +Checking Log Flag and Print Empty Message. + +### LogArray(T &array[], string label = NULL) + +Checking Log Flag and Print Array. + +### LogError(int error = -1) + +Checking Log Flag and then Generate Error Message based on provided error number, +then Print Tag Specified Message. + +### string GetErrorDescription(int err_code) + +Generate Specified Error Messaged based on Provided error code. + +### string GetTradeServerReturnCodeDescription(int return_code) + +Generate Specified Error Message based on Provided server error code. + +### bool CanLog() + +protected +return a Flag for Specified Flag which allowed Print Logs or not. + +### bool CanLogAlert() + +protected +return a Flag for Specified Flag which allowed Print Logs and also Enabled or not. + +### bool CanTerminalAlert() + +protected +return a Flag for Specified Flag which allowed Sending Logs to Terminal and also Enabled or not. + +### bool CanMailAlert() + +protected +return a Flag for Specified Flag which allowed Sending Logs as Mail and also Enabled or not. + +### bool CanPushAlert() + +protected +return a Flag for Speified Flag which allowed Sending Logs as Push and also Enabled or not. + +### Save(string message) + +protected +Saving Specified Message into Logger File. if alert Saving is Enabled. + +#### Descriptions + +- Preparing a File Name by Combining setted Prefix + ".XLogs". +- Generating File Path based on XCDataCollector instance Path. +- Validate Generated filePath. +- Preparing Log Message for Saving in Log File by attaching Current Time. +- Append prepared Message to Log File using XCDataCollector instance. + +### string PrepareMessage(string message) + +private +Replace Escaped strings and Attach Prefix to Message. + ## Maintainer Hadi Khazaee asl diff --git a/Documents/Docs/XCDataCollector.md b/Documents/Docs/XCDataCollector.md index 384cd166..314b2b3d 100644 --- a/Documents/Docs/XCDataCollector.md +++ b/Documents/Docs/XCDataCollector.md @@ -21,7 +21,7 @@ there is not any args in Constructor. ### Path -is aProperty Setter and Getter Action for Setting Collector Path. +is a Property Setter and Getter Action for Setting Collector Path. for setter it's have an input Parameters (string value) which Specified the File's Path. ### GetFilePath(string fileName) diff --git a/Documents/Docs/XCVolume.md b/Documents/Docs/XCVolume.md index e69de29b..369d6604 100644 --- a/Documents/Docs/XCVolume.md +++ b/Documents/Docs/XCVolume.md @@ -0,0 +1,25 @@ +# XCVolume + +it is a module which used for Accoess Trading Account Data in SaherElm's XTrade Framework. + +## Dependencies + +there is no Dependencies on this modules. + +## Instancing + +there is not any args in Constructor. + +## Instructions + +use provided Actions for Access Account informations in where you need. + +## Actions + +## Maintainer + +Hadi Khazaee asl + +[https://www.saherelm.ir](https://www.saherelm.ir) + +[hadi_khazaee_asl@yahoo.com](mailto:hadi_khazaee_asl@yahoo.com)