From de8143585b6bcfbee1581bccc5642fcbb8269804 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sat, 22 Jun 2024 21:55:55 +0330 Subject: [PATCH] last ... --- Classes/x-saherelm.x121.setup.cycle.class.mq5 | 223 ++++- Classes/x-saherelm.x121.setup.xea.mq5 | 943 +++++++----------- Documents/BKP/usefull.mq5 | 316 ++++++ Libraries/x-saherelm.xtrade.lib.mq5 | 2 +- 4 files changed, 913 insertions(+), 571 deletions(-) diff --git a/Classes/x-saherelm.x121.setup.cycle.class.mq5 b/Classes/x-saherelm.x121.setup.cycle.class.mq5 index 3eab1737..d8ab3043 100644 --- a/Classes/x-saherelm.x121.setup.cycle.class.mq5 +++ b/Classes/x-saherelm.x121.setup.cycle.class.mq5 @@ -182,6 +182,14 @@ class XSCX121SetupCycles : public XSCBaseAlert public: // // Props ... + X121SignalGenerator signalGenerator; + + // + X121SetupCycleInputs cCycle; // Current (Host) Cycle + X121SetupCycleInputs sCycle; // Short Cycle + X121SetupCycleInputs mCycle; // Medium Cycle + X121SetupCycleInputs lCycle; // Long Cycle + X121SetupCycleInputs hCycle; // Hind Cycle // // Constructor(s) ... @@ -266,6 +274,16 @@ public: return result; } + // + result = sBarTracker.Init( + _inputs.symbol, + sCycle.cycle.period // + ); + if (!result) + { + return result; + } + // // Medium ... result = mCycle.Init( @@ -280,6 +298,16 @@ public: return result; } + // + result = mBarTracker.Init( + _inputs.symbol, + mCycle.cycle.period // + ); + if (!result) + { + return result; + } + // // Long ... result = lCycle.Init( @@ -294,6 +322,16 @@ public: return result; } + // + result = lBarTracker.Init( + _inputs.symbol, + lCycle.cycle.period // + ); + if (!result) + { + return result; + } + // // Hind ... result = hCycle.Init( @@ -308,6 +346,16 @@ public: return result; } + // + result = hBarTracker.Init( + _inputs.symbol, + hCycle.cycle.period // + ); + if (!result) + { + return result; + } + // _inputs.period = cCycle.GetPeriod(); @@ -403,6 +451,48 @@ public: return result; } + // + datetime GetNextSignalTime( + ENUM_X_MARKET_CYCLES cycle = X_MARKET_CYCLE_UNKNOWN // + ) + { + // + datetime result = NULL; + + // + switch (cycle) + { + // + case X_MARKET_CYCLE_SHORT: + result = sNextValidSignal; + break; + + // + case X_MARKET_CYCLE_MEDIUM: + result = mNextValidSignal; + break; + + // + case X_MARKET_CYCLE_LONG: + result = lNextValidSignal; + break; + + // + case X_MARKET_CYCLE_HIND: + result = hNextValidSignal; + break; + + // + default: + case X_MARKET_CYCLE_UNKNOWN: + result = cNextValidSignal; + break; + } + + // + return result; + } + // void WaitsUntilNextBar( ENUM_X_MARKET_CYCLES cycle = X_MARKET_CYCLE_UNKNOWN // @@ -414,24 +504,40 @@ public: // case X_MARKET_CYCLE_SHORT: // + FillNextBarTime( + sNextValidSignal, + sBarTracker // + ); sBarTracker.Waits(); break; // case X_MARKET_CYCLE_MEDIUM: // + FillNextBarTime( + mNextValidSignal, + mBarTracker // + ); mBarTracker.Waits(); break; // case X_MARKET_CYCLE_LONG: // + FillNextBarTime( + lNextValidSignal, + lBarTracker // + ); lBarTracker.Waits(); break; // case X_MARKET_CYCLE_HIND: // + FillNextBarTime( + hNextValidSignal, + hBarTracker // + ); hBarTracker.Waits(); break; @@ -439,6 +545,10 @@ public: default: case X_MARKET_CYCLE_UNKNOWN: // + FillNextBarTime( + cNextValidSignal, + cBarTracker // + ); cBarTracker.Waits(); break; } @@ -581,6 +691,79 @@ public: return result; } + // + bool ProcessMarket( + XSignal &signal, + X121SetupConditions &conditions, + int &pushers, + string &provider, + ENUM_X_MARKET_CYCLES cycle = X_MARKET_CYCLE_UNKNOWN, + bool allowSupports = false, // Allow Support Signal Generating ... + bool allowLong = false, + bool allowShort = false, + double volume = 0.01, + double slPoint = 100, + bool ignoreSL = false, + double tpPoint = 100, + bool ignoreTP = false, + int barIndex = 0, + int loopback = 5 // + ) + { + // + bool result = false; + + // + result = CanProcessBar( + cycle // + ); + if (!result) + { + return result; + } + + // + result = GetConditions( + conditions, + cycle, // Current Market ... + barIndex, // Bar Index ... + loopback // Loop Back ... + ); + if (!result) + { + return result; + } + + // + // Parse Conditions for Signal ... + result = signalGenerator.HasSignal( + conditions, + signal, + pushers, + provider, + allowSupports, + allowLong, + allowShort, + volume, + slPoint, + ignoreSL, + tpPoint, + ignoreTP // + ); + + // + if (result) + { + // + WaitsUntilNextBar( + cycle // + ); + } + + // + return result; + } + // // Protected ... protected: @@ -602,11 +785,41 @@ private: XBarTracker hBarTracker; // - X121SetupCycleInputs cCycle; // Current (Host) Cycle - X121SetupCycleInputs sCycle; // Short Cycle - X121SetupCycleInputs mCycle; // Medium Cycle - X121SetupCycleInputs lCycle; // Long Cycle - X121SetupCycleInputs hCycle; // Hind Cycle + datetime cNextValidSignal; + datetime sNextValidSignal; + datetime mNextValidSignal; + datetime lNextValidSignal; + datetime hNextValidSignal; + + // + void FillNextBarTime( + datetime &next, + XBarTracker &tracker) + { + // + next = iTime( + tracker.symbol, + tracker.period, + 0) + + PeriodSeconds(tracker.period); + } + + // // + // bool ProcessCurrentMarket( + // XSignal &signal, + // X121SetupConditions &conditions, + // int &pushers, + // string &provider, + // int barIndex = 0, + // int loopback = 5 // + // ) + // { + // // + // bool result = false; + + // // + // return result; + // } }; // \ No newline at end of file diff --git a/Classes/x-saherelm.x121.setup.xea.mq5 b/Classes/x-saherelm.x121.setup.xea.mq5 index 9dca355f..53dc2757 100644 --- a/Classes/x-saherelm.x121.setup.xea.mq5 +++ b/Classes/x-saherelm.x121.setup.xea.mq5 @@ -3504,367 +3504,164 @@ public: // int maxAllowed = MaxAllowedTrades(); - X121SignalGenerator signalGenerator; + + // + double volume = Volume(); + double slPoint = SLPoint(); + double tpPoint = TPPoint(); + bool ignoreSL = IgnoreSL(); + bool ignoreTP = IgnoreTP(); + bool allowLong = AllowLong(); + bool allowShort = AllowShort(); + bool allowSupport = AllowSupport(); // for (int i = 0; i < count; i++) { + // + // Current Market ... + // cPusher = 0; - sPusher = 0; - mPusher = 0; - lPusher = 0; - hPusher = 0; - - // - cProvider = NULL; - sProvider = NULL; - mProvider = NULL; - lProvider = NULL; - hProvider = NULL; - - // cSignal.Clean(); - sSignal.Clean(); - mSignal.Clean(); - lSignal.Clean(); - hSignal.Clean(); - - // + cProvider = NULL; cHasSignal = false; - sHasSignal = false; - mHasSignal = false; - lHasSignal = false; - hHasSignal = false; + cConditions.Clean(); // - cConditions.Clean(); + cHasSignal = mSetups[i].ProcessMarket( + cSignal, + cConditions, + cPusher, + cProvider, + X_MARKET_CYCLE_UNKNOWN, + allowSupport, + allowLong, + allowShort, + volume, + slPoint, + ignoreSL, + tpPoint, + ignoreTP, + 0, + 5 // + ); + + // + // Short Market ... + + // + sPusher = 0; + sSignal.Clean(); + sProvider = NULL; + sHasSignal = false; sConditions.Clean(); + + // + sHasSignal = mSetups[i].ProcessMarket( + sSignal, + sConditions, + sPusher, + sProvider, + X_MARKET_CYCLE_SHORT, + allowSupport, + allowLong, + allowShort, + volume, + slPoint, + ignoreSL, + tpPoint, + ignoreTP, + 0, + 5 // + ); + + // + // Medium Market ... + + // + mPusher = 0; + mSignal.Clean(); + mProvider = NULL; + mHasSignal = false; mConditions.Clean(); + + // + mHasSignal = mSetups[i].ProcessMarket( + mSignal, + mConditions, + mPusher, + mProvider, + X_MARKET_CYCLE_MEDIUM, + allowSupport, + allowLong, + allowShort, + volume, + slPoint, + ignoreSL, + tpPoint, + ignoreTP, + 0, + 5 // + ); + + // + // Long Market ... + + // + lPusher = 0; + lSignal.Clean(); + lProvider = NULL; + lHasSignal = false; lConditions.Clean(); + + // + lHasSignal = mSetups[i].ProcessMarket( + lSignal, + lConditions, + lPusher, + lProvider, + X_MARKET_CYCLE_LONG, + allowSupport, + allowLong, + allowShort, + volume, + slPoint, + ignoreSL, + tpPoint, + ignoreTP, + 0, + 5 // + ); + + // + // Hind Market ... + + // + hPusher = 0; + hSignal.Clean(); + hProvider = NULL; + hHasSignal = false; hConditions.Clean(); // - // Current ... - bool canProcess = mSetups[i] - .CanProcessBar( - X_MARKET_CYCLE_UNKNOWN // - ); - if (canProcess) - { - // - bool iHasConditions = mSetups[i].GetConditions( - cConditions, - X_MARKET_CYCLE_UNKNOWN, // Current Market ... - 0, // Bar Index ... - 5 // Loop Back ... - ); - - // - if (!iHasConditions) - { - continue; - } - - // - mVolumeOSC = 0; - mBullishSigns = 0; - mBullishScore = 0; - mBearishSigns = 0; - mBearishScore = 0; - - // - // Retrieve Scores ... - double bullishScore = 0; - double bearishScore = 0; - cConditions.GenerateScore( - bullishScore, - bearishScore // - ); - mBullishScore += bullishScore; - mBearishScore += bearishScore; - - // - mVolumeOSC += cConditions.vlmConditions.volume[1]; - - // - // Parse Conditions for Signal ... - cHasSignal = signalGenerator.HasSignal( - cConditions, - cSignal, - cPusher, - cProvider, - AllowSupport(), - mAllowLong, - mAllowShort, - mVolume, - mSLPoint, - mIgnoreSL, - mTPPoint, - mIgnoreTP // - ); - - // - if (cHasSignal) - { - // - mSetups[i].WaitsUntilNextBar( - X_MARKET_CYCLE_UNKNOWN // - ); - } - } - - // - // Short ... - canProcess = mSetups[i] - .CanProcessBar( - X_MARKET_CYCLE_SHORT // - ); - if (canProcess) - { - // - bool iHasConditions = mSetups[i].GetConditions( - sConditions, - X_MARKET_CYCLE_SHORT, // Current Market ... - 0, // Bar Index ... - 5 // Loop Back ... - ); - - // - if (!iHasConditions) - { - continue; - } - - // - // Retrieve Scores ... - double bullishScore = 0; - double bearishScore = 0; - sConditions.GenerateScore( - bullishScore, - bearishScore // - ); - mBullishScore += bullishScore; - mBearishScore += bearishScore; - - // - mVolumeOSC += sConditions.vlmConditions.volume[1]; - - // - // Parse Conditions for Signal ... - sHasSignal = signalGenerator.HasSignal( - sConditions, - sSignal, - sPusher, - sProvider, - AllowSupport(), - mAllowLong, - mAllowShort, - mVolume, - mSLPoint, - mIgnoreSL, - mTPPoint, - mIgnoreTP // - ); - - // - if (sHasSignal) - { - // - mSetups[i].WaitsUntilNextBar( - X_MARKET_CYCLE_SHORT // - ); - } - } - - // - // Medium ... - canProcess = mSetups[i] - .CanProcessBar( - X_MARKET_CYCLE_MEDIUM // - ); - if (canProcess) - { - // - bool iHasConditions = mSetups[i].GetConditions( - mConditions, - X_MARKET_CYCLE_MEDIUM, // Current Market ... - 0, // Bar Index ... - 5 // Loop Back ... - ); - - // - if (!iHasConditions) - { - continue; - } - - // - // Retrieve Scores ... - double bullishScore = 0; - double bearishScore = 0; - mConditions.GenerateScore( - bullishScore, - bearishScore // - ); - mBullishScore += bullishScore; - mBearishScore += bearishScore; - - // - mVolumeOSC += mConditions.vlmConditions.volume[1]; - - // - // Parse Conditions for Signal ... - mHasSignal = signalGenerator.HasSignal( - mConditions, - mSignal, - mPusher, - mProvider, - AllowSupport(), - mAllowLong, - mAllowShort, - mVolume, - mSLPoint, - mIgnoreSL, - mTPPoint, - mIgnoreTP // - ); - - // - if (mHasSignal) - { - // - mSetups[i].WaitsUntilNextBar( - X_MARKET_CYCLE_MEDIUM // - ); - } - } - - // - // Long ... - canProcess = mSetups[i] - .CanProcessBar( - X_MARKET_CYCLE_LONG // - ); - if (canProcess) - { - // - bool iHasConditions = mSetups[i].GetConditions( - lConditions, - X_MARKET_CYCLE_LONG, // Current Market ... - 0, // Bar Index ... - 5 // Loop Back ... - ); - - // - if (!iHasConditions) - { - continue; - } - - // - // Retrieve Scores ... - double bullishScore = 0; - double bearishScore = 0; - lConditions.GenerateScore( - bullishScore, - bearishScore // - ); - mBullishScore += bullishScore; - mBearishScore += bearishScore; - - // - mVolumeOSC += lConditions.vlmConditions.volume[1]; - - // - // Parse Conditions for Signal ... - lHasSignal = signalGenerator.HasSignal( - lConditions, - lSignal, - lPusher, - lProvider, - AllowSupport(), - mAllowLong, - mAllowShort, - mVolume, - mSLPoint, - mIgnoreSL, - mTPPoint, - mIgnoreTP // - ); - - // - if (lHasSignal) - { - // - mSetups[i].WaitsUntilNextBar( - X_MARKET_CYCLE_LONG // - ); - } - } - - // - // Hind ... - canProcess = mSetups[i] - .CanProcessBar( - X_MARKET_CYCLE_HIND // - ); - if (canProcess) - { - // - bool iHasConditions = mSetups[i].GetConditions( - hConditions, - X_MARKET_CYCLE_HIND, // Current Market ... - 0, // Bar Index ... - 5 // Loop Back ... - ); - - // - if (!iHasConditions) - { - continue; - } - - // - // Retrieve Scores ... - double bullishScore = 0; - double bearishScore = 0; - hConditions.GenerateScore( - bullishScore, - bearishScore // - ); - mBullishScore += bullishScore; - mBearishScore += bearishScore; - - // - mVolumeOSC += hConditions.vlmConditions.volume[1]; - - // - // Parse Conditions for Signal ... - hHasSignal = signalGenerator.HasSignal( - hConditions, - hSignal, - hPusher, - hProvider, - AllowSupport(), - mAllowLong, - mAllowShort, - mVolume, - mSLPoint, - mIgnoreSL, - mTPPoint, - mIgnoreTP // - ); - - // - if (hHasSignal) - { - // - mSetups[i].WaitsUntilNextBar( - X_MARKET_CYCLE_HIND // - ); - } - } + hHasSignal = mSetups[i].ProcessMarket( + hSignal, + hConditions, + hPusher, + hProvider, + X_MARKET_CYCLE_HIND, + allowSupport, + allowLong, + allowShort, + volume, + slPoint, + ignoreSL, + tpPoint, + ignoreTP, + 0, + 5 // + ); // // Parse Signals and Add them for Executing ... @@ -3875,242 +3672,258 @@ public: if (hasSignal) { // - // Handle Creating a new Signal Info ... - XSignal signal; - X121SetupConditions otherConditions[]; + if (cHasSignal) + { + // + Print("Current Market Has Signal ..."); + } + + // + if (sHasSignal) + { + // + Print("Short Market Has Signal ..."); + } + + // + if (mHasSignal) + { + // + Print("Medium Market Has Signal ..."); + } + + // + if (lHasSignal) + { + // + Print("Long Market Has Signal ..."); + Print(ToString(mSetups[i].lCycle.cycle.period)); + } + + // if (hHasSignal) { // - signal = hSignal; - - // - AddRef( - cConditions, - otherConditions // - ); - AddRef( - sConditions, - otherConditions // - ); - } - else if (lHasSignal) - { - // - signal = lSignal; - - // - AddRef( - cConditions, - otherConditions // - ); - AddRef( - sConditions, - otherConditions // - ); - AddRef( - mConditions, - otherConditions // - ); - } - else if (mHasSignal) - { - // - signal = mSignal; - - // - AddRef( - cConditions, - otherConditions // - ); - AddRef( - sConditions, - otherConditions // - ); - } - else if (sHasSignal) - { - // - signal = sSignal; - - // - AddRef( - cConditions, - otherConditions // - ); - AddRef( - mConditions, - otherConditions // - ); - AddRef( - lConditions, - otherConditions // - ); - AddRef( - hConditions, - otherConditions // - ); - } - else if (cHasSignal) - { - // - signal = cSignal; - - // - AddRef( - sConditions, - otherConditions // - ); - AddRef( - mConditions, - otherConditions // - ); - AddRef( - lConditions, - otherConditions // - ); - AddRef( - hConditions, - otherConditions // - ); + Print("Hind Market Has Signal ..."); } // - int pushers = cPusher + sPusher + mPusher + lPusher + hPusher; + // Handle Creating a new Signal Info ... + // XSignal signal; + // X121SetupConditions otherConditions[]; + // if (hHasSignal) + // { + // // + // signal = hSignal; - // - bool isLong = IsLong(signal.type); + // // + // AddRef( + // cConditions, + // otherConditions // + // ); + // AddRef( + // sConditions, + // otherConditions // + // ); + // } + // else if (lHasSignal) + // { + // // + // signal = lSignal; - // - // Collecting Bullish/Bearish Signs ... - if (isLong) - { - mBullishSigns += pushers; - } - else - { - mBearishSigns += pushers; - } + // // + // AddRef( + // cConditions, + // otherConditions // + // ); + // AddRef( + // sConditions, + // otherConditions // + // ); + // AddRef( + // mConditions, + // otherConditions // + // ); + // } + // else if (mHasSignal) + // { + // // + // signal = mSignal; - // - // Validate Signal ... - bool isValid = - // - // Handle Pusher Validations ... - (mReuiredSignalVerifications <= 0 - ? true - : pushers >= mReuiredSignalVerifications) - // - && - // - // Handle Other Conditions Validations ... - (!mGetVerificationFromOtherTimeFrames - ? true - : isLong - ? signalGenerator.HasLongVerifications(otherConditions) - : signalGenerator.HasShortVerifications(otherConditions)) - // - ; + // // + // AddRef( + // cConditions, + // otherConditions // + // ); + // AddRef( + // sConditions, + // otherConditions // + // ); + // } + // else if (sHasSignal) + // { + // // + // signal = sSignal; - // - bool forceState = ForceState(); + // // + // AddRef( + // cConditions, + // otherConditions // + // ); + // AddRef( + // mConditions, + // otherConditions // + // ); + // AddRef( + // lConditions, + // otherConditions // + // ); + // AddRef( + // hConditions, + // otherConditions // + // ); + // } + // else if (cHasSignal) + // { + // // + // signal = cSignal; - // - if (!isValid || (forceState && isValid)) - { - // - // Clear Other Conditions ... - Clean(otherConditions); + // // + // AddRef( + // sConditions, + // otherConditions // + // ); + // AddRef( + // mConditions, + // otherConditions // + // ); + // AddRef( + // lConditions, + // otherConditions // + // ); + // AddRef( + // hConditions, + // otherConditions // + // ); + // } - // - // Fill All Conditions to Other Conditions ... - AddRef( - cConditions, - otherConditions // - ); - AddRef( - sConditions, - otherConditions // - ); - AddRef( - mConditions, - otherConditions // - ); - AddRef( - lConditions, - otherConditions // - ); - AddRef( - hConditions, - otherConditions // - ); + // // + // int pushers = cPusher + sPusher + mPusher + lPusher + hPusher; - // - // If Recieved Any Unverified Signal - // we Passed it to EQM Manager ... - EQMHandleInvalidSignal( - signal, - pushers, - mVolumeOSC, - mBullishScore, - mBullishSigns, - mBearishScore, - mBearishSigns, - otherConditions, - isValid // - ); - continue; - } + // // + // bool isLong = IsLong(signal.type); - // - if (!forceState) - { - // - // Add Signal to Execution Result ... - AddRef( - signal, - signals // - ); + // // + // // Collecting Bullish/Bearish Signs ... + // if (isLong) + // { + // mBullishSigns += pushers; + // } + // else + // { + // mBearishSigns += pushers; + // } - // - // Add new Signal Info ... - mTradeHandler.Add( - signal, - pushers, - mVolumeOSC, - mBullishSigns, - mBearishSigns, - mBullishScore, - mBearishScore, - cConditions, - sConditions, - mConditions, - lConditions, - hConditions // - ); - } + // // + // // Validate Signal ... + // bool isValid = + // // + // // Handle Pusher Validations ... + // (mReuiredSignalVerifications <= 0 + // ? true + // : pushers >= mReuiredSignalVerifications) + // // + // && + // // + // // Handle Other Conditions Validations ... + // (!mGetVerificationFromOtherTimeFrames + // ? true + // : isLong + // ? signalGenerator.HasLongVerifications(otherConditions) + // : signalGenerator.HasShortVerifications(otherConditions)) + // // + // ; + + // // + // bool forceState = ForceState(); + + // // + // if (!isValid || (forceState && isValid)) + // { + // // + // // Clear Other Conditions ... + // Clean(otherConditions); + + // // + // // Fill All Conditions to Other Conditions ... + // AddRef( + // cConditions, + // otherConditions // + // ); + // AddRef( + // sConditions, + // otherConditions // + // ); + // AddRef( + // mConditions, + // otherConditions // + // ); + // AddRef( + // lConditions, + // otherConditions // + // ); + // AddRef( + // hConditions, + // otherConditions // + // ); + + // // + // // If Recieved Any Unverified Signal + // // we Passed it to EQM Manager ... + // EQMHandleInvalidSignal( + // signal, + // pushers, + // mVolumeOSC, + // mBullishScore, + // mBullishSigns, + // mBearishScore, + // mBearishSigns, + // otherConditions, + // isValid // + // ); + // continue; + // } + + // // + // if (!forceState) + // { + // // + // // Add Signal to Execution Result ... + // AddRef( + // signal, + // signals // + // ); + + // // + // // Add new Signal Info ... + // mTradeHandler.Add( + // signal, + // pushers, + // mVolumeOSC, + // mBullishSigns, + // mBearishSigns, + // mBullishScore, + // mBearishScore, + // cConditions, + // sConditions, + // mConditions, + // lConditions, + // hConditions // + // ); + // } } } - // // - // // Create Score Summary for Commenting on Chart ... - // string scoreSummary = - // // - // "----------" + separator + - // "Bullish Score: " + ToString(mBullishScore) + separator + - // "Bullish Signs: " + ToString(mBullishSigns) + separator + - // "----------" + separator + - // "Bearish Score: " + ToString(mBearishScore) + separator + - // "Bearish Signs: " + ToString(mBearishSigns) + separator + - // "----------" + separator + - // "Volume: " + ToString(mVolumeOSC) + separator + - // "DrawDown: " + ToString(GetDrawdownPercent()) + "%" + - // "" - // // - // ; - - // // - // Comment(scoreSummary); - // result = ArraySize(signals); @@ -4950,7 +4763,7 @@ private: if (isClosed) { // - string message = XEQMSupportToken + "Close " + ToString(positions[maxInDIDX].ticket) + " Due Max In Drawdown ..."; + string message = XEQMSupportToken + " Close " + ToString(positions[maxInDIDX].ticket) + " Due Max In Drawdown ..."; // Alert(message); @@ -5006,7 +4819,7 @@ private: if (isClosed) { // - string message = XEQMSupportToken + "Close " + ToString(positions[minInPIDX].ticket) + " Due Min In Profit ..."; + string message = XEQMSupportToken + " Close " + ToString(positions[minInPIDX].ticket) + " Due Min In Profit ..."; // Alert(message); diff --git a/Documents/BKP/usefull.mq5 b/Documents/BKP/usefull.mq5 index 7de7e904..8640d271 100644 --- a/Documents/BKP/usefull.mq5 +++ b/Documents/BKP/usefull.mq5 @@ -3070,3 +3070,319 @@ } } } + + +//////////////////////////////////////////////////////////////////////// + + // + cPusher = 0; + sPusher = 0; + mPusher = 0; + lPusher = 0; + hPusher = 0; + + // + cProvider = NULL; + sProvider = NULL; + mProvider = NULL; + lProvider = NULL; + hProvider = NULL; + + // + cSignal.Clean(); + sSignal.Clean(); + mSignal.Clean(); + lSignal.Clean(); + hSignal.Clean(); + + // + cHasSignal = false; + sHasSignal = false; + mHasSignal = false; + lHasSignal = false; + hHasSignal = false; + + // + cConditions.Clean(); + sConditions.Clean(); + mConditions.Clean(); + lConditions.Clean(); + hConditions.Clean(); + + // + datetime cTime = TimeCurrent(); + + // + // Current ... + bool canProcess = mSetups[i] + .CanProcessBar( + X_MARKET_CYCLE_UNKNOWN // + ); + // + datetime next = mSetups[i].GetNextSignalTime(X_MARKET_CYCLE_UNKNOWN); + if (IsValid(next)) + { + canProcess = canProcess && cTime >= next; + } + + // + if (canProcess) + { + // + bool iHasConditions = mSetups[i].GetConditions( + cConditions, + X_MARKET_CYCLE_UNKNOWN, // Current Market ... + 0, // Bar Index ... + 5 // Loop Back ... + ); + + // + if (iHasConditions) + { + // + // Parse Conditions for Signal ... + cHasSignal = signalGenerator.HasSignal( + cConditions, + cSignal, + cPusher, + cProvider, + AllowSupport(), + mAllowLong, + mAllowShort, + mVolume, + mSLPoint, + mIgnoreSL, + mTPPoint, + mIgnoreTP // + ); + + // + if (cHasSignal) + { + // + mSetups[i].WaitsUntilNextBar( + X_MARKET_CYCLE_UNKNOWN // + ); + } + } + } + + // + // Short ... + canProcess = mSetups[i] + .CanProcessBar( + X_MARKET_CYCLE_SHORT // + ); + // + next = mSetups[i].GetNextSignalTime(X_MARKET_CYCLE_SHORT); + if (IsValid(next)) + { + sHasSignal = canProcess && cTime >= next; + } + + // + if (canProcess) + { + // + bool iHasConditions = mSetups[i].GetConditions( + sConditions, + X_MARKET_CYCLE_SHORT, // Current Market ... + 0, // Bar Index ... + 5 // Loop Back ... + ); + + // + if (iHasConditions) + { + // + // Parse Conditions for Signal ... + sHasSignal = signalGenerator.HasSignal( + sConditions, + sSignal, + sPusher, + sProvider, + AllowSupport(), + mAllowLong, + mAllowShort, + mVolume, + mSLPoint, + mIgnoreSL, + mTPPoint, + mIgnoreTP // + ); + + // + if (sHasSignal) + { + // + mSetups[i].WaitsUntilNextBar( + X_MARKET_CYCLE_SHORT // + ); + } + } + } + + // + // Medium ... + canProcess = mSetups[i] + .CanProcessBar( + X_MARKET_CYCLE_MEDIUM // + ); + // + next = mSetups[i].GetNextSignalTime(X_MARKET_CYCLE_MEDIUM); + if (IsValid(next)) + { + mHasSignal = canProcess && cTime >= next; + } + + // + if (canProcess) + { + // + bool iHasConditions = mSetups[i].GetConditions( + mConditions, + X_MARKET_CYCLE_MEDIUM, // Current Market ... + 0, // Bar Index ... + 5 // Loop Back ... + ); + + // + if (iHasConditions) + { + // + // Parse Conditions for Signal ... + mHasSignal = signalGenerator.HasSignal( + mConditions, + mSignal, + mPusher, + mProvider, + AllowSupport(), + mAllowLong, + mAllowShort, + mVolume, + mSLPoint, + mIgnoreSL, + mTPPoint, + mIgnoreTP // + ); + + // + if (mHasSignal) + { + // + mSetups[i].WaitsUntilNextBar( + X_MARKET_CYCLE_MEDIUM // + ); + } + } + } + + // + // Long ... + canProcess = mSetups[i] + .CanProcessBar( + X_MARKET_CYCLE_LONG // + ); + // + next = mSetups[i].GetNextSignalTime(X_MARKET_CYCLE_LONG); + if (IsValid(next)) + { + lHasSignal = canProcess && cTime >= next; + } + + // + if (canProcess) + { + // + bool iHasConditions = mSetups[i].GetConditions( + lConditions, + X_MARKET_CYCLE_LONG, // Current Market ... + 0, // Bar Index ... + 5 // Loop Back ... + ); + + // + if (iHasConditions) + { + // + // Parse Conditions for Signal ... + lHasSignal = signalGenerator.HasSignal( + lConditions, + lSignal, + lPusher, + lProvider, + AllowSupport(), + mAllowLong, + mAllowShort, + mVolume, + mSLPoint, + mIgnoreSL, + mTPPoint, + mIgnoreTP // + ); + + // + if (lHasSignal) + { + // + mSetups[i].WaitsUntilNextBar( + X_MARKET_CYCLE_LONG // + ); + } + } + } + + // + // Hind ... + canProcess = mSetups[i] + .CanProcessBar( + X_MARKET_CYCLE_HIND // + ); + // + next = mSetups[i].GetNextSignalTime(X_MARKET_CYCLE_HIND); + if (IsValid(next)) + { + hHasSignal = canProcess && cTime >= next; + } + + // + if (canProcess) + { + // + bool iHasConditions = mSetups[i].GetConditions( + hConditions, + X_MARKET_CYCLE_HIND, // Current Market ... + 0, // Bar Index ... + 5 // Loop Back ... + ); + + // + if (iHasConditions) + { + // + // Parse Conditions for Signal ... + hHasSignal = signalGenerator.HasSignal( + hConditions, + hSignal, + hPusher, + hProvider, + AllowSupport(), + mAllowLong, + mAllowShort, + mVolume, + mSLPoint, + mIgnoreSL, + mTPPoint, + mIgnoreTP // + ); + + // + if (hHasSignal) + { + // + mSetups[i].WaitsUntilNextBar( + X_MARKET_CYCLE_HIND // + ); + } + } + } diff --git a/Libraries/x-saherelm.xtrade.lib.mq5 b/Libraries/x-saherelm.xtrade.lib.mq5 index 9365b301..fcf8ee18 100644 --- a/Libraries/x-saherelm.xtrade.lib.mq5 +++ b/Libraries/x-saherelm.xtrade.lib.mq5 @@ -3377,7 +3377,7 @@ int FindMaxDrawdownIndex( // if (max == 0 || - max < iPosition.profit) + MathAbs(max) < MathAbs(iPosition.profit)) { // result = i;