/////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 Class // ------------------------------------------------- // Name: XCXGuard ... // Description: Guard Provider Class ... // // // Maintainer: // ------------ // Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) // ////////////////////////////////////////////////////// // // Global Properties ... #property library #property copyright "Copyright 2023, SaherElm IT Center" #property link "https://saherelm.ir" #property version "1.00" #property description "SaherElm Guard Provider Class" #property strict // // Imports ... #include "../Classes/x-saherelm.base.class.mq5"; // // Enumeration ... // // Guard Actions ... enum ENUM_X_GUARD_ACTIONS { X_GUARD_ACTION_NONE, // Nothing to Do X_GUARD_ACTION_CLOSE, // Close Specified Position X_GUARD_ACTION_CLOSE_ALL, // Close All Positions X_GUARD_ACTION_CLOSE_LONGS, // Close All Long Positions X_GUARD_ACTION_CLOSE_SHORTS, // Close All Short Position X_GUARD_ACTION_PARTIAL_CLOSE, // Partial Close Specified Position X_GUARD_ACTION_TRAIL_STOP, // Trail Stop of Specified Position X_GUARD_ACTION_TRAIL_TARGET, // Trail Target of Specified Position X_GUARD_ACTION_HEDGE, // Hedge Specified Positions }; // // Definitions ... // // Model a Guard Action ... struct XGuard { // // Props ... ENUM_X_GUARD_ACTIONS action; datetime time; // string symbol; string provider; // // Specified Position ... ulong ticket; // // Partial Close ... double volumeMultiplier; // // SL Trial ... double sl; // // TP Trial ... double tp; // // Constructor ... XGuard() { Clean(); } // // Tools ... /** * Cleanup ... */ void Clean() { // time = NULL; action = X_GUARD_ACTION_NONE; // symbol = NULL; provider = NULL; // ticket = 0; // volumeMultiplier = 0; // sl = 0; tp = 0; // ZeroMemory(this); } /** * Validate ... * * @return ( bool ) */ bool IsValid() { // bool result = false; // result = // IsValid(time) && IsValid(symbol) && IsValid(provider) && action != X_GUARD_ACTION_NONE // ; if (!result) { return result; } // // Validate Model Based On Specified Guard Actions ... // return result; } }; // // Extensions ... // bool IsValid(ENUM_X_GUARD_ACTIONS item) { // bool result = false; // result = item != X_GUARD_ACTION_NONE; // return result; } /** * Add Guard to Collection ... * * @param guard: XGuard instance ... * @param guards: XGuard instance Collection ... * * @return ( int ) */ int AddGuard( XGuard &guard, XGuard &guards[] // ) { // int result = 0; // if (!guard.IsValid()) { return result; } // AddRef( guard, guards // ); // result = ArraySize(guards); // return result; } // // Implementation ...