diff --git a/Classes/x-saherelm.xtrade.class.mq5 b/Classes/x-saherelm.xtrade.class.mq5 index 2135013f..02df7ef3 100644 --- a/Classes/x-saherelm.xtrade.class.mq5 +++ b/Classes/x-saherelm.xtrade.class.mq5 @@ -22,6 +22,7 @@ // // Imports ... #include "../Classes/x-saherelm.base.class.mq5" +#include "../Libraries/x-saherelm.tools.lib.mq5" #include "../Classes/x-saherelm.xalert.class.mq5" #include "../Libraries/x-saherelm.xtrade.lib.mq5" #include "../Classes/x-saherelm.xaccount.class.mq5" @@ -4232,6 +4233,109 @@ public: mTrailBasedOnProfit = value; } + // + // Recovery ... + + // + bool AllowRecover() + { + return mAllowRecover; + } + + // + void AllowRecover(bool value) + { + mAllowRecover = value; + } + + // + double RecoveryTPPoint() + { + return mRecoveryTPPoint; + } + + // + void RecoveryTPPoint(double value) + { + // + if (value < 0) + { + value = 0; + } + + // + mRecoveryTPPoint = value; + } + + // + double RecoverySLPoint() + { + return mRecoverySLPoint; + } + + // + void RecoverySLPoint(double value) + { + // + if (value < 0) + { + value = 0; + } + + // + mRecoverySLPoint = value; + } + + // + bool RecoverBasedOnPressures() + { + return mRecoverBasedOnPressures; + } + + // + void RecoverBasedOnPressures(bool value) + { + mRecoverBasedOnPressures = value; + } + + // + int MaxAllowedRecover() + { + return mMaxAllowedRecover; + } + + // + void MaxAllowedRecover(int value) + { + // + if (value < 0) + { + value = 0; + } + + // + mMaxAllowedRecover = value; + } + + // + double RecoveryVolumeMultiplier() + { + return mRecoveryVolumeMultiplier; + } + + // + void RecoveryVolumeMultiplier(double value) + { + // + if (value < 0) + { + value = 0; + } + + // + mRecoveryVolumeMultiplier = value; + } + // // Hedging ... @@ -4304,9 +4408,10 @@ public: // First Step of Trade Handling ... // Since Must Call when a Signal Executed ... void AddData( - XSignal &signal, // Executed Signal - double commission = 0, // Commission - bool forceTrail = false // + XSignal &signal, // Executed Signal + double commission = 0, // Commission + bool forceTrail = false, // Force Signal Trailling Stop + bool forceRecover = false // Force Signal Recovery ) { // @@ -4345,6 +4450,22 @@ public: item.trailBasedOnProfit = mTrailBasedOnProfit; } + // + // Recovery Configuration ... + + // + // Force Recovery used to implement Recovery for + // Custom Positions ... + if (mAllowRecover || forceRecover) + { + // + item.allowRecover = true; + + // + item.recoveryTPPoint = mRecoveryTPPoint; + item.recoverySLPoint = mRecoverySLPoint; + } + // Add(item); @@ -4585,6 +4706,8 @@ public: double trailStepInPoints = mData[i].trailStepInPoint; double trailStartInPoint = mData[i].trailStartInPoint; bool trailBasedOnProfit = mData[i].trailBasedOnProfit; + double recoveryTPPoint = mData[i].recoveryTPPoint; + double recoverySLPoint = mData[i].recoverySLPoint; // XPosition iPosition; @@ -4608,6 +4731,49 @@ public: continue; } + // + // Retriece CIndex Bar ... + XOHCL cBar; + bool isBarInited = cBar.Init( + symbol, + period, + 1 // + ); + if (!isBarInited) + { + continue; + } + + // + // For Trend ... + XOHCL tmpHSW[]; + XOHCL tmpLSW[]; + + // + // Detect Bullish/Bearish Patterns and Trends ... + + // + // Bullish ... + bool hasBullishPower = cBar.HasBullishPower(); + bool hasBullishPattern = HasBullishPattern(cBar); + bool hasBullishPressure = cBar.HasBullishPressure(); + bool isBullishTrend = cBar.HasBullishTrend( + tmpHSW, + tmpLSW, + true // + ); + + // + // Bearish ... + bool hasBearishPower = cBar.HasBearishPower(); + bool hasBearishPattern = HasBearishPattern(cBar); + bool hasBearishPressure = cBar.HasBearishPressure(); + bool isBearishTrend = cBar.HasBearishTrend( + tmpHSW, + tmpLSW, + false // + ); + // // Trail ... if (mData[i].allowTrailStop) @@ -4779,7 +4945,79 @@ public: } // - // Grid ... + // Recovery ... + if (mData[i].allowRecover) + { + // + // Do Recovery ... + + // + // Profit Must be Negative ... + if ( + profit < 0 && + recoveryTPPoint > 0 && + recoverySLPoint > 0) + { + // + // Current Profit ... + double drawdownInPoints = (MathAbs(profit) / volume); + + // + // Try to Remove SL of Recovery Signals ... + if (iPosition.sl > 0) + { + // + string comment = "EQM Recover Remove SL"; + bool isSLRemoved = mTrader.Modify( + ticket, + 0, + iPosition.tp, + comment // + ); + } + else + { + // + // Check Position TP ... + double rewardInPoints = iPosition.GetReward() / points; + if (rewardInPoints != recoveryTPPoint) + { + // + double reward = recoveryTPPoint * points; + double tp = + isLong + ? iPosition.entry + reward + : iPosition.entry - reward; + string comment = "EQM Recover Fix TP"; + bool isSLRemoved = mTrader.Modify( + ticket, + iPosition.sl, + tp, + comment // + ); + } + else + { + // + // Check Price Distance For Recovery ... + bool canLookForPressure = + // + // in 75% ... + drawdownInPoints > ((recoverySLPoint / 3) * 2) + // + ; + + // + if (canLookForPressure) + { + // + // Looking for Signal Direction and + // Founding Pressure ... + } + } + } + } + } } } @@ -4802,6 +5040,7 @@ public: // TODO: // Here we can apply Same type or Opposit Type // Signals behaviour ... + // also Implement Signal Filtering ... // return result; @@ -4829,6 +5068,15 @@ protected: double mTrailStartInPoint; // Trail Starts in Points of Profit double mTrailStepInPoint; // Profit Must Grows Point to do Trailling + // + // Recovery ... + bool mAllowRecover; // Allow Signal Recovery + int mMaxAllowedRecover; // Max Allowed Recovery + double mRecoveryTPPoint; // Recovery TP in Points + double mRecoverySLPoint; // Recovery SL in Points + bool mRecoverBasedOnPressures; // Do Recovery based on Market Pressures + double mRecoveryVolumeMultiplier; // Recovery Volume Multiplier + // // Hedging ... bool mAllowHedging; // Hedge Trades diff --git a/Experts/x-test-strategies.ea.mq5 b/Experts/x-test-strategies.ea.mq5 index ffae68dc..f2d10b1b 100644 --- a/Experts/x-test-strategies.ea.mq5 +++ b/Experts/x-test-strategies.ea.mq5 @@ -43,8 +43,8 @@ double eaAllowLong = true; // Allow Long Positions double eaAllowShort = true; // Allow Short Positions // -int eaMaxAllowedLongs = 1; // Max Allowed Long Positions -int eaMaxAllowedShorts = 1; // Max Allowed Short Positions +int eaMaxAllowedLongs = 0; // Max Allowed Long Positions +int eaMaxAllowedShorts = 0; // Max Allowed Short Positions // double eaTPPoint = 100; // Static TP Point @@ -259,8 +259,8 @@ bool InitialEA() // Initialize Trade Handler ... eaTradeHandler = new XSCXTradeHandler(eaTrader); eaTradeHandler.SetAlertPrefix(ShortName + "> TradeHandler"); - eaTradeHandler.SaveTrades(false); - eaTradeHandler.SaveSignals(false); + eaTradeHandler.SaveTrades(true); + eaTradeHandler.SaveSignals(true); // // Configure Hedging ... @@ -277,6 +277,15 @@ bool InitialEA() eaTradeHandler.IgnoreTPOnTrail(true); eaTradeHandler.TrailBasedOnProfit(true); + // + // Configure Recovery ... + eaTradeHandler.AllowRecover(true); + eaTradeHandler.MaxAllowedRecover(2); + eaTradeHandler.RecoveryTPPoint(eaTPPoint); + eaTradeHandler.RecoverySLPoint(eaSLPoint); + eaTradeHandler.RecoveryVolumeMultiplier(2); + eaTradeHandler.RecoverBasedOnPressures(false); + // XSymbolParser symbolParser; diff --git a/Helpers/x-saherelm.xche.helper.mq5 b/Helpers/x-saherelm.xche.helper.mq5 index 7efbb286..65925646 100644 --- a/Helpers/x-saherelm.xche.helper.mq5 +++ b/Helpers/x-saherelm.xche.helper.mq5 @@ -627,6 +627,128 @@ public: ); } + // + // Tools ... + + // + double GetMaxLongExit( + int barIndex // Bar Index + ) + { + // + double result = 0; + + // + double le1 = GetLongExit1(barIndex); + double le2 = GetLongExit2(barIndex); + + // + if ( + le1 == 0 || + le2 == 0 || + le1 == EMPTY_VALUE || + le2 == EMPTY_VALUE) + { + return result; + } + + // + result = MathMax(le1, le1); + + // + return result; + } + + // + double GetMinLongExit( + int barIndex // Bar Index + ) + { + // + double result = 0; + + // + double le1 = GetLongExit1(barIndex); + double le2 = GetLongExit2(barIndex); + + // + if ( + le1 == 0 || + le2 == 0 || + le1 == EMPTY_VALUE || + le2 == EMPTY_VALUE) + { + return result; + } + + // + result = MathMin(le1, le1); + + // + return result; + } + + // + double GetMaxShortExit( + int barIndex // Bar Index + ) + { + // + double result = 0; + + // + double le1 = GetShortExit1(barIndex); + double le2 = GetShortExit2(barIndex); + + // + if ( + le1 == 0 || + le2 == 0 || + le1 == EMPTY_VALUE || + le2 == EMPTY_VALUE) + { + return result; + } + + // + result = MathMax(le1, le1); + + // + return result; + } + + // + double GetMinShortExit( + int barIndex // Bar Index + ) + { + // + double result = 0; + + // + double le1 = GetShortExit1(barIndex); + double le2 = GetShortExit2(barIndex); + + // + if ( + le1 == 0 || + le2 == 0 || + le1 == EMPTY_VALUE || + le2 == EMPTY_VALUE) + { + return result; + } + + // + result = MathMin(le1, le1); + + // + return result; + } + + // + // Conditions ... + // bool GetConditions( XCHEConditions &conditions, // diff --git a/Libraries/x-saherelm.xtrade.lib.mq5 b/Libraries/x-saherelm.xtrade.lib.mq5 index b13fd517..e840a6bd 100644 --- a/Libraries/x-saherelm.xtrade.lib.mq5 +++ b/Libraries/x-saherelm.xtrade.lib.mq5 @@ -67,6 +67,9 @@ string XActionToken = "A"; string XDirectionalToken = "D"; string XINDirectionalToken = "IND"; +// +string XRecoveryToken = "XRCV"; + // // Available Order Modes ... enum ENUM_X_ORDER_MODES @@ -3393,12 +3396,15 @@ struct XTradeData ENUM_X_POSITION_TYPES type; // Position Type // - ulong ticket; // Position Ticket - double profit; // Profit on Close - double commission; // Commission - double swap; // Swap - string message; // Close Reason - datetime endTime; // End Time + ulong ticket; // Position Ticket + double swap; // Swap + double profit; // Profit on Close + double commission; // Commission + double maxDrawdown; // Max Position Drawdown + string message; // Close Reason + datetime endTime; // End Time + + // // // Constructor ... @@ -3496,6 +3502,14 @@ struct XTradeData profit = _position.profit; swap = _position.swap; + // + if (profit < 0 && + (maxDrawdown == 0 || + MathAbs(profit) > MathAbs(maxDrawdown))) + { + profit = maxDrawdown; + } + // return result; } @@ -3523,9 +3537,11 @@ struct XTradeData profit = 0; volume = 0; commission = 0; + maxDrawdown = 0; // ResetTrail(); + ResetRecovery(); } // @@ -3722,6 +3738,7 @@ struct XTradeData ToString("Profit", profit) + ToString("Commission", commission) + ToString("Swap", swap) + + ToString("Max Drawdown", maxDrawdown) + ToString("End Time", endTime) + ToString("Age", age) + ToString("Message", message) @@ -3744,7 +3761,7 @@ struct XTradeData // Trailing Stop .... // - bool allowTrailStop; // Specified Position Can Trail Stop or not + bool allowTrailStop; // Specified Position Can Trail Stop or not bool ignoreTPOnTrail; // Ignore TP when SL Trailed bool trailBasedOnProfit; // Do Trail Based on Profit Points int trailLevel; // Last Trail Level @@ -3764,6 +3781,24 @@ struct XTradeData trailBasedOnProfit = false; } + // + // Recovery ... + + // + bool allowRecover; // Allow Recover Specified Position + double recoveryTPPoint; // Recovery TP Point + double recoverySLPoint; // Recovery SL Point + int maxAllowedRecover; // Max Allowed Recovery + + // + void ResetRecovery() + { + // + allowRecover = false; + recoveryTPPoint = 0; + recoverySLPoint = 0; + } + // }; @@ -5286,6 +5321,121 @@ ulong ExtractParentTicket(string value) return result; } +// +// XRecovery ... + +// +string GenerateRecoveryTag(ulong ticket) +{ + // + return Surround( + XRecoveryToken, + ticket // + ); +} + +// +ulong ExtractRecoveredTicket(string value) +{ + // + return ParseLongSurrounded( + value, + XRecoveryToken // + ); +} + +// +// Extract Recoveries ... +template +int ExtractRecoveries( + T &source[], + T &dest[] // Result ... +) +{ + // + int result = 0; + + // + Clean(dest); + + // + int sourceCount = ArraySize(source); + if (!IsValidSize(sourceCount)) + { + return result; + } + + // + for (int i = 0; i < sourceCount; i++) + { + // + T iSource = source[i]; + + // + ulong isRecovery = ExtractRecoveredTicket(iSource.comment) > 0; + if (isRecovery) + { + // + AddRef( + iSource, + dest // + ); + } + } + + // + result = ArraySize(dest); + + // + return result; +} + +// +// Extract Specified Position's Recoveries ... +int ExtractRecoveries( + ulong ticket, + XPosition &source[], + XPosition &dest[] // Result ... +) +{ + // + int result = 0; + + // + Clean(dest); + + // + int sourceCount = ArraySize(source); + if (!IsValidSize(sourceCount)) + { + return result; + } + + // + for (int i = 0; i < sourceCount; i++) + { + // + XPosition iSource = source[i]; + + // + ulong isRecovery = ExtractRecoveredTicket(iSource.comment) > 0; + if (isRecovery && iSource.ticket == ticket) + { + // + AddRef( + iSource, + dest // + ); + } + } + + // + result = ArraySize(dest); + + // + return result; +} + // // SL Trails ... diff --git a/Strategies/x-saherelm.xchkm.strategy.mq5 b/Strategies/x-saherelm.xchkm.strategy.mq5 index 715d8cb6..ebf176fb 100644 --- a/Strategies/x-saherelm.xchkm.strategy.mq5 +++ b/Strategies/x-saherelm.xchkm.strategy.mq5 @@ -114,6 +114,78 @@ public: // // Getter / Setter (s) ... + // + ENUM_TIMEFRAMES AnalizePeriod() + { + return mAnalizePeriod; + } + + // + void AnalizePeriod(ENUM_TIMEFRAMES value) + { + mAnalizePeriod = value; + } + + // + bool DrawImportantAreas() + { + return mDrawImportantAreas; + } + + // + void DrawImportantAreas(bool value) + { + mDrawImportantAreas = value; + } + + // + bool EnableXCHE() + { + return mEnableXCHE; + } + + // + void EnableXCHE(bool value) + { + mEnableXCHE = value; + } + + // + bool EnableXCHM() + { + return mEnableXCHM; + } + + // + void EnableXCHM(bool value) + { + mEnableXCHM = value; + } + + // + bool EnableXCHHK() + { + return mEnableXCHHK; + } + + // + void EnableXCHHK(bool value) + { + mEnableXCHHK = value; + } + + // + bool EnableXCHSTR() + { + return mEnableXCHSTR; + } + + // + void EnableXCHSTR(bool value) + { + mEnableXCHSTR = value; + } + // // Overrides ... @@ -150,10 +222,6 @@ public: bool hasLong = false; bool hasShort = false; - // - // Draw Support/Resistance/OB(s)/FVG(s) ... - bool drawImportantAreas = true; - // // Retrieve Conditions ... @@ -316,7 +384,7 @@ public: if (hasSupport) { // - if (drawImportantAreas) + if (mDrawImportantAreas) { // DrawSupport( @@ -346,7 +414,7 @@ public: if (hasResistance) { // - if (drawImportantAreas) + if (mDrawImportantAreas) { // DrawResistance( @@ -378,7 +446,7 @@ public: if (hasBullishOB) { // - if (drawImportantAreas) + if (mDrawImportantAreas) { // DrawBullishOrderBlock( @@ -407,7 +475,7 @@ public: if (hasBearishOB) { // - if (drawImportantAreas) + if (mDrawImportantAreas) { // DrawBearishOrderBlock( @@ -445,7 +513,7 @@ public: bullishFVG = aBar; // - if (drawImportantAreas) + if (mDrawImportantAreas) { // DrawBullishFVG( @@ -482,7 +550,7 @@ public: bearishFVG = aBar; // - if (drawImportantAreas) + if (mDrawImportantAreas) { // DrawBearishFVG( @@ -596,174 +664,330 @@ public: double chstrMaxBearish = chstrHelper.GetMaxBearish(cIndex); // - // XCHHK ... + double cheMaxLE = cheHelper.GetMaxLongExit(cIndex); + double cheMinLE = cheHelper.GetMinLongExit(cIndex); + double cheMaxSE = cheHelper.GetMaxShortExit(cIndex); + double cheMinSE = cheHelper.GetMinShortExit(cIndex); + + // int pushers = 0; + string signallers[]; // - if (chhkConditions.isBullishPowerUp) + // XCHHK ... + if (mEnableXCHHK) { // - bool chhkHasLong = - // - hasBullishPower && - cBar.IsBullish() && - hasBullishPattern && - hasBullishPressure && - cheConditions.isStrongBullish && - cBar.low > chhkMinBullishHigh && - chhkConditions.isBullishPowerUp - // - ; - - // - hasLong = chhkHasLong; - if (hasLong) + if (chhkConditions.isBullishPowerUp) { // - pushers++; - sl = chhkMaxBullishLow; - type = POSITION_TYPE_BUY; + bool chhkHasLong = + // + hasBullishPower && + cBar.IsBullish() && + hasBullishPattern && + hasBullishPressure && + cheConditions.isStrongBullish && + cBar.low > chhkMinBullishHigh && + chhkConditions.isBullishPowerUp + // + ; + + // + if (chhkHasLong) + { + // + hasLong = chhkHasLong; + if (hasLong) + { + // + pushers++; + Add( + "XCHHK", + signallers // + ); + + // + sl = chhkMaxBullishLow; + type = POSITION_TYPE_BUY; + } + } } - } - - // - if (chhkConditions.isBearishPowerUp) - { - // - bool chhkHasShort = - // - hasBearishPower && - cBar.IsBearish() && - hasBearishPattern && - hasBearishPressure && - cheConditions.isStrongBearish && - cBar.high < chhkMaxBearishLow && - chhkConditions.isBearishPowerUp - // - ; // - hasShort = chhkHasShort; - if (hasShort) + if (chhkConditions.isBearishPowerUp) { // - pushers++; - sl = chhkMinBearishHigh; - type = POSITION_TYPE_SELL; + bool chhkHasShort = + // + hasBearishPower && + cBar.IsBearish() && + hasBearishPattern && + hasBearishPressure && + cheConditions.isStrongBearish && + cBar.high < chhkMaxBearishLow && + chhkConditions.isBearishPowerUp + // + ; + + // + if (chhkHasShort) + { + // + hasShort = chhkHasShort; + if (hasShort) + { + // + pushers++; + Add( + "XCHHK", + signallers // + ); + + // + sl = chhkMinBearishHigh; + type = POSITION_TYPE_SELL; + } + } } } // // XCHM ... - - // - if (chmConditions.isBullishPowerUp) + if (mEnableXCHM) { // - bool chmHasLong = - // - hasBullishPower && - cBar.IsBullish() && - hasBullishPattern && - hasBullishPressure && - cBar.low > chmMinBullishFast && - cheConditions.isStrongBullish && - chmConditions.isBullishPowerUp - // - ; - - // - hasLong = chmHasLong; - if (hasLong) + if (chmConditions.isBullishPowerUp) { // - pushers++; - sl = chmMaxBullishFast; - type = POSITION_TYPE_BUY; + bool chmHasLong = + // + hasBullishPower && + cBar.IsBullish() && + hasBullishPattern && + hasBullishPressure && + cBar.low > chmMinBullishFast && + cheConditions.isStrongBullish && + chmConditions.isBullishPowerUp + // + ; + + // + if (chmHasLong) + { + // + hasLong = chmHasLong; + if (hasLong) + { + // + pushers++; + Add( + "XCHM", + signallers // + ); + + // + sl = chmMaxBullishFast; + type = POSITION_TYPE_BUY; + } + } } - } - - // - if (chmConditions.isBearishPowerUp) - { - // - bool chmHasShort = - // - hasBearishPower && - cBar.IsBearish() && - hasBearishPattern && - hasBearishPressure && - cBar.high < chmMaxBearishFast && - cheConditions.isStrongBearish && - chmConditions.isBearishPowerUp - // - ; // - hasShort = chmHasShort; - if (hasShort) + if (chmConditions.isBearishPowerUp) { // - pushers++; - sl = chmMinBearishFast; - type = POSITION_TYPE_SELL; + bool chmHasShort = + // + hasBearishPower && + cBar.IsBearish() && + hasBearishPattern && + hasBearishPressure && + cBar.high < chmMaxBearishFast && + cheConditions.isStrongBearish && + chmConditions.isBearishPowerUp + // + ; + + // + if (chmHasShort) + { + // + hasShort = chmHasShort; + if (hasShort) + { + // + pushers++; + Add( + "XCHM", + signallers // + ); + + // + sl = chmMinBearishFast; + type = POSITION_TYPE_SELL; + } + } } } // // XCHSTR ... - - // - if (chstrConditions.isBullishPowerUp) + if (mEnableXCHSTR) { // - bool chstrHasLong = - // - hasBullishPower && - cBar.IsBullish() && - hasBullishPattern && - hasBullishPressure && - cBar.low > chstrMinBullish && - cheConditions.isStrongBullish && - chstrConditions.isBullishPowerUp - // - ; - - // - hasLong = chstrHasLong; - if (hasLong) + if (chstrConditions.isBullishPowerUp) { // - pushers++; - sl = chstrMinBullish; - type = POSITION_TYPE_BUY; + bool chstrHasLong = + // + hasBullishPower && + cBar.IsBullish() && + hasBullishPattern && + hasBullishPressure && + cBar.low > chstrMinBullish && + cheConditions.isStrongBullish && + chstrConditions.isBullishPowerUp + // + ; + + // + if (chstrHasLong) + { + // + hasLong = chstrHasLong; + if (hasLong) + { + // + pushers++; + Add( + "XCHSTR", + signallers // + ); + + // + sl = chstrMinBullish; + type = POSITION_TYPE_BUY; + } + } + } + + // + if (chstrConditions.isBearishPowerUp) + { + // + bool chstrHasShort = + // + hasBearishPower && + cBar.IsBearish() && + hasBearishPattern && + hasBearishPressure && + cBar.high < chstrMaxBearish && + cheConditions.isStrongBearish && + chstrConditions.isBearishPowerUp + // + ; + + // + if (chstrHasShort) + { + // + hasShort = chstrHasShort; + if (hasShort) + { + // + pushers++; + Add( + "XCHSTR", + signallers // + ); + + // + sl = chstrMaxBearish; + type = POSITION_TYPE_SELL; + } + } } } // - if (chstrConditions.isBearishPowerUp) + // XCHE ... + if (mEnableXCHE) { // - bool chstrHasShort = - // - hasBearishPower && - cBar.IsBearish() && - hasBearishPattern && - hasBearishPressure && - cBar.high < chstrMaxBearish && - cheConditions.isStrongBearish && - chstrConditions.isBearishPowerUp - // - ; - - // - hasShort = chstrHasShort; - if (hasShort) + if (cheConditions.isStrongBullish) { // - pushers++; - sl = chstrMaxBearish; - type = POSITION_TYPE_SELL; + bool cheHasLong = + // + HasCheLast() && + cheMinLE > 0 && + hasBullishPower && + cBar.IsBullish() && + hasBullishPattern && + hasBullishPressure && + cheMinLE > GetMaxCHELast() && + cheConditions.isStrongBullish + // + ; + + // + if (cheHasLong) + { + // + hasLong = cheHasLong; + if (hasLong) + { + // + pushers++; + Add( + "XCHE", + signallers // + ); + + // + sl = cheMinLE; + type = POSITION_TYPE_BUY; + } + } + } + + // + if (cheConditions.isStrongBearish) + { + // + bool cheHasShort = + // + HasCheLast() && + cheMaxSE > 0 && + hasBearishPower && + cBar.IsBearish() && + hasBearishPattern && + hasBearishPressure && + cheMaxSE < GetMinCHELast() && + cheConditions.isStrongBearish + // + ; + + // + if (cheHasShort) + { + // + hasShort = cheHasShort; + if (hasShort) + { + // + pushers++; + Add( + "XCHE", + signallers // + ); + + // + sl = cheMaxSE; + type = POSITION_TYPE_SELL; + } + } } } @@ -868,22 +1092,33 @@ public: // // Preparing Signal ... - result = signal.Prepare( - mSymbol, - GetTag(), - mPeriod, - type, - mode, - entry, - mVolume, - sl, - tp // - ); + if (pushers > 0) + { + // + result = signal.Prepare( + mSymbol, + signallers[0], + mPeriod, + type, + mode, + entry, + mVolume, + sl, + tp // + ); + } + else + { + result = false; + } // if (pushers > 1) { + // + Print("======"); Print("Pusher: ", pushers); + ArrayPrint(signallers); } // @@ -899,6 +1134,15 @@ protected: // ENUM_TIMEFRAMES mAnalizePeriod; // Important Area Detect Time Frame + // + bool mDrawImportantAreas; // Draw Important Areas where Founded in Analyzing Time Frame + + // + bool mEnableXCHE; // Enable XCHE Signaller + bool mEnableXCHM; // Enable XCHM Signaller + bool mEnableXCHHK; // Enable XCHHK Signaller + bool mEnableXCHSTR; // Enable XCHSTR Signaller + // XOHCL support; XOHCL resistance; @@ -951,6 +1195,15 @@ private: // Configurations for required Indicators ... void PrepareRequirements() { + // + mDrawImportantAreas = false; + + // + mEnableXCHE = true; + mEnableXCHM = true; + mEnableXCHHK = true; + mEnableXCHSTR = true; + // support.Clean(); supportTime = NULL; @@ -1404,6 +1657,21 @@ private: ); } + // + bool HasCheLast() + { + // + bool result = false; + + // + result = + IsValid(cheLastLongExitTime) || + IsValid(cheLastShortExitTime); + + // + return result; + } + // };