/////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 Class Library // -------------------------------------- // Name: XSCXCHKMStrategy // Description: provides all based classes for use ... // // // Maintainer: // ------------ // Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) // ////////////////////////////////////////////////////// // // Global Properties ... #property library #property copyright "Copyright 2023, SaherElm IT Center" #property link "https://www.saherelm.ir" #property version "1.00" #property strict // // Imports ... // // Import(s) Helper(s) ... #include "../Helpers/x-saherelm.xpv.helper.mq5" #include "../Helpers/x-saherelm.xstr.helper.mq5" #include "../Helpers/x-saherelm.xche.helper.mq5" #include "../Helpers/x-saherelm.xchma.helper.mq5" #include "../Helpers/x-saherelm.xchhk.helper.mq5" // // Base Classes ... #include "../Classes/x-saherelm.xstrategy.class.mq5" // // Specific Identifier(s) of XStrategy ... string XCHKMStartegyToken = "XCHKM"; // // XStrategy Class Implementation(s) ... class XSCXCHKMStrategy : public XSCBaseStrategy { // // Public ... public: // // Constructor(s) ... void XSCXCHKMStrategy( // // Base ... string _symbol, // Trading Symbol ENUM_TIMEFRAMES _period, // Trading TimeFrame double _volume, // Voluem double _r2r, // Risk/Reward Ratio int _slippage, // Trader Slippage long _magicNumber, // Trader Magic Number bool _ignoreSignalExecution = false, // Ignore Signal Execution bool _useTPSLAsPoint = false, // Converts TP and SL by Provided Points bool _forceMaxTPSLAsPoint = false, // Force Max TP and SL by Provided Points double _tpPoint = 0, // TP As Point double _slPoint = 0, // SL As Point bool _ignoreTP = false, // TP set to 0 bool _ignoreSL = false, // SL set to 0 bool _allowLong = true, bool _allowShort = true, int _maxAllowedLongs = 0, int _maxAllowedShorts = 0 // ) : XSCBaseStrategy(_symbol, _period, _volume, _r2r, _slippage, _magicNumber, _ignoreSignalExecution, _useTPSLAsPoint, _forceMaxTPSLAsPoint, _tpPoint, _slPoint, _ignoreTP, _ignoreSL, _allowLong, _allowShort, _maxAllowedLongs, _maxAllowedShorts // ) { // SetAlertPrefix(GetTag()); // PrepareRequirements(); } // // Deconstructor ... void ~XSCXCHKMStrategy() { // delete pvHelper; delete strHelper; delete cheHelper; // delete chhkHelper; delete chmaHelper; } // // Getter / Setter (s) ... // // Overrides ... // // Customize Strategy Identifier ... string GetTag() override { return XCHKMStartegyToken; } // // Check Conditions For Signal ... bool HasSignal( XSignal &signal // ) override { // bool result = false; // signal.Clean(); // double sl = 0; double tp = 0; double risk = 0; double entry = 0; double reward = 0; double r2r = R2R(); ENUM_POSITION_TYPE type = POSITION_TYPE_BUY; ENUM_X_ORDER_MODES mode = X_ORDER_MODE_MARKET; // bool hasLong = false; bool hasShort = false; // bool forceCloseLongs = false; bool forceCloseShorts = false; // // Retrieve Conditions ... // // XCHMA ... XCHMAConditions chmaConditions; result = chmaHelper.GetConditions(chmaConditions); if (!result) { return result; } // // XCHE ... XCHHKConditions chhkConditions; result = chhkHelper.GetConditions(chhkConditions); if (!result) { return result; } // // Start Calculations ... // double points = GetPoints(mSymbol); // int zIndex = 0; int cIndex = zIndex + 1; int pIndex = cIndex + 1; int ppIndex = pIndex + 1; // // Retrieve Bars ... // // Last Bar ... XOHCL cBar; result = cBar.Init( mSymbol, mPeriod, cIndex // ); if (!result) { return result; } // // Previous Bar of Last Bar ... XOHCL pBar; result = cBar.GetPreviousBar(pBar); if (!result) { return result; } // // Last Swing Low Bar ... XOHCL lastSwingLow; result = cBar.FindLastSwingLow(lastSwingLow); if (!result) { return result; } // // Last Swing High Bar ... XOHCL lastSwingHigh; result = cBar.FindLastSwingHigh(lastSwingHigh); if (!result) { return result; } // // Retrieve Highest High(s) and Lowest Low(s) ... // // Highest High ... double hh5 = cBar.FindHighest( 5, MODE_HIGH // ); // // Lowest Low ... double ll5 = cBar.FindLowest( 5, MODE_LOW // ); // // Check Support Exists or Find ... bool hasSupport = support.IsValid(); if (!hasSupport) { // hasSupport = // cBar.HasSupport(support) // ; // if (hasSupport) { // DrawSupport( support, ChartID() // ); // supportTime = cBar.time; } } // // Check Resistance Exists or Find ... bool hasResistance = resistance.IsValid(); if (!hasResistance) { // hasResistance = // cBar.HasResistance(resistance) // ; // if (hasResistance) { // DrawResistance( resistance, ChartID() // ); // resistanceTime = cBar.time; } } // // For Trend ... XOHCL tmpHSW[]; XOHCL tmpLSW[]; // // Detect Bullish/Bearish Patterns and Trends ... // // Bullish ... bool hasBullishPattern = HasBullishPattern(cBar); bool isBullishTrend = cBar.HasBullishTrend( tmpHSW, tmpLSW, true // ); // // Bearish ... bool hasBearishPattern = HasBearishPattern(cBar); bool isBearishTrend = cBar.HasBearishTrend( tmpHSW, tmpLSW, false // ); // // Detect XCHMA based Conditions ... // // Bullish ... // bool isCHMAHCrossedOver = // ( // chmaConditions.isHFastCrossedOverSlow && chmaConditions.isLFastOverSlow && chmaConditions.isMFastOverSlow && chmaConditions.isSFastOverSlow // ) // ; // bool isCHMALCrossedOver = // ( // chmaConditions.isLFastCrossedOverSlow && chmaConditions.isHFastOverSlow && chmaConditions.isMFastOverSlow && chmaConditions.isSFastOverSlow // ) // ; // bool isCHMAMCrossedOver = // ( // chmaConditions.isMFastCrossedOverSlow && chmaConditions.isHFastOverSlow && chmaConditions.isLFastOverSlow && chmaConditions.isSFastOverSlow // ) // ; // bool isCHMASCrossedOver = // ( // chmaConditions.isSFastCrossedOverSlow && chmaConditions.isHFastOverSlow && chmaConditions.isLFastOverSlow && chmaConditions.isMFastOverSlow // ) // ; // // Bullish XCHMA Conditions ... bool isCHMABullish = // isCHMAHCrossedOver // || // isCHMALCrossedOver // || // isCHMAMCrossedOver // || // isCHMASCrossedOver // ; // // Bearish ... // bool isCHMAHCrossedUnder = // ( // chmaConditions.isHFastCrossedUnderSlow && chmaConditions.isLFastUnderSlow && chmaConditions.isMFastUnderSlow && chmaConditions.isSFastUnderSlow // ) // ; // bool isCHMALCrossedUnder = // ( // chmaConditions.isLFastCrossedUnderSlow && chmaConditions.isHFastUnderSlow && chmaConditions.isMFastUnderSlow && chmaConditions.isSFastUnderSlow // ) // ; // bool isCHMAMCrossedUnder = // ( // chmaConditions.isMFastCrossedUnderSlow && chmaConditions.isHFastUnderSlow && chmaConditions.isLFastUnderSlow && chmaConditions.isSFastUnderSlow // ) // ; // bool isCHMASCrossedUnder = // ( // chmaConditions.isSFastCrossedUnderSlow && chmaConditions.isHFastUnderSlow && chmaConditions.isLFastUnderSlow && chmaConditions.isMFastUnderSlow // ) // ; // // Bullish XCHMA Conditions ... bool isCHMABearish = // isCHMAHCrossedUnder // || // isCHMALCrossedUnder // || // isCHMAMCrossedUnder // || // isCHMASCrossedUnder // ; // // Max ... double maxCHMA = MathMax( chmaConditions.cFast[cIndex], chmaConditions.cSlow[cIndex] // ); maxCHMA = MathMax( maxCHMA, chmaConditions.sFast[cIndex] // ); maxCHMA = MathMax( maxCHMA, chmaConditions.sSlow[cIndex] // ); maxCHMA = MathMax( maxCHMA, chmaConditions.mFast[cIndex] // ); maxCHMA = MathMax( maxCHMA, chmaConditions.mSlow[cIndex] // ); maxCHMA = MathMax( maxCHMA, chmaConditions.lFast[cIndex] // ); maxCHMA = MathMax( maxCHMA, chmaConditions.lSlow[cIndex] // ); maxCHMA = MathMax( maxCHMA, chmaConditions.hFast[cIndex] // ); maxCHMA = MathMax( maxCHMA, chmaConditions.hSlow[cIndex] // ); // // Min double minCHMA = MathMin( chmaConditions.cFast[cIndex], chmaConditions.cSlow[cIndex] // ); minCHMA = MathMin( minCHMA, chmaConditions.sFast[cIndex] // ); minCHMA = MathMin( minCHMA, chmaConditions.sSlow[cIndex] // ); minCHMA = MathMin( minCHMA, chmaConditions.mFast[cIndex] // ); minCHMA = MathMin( minCHMA, chmaConditions.mSlow[cIndex] // ); minCHMA = MathMin( minCHMA, chmaConditions.lFast[cIndex] // ); minCHMA = MathMin( minCHMA, chmaConditions.lSlow[cIndex] // ); minCHMA = MathMin( minCHMA, chmaConditions.hFast[cIndex] // ); minCHMA = MathMin( minCHMA, chmaConditions.hSlow[cIndex] // ); // double chmaDistanceDiffInPoint = // (maxCHMA - minCHMA) / points // ; // // XCHHM Conditions ... // // Bullish ... // bool isCHHKCSwitchedToBullish = // ( // chhkConditions.isCSwitchedToBullish && chhkConditions.isSBullish && chhkConditions.isMBullish && chhkConditions.isLBullish && chhkConditions.isHBullish // ) // ; // bool isCHHKSSwitchedToBullish = // ( // chhkConditions.isSSwitchedToBullish && chhkConditions.isCBullish && chhkConditions.isMBullish && chhkConditions.isLBullish && chhkConditions.isHBullish // ) // ; // bool isCHHKMSwitchedToBullish = // ( // chhkConditions.isMSwitchedToBullish && chhkConditions.isCBullish && chhkConditions.isSBullish && chhkConditions.isLBullish && chhkConditions.isHBullish // ) // ; // bool isCHHKLSwitchedToBullish = // ( // chhkConditions.isLSwitchedToBullish && chhkConditions.isCBullish && chhkConditions.isSBullish && chhkConditions.isMBullish && chhkConditions.isHBullish // ) // ; // bool isCHHKHSwitchedToBullish = // ( // chhkConditions.isHSwitchedToBullish && chhkConditions.isCBullish && chhkConditions.isSBullish && chhkConditions.isMBullish && chhkConditions.isLBullish // ) // ; // bool isCHHKCBullishBreaked = // ( // chhkConditions.isCBearish && chhkConditions.isSBullish && chhkConditions.isMBullish && chhkConditions.isLBullish && chhkConditions.isHBullish // ) // ; // bool isCHHKSBullishBreaked = // ( // chhkConditions.isSBearish && chhkConditions.isCBullish && chhkConditions.isMBullish && chhkConditions.isLBullish && chhkConditions.isHBullish // ) // ; // bool isCHHKMBullishBreaked = // ( // chhkConditions.isMBearish && chhkConditions.isCBullish && chhkConditions.isSBullish && chhkConditions.isLBullish && chhkConditions.isHBullish // ) // ; // bool isCHHKLBullishBreaked = // ( // chhkConditions.isLBearish && chhkConditions.isCBullish && chhkConditions.isSBullish && chhkConditions.isMBullish && chhkConditions.isHBullish // ) // ; // bool isCHHKHBullishBreaked = // ( // chhkConditions.isHBearish && chhkConditions.isCBullish && chhkConditions.isSBullish && chhkConditions.isMBullish && chhkConditions.isLBullish // ) // ; // bool isCHHKBullish = // isCHHKCSwitchedToBullish // || // isCHHKSSwitchedToBullish // || // isCHHKMSwitchedToBullish // || // isCHHKLSwitchedToBullish // || // isCHHKHSwitchedToBullish // ; // bool isCHHKBullishBreaked = // isCHHKCBullishBreaked // || // isCHHKSBullishBreaked // || // isCHHKMBullishBreaked // || // isCHHKLBullishBreaked // || // isCHHKHBullishBreaked // ; // // Bearish ... // bool isCHHKCSwitchedToBearish = // ( // chhkConditions.isCSwitchedToBearish && chhkConditions.isSBearish && chhkConditions.isMBearish && chhkConditions.isLBearish && chhkConditions.isHBearish // ) // ; // bool isCHHKSSwitchedToBearish = // ( // chhkConditions.isSSwitchedToBearish && chhkConditions.isCBearish && chhkConditions.isMBearish && chhkConditions.isLBearish && chhkConditions.isHBearish // ) // ; // bool isCHHKMSwitchedToBearish = // ( // chhkConditions.isMSwitchedToBearish && chhkConditions.isCBearish && chhkConditions.isSBearish && chhkConditions.isLBearish && chhkConditions.isHBearish // ) // ; // bool isCHHKLSwitchedToBearish = // ( // chhkConditions.isLSwitchedToBearish && chhkConditions.isCBearish && chhkConditions.isSBearish && chhkConditions.isMBearish && chhkConditions.isHBearish // ) // ; // bool isCHHKHSwitchedToBearish = // ( // chhkConditions.isHSwitchedToBearish && chhkConditions.isCBearish && chhkConditions.isSBearish && chhkConditions.isMBearish && chhkConditions.isLBearish // ) // ; // bool isCHHKCBearishBreaked = // ( // chhkConditions.isCBullish && chhkConditions.isSBearish && chhkConditions.isMBearish && chhkConditions.isLBearish && chhkConditions.isHBearish // ) // ; // bool isCHHKSBearishBreaked = // ( // chhkConditions.isSBullish && chhkConditions.isCBearish && chhkConditions.isMBearish && chhkConditions.isLBearish && chhkConditions.isHBearish // ) // ; // bool isCHHKMBearishBreaked = // ( // chhkConditions.isMBullish && chhkConditions.isCBearish && chhkConditions.isSBearish && chhkConditions.isLBearish && chhkConditions.isHBearish // ) // ; // bool isCHHKLBearishBreaked = // ( // chhkConditions.isLBullish && chhkConditions.isCBearish && chhkConditions.isSBearish && chhkConditions.isMBearish && chhkConditions.isHBearish // ) // ; // bool isCHHKHBearishBreaked = // ( // chhkConditions.isHBullish && chhkConditions.isCBearish && chhkConditions.isSBearish && chhkConditions.isMBearish && chhkConditions.isLBearish // ) // ; // bool isCHHKBearish = // isCHHKCSwitchedToBearish // || // isCHHKSSwitchedToBearish // || // isCHHKMSwitchedToBearish // || // isCHHKLSwitchedToBearish // || // isCHHKHSwitchedToBearish // ; // bool isCHHKBearishBreaked = // isCHHKCBearishBreaked // || // isCHHKSBearishBreaked // || // isCHHKMBearishBreaked // || // isCHHKLBearishBreaked // || // isCHHKHBearishBreaked // ; // // Max High ... double maxCHHKHigh = MathMax( chhkConditions.cBars[cIndex].high, chhkConditions.sBars[cIndex].high // ); maxCHHKHigh = MathMax( maxCHHKHigh, chhkConditions.mBars[cIndex].high // ); maxCHHKHigh = MathMax( maxCHHKHigh, chhkConditions.lBars[cIndex].high // ); maxCHHKHigh = MathMax( maxCHHKHigh, chhkConditions.hBars[cIndex].high // ); // // Min High ... double minCHHKHigh = MathMin( chhkConditions.cBars[cIndex].high, chhkConditions.sBars[cIndex].high // ); minCHHKHigh = MathMin( minCHHKHigh, chhkConditions.mBars[cIndex].high // ); minCHHKHigh = MathMin( minCHHKHigh, chhkConditions.lBars[cIndex].high // ); minCHHKHigh = MathMin( minCHHKHigh, chhkConditions.hBars[cIndex].high // ); // // Max Low ... double maxCHHKLow = MathMax( chhkConditions.cBars[cIndex].low, chhkConditions.sBars[cIndex].low // ); maxCHHKLow = MathMax( maxCHHKLow, chhkConditions.mBars[cIndex].low // ); maxCHHKLow = MathMax( maxCHHKLow, chhkConditions.lBars[cIndex].low // ); maxCHHKLow = MathMax( maxCHHKLow, chhkConditions.hBars[cIndex].low // ); // // Min Low ... double minCHHKLow = MathMin( chhkConditions.cBars[cIndex].low, chhkConditions.sBars[cIndex].low // ); minCHHKLow = MathMin( minCHHKLow, chhkConditions.mBars[cIndex].low // ); minCHHKLow = MathMin( minCHHKLow, chhkConditions.lBars[cIndex].low // ); minCHHKLow = MathMin( minCHHKLow, chhkConditions.hBars[cIndex].low // ); // double chhkDistanceDiffInPoint = // (maxCHHKHigh - minCHHKLow) / points // ; // // Signalling ... // Looking for Signals Based on Conditions ... // // Preparing Signals for Execution ... bool allowCHHKSignals = true; bool allowCHMASignals = false; // // XCHMA ... if (allowCHMASignals) { // double pressureDistance = 200; // if (isCHMABullish) { // hasLong = // isCHMABullish && hasBullishPattern && chmaDistanceDiffInPoint <= pressureDistance // ; // if (hasLong) { // type = POSITION_TYPE_SELL; sl = minCHMA; } } // if (isCHMABearish) { // hasShort = // isCHMABearish && hasBearishPattern && chmaDistanceDiffInPoint <= pressureDistance // ; // if (hasShort) { // type = POSITION_TYPE_SELL; sl = minCHMA; } } } // // XCHHK ... if (allowCHHKSignals) { // double pressureDistance = 200; // if (isCHHKBullish) { // hasLong = // isCHHKBullish && hasBullishPattern && chhkDistanceDiffInPoint <= pressureDistance // ; // if (hasLong) { // type = POSITION_TYPE_BUY; sl = maxCHHKLow; } } // if (isCHHKBearish) { // hasShort = // isCHHKBearish && hasBearishPattern && chhkDistanceDiffInPoint <= pressureDistance // ; // if (hasShort) { // type = POSITION_TYPE_SELL; sl = minCHHKHigh; } } } // // forceCloseLongs = isCHHKBullishBreaked; // forceCloseShorts = isCHHKBearishBreaked; // // Check Exist Conditions ... if (forceCloseLongs || forceCloseShorts) { // string comment = "Exit Condition ..."; // ENUM_X_POSITION_TYPES mType = forceCloseLongs ? X_POSITION_TYPE_LONG : X_POSITION_TYPE_SHORT; // int count = trader.Close( comment, mSymbol, GetTag(), mPeriod, mType, false // Filter By Magic ... ); if (IsValidSize(count)) { // string msg = "Close (" + ToString(count) + ") " + (forceCloseLongs ? "Long" : "Short") + " Positions due Exit Conditions ..."; Alert(msg); } } // result = hasLong || hasShort; if (!result) { // CheckSupportValidation(); CheckResistanceValidation(); return result; } // if (hasSupport) { // supportTime = NULL; isSupportTested = false; RemoveSupport(support); support.Clean(); } // if (hasResistance) { // resistanceTime = NULL; isResistanceTested = false; RemoveResistance(resistance); resistance.Clean(); } // // Retrieve Entry Price based on Position Type ... entry = GetEntry(mSymbol, type); // // Calculate TP and SL ... // based on Strategy ... CalculateTPSLByPrice( sl, tp, type, entry, r2r // ); // // Preparing Signal ... result = signal.Prepare( mSymbol, GetTag(), mPeriod, type, mode, entry, mVolume, sl, tp // ); // return result; } // // Protected ... protected: // // Props ... // XOHCL support; XOHCL resistance; // // XPV ... XPVInputs pvInputs; XSCXPVHelper *pvHelper; // // XSTR ... XSTRInputs strInputs; XSCXSTRHelper *strHelper; // // XCHE ... XCHEInputs cheInputs; XSCXCHEHelper *cheHelper; // // XHK ... XCHHKInputs chhkInputs; XSCXCHHKHelper *chhkHelper; // // XCHMA ... XCHMAInputs chmaInputs; XSCXCHMAHelper *chmaHelper; // // Private ... private: // // Props ... // void PrepareRequirements() { // support.Clean(); supportTime = NULL; isSupportTested = false; // resistance.Clean(); resistanceTime = NULL; isResistanceTested = false; // // XCHMA ... // chmaInputs.Default(); // chmaInputs.showFast = true; chmaInputs.showSlow = true; chmaInputs.showCCFast = false; chmaInputs.showCCSlow = false; chmaInputs.showSCFast = false; chmaInputs.showSCSlow = false; chmaInputs.showMCFast = false; chmaInputs.showMCSlow = false; chmaInputs.showLCFast = false; chmaInputs.showLCSlow = false; chmaInputs.showHCFast = false; chmaInputs.showHCSlow = false; // chmaHelper = new XSCXCHMAHelper(); chmaHelper.Init( mSymbol, mPeriod, chmaInputs // ); // // XCHHK ... // chhkInputs.Default(); // chhkInputs.showCurrent = true; chhkInputs.showShort = true; chhkInputs.showMedium = true; chhkInputs.showLong = true; chhkInputs.showHind = true; // chhkHelper = new XSCXCHHKHelper(); chhkHelper.Init( mSymbol, mPeriod, chhkInputs // ); // // XPV ... // pvInputs.Default(); // pvInputs.showPeaksAndVales = true; pvInputs.showLevels = false; pvInputs.showConsolidations = false; pvInputs.showFibo1Levels = false; pvInputs.showFibo2Levels = false; pvInputs.showFibo3Levels = false; pvInputs.showFibo4Levels = false; pvInputs.showFibo5Levels = false; // pvHelper = new XSCXPVHelper(); pvHelper.Init( mSymbol, mPeriod, pvInputs // ); // // XSTR ... // strInputs.Default(); // strInputs.showTrends = true; strInputs.fillTrends = false; // strHelper = new XSCXSTRHelper(); strHelper.Init( mSymbol, mPeriod, strInputs // ); // // XCHE ... // cheInputs.Default(); // cheInputs.showLongExit1Line = true; cheInputs.showShortExit1Line = true; cheInputs.showLongExit2Line = true; cheInputs.showShortExit2Line = true; // cheHelper = new XSCXCHEHelper(); cheHelper.Init( mSymbol, mPeriod, cheInputs // ); } // bool isSupportTested; datetime supportTime; void CheckSupportValidation() { // if (!isSupportTested) { // if (support.IsValid() && IsValid(supportTime)) { // int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(supportTime))) / PeriodSeconds(mPeriod)); if (age >= 50) { // isSupportTested = false; supportTime = NULL; RemoveSupport(support); support.Clean(); } } return; } // XOHCL cBar; bool isInited = cBar.Init( mSymbol, mPeriod, 1 // ); if (!isInited) { return; } // double points = GetPoints(mSymbol); // // Find Price Distance ... double highDiff = MathAbs(cBar.high - support.high); double lowDiff = MathAbs(cBar.low - support.high); // bool isBreaked = MathMax(highDiff, lowDiff) >= 100 * points; if (!isBreaked) { return; } // isSupportTested = false; RemoveSupport(support); supportTime = NULL; support.Clean(); } // bool isResistanceTested; datetime resistanceTime; void CheckResistanceValidation() { // if (!isResistanceTested) { // if (resistance.IsValid() && IsValid(resistanceTime)) { // int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(resistanceTime))) / PeriodSeconds(mPeriod)); if (age >= 50) { // isResistanceTested = false; resistanceTime = NULL; RemoveResistance(resistance); resistance.Clean(); } } return; } // XOHCL cBar; bool isInited = cBar.Init( mSymbol, mPeriod, 1 // ); if (!isInited) { return; } // double points = GetPoints(mSymbol); // // Find Price Distance ... double highDiff = MathAbs(cBar.high - resistance.low); double lowDiff = MathAbs(cBar.low - resistance.low); // bool isBreaked = MathMax(highDiff, lowDiff) >= 100 * points; if (!isBreaked) { return; } // isResistanceTested = false; RemoveResistance(resistance); resistanceTime = NULL; resistance.Clean(); } }; //