From 3b7b3cd1cd3604f47d19aa0f003b442bd8f032be Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Sun, 16 Jun 2024 16:39:11 +0330 Subject: [PATCH] last ... --- Classes/x-saherelm.x121.setup.xea.mq5 | 1083 ++++++++++--------------- Classes/x-saherelm.xea.class.mq5 | 8 +- Documents/BKP/usefull.mq5 | 669 +++++++++++++++ Experts/x-saherelm.x121.ea.mq5 | 148 ++-- 4 files changed, 1212 insertions(+), 696 deletions(-) diff --git a/Classes/x-saherelm.x121.setup.xea.mq5 b/Classes/x-saherelm.x121.setup.xea.mq5 index 1ddc9c2f..d1c93462 100644 --- a/Classes/x-saherelm.x121.setup.xea.mq5 +++ b/Classes/x-saherelm.x121.setup.xea.mq5 @@ -1007,7 +1007,7 @@ private: // - Conditions; // - Scores; // - etc ... -class XTradeInfoHandler +class XTradeHandler { // public: @@ -1016,7 +1016,7 @@ public: // // Constructor ... - void XTradeInfoHandler( + void XTradeHandler( XSCTrade *trade // an Instance of Trader Class ) { @@ -1030,6 +1030,9 @@ public: // // Getter(s) / Setter(s) ... + // + // Others ... + // bool GetSave() { @@ -1043,7 +1046,7 @@ public: } // - // Support ... + // Supporting ... // bool AllowSupport() @@ -1057,6 +1060,82 @@ public: mAllowSupport = value; } + // + int MaxNumberOfSupports() + { + return mMaxNumberOfSupports; + } + + // + void MaxNumberOfSupports(int value) + { + // + if (value < 0) + { + value = 0; + } + + // + mMaxNumberOfSupports = value; + } + + // + double SupportVolumeMultiplier() + { + return mSupportVolumeMultiplier; + } + + // + void SupportVolumeMultiplier(double value) + { + // + if (value < 1) + { + value = 1; + } + + // + mSupportVolumeMultiplier = value; + } + + // + double MaxAllowedSupportVolume() + { + return mMaxAllowedSupportVolume(); + } + + // + void MaxAllowedSupportVolume(double value) + { + // + if (value < 0.01) + { + value = 0.01; + } + + // + mMaxAllowedSupportVolume = value; + } + + // + bool EnableSupport() + { + // + bool result = false; + + // + result = + // + AllowSupport() && + MaxNumberOfSupports() > 0 && + SupportVolumeMultiplier() > 0 + // + ; + + // + return result; + } + // // Trailling Stop ... @@ -1742,17 +1821,20 @@ public: // int RequestForSupport( XSignal &signals[], - XSCX121SetupCycles *&setups[] // Number of Setups + XSCX121SetupCycles *&setups[], // Number of Setups + double supportDistance = 50, + double volumeMultiplier = 2 // ) { // int result = 0; // - Clean(signals); + // TODO: Complete this Later ... + return result; // - double supportDistance = 50; + Clean(signals); // if (!AllowSupport()) @@ -1760,6 +1842,9 @@ public: return result; } + // + Sync(); + // // Validate Setups Count ... int setupsCount = ArraySize(setups); @@ -1810,6 +1895,13 @@ public: continue; } + // + int index = FindIndex(iPosition.ticket); + if (!IsValidIndex(index)) + { + continue; + } + // // Check Position must atleast 20 Point in drawdown ... @@ -1830,424 +1922,12 @@ public: double priceDiffPoints = priceDiff / onePointPrice; // - bool isFarEnough = priceDiffPoints >= supportDistance; + bool isFarEnough = priceDiffPoints >= (supportDistance / 2); if (!isFarEnough) { continue; } - // - // Now Check Position SUpports ... - XPosition iSupports[]; - int iSupportsCount = mTrader.GetSupports( - iPosition.ticket, - iSupports // - ); - bool isFirst = !IsValidSize(iSupportsCount); - bool canSupport = isFirst; // || iSupportsCount < 3; - if (!canSupport) - { - continue; - } - - // - // Now Check Signals For not Exists ... - int signalsCount = ArraySize(signals); - if (IsValidSize(signalsCount)) - { - // - bool isInserted = false; - for (int j = 0; j < signalsCount; j++) - { - // - isInserted = signals[j].positionId == iPosition.ticket; - if (isInserted) - { - break; - } - } - - // - if (isInserted) - { - continue; - } - } - - // - // First Try to Get Market State ... - - // - double bullishScore = 0; - double bearishScore = 0; - double tmpBullishScore = 0; - double tmpBearishScore = 0; - - // - // Max Verifications is 11 ... - int reqValidation = 6; - int longVerifications = 0; - int shortVerifications = 0; - - // - // Pushers ... - int longPushers = 0; - int shortPushers = 0; - int tmpLongPushers = 0; - int tmpShortPushers = 0; - - // - string tmpProvider; - string longProviders[]; - string shortProviders[]; - - // - double volumeOSC = 0; - - // - // Current ... - X121SetupConditions cConditions; - bool cHasConditions = setups[idx].GetConditions( - cConditions, - X_MARKET_CYCLE_UNKNOWN // - ); - if (!cHasConditions) - { - continue; - } - bool isCValidForLong = signalGenerator.IsConditionsValidForLong( - cConditions, - reqValidation // - ); - if (isCValidForLong) - { - longVerifications += reqValidation; - } - bool isCValidForShort = signalGenerator.IsConditionsValidForShort( - cConditions, - reqValidation // - ); - if (isCValidForShort) - { - shortVerifications += reqValidation; - } - bool cHasLongConditions = signalGenerator.HasLongConditions( - cConditions, - tmpLongPushers, - tmpProvider // - ); - if (cHasLongConditions) - { - // - AddSpecific( - tmpProvider, - longProviders // - ); - - // - longPushers += tmpLongPushers; - } - bool cHasShortConditions = signalGenerator.HasShortConditions( - cConditions, - tmpShortPushers, - tmpProvider // - ); - if (cHasShortConditions) - { - // - AddSpecific( - tmpProvider, - shortProviders // - ); - - // - shortPushers += tmpShortPushers; - } - volumeOSC += cConditions.vlmConditions.volume[1]; - cConditions.GenerateScore( - tmpBullishScore, - tmpBearishScore // - ); - bullishScore += tmpBullishScore; - bearishScore += tmpBearishScore; - - // - // Short ... - X121SetupConditions sConditions; - bool sHasConditions = setups[idx].GetConditions( - sConditions, - X_MARKET_CYCLE_SHORT // - ); - if (!sHasConditions) - { - continue; - } - bool isSValidForLong = signalGenerator.IsConditionsValidForLong( - sConditions, - reqValidation // - ); - if (isSValidForLong) - { - longVerifications += reqValidation; - } - bool isSValidForShort = signalGenerator.IsConditionsValidForShort( - sConditions, - reqValidation // - ); - if (isSValidForShort) - { - shortVerifications += reqValidation; - } - bool sHasLongConditions = signalGenerator.HasLongConditions( - sConditions, - tmpLongPushers, - tmpProvider // - ); - if (sHasLongConditions) - { - // - AddSpecific( - tmpProvider, - longProviders // - ); - - // - longPushers += tmpLongPushers; - } - bool sHasShortConditions = signalGenerator.HasShortConditions( - sConditions, - tmpShortPushers, - tmpProvider // - ); - if (sHasShortConditions) - { - // - AddSpecific( - tmpProvider, - shortProviders // - ); - - // - shortPushers += tmpShortPushers; - } - volumeOSC += sConditions.vlmConditions.volume[1]; - sConditions.GenerateScore( - tmpBullishScore, - tmpBearishScore // - ); - bullishScore += tmpBullishScore; - bearishScore += tmpBearishScore; - - // - // Medium ... - X121SetupConditions mConditions; - bool mHasConditions = setups[idx].GetConditions( - mConditions, - X_MARKET_CYCLE_MEDIUM // - ); - if (!mHasConditions) - { - continue; - } - XSCZones *mZones = setups[idx].GetZones( - X_MARKET_CYCLE_MEDIUM // - ); - bool isMValidForLong = signalGenerator.IsConditionsValidForLong( - mConditions, - reqValidation // - ); - if (isMValidForLong) - { - longVerifications += reqValidation; - } - bool isMValidForShort = signalGenerator.IsConditionsValidForShort( - mConditions, - reqValidation // - ); - if (isMValidForShort) - { - shortVerifications += reqValidation; - } - bool mHasLongConditions = signalGenerator.HasLongConditions( - mConditions, - tmpLongPushers, - tmpProvider // - ); - if (mHasLongConditions) - { - // - AddSpecific( - tmpProvider, - longProviders // - ); - - // - longPushers += tmpLongPushers; - } - bool mHasShortConditions = signalGenerator.HasShortConditions( - mConditions, - tmpShortPushers, - tmpProvider // - ); - if (mHasShortConditions) - { - // - AddSpecific( - tmpProvider, - shortProviders // - ); - - // - shortPushers += tmpShortPushers; - } - volumeOSC += mConditions.vlmConditions.volume[1]; - mConditions.GenerateScore( - tmpBullishScore, - tmpBearishScore // - ); - bullishScore += tmpBullishScore; - bearishScore += tmpBearishScore; - - // - // Long ... - X121SetupConditions lConditions; - bool lHasConditions = setups[idx].GetConditions( - lConditions, - X_MARKET_CYCLE_LONG // - ); - if (!lHasConditions) - { - continue; - } - XSCZones *lZones = setups[idx].GetZones( - X_MARKET_CYCLE_LONG // - ); - bool isLValidForLong = signalGenerator.IsConditionsValidForLong( - lConditions, - reqValidation // - ); - if (isLValidForLong) - { - longVerifications += reqValidation; - } - bool isLValidForShort = signalGenerator.IsConditionsValidForShort( - lConditions, - reqValidation // - ); - if (isLValidForShort) - { - shortVerifications += reqValidation; - } - bool lHasLongConditions = signalGenerator.HasLongConditions( - lConditions, - tmpLongPushers, - tmpProvider // - ); - if (lHasLongConditions) - { - // - AddSpecific( - tmpProvider, - longProviders // - ); - - // - longPushers += tmpLongPushers; - } - bool lHasShortConditions = signalGenerator.HasShortConditions( - lConditions, - tmpShortPushers, - tmpProvider // - ); - if (lHasShortConditions) - { - // - AddSpecific( - tmpProvider, - shortProviders // - ); - - // - shortPushers += tmpShortPushers; - } - volumeOSC += lConditions.vlmConditions.volume[1]; - lConditions.GenerateScore( - tmpBullishScore, - tmpBearishScore // - ); - bullishScore += tmpBullishScore; - bearishScore += tmpBearishScore; - - // - // Hind ... - X121SetupConditions hConditions; - bool hHasConditions = setups[idx].GetConditions( - hConditions, - X_MARKET_CYCLE_HIND // - ); - if (!hHasConditions) - { - continue; - } - XSCZones *hZones = setups[idx].GetZones( - X_MARKET_CYCLE_HIND // - ); - bool isHValidForLong = signalGenerator.IsConditionsValidForLong( - hConditions, - reqValidation // - ); - if (isHValidForLong) - { - longVerifications += reqValidation; - } - bool isHValidForShort = signalGenerator.IsConditionsValidForShort( - hConditions, - reqValidation // - ); - if (isHValidForShort) - { - shortVerifications += reqValidation; - } - bool hHasLongConditions = signalGenerator.HasLongConditions( - hConditions, - tmpLongPushers, - tmpProvider // - ); - if (hHasLongConditions) - { - // - AddSpecific( - tmpProvider, - longProviders // - ); - - // - longPushers += tmpLongPushers; - } - bool hHasShortConditions = signalGenerator.HasShortConditions( - hConditions, - tmpShortPushers, - tmpProvider // - ); - if (hHasShortConditions) - { - // - AddSpecific( - tmpProvider, - shortProviders // - ); - - // - shortPushers += tmpShortPushers; - } - volumeOSC += hConditions.vlmConditions.volume[1]; - hConditions.GenerateScore( - tmpBullishScore, - tmpBearishScore // - ); - bullishScore += tmpBullishScore; - bearishScore += tmpBearishScore; - // // Now We Have all required Data to Decide What Supports for // Specified In DrawDown Position ... @@ -2273,35 +1953,32 @@ public: bool isLong = IsLong(iPosition.type); // - // Long Support ... - bool canLongSupport = - // - volumeOSC > 5 && - bullishScore > bearishScore && - ArraySize(longProviders) >= 2 && - bearishScore < bullishScore / 3.5 && - longVerifications > reqValidation * 3 - // - ; - if (canLongSupport) + // Here we Can Start a Recovery Zone ... + if (data[index].rLongEntry <= 0 && + data[index].rShortEntry <= 0 && + data[index].rVolume <= 0) { // - bool isPrepared = tmpSignal.Prepare( - iPosition.symbol, - iPosition.provider, - iPosition.period, - POSITION_TYPE_BUY, - X_ORDER_MODE_MARKET, - longEntry, - mVolume // + data[index].PrepareNextRecovery( + supportDistance, + volumeMultiplier, + iPosition.type // ); - + } + else + { // - if (isPrepared) + bool hasRecovery = data[index].HasRecovery( + tmpSignal, + supportDistance, + volumeMultiplier // + ); + if (hasRecovery) { // - tmpSignal.positionId = iPosition.ticket; - string comment = GenerateSupportTag(iPosition.ticket); + // tmpSignal.sl = 0; + // tmpSignal.tp = 0; + string comment = GenerateEQMSupportTag(iPosition.ticket); tmpSignal.comment = comment; // @@ -2309,107 +1986,22 @@ public: tmpSignal, signals // ); - - // - tmpSignal.Clean(); } - } - - // - // Short Support ... - bool canShortSupport = - // - volumeOSC < -5 && - bearishScore > bullishScore && - ArraySize(shortProviders) >= 2 && - bullishScore < bearishScore / 3.5 && - shortVerifications > reqValidation * 3 - // - ; - if (canShortSupport) - { - // - bool isPrepared = tmpSignal.Prepare( - iPosition.symbol, - iPosition.provider, - iPosition.period, - POSITION_TYPE_SELL, - X_ORDER_MODE_MARKET, - shortEntry, - mVolume // - ); - - // - if (isPrepared) + else if (priceDiffPoints >= supportDistance) { // - tmpSignal.positionId = iPosition.ticket; - string comment = GenerateSupportTag(iPosition.ticket); - tmpSignal.comment = comment; + // Reset + if (longEntry > data[index].rZoneUpper || shortEntry < data[index].rZoneLower) + { + // + // data[index].ResetRecovery(); - // - AddRef( - tmpSignal, - signals // - ); - - // - tmpSignal.Clean(); + // + } } } // - // If no Support Presents ... - if (!canLongSupport && !canShortSupport) - { - // - // RemoveDraws("MED"); - // RemoveDraws("LON"); - // RemoveDraws("HND"); - AddHotLevelsToZones(mZones); - AddHotLevelsToZones(lZones); - AddHotLevelsToZones(hZones); - - // - // bool isDrawn = mZones.DrawZones(0, "MED"); - // if (isDrawn) - // { - // // - // isDrawn = false; - // RemoveDraws("MED"); - // } - - // // - // isDrawn = lZones.DrawZones(0, "LON"); - // if (isDrawn) - // { - // // - // isDrawn = false; - // RemoveDraws("LON"); - // } - - // // - // isDrawn = hZones.DrawZones(0, "HND"); - // if (isDrawn) - // { - // // - // isDrawn = false; - // RemoveDraws("HND"); - // } - - // // - // isDrawn = mZones.DrawZones(0, "MED"); - // isDrawn = lZones.DrawZones(0, "LON"); - // isDrawn = hZones.DrawZones(0, "HND"); - // if (isDrawn) - // { - // // - // isDrawn = false; - // // RemoveDraws("MED"); - // // RemoveDraws("LON"); - // // RemoveDraws("HND"); - // } - } } // @@ -2728,8 +2320,11 @@ public: ) { // - mTradeInfoHandler = new XTradeInfoHandler(mTrader); - SaveResults(false); + mTradeHandler = new XTradeHandler(mTrader); + + // + // Implement Default Configs ... + DefaultConfigs(); } // @@ -2737,7 +2332,7 @@ public: ~XSCX121SetupEA() { // - delete mTradeInfoHandler; + delete mTradeHandler; // Clean(mSetups); @@ -2769,6 +2364,9 @@ public: // // Getter(s) / Setter(s) ... + // + /// Signals ... + // bool AllowLong() { @@ -2793,6 +2391,40 @@ public: mAllowShort = value; } + // + int ReuiredSignalVerifications() + { + return mReuiredSignalVerifications; + } + + // + void ReuiredSignalVerifications(int value) + { + // + if (value < 1) + { + value = 1; + } + + // + mReuiredSignalVerifications = value; + } + + // + bool GetVerificationFromOtherTimeFrames() + { + return mGetVerificationFromOtherTimeFrames; + } + + // + void GetVerificationFromOtherTimeFrames(bool value) + { + mGetVerificationFromOtherTimeFrames = value; + } + + // + // Risk Management ... + // double Volume() { @@ -2850,6 +2482,26 @@ public: mSLPoint = value; } + // + int MaxAllowedTrades() + { + return mMaxAllowedTrades; + } + + // + void MaxAllowedTrades(int value) + { + // + if (value < 0) + { + value = 0; + } + + // + mMaxAllowedTrades = value; + mTrader.SetMaxAllowedPositions(value); + } + // bool IgnoreTP() { @@ -2875,66 +2527,44 @@ public: } // - bool CloseOnOpposit() + // Signalling ... + + // + int StartSignallingHoure() { - return mCloseOnOpposit; + return mStartSignallingHoure; } // - void CloseOnOpposit(bool value) - { - mCloseOnOpposit = value; - } - - // - int ReuiredSignalVerifications() - { - return mReuiredSignalVerifications; - } - - // - void ReuiredSignalVerifications(int value) + void StartSignallingHoure(int value) { // - if (value < 1) + if (value < -1) { - value = 1; + value = -1; } // - mReuiredSignalVerifications = value; + mStartSignallingHoure = value; } // - bool GetVerificationFromOtherTimeFrames() + int EndSignallingHoure() { - return mGetVerificationFromOtherTimeFrames; + return mEndSignallingHoure; } // - void GetVerificationFromOtherTimeFrames(bool value) - { - mGetVerificationFromOtherTimeFrames = value; - } - - // - int MaxAllowedTrades() - { - return mMaxAllowedTrades; - } - - // - void MaxAllowedTrades(int value) + void EndSignallingHoure(int value) { // - if (value < 0) + if (value < -1) { - value = 0; + value = -1; } // - mMaxAllowedTrades = value; - mTrader.SetMaxAllowedPositions(value); + mEndSignallingHoure = value; } // @@ -2947,136 +2577,202 @@ public: void CloseOnSpecificTime(int value) { // - if (value < 0) + if (value < -1) { value = -1; } - // - if (value > 23) - { - value = 23; - } - // mCloseOnSpecificTime = value; } // - // Support ... - - // - bool AllowSupport() + bool CloseOnOpposit() { - return mTradeInfoHandler.AllowSupport(); + return mCloseOnOpposit; } // - void AllowSupport(bool value) + void CloseOnOpposit(bool value) { - mTradeInfoHandler.AllowSupport(value); + mCloseOnOpposit = value; } // - // Trailling Stop ... + // Trailling ... // bool AllowTrailStop() { - return mTradeInfoHandler.AllowTrailStop(); + return mTradeHandler.AllowTrailStop(); } // void AllowTrailStop(bool value) { - mTradeInfoHandler.AllowTrailStop(value); + mTradeHandler.AllowTrailStop(value); } // double NextTrailPoint() { - return mTradeInfoHandler.NextTrailPoint(); + return mTradeHandler.NextTrailPoint(); } // void NextTrailPoint(double value) { - mTradeInfoHandler.NextTrailPoint(value); + mTradeHandler.NextTrailPoint(value); } // double FirstTrailPoint() { - return mTradeInfoHandler.FirstTrailPoint(); + return mTradeHandler.FirstTrailPoint(); } // void FirstTrailPoint(double value) { - mTradeInfoHandler.FirstTrailPoint(value); + mTradeHandler.FirstTrailPoint(value); } // double NextTrailDistance() { - return mTradeInfoHandler.NextTrailDistance(); + return mTradeHandler.NextTrailDistance(); } // void NextTrailDistance(double value) { - mTradeInfoHandler.NextTrailDistance(value); + mTradeHandler.NextTrailDistance(value); } // double FirstTrailDistance() { - return mTradeInfoHandler.FirstTrailDistance(); + return mTradeHandler.FirstTrailDistance(); } // void FirstTrailDistance(double value) { - mTradeInfoHandler.FirstTrailDistance(value); + mTradeHandler.FirstTrailDistance(value); } // - // Grid System ... + // Supporting ... + + // + bool AllowSupport() + { + return mTradeHandler.AllowSupport(); + } + + // + void AllowSupport(bool value) + { + mTradeHandler.AllowSupport(value); + } + + // + int MaxNumberOfSupports() + { + return mTradeHandler.MaxNumberOfSupports(); + } + + // + void MaxNumberOfSupports(int value) + { + mTradeHandler.MaxNumberOfSupports(value); + } + + // + double SupportVolumeMultiplier() + { + return mTradeHandler.SupportVolumeMultiplier(); + } + + // + void SupportVolumeMultiplier(double value) + { + mTradeHandler.SupportVolumeMultiplier(value); + } + + // + double MaxAllowedSupportVolume() + { + return mTradeHandler.MaxAllowedSupportVolume(); + } + + // + void MaxAllowedSupportVolume(double value) + { + mTradeHandler.MaxAllowedSupportVolume(value); + } + + // + // Grid ... // bool AllowGrid() { - return mTradeInfoHandler.AllowGrid(); + return mTradeHandler.AllowGrid(); } // void AllowGrid(bool value) { - mTradeInfoHandler.AllowGrid(value); + mTradeHandler.AllowGrid(value); + } + + // + int MaxNumberOfGrids() + { + return mTradeHandler.MaxNumberOfGrids(); + } + + // + void MaxNumberOfGrids(int value) + { + mTradeHandler.MaxNumberOfGrids(value); } // double GridDistance() { - return mTradeInfoHandler.GridDistance(); + return mTradeHandler.GridDistance(); } // void GridDistance(double value) { - mTradeInfoHandler.GridDistance(value); + mTradeHandler.GridDistance(value); } // double GridVolumeMultiplier() { - return mTradeInfoHandler.GridVolumeMultiplier(); + return mTradeHandler.GridVolumeMultiplier(); } // void GridVolumeMultiplier(double value) { - mTradeInfoHandler.GridVolumeMultiplier(value); + mTradeHandler.GridVolumeMultiplier(value); + } + + // + double MaxAllowedGridVolume() + { + return mTradeHandler.MaxAllowedGridVolume(); + } + + // + void MaxAllowedGridVolume(double value) + { + mTradeHandler.MaxAllowedGridVolume(value); } // @@ -3085,49 +2781,76 @@ public: // bool AllowRecovery() { - return mTradeInfoHandler.AllowRecovery(); + return mTradeHandler.AllowRecovery(); } // void AllowRecovery(bool value) { - mTradeInfoHandler.AllowRecovery(value); + mTradeHandler.AllowRecovery(value); + } + + // + int MaxNumberOfRecoveries() + { + return mTradeHandler.MaxNumberOfRecoveries(); + } + + // + void MaxNumberOfRecoveries(int value) + { + mTradeHandler.MaxNumberOfRecoveries(value); } // double RecoveryDistance() { - return mTradeInfoHandler.RecoveryDistance(); + return mTradeHandler.RecoveryDistance(); } // void RecoveryDistance(double value) { - mTradeInfoHandler.RecoveryDistance(value); + mTradeHandler.RecoveryDistance(value); } // double RecoveryVolumeMultiplier() { - return mTradeInfoHandler.RecoveryVolumeMultiplier(); + return mTradeHandler.RecoveryVolumeMultiplier(); } // void RecoveryVolumeMultiplier(double value) { - mTradeInfoHandler.RecoveryVolumeMultiplier(value); + mTradeHandler.RecoveryVolumeMultiplier(value); } + // + double MaxAllowedRecoveryVolume() + { + return mTradeHandler.MaxAllowedRecoveryVolume(); + } + + // + void MaxAllowedRecoveryVolume(double value) + { + mTradeHandler.MaxAllowedRecoveryVolume(value); + } + + // + // Others ... + // bool SaveResults() { - return mTradeInfoHandler.GetSave(); + return mTradeHandler.GetSave(); } // void SaveResults(bool value) { - mTradeInfoHandler.SetSave(value); + mTradeHandler.SetSave(value); } // @@ -3146,6 +2869,9 @@ public: return this.GetToken(); } + // + // Tools ... + // // Check Provider for any Guards ... bool CheckForGuard(XGuard &guards[]) override @@ -3753,7 +3479,7 @@ public: // // Add new Signal Info ... - mTradeInfoHandler.Add( + mTradeHandler.Add( signal, pushers, mVolumeOSC, @@ -3931,11 +3657,11 @@ public: bool isEQMSupport = ExtractEQMSupportedTicket(signal.comment) > 0; if (!isSupport && !isEQMSupport) { - mTradeInfoHandler.Update(tSignal); + mTradeHandler.Update(tSignal); } // - mTradeInfoHandler.Sync(); + mTradeHandler.Sync(); } // @@ -3947,8 +3673,8 @@ public: // // Signal Info Manager ... XSignal tSignal = signal; - mTradeInfoHandler.Remove(tSignal); - mTradeInfoHandler.Sync(); + mTradeHandler.Remove(tSignal); + mTradeHandler.Sync(); } // @@ -3966,11 +3692,11 @@ public: tPosition.comment = comment; if (!isSupport && !isEQMSupport) { - mTradeInfoHandler.Update(tPosition); + mTradeHandler.Update(tPosition); } // - mTradeInfoHandler.Sync(); + mTradeHandler.Sync(); } // @@ -3980,8 +3706,8 @@ public: // When a Position's Stop Loss Triggered ... // Signal Info Manager ... XDeal tDeal = deal; - mTradeInfoHandler.Update(tDeal); - mTradeInfoHandler.Sync(); + mTradeHandler.Update(tDeal); + mTradeHandler.Sync(); } // @@ -3991,8 +3717,8 @@ public: // When a Position's Take Profit Triggered ... // Signal Info Manager ... XDeal tDeal = deal; - mTradeInfoHandler.Update(tDeal); - mTradeInfoHandler.Sync(); + mTradeHandler.Update(tDeal); + mTradeHandler.Sync(); } // @@ -4042,25 +3768,92 @@ private: // Props ... // + // Signals ... bool mAllowLong; // Allow Long bool mAllowShort; // Allow Short - double mVolume; // Volume - double mTPPoint; // TP Point - double mSLPoint; // SL Point - bool mIgnoreTP; // Ignore Calculated TP - bool mIgnoreSL; // Ignore Calculated SL - int mMaxAllowedTrades; // Max Alloed Positions - bool mCloseOnOpposit; // Close all Positions on Opposit - int mCloseOnSpecificTime; // Close All Trades in Specific Time int mReuiredSignalVerifications; // Required Verifications for Validate Signals bool mGetVerificationFromOtherTimeFrames; // Get Verifications from Other Time Frames // - bool mUseSupport; // Use Support Signals + // Risk Management ... + double mVolume; // Volume + double mTPPoint; // TP Point + double mSLPoint; // SL Point + int mMaxAllowedTrades; // Max Alloed Positions + bool mIgnoreTP; // Ignore Calculated TP + bool mIgnoreSL; // Ignore Calculated SL // - bool mSaveResults; // Save Results in Specific Structure for Test Purposes ... - XTradeInfoHandler *mTradeInfoHandler; // Handle all Event which related to Signals and Positions + // Signalling ... + bool mCloseOnOpposit; // Close all Positions on Opposit + int mEndSignallingHoure; // End Signalling at Specific Time + int mCloseOnSpecificTime; // Close All Trades in Specific Time + int mStartSignallingHoure; // Start Signalling at Specific Time + + // + XTradeHandler *mTradeHandler; // Handle all Event which related to Signals and Positions + + // + // Apply Default Configurations ... + void DefaultConfigs() + { + // + // Signals ... + AllowLong(false); + AllowShort(false); + ReuiredSignalVerifications(0); + GetVerificationFromOtherTimeFrames(false); + + // + // Risk Management ... + TPPoint(0); + SLPoint(0); + Volume(0.01); + IgnoreTP(false); + IgnoreSL(false); + MaxAllowedTrades(0); + + // + // Signalling ... + CloseOnOpposit(false); + EndSignallingHoure(-1); + CloseOnSpecificTime(-1); + StartSignallingHoure(-1); + + // + // Trailling ... + AllowTrailStop(false); + NextTrailPoint(0); + FirstTrailPoint(0); + NextTrailDistance(0); + FirstTrailDistance(0); + + // + // Supporting ... + AllowSupport(false); + MaxNumberOfSupports(0); + SupportVolumeMultiplier(0.01); + MaxAllowedSupportVolume(0.08); + + // + // Grid ... + AllowGrid(false); + GridDistance(0); + MaxNumberOfGrids(0); + GridVolumeMultiplier(0.01); + MaxAllowedGridVolume(0.08); + + // + // Recovery ... + AllowRecovery(false); + MaxNumberOfRecoveries(0); + RecoveryDistance(0); + RecoveryVolumeMultiplier(0.01); + MaxAllowedRecoveryVolume(0.08); + + // + SaveResults(false); + } // int mBullishSigns; @@ -4164,19 +3957,19 @@ private: // bool EnableTrailling() { - return mTradeInfoHandler.EnableTrailling(); + return mTradeHandler.EnableTrailling(); } // bool EnableGrid() { - return mTradeInfoHandler.EnableGrid(); + return mTradeHandler.EnableGrid(); } // bool EnableRecovery() { - return mTradeInfoHandler.EnableRecovery(); + return mTradeHandler.EnableRecovery(); } // @@ -4429,14 +4222,14 @@ private: if (EnableTrailling()) { // - int trailsCount = mTradeInfoHandler.HandleTrailling(); + int trailsCount = mTradeHandler.HandleTrailling(); if (IsValidSize(trailsCount)) { // string message = XEQMSupportToken + " Successfully Trail Stop for: " + ToString(trailsCount) + " Position(s) ..."; // - Alert(message); + // Alert(message); } } @@ -4446,7 +4239,7 @@ private: { // XSignal supports[]; - int supportsCount = mTradeInfoHandler.RequestForSupport( + int supportsCount = mTradeHandler.RequestForSupport( supports, mSetups // ); @@ -4462,7 +4255,7 @@ private: { // XSignal signals[]; - int signalsCount = mTradeInfoHandler + int signalsCount = mTradeHandler .RequestForGrid(signals); if (IsValidSize(signalsCount)) { @@ -4476,7 +4269,7 @@ private: { // XSignal signals[]; - int signalsCount = mTradeInfoHandler + int signalsCount = mTradeHandler .RequestForRecovery(signals); if (IsValidSize(signalsCount)) { diff --git a/Classes/x-saherelm.xea.class.mq5 b/Classes/x-saherelm.xea.class.mq5 index 5ad4412a..844f84f6 100644 --- a/Classes/x-saherelm.xea.class.mq5 +++ b/Classes/x-saherelm.xea.class.mq5 @@ -671,11 +671,11 @@ protected: // OnSignalExecutionFailed(signal, state); - // - string message = "Signal Execution Failed: " + ToString(state) + " ..."; + // // + // string message = "Signal Execution Failed: " + ToString(state) + " ..."; - // - Alert(message); + // // + // Alert(message); } // diff --git a/Documents/BKP/usefull.mq5 b/Documents/BKP/usefull.mq5 index 24cdf913..1341cc4c 100644 --- a/Documents/BKP/usefull.mq5 +++ b/Documents/BKP/usefull.mq5 @@ -473,3 +473,672 @@ // return result; } + + + +///////////////////////////////////////////////////////////// + + + // + // Long Support ... + bool canLongSupport = + // + volumeOSC > 5 && + bullishScore > bearishScore && + ArraySize(longProviders) >= 2 && + bearishScore < bullishScore / 3.5 && + longVerifications > reqValidation * 3 + // + ; + if (canLongSupport) + { + // + bool isPrepared = tmpSignal.Prepare( + iPosition.symbol, + iPosition.provider, + iPosition.period, + POSITION_TYPE_BUY, + X_ORDER_MODE_MARKET, + longEntry, + mVolume // + ); + + // + if (isPrepared) + { + // + tmpSignal.positionId = iPosition.ticket; + string comment = GenerateSupportTag(iPosition.ticket); + tmpSignal.comment = comment; + + // + AddRef( + tmpSignal, + signals // + ); + + // + tmpSignal.Clean(); + } + + // + isPrepared = tmpSignal.Prepare( + iPosition.symbol, + iPosition.provider, + iPosition.period, + POSITION_TYPE_SELL, + X_ORDER_MODE_MARKET, + shortEntry, + mVolume // + ); + + // + if (isPrepared) + { + // + tmpSignal.positionId = iPosition.ticket; + string comment = GenerateSupportTag(iPosition.ticket); + tmpSignal.comment = comment; + + // + AddRef( + tmpSignal, + signals // + ); + + // + tmpSignal.Clean(); + } + } + + // + // Short Support ... + bool canShortSupport = + // + volumeOSC < -5 && + bearishScore > bullishScore && + ArraySize(shortProviders) >= 2 && + bullishScore < bearishScore / 3.5 && + shortVerifications > reqValidation * 3 + // + ; + if (canShortSupport) + { + // + bool isPrepared = tmpSignal.Prepare( + iPosition.symbol, + iPosition.provider, + iPosition.period, + POSITION_TYPE_SELL, + X_ORDER_MODE_MARKET, + shortEntry, + mVolume // + ); + + // + if (isPrepared) + { + // + tmpSignal.positionId = iPosition.ticket; + string comment = GenerateSupportTag(iPosition.ticket); + tmpSignal.comment = comment; + + // + AddRef( + tmpSignal, + signals // + ); + + // + tmpSignal.Clean(); + } + + // + isPrepared = tmpSignal.Prepare( + iPosition.symbol, + iPosition.provider, + iPosition.period, + POSITION_TYPE_BUY, + X_ORDER_MODE_MARKET, + longEntry, + mVolume // + ); + + // + if (isPrepared) + { + // + tmpSignal.positionId = iPosition.ticket; + string comment = GenerateSupportTag(iPosition.ticket); + tmpSignal.comment = comment; + + // + AddRef( + tmpSignal, + signals // + ); + + // + tmpSignal.Clean(); + } + } + + // + // If no Support Presents ... + if (!canLongSupport && !canShortSupport) + { + // + // RemoveDraws("MED"); + // RemoveDraws("LON"); + // RemoveDraws("HND"); + AddHotLevelsToZones(mZones); + AddHotLevelsToZones(lZones); + AddHotLevelsToZones(hZones); + + // + bool isPrepared = tmpSignal.Prepare( + iPosition.symbol, + iPosition.provider, + iPosition.period, + POSITION_TYPE_BUY, + X_ORDER_MODE_MARKET, + longEntry, + iPosition.volume // + ); + if (isPrepared) + { + // + tmpSignal.positionId = iPosition.ticket; + string comment = GenerateSupportTag(iPosition.ticket); + tmpSignal.comment = comment; + + // + AddRef( + tmpSignal, + signals // + ); + + // + tmpSignal.Clean(); + } + + // + isPrepared = tmpSignal.Prepare( + iPosition.symbol, + iPosition.provider, + iPosition.period, + POSITION_TYPE_SELL, + X_ORDER_MODE_MARKET, + shortEntry, + iPosition.volume // + ); + if (isPrepared) + { + // + tmpSignal.positionId = iPosition.ticket; + string comment = GenerateSupportTag(iPosition.ticket); + tmpSignal.comment = comment; + + // + AddRef( + tmpSignal, + signals // + ); + + // + tmpSignal.Clean(); + } + + // + // bool isDrawn = mZones.DrawZones(0, "MED"); + // if (isDrawn) + // { + // // + // isDrawn = false; + // RemoveDraws("MED"); + // } + + // // + // isDrawn = lZones.DrawZones(0, "LON"); + // if (isDrawn) + // { + // // + // isDrawn = false; + // RemoveDraws("LON"); + // } + + // // + // isDrawn = hZones.DrawZones(0, "HND"); + // if (isDrawn) + // { + // // + // isDrawn = false; + // RemoveDraws("HND"); + // } + + // // + // isDrawn = mZones.DrawZones(0, "MED"); + // isDrawn = lZones.DrawZones(0, "LON"); + // isDrawn = hZones.DrawZones(0, "HND"); + // if (isDrawn) + // { + // // + // isDrawn = false; + // // RemoveDraws("MED"); + // // RemoveDraws("LON"); + // // RemoveDraws("HND"); + // } + } + + + // + // Now Check Position SUpports ... + XPosition iSupports[]; + int iSupportsCount = mTrader.GetSupports( + iPosition.ticket, + iSupports // + ); + bool isFirst = !IsValidSize(iSupportsCount); + bool canSupport = isFirst || iSupportsCount < 3; + if (!canSupport) + { + continue; + } + + // + // Now Check Signals For not Exists ... + int signalsCount = ArraySize(signals); + if (IsValidSize(signalsCount)) + { + // + bool isInserted = false; + for (int j = 0; j < signalsCount; j++) + { + // + isInserted = signals[j].positionId == iPosition.ticket; + if (isInserted) + { + break; + } + } + + // + if (isInserted) + { + continue; + } + } + + // + // First Try to Get Market State ... + + // + double bullishScore = 0; + double bearishScore = 0; + double tmpBullishScore = 0; + double tmpBearishScore = 0; + + // + // Max Verifications is 11 ... + int reqValidation = 6; + int longVerifications = 0; + int shortVerifications = 0; + + // + // Pushers ... + int longPushers = 0; + int shortPushers = 0; + int tmpLongPushers = 0; + int tmpShortPushers = 0; + + // + string tmpProvider; + string longProviders[]; + string shortProviders[]; + + // + double volumeOSC = 0; + + // + // Current ... + X121SetupConditions cConditions; + bool cHasConditions = setups[idx].GetConditions( + cConditions, + X_MARKET_CYCLE_UNKNOWN // + ); + if (!cHasConditions) + { + continue; + } + bool isCValidForLong = signalGenerator.IsConditionsValidForLong( + cConditions, + reqValidation // + ); + if (isCValidForLong) + { + longVerifications += reqValidation; + } + bool isCValidForShort = signalGenerator.IsConditionsValidForShort( + cConditions, + reqValidation // + ); + if (isCValidForShort) + { + shortVerifications += reqValidation; + } + bool cHasLongConditions = signalGenerator.HasLongConditions( + cConditions, + tmpLongPushers, + tmpProvider // + ); + if (cHasLongConditions) + { + // + AddSpecific( + tmpProvider, + longProviders // + ); + + // + longPushers += tmpLongPushers; + } + bool cHasShortConditions = signalGenerator.HasShortConditions( + cConditions, + tmpShortPushers, + tmpProvider // + ); + if (cHasShortConditions) + { + // + AddSpecific( + tmpProvider, + shortProviders // + ); + + // + shortPushers += tmpShortPushers; + } + volumeOSC += cConditions.vlmConditions.volume[1]; + cConditions.GenerateScore( + tmpBullishScore, + tmpBearishScore // + ); + bullishScore += tmpBullishScore; + bearishScore += tmpBearishScore; + + // + // Short ... + X121SetupConditions sConditions; + bool sHasConditions = setups[idx].GetConditions( + sConditions, + X_MARKET_CYCLE_SHORT // + ); + if (!sHasConditions) + { + continue; + } + bool isSValidForLong = signalGenerator.IsConditionsValidForLong( + sConditions, + reqValidation // + ); + if (isSValidForLong) + { + longVerifications += reqValidation; + } + bool isSValidForShort = signalGenerator.IsConditionsValidForShort( + sConditions, + reqValidation // + ); + if (isSValidForShort) + { + shortVerifications += reqValidation; + } + bool sHasLongConditions = signalGenerator.HasLongConditions( + sConditions, + tmpLongPushers, + tmpProvider // + ); + if (sHasLongConditions) + { + // + AddSpecific( + tmpProvider, + longProviders // + ); + + // + longPushers += tmpLongPushers; + } + bool sHasShortConditions = signalGenerator.HasShortConditions( + sConditions, + tmpShortPushers, + tmpProvider // + ); + if (sHasShortConditions) + { + // + AddSpecific( + tmpProvider, + shortProviders // + ); + + // + shortPushers += tmpShortPushers; + } + volumeOSC += sConditions.vlmConditions.volume[1]; + sConditions.GenerateScore( + tmpBullishScore, + tmpBearishScore // + ); + bullishScore += tmpBullishScore; + bearishScore += tmpBearishScore; + + // + // Medium ... + X121SetupConditions mConditions; + bool mHasConditions = setups[idx].GetConditions( + mConditions, + X_MARKET_CYCLE_MEDIUM // + ); + if (!mHasConditions) + { + continue; + } + XSCZones *mZones = setups[idx].GetZones( + X_MARKET_CYCLE_MEDIUM // + ); + bool isMValidForLong = signalGenerator.IsConditionsValidForLong( + mConditions, + reqValidation // + ); + if (isMValidForLong) + { + longVerifications += reqValidation; + } + bool isMValidForShort = signalGenerator.IsConditionsValidForShort( + mConditions, + reqValidation // + ); + if (isMValidForShort) + { + shortVerifications += reqValidation; + } + bool mHasLongConditions = signalGenerator.HasLongConditions( + mConditions, + tmpLongPushers, + tmpProvider // + ); + if (mHasLongConditions) + { + // + AddSpecific( + tmpProvider, + longProviders // + ); + + // + longPushers += tmpLongPushers; + } + bool mHasShortConditions = signalGenerator.HasShortConditions( + mConditions, + tmpShortPushers, + tmpProvider // + ); + if (mHasShortConditions) + { + // + AddSpecific( + tmpProvider, + shortProviders // + ); + + // + shortPushers += tmpShortPushers; + } + volumeOSC += mConditions.vlmConditions.volume[1]; + mConditions.GenerateScore( + tmpBullishScore, + tmpBearishScore // + ); + bullishScore += tmpBullishScore; + bearishScore += tmpBearishScore; + + // + // Long ... + X121SetupConditions lConditions; + bool lHasConditions = setups[idx].GetConditions( + lConditions, + X_MARKET_CYCLE_LONG // + ); + if (!lHasConditions) + { + continue; + } + XSCZones *lZones = setups[idx].GetZones( + X_MARKET_CYCLE_LONG // + ); + bool isLValidForLong = signalGenerator.IsConditionsValidForLong( + lConditions, + reqValidation // + ); + if (isLValidForLong) + { + longVerifications += reqValidation; + } + bool isLValidForShort = signalGenerator.IsConditionsValidForShort( + lConditions, + reqValidation // + ); + if (isLValidForShort) + { + shortVerifications += reqValidation; + } + bool lHasLongConditions = signalGenerator.HasLongConditions( + lConditions, + tmpLongPushers, + tmpProvider // + ); + if (lHasLongConditions) + { + // + AddSpecific( + tmpProvider, + longProviders // + ); + + // + longPushers += tmpLongPushers; + } + bool lHasShortConditions = signalGenerator.HasShortConditions( + lConditions, + tmpShortPushers, + tmpProvider // + ); + if (lHasShortConditions) + { + // + AddSpecific( + tmpProvider, + shortProviders // + ); + + // + shortPushers += tmpShortPushers; + } + volumeOSC += lConditions.vlmConditions.volume[1]; + lConditions.GenerateScore( + tmpBullishScore, + tmpBearishScore // + ); + bullishScore += tmpBullishScore; + bearishScore += tmpBearishScore; + + // + // Hind ... + X121SetupConditions hConditions; + bool hHasConditions = setups[idx].GetConditions( + hConditions, + X_MARKET_CYCLE_HIND // + ); + if (!hHasConditions) + { + continue; + } + XSCZones *hZones = setups[idx].GetZones( + X_MARKET_CYCLE_HIND // + ); + bool isHValidForLong = signalGenerator.IsConditionsValidForLong( + hConditions, + reqValidation // + ); + if (isHValidForLong) + { + longVerifications += reqValidation; + } + bool isHValidForShort = signalGenerator.IsConditionsValidForShort( + hConditions, + reqValidation // + ); + if (isHValidForShort) + { + shortVerifications += reqValidation; + } + bool hHasLongConditions = signalGenerator.HasLongConditions( + hConditions, + tmpLongPushers, + tmpProvider // + ); + if (hHasLongConditions) + { + // + AddSpecific( + tmpProvider, + longProviders // + ); + + // + longPushers += tmpLongPushers; + } + bool hHasShortConditions = signalGenerator.HasShortConditions( + hConditions, + tmpShortPushers, + tmpProvider // + ); + if (hHasShortConditions) + { + // + AddSpecific( + tmpProvider, + shortProviders // + ); + + // + shortPushers += tmpShortPushers; + } + volumeOSC += hConditions.vlmConditions.volume[1]; + hConditions.GenerateScore( + tmpBullishScore, + tmpBearishScore // + ); + bullishScore += tmpBullishScore; + bearishScore += tmpBearishScore; diff --git a/Experts/x-saherelm.x121.ea.mq5 b/Experts/x-saherelm.x121.ea.mq5 index 99218a41..b87abff9 100644 --- a/Experts/x-saherelm.x121.ea.mq5 +++ b/Experts/x-saherelm.x121.ea.mq5 @@ -48,29 +48,57 @@ input bool x121EAGetVerificationFromOtherTimeFrames = true; // Get Verifications // // Risk Management ... input group "Risk Management"; -input double x121EAVolume = 0.01; // Static Volume -input double x121EATPPoint = 500; // TP Point -input double x121EASLPoint = 500; // SL Point -input int x121EAMaxAllowedTrades = 1; // Max Allowed Positions -input bool x121EAIgnoreSL = false; // Ignore Calculated SL -input bool x121EAIgnoreTP = false; // Ignore Calculated TP -input bool x121EAAllowTrailStop = true; // Enable Trailling Stop Losses -input double x121EAFirstTrailDistance = 60; // Start Trailling Distance -input double x121EAFirstTrailPoint = 50; // First Stop Trail -input double x121EANextTrailDistance = 25; // Next Trailling Distance -input double x121EANextTrailPoint = 10; // Next Trailling Step -input bool x121EAAllowSupport = false; // Allow Support Signals -input bool x121EAAllowGrid = false; // Allow Grid Signals -input double x121EAGridDistance = 100; // Grid Distance -input double x121EAGridVolumeMultiplier = 2; // Grid Volume Multiplier -input bool x121EAAllowRecovery = false; // Allow Recovery Signals -input double x121EARecoveryDistance = 100; // Recovery Distance -input double x121EARecoveryVolumeMultiplier = 2; // Recovery Volume Multiplier +input double x121EAVolume = 0.01; // Static Volume +input double x121EATPPoint = 500; // TP Point +input double x121EASLPoint = 500; // SL Point +input int x121EAMaxAllowedTrades = 1; // Max Allowed Positions +input bool x121EAIgnoreSL = false; // Ignore Calculated SL +input bool x121EAIgnoreTP = false; // Ignore Calculated TP + +// +// Protection ... +input group "Signalling"; +input int x121EAStartSignallingHoure = -1; // Start Signalling at Specific Time +input int x121EAEndSignallingHoure = -1; // End Signalling at Specific Time +input int x121EACloseOnSpecificTime = -1; // Close All Trades in Specific Time +input bool x121EACloseOnOpposit = false; // Close all Positions on Opposit + +// +input group "Trailling"; +input bool x121EAAllowTrailStop = true; // Enable Trailling Stop Losses +input double x121EAFirstTrailDistance = 60; // Start Trailling Distance +input double x121EAFirstTrailPoint = 50; // First Stop Trail +input double x121EANextTrailDistance = 25; // Next Trailling Distance +input double x121EANextTrailPoint = 10; // Next Trailling Step + +// +input group "Supporting"; +input bool x121EAAllowSupport = false; // Allow Support Signals +input int x121EAMaxNumberOfSupports = 1; // Max Number of Support Signals +input double x121EASupportVolumeMultiplier = 2.0; // Support Signals Volume Multiplier +input double x121EAMaxAllowedSupportVolume = 0.8; // Max Allowed Support Signals Volume + +// +input group "Grid"; +input bool x121EAAllowGrid = false; // Allow Grid Signals +input int x121EAMaxNumberOfGrids = 5; // Max Number of Grid Signals +input double x121EAGridDistance = 100; // Grid Distance +input double x121EAGridVolumeMultiplier = 2.0; // Grid Volume Multiplier +input double x121EAMaxAllowedGridVolume = 0.8; // Max Allowed Grid Signals Volume + +// +input group "Recovery"; +input bool x121EAAllowRecovery = false; // Allow Recovery Signals +input int x121EAMaxNumberOfRecoveries = 2; // Max Number of Recovery Signals +input double x121EARecoveryDistance = 100; // Recovery Distance +input double x121EARecoveryVolumeMultiplier = 2; // Recovery Volume Multiplier +input double x121EAMaxAllowedRecoveryVolume = 0.8; // Max Allowed Recovery Signals Volume + +// +input group "Hedging"; +input int x121EARestingAfterHedge = 1000; // Resting Seconds After Hedge input double x121EAMinRequiredProfitPerTrade = 0.5; // Minimum Required Profit for Hedging input double x121EAMinRequiredProfitPerVolumeFactor = 0.01; // Minimum Required Profit for Hedging Per Volume -input int x121EARestingAfterHedge = 300; // Resting Seconds After Hedge -input int x121EACloseOnSpecificTime = -1; // Close All Trades in Specific Time -input bool x121EACloseOnOpposit = false; // Close all Positions on Opposit // // Alert ... @@ -177,40 +205,36 @@ bool InitialEA() ); // - // Configure EA ... + // Configure EA Class Instance ... + + // + // Signals ... + x121EA.AllowLong(x121EAAllowLong); + x121EA.AllowShort(x121EAAllowShort); + x121EA.ReuiredSignalVerifications(x121EAReuiredSignalVerifications); + x121EA.GetVerificationFromOtherTimeFrames(x121EAGetVerificationFromOtherTimeFrames); + + // + // Risk Management ... x121EA.Volume(x121EAVolume); x121EA.TPPoint(x121EATPPoint); x121EA.SLPoint(x121EASLPoint); x121EA.IgnoreSL(x121EAIgnoreSL); x121EA.IgnoreTP(x121EAIgnoreTP); - x121EA.AllowLong(x121EAAllowLong); - x121EA.AllowShort(x121EAAllowShort); - x121EA.CloseOnOpposit(x121EACloseOnOpposit); x121EA.MaxAllowedTrades(x121EAMaxAllowedTrades); - x121EA.RestingAfterHedge(x121EARestingAfterHedge); + + // + // Protection ... + + // + // Signalling ... + x121EA.CloseOnOpposit(x121EACloseOnOpposit); + x121EA.EndSignallingHoure(x121EAEndSignallingHoure); x121EA.CloseOnSpecificTime(x121EACloseOnSpecificTime); - x121EA.MinRequiredProfitPerTrade(x121EAMinRequiredProfitPerTrade); - x121EA.ReuiredSignalVerifications(x121EAReuiredSignalVerifications); - x121EA.MinRequiredProfitPerVolumeFactor(x121EAMinRequiredProfitPerVolumeFactor); - x121EA.GetVerificationFromOtherTimeFrames(x121EAGetVerificationFromOtherTimeFrames); + x121EA.StartSignallingHoure(x121EAStartSignallingHoure); // - x121EA.AllowSupport(x121EAAllowSupport); - - // - // Grid System ... - x121EA.AllowGrid(x121EAAllowGrid); - x121EA.GridDistance(x121EAGridDistance); - x121EA.GridVolumeMultiplier(x121EAGridVolumeMultiplier); - - // - // Recovery System ... - x121EA.AllowRecovery(x121EAAllowRecovery); - x121EA.RecoveryDistance(x121EARecoveryDistance); - x121EA.RecoveryVolumeMultiplier(x121EARecoveryVolumeMultiplier); - - // - // Stop Loss Trailing ... + // Trailling ... x121EA.AllowTrailStop(x121EAAllowTrailStop); x121EA.NextTrailPoint(x121EANextTrailPoint); x121EA.FirstTrailPoint(x121EAFirstTrailPoint); @@ -218,7 +242,36 @@ bool InitialEA() x121EA.FirstTrailDistance(x121EAFirstTrailDistance); // - // Configure Alert ... + // Supporting ... + x121EA.AllowSupport(x121EAAllowSupport); + x121EA.MaxNumberOfSupports(x121EAMaxNumberOfSupports); + x121EA.SupportVolumeMultiplier(x121EASupportVolumeMultiplier); + x121EA.MaxAllowedSupportVolume(x121EAMaxAllowedSupportVolume); + + // + // Grid ... + x121EA.AllowGrid(x121EAAllowGrid); + x121EA.GridDistance(x121EAGridDistance); + x121EA.MaxNumberOfGrids(x121EAMaxNumberOfGrids); + x121EA.GridVolumeMultiplier(x121EAGridVolumeMultiplier); + x121EA.MaxAllowedGridVolume(x121EAMaxAllowedGridVolume); + + // + // Recovery ... + x121EA.AllowRecovery(x121EAAllowRecovery); + x121EA.RecoveryDistance(x121EARecoveryDistance); + x121EA.MaxNumberOfRecoveries(x121EAMaxNumberOfRecoveries); + x121EA.RecoveryVolumeMultiplier(x121EARecoveryVolumeMultiplier); + x121EA.MaxAllowedRecoveryVolume(x121EAMaxAllowedRecoveryVolume); + + // + // Hedging ... + x121EA.RestingAfterHedge(x121EARestingAfterHedge); + x121EA.MinRequiredProfitPerTrade(x121EAMinRequiredProfitPerTrade); + x121EA.MinRequiredProfitPerVolumeFactor(x121EAMinRequiredProfitPerVolumeFactor); + + // + // Alert ... x121EA.SetAlertPrefix(ShortName); x121EA.SetAlertEnableAlerts(x121EAEnableAlerts); x121EA.SetAlertLogAlerts(x121EALogAlerts); @@ -227,6 +280,7 @@ bool InitialEA() x121EA.SetAlertTerminalAlerts(x121EATerminalAlerts); // + // Configure Indicators ... X121SetupInputs setupInputsDefault; setupInputsDefault.Default();