/////////////////////////////////////////////////////// // // SaherElm IT Center MQL5 Class Library // ---------------------------------------------- // Name: XSCX121Provider // Description: X121 Signal Provider ... // // // 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 // // START Definitions ... // // // START Import and Inclused requirements ... // // // Includes ... #include "../Classes/x-saherelm.xprovider.class.mq5" #include "../Helpers/x-saherelm.x121.xct.helper.class.mq5" #include "../Helpers/x-saherelm.x121.xcc.helper.class.mq5" #include "../Helpers/x-saherelm.x121.xhk.helper.class.mq5" #include "../Helpers/x-saherelm.x121.xtm.helper.class.mq5" #include "../Helpers/x-saherelm.x121.xpv.helper.class.mq5" #include "../Helpers/x-saherelm.x121.xstr.helper.class.mq5" #include "../Helpers/x-saherelm.x121.xfbb.helper.class.mq5" #include "../Helpers/x-saherelm.x121.xosc.helper.class.mq5" #include "../Helpers/x-saherelm.x121.xama.helper.class.mq5" #include "../Helpers/x-saherelm.x121.xmrb.helper.class.mq5" #include "../Helpers/x-saherelm.x121.xche.helper.class.mq5" #include "../Helpers/x-saherelm.x121.xich.helper.class.mq5" #include "../Helpers/x-saherelm.x121.xdema.helper.class.mq5" #include "../Helpers/x-saherelm.x121.xtrnd.helper.class.mq5" #include "../Helpers/x-saherelm.x121.xsslc.helper.class.mq5" #include "../Helpers/x-saherelm.x121.xhull.helper.class.mq5" // // Library ... #include "../Libraries/x-saherelm.draw.lib.mq5" #include "../Libraries/x-saherelm.seriallizer.lib.mq5" // // END Import and Inclused requirements ... // // // Here we Have to Define an Input Structure Model // for Provider Class to Handle Helpers Definitions ... struct X121ProviderInputs { // // XCT ... // Candle Timer ... XCTInputs xctConfig; // // XCC ... // Candle Styling ... XCCInputs xccConfig; // // XHK ... // HikenAshi Candle Representing ... XHKInputs xhkConfig; // // XTM ... // Trend Magic ... XTMInputs xtmConfig; // // XPV ... // Peaks And Vales ... XPVInputs xpvConfig; // // XOSC ... // OSCILLATORS ... XOSCInputs xoscConfig; // // XAMA ... // Adaptive Moving Average ... XAMAInputs xamaConfig; // // XMRB ... // Moving Average Ribbon ... XMRBInputs xmrbConfig; // // XCHE ... // Chandelier Exit Points ... XCHEInputs xcheConfig; // // XICH ... // Ichimopku Kinko Hyo ... XICHInputs xichConfig; // // XTRND ... // Trend Detector ... XTRNDInputs xtrndConfig; // // XSSLC ... // SSL Channel ... XSSLCInputs xsslcConfig; // // XHULL ... // Hull Trend Detection Channel ... XHULLInputs xhullConfig; // // XFBB ... XFBBInputs xfbbConfig; // // XSTR ... XSTRInputs xstrConfig; // // XDEMA ... XDEMAInputs xdemaConfig; }; // // Model Market Sense based On Current Captured conditions ... struct X121MarketConditions { // // Commonly Used Info ... // // Symbol ... string symbol; // // Period ... ENUM_TIMEFRAMES period; // // Bar Time ... datetime barTime; // XCandleRemains barRemains; // // Bar Index ... int barIndex; // // Check Current Market Condition has Signal or not ... bool hasSignal; // // If has any Signal, Models it's related info here ... XSignal signal; // // Support and Resistances ... // if provides Signal ... XOHCLSupRes supportResistances; // // Change Price Steps ... double momentumStep; // XOHCL candles[]; // // INDICATORS Market Sense ... // // XCT ... // there is not any Info provided here ... // // XCC ... // there is not any Info provided here ... // // XHK ... XHKInfo xhkInfo; // // XTM ... XTMInfo xtmInfo; // // XPV ... XPVInfo xpvInfo; // // XOSC ... XOSCInfo xoscInfo; // // XAMA ... XAMAInfo xamaInfo; // // XMRB ... XMRBInfo xmrbInfo; // // XCHE ... XCHEInfo xcheInfo; // // XICH ... XICHInfo xichInfo; // // XTRND ... XTRNDInfo xtrndInfo; // // XSSLC ... XSSLCInfo xsslcInfo; // // XHULL ... XHULLInfo xhullInfo; // // XSTR ... XSTRInfo xstrInfo; // // XFBB ... XFBBInfo xfbbInfo; // // XDEMA ... XDEMAInfo xdemaInfo; }; // // Notified a Signal was Appears ... typedef void (*TOnSignalConditions)( X121MarketConditions &info); // // All Available Signal Types ... enum ENUM_X121_SIGNAL_PROVIDERS { NONE, // NONE ... X786, // Hadi Khazaee Asl ... X92, // Hadi Khazaee Asl ... X110, // AmirAli Khazaee ... X121, // Hadi Khazaee Asl ... X128, // Farhad Farahmand ... }; // // END Definitions ... // // // START Overrides ... // // // END Overrides ... // // // a Base Class for All of our EA's ... class XSCX121Provider : public XSCEABaseProvider { // // Public ... public: // // Props ... X121ProviderInputs providedConfig; X121ProviderInputs currentConfig; X121ProviderInputs cleanConfig; // // Indicator Helper Classes Instance ... // // XCT ... XSCXCTHelper *mXCTHelper; // // XCC ... XSCXCCHelper *mXCCHelper; // // XHK ... XSCXHKHelper *mXHKHelper; // // XTM ... XSCXTMHelper *mXTMHelper; // // XPV ... XSCXPVHelper *mXPVHelper; // // XOSC ... XSCXOSCHelper *mXOSCHelper; // // XAMA ... XSCXAMAHelper *mXAMAHelper; // // XMRB ... XSCXMRBHelper *mXMRBHelper; // // XCHE ... XSCXCHEHelper *mXCHEHelper; // // XICH ... XSCXICHHelper *mXICHHelper; // // XTRND ... XSCXTRNDHelper *mXTRNDHelper; // // XSSLC ... XSCXSSLCHelper *mXSSLCHelper; // // XHULL ... XSCXHULLHelper *mXHULLHelper; // // XSTR ... XSCXSTRHelper *mXSTRHelper; // // XFBB ... XSCXFBBHelper *mXFBBHelper; // // XDEMA ... XSCXDEMAHelper *mXDEMAHelper; // // Hull Pivot Points ... double upZonePivots[]; double downZonePivots[]; // // Peaks and Vales Verifications Number ... double peaksPivots[]; double valesPivots[]; // double ichPivots[]; // double fiboPivots[]; // int pvConsequences; // // Constructor ... void XSCX121Provider( string symbol, // Trading Symbol ... ENUM_TIMEFRAMES period // Trading Time Frame ... ) { // mMinPivots = 100; pvConsequences = 26; // PrepareTag(); } // // Deconstructor ... void ~XSCX121Provider() { // IndicatorRelease(mCTimerHandler); // // De construct Helpers ... delete mXCTHelper; delete mXCCHelper; delete mXHKHelper; delete mXTMHelper; delete mXPVHelper; delete mXOSCHelper; delete mXAMAHelper; delete mXMRBHelper; delete mXCHEHelper; delete mXICHHelper; delete mXSTRHelper; delete mXFBBHelper; delete mXTRNDHelper; delete mXSSLCHelper; delete mXHULLHelper; delete mXDEMAHelper; } // virtual void PrepareTag() { mTag = "X121Provider((" + mSymbol + ")(" + ToString(mPeriod) + ")"; } // virtual bool Init() { // bool result = false; // // Instantiate all Indicators Helper Classes ... // // XCT ... mXCTHelper = new XSCXCTHelper( mSymbol, mPeriod); result = mXCTHelper.SetConfig(currentConfig.xctConfig); if (!result) { return result; } // // XCC ... mXCCHelper = new XSCXCCHelper( mSymbol, mPeriod); result = mXCCHelper.SetConfig(currentConfig.xccConfig); if (!result) { return result; } // // XHK ... mXHKHelper = new XSCXHKHelper( mSymbol, mPeriod); result = mXHKHelper.SetConfig(currentConfig.xhkConfig); if (!result) { return result; }; // // XTM ... mXTMHelper = new XSCXTMHelper( mSymbol, mPeriod); result = mXTMHelper.SetConfig(currentConfig.xtmConfig); if (!result) { return result; }; // // XPV ... mXPVHelper = new XSCXPVHelper( mSymbol, mPeriod); result = mXPVHelper.SetConfig(currentConfig.xpvConfig); if (!result) { return result; }; // // XOSC ... mXOSCHelper = new XSCXOSCHelper( mSymbol, mPeriod); result = mXOSCHelper.SetConfig(currentConfig.xoscConfig); if (!result) { return result; }; // // XAMA ... mXAMAHelper = new XSCXAMAHelper( mSymbol, mPeriod); result = mXAMAHelper.SetConfig(currentConfig.xamaConfig); if (!result) { return result; }; // // XMRB ... mXMRBHelper = new XSCXMRBHelper( mSymbol, mPeriod); result = mXMRBHelper.SetConfig(currentConfig.xmrbConfig); if (!result) { return result; }; // // XCHE ... mXCHEHelper = new XSCXCHEHelper( mSymbol, mPeriod); result = mXCHEHelper.SetConfig(currentConfig.xcheConfig); if (!result) { return result; }; // // XICH ... mXICHHelper = new XSCXICHHelper( mSymbol, mPeriod); result = mXICHHelper.SetConfig(currentConfig.xichConfig); if (!result) { return result; }; // // XTRND ... mXTRNDHelper = new XSCXTRNDHelper( mSymbol, mPeriod); result = mXTRNDHelper.SetConfig(currentConfig.xtrndConfig); if (!result) { return result; }; // // XSSLC ... mXSSLCHelper = new XSCXSSLCHelper( mSymbol, mPeriod); result = mXSSLCHelper.SetConfig(currentConfig.xsslcConfig); if (!result) { return result; }; // // XHULL ... mXHULLHelper = new XSCXHULLHelper( mSymbol, mPeriod); result = mXHULLHelper.SetConfig(currentConfig.xhullConfig); if (!result) { return result; }; // // XSTR ... mXSTRHelper = new XSCXSTRHelper( mSymbol, mPeriod); result = mXSTRHelper.SetConfig(currentConfig.xstrConfig); if (!result) { return result; }; // // XFBB ... mXFBBHelper = new XSCXFBBHelper( mSymbol, mPeriod); result = mXFBBHelper.SetConfig(currentConfig.xfbbConfig); if (!result) { return result; }; // // XDEMA ... mXDEMAHelper = new XSCXDEMAHelper( mSymbol, mPeriod); result = mXDEMAHelper.SetConfig(currentConfig.xdemaConfig); if (!result) { return result; }; // return result; } // virtual int GetMaxLength() { // int result = -1; // result = MathMax(result, mXCTHelper.GetMaxLength()); result = MathMax(result, mXCCHelper.GetMaxLength()); result = MathMax(result, mXHKHelper.GetMaxLength()); result = MathMax(result, mXTMHelper.GetMaxLength()); result = MathMax(result, mXPVHelper.GetMaxLength()); result = MathMax(result, mXOSCHelper.GetMaxLength()); result = MathMax(result, mXAMAHelper.GetMaxLength()); result = MathMax(result, mXMRBHelper.GetMaxLength()); result = MathMax(result, mXCHEHelper.GetMaxLength()); result = MathMax(result, mXICHHelper.GetMaxLength()); result = MathMax(result, mXTRNDHelper.GetMaxLength()); result = MathMax(result, mXSSLCHelper.GetMaxLength()); result = MathMax(result, mXHULLHelper.GetMaxLength()); result = MathMax(result, mXSTRHelper.GetMaxLength()); result = MathMax(result, mXFBBHelper.GetMaxLength()); result = MathMax(result, mXDEMAHelper.GetMaxLength()); // return result; } // virtual int GetCalculatedBars() { // int result = -1; // int mXCTBars = mXCTHelper.GetCalculatedBars(); int mXCCBars = mXCCHelper.GetCalculatedBars(); int mXHKBars = mXHKHelper.GetCalculatedBars(); int mXTMBars = mXTMHelper.GetCalculatedBars(); int mXPVBars = mXPVHelper.GetCalculatedBars(); int mXOSCBars = mXOSCHelper.GetCalculatedBars(); int mXAMABars = mXAMAHelper.GetCalculatedBars(); int mXMRBBars = mXMRBHelper.GetCalculatedBars(); int mXCHEBars = mXCHEHelper.GetCalculatedBars(); int mXICHBars = mXICHHelper.GetCalculatedBars(); int mXTRNDBars = mXTRNDHelper.GetCalculatedBars(); int mXSSLCBars = mXSSLCHelper.GetCalculatedBars(); int mXHULLBars = mXHULLHelper.GetCalculatedBars(); int mXSTRBars = mXSTRHelper.GetCalculatedBars(); int mXFBBBars = mXFBBHelper.GetCalculatedBars(); int mXDEMABars = mXDEMAHelper.GetCalculatedBars(); // int min = MathMin(mXCTBars, mXCCBars); min = MathMin(min, mXHKBars); min = MathMin(min, mXTMBars); min = MathMin(min, mXPVBars); min = MathMin(min, mXOSCBars); min = MathMin(min, mXAMABars); min = MathMin(min, mXMRBBars); min = MathMin(min, mXCHEBars); min = MathMin(min, mXICHBars); min = MathMin(min, mXTRNDBars); min = MathMin(min, mXSSLCBars); min = MathMin(min, mXHULLBars); min = MathMin(min, mXSTRBars); min = MathMin(min, mXFBBBars); min = MathMin(min, mXDEMABars); // int max = MathMax(mXCTBars, mXCCBars); max = MathMax(max, mXHKBars); max = MathMax(max, mXTMBars); max = MathMax(max, mXPVBars); max = MathMax(max, mXOSCBars); max = MathMax(max, mXAMABars); max = MathMax(max, mXMRBBars); max = MathMax(max, mXCHEBars); max = MathMax(max, mXICHBars); max = MathMax(max, mXTRNDBars); max = MathMax(max, mXSSLCBars); max = MathMax(max, mXHULLBars); max = MathMax(max, mXSTRBars); max = MathMax(max, mXFBBBars); max = MathMax(max, mXDEMABars); // result = min; // return result; } // virtual void ProcessBuffers() { UpdatePivotPoints(); } // virtual bool ProcessTick(X121MarketConditions &conditions) { // if (CanIgnoreTick()) { return false; } // return ProcessSignals(conditions); } // int GetMinPivots() { return mMinPivots; } // X121ProviderInputs GetConfig() { // X121ProviderInputs result; // result = currentConfig; // return result; } // // Set Available Signallers ... bool SetSignallers( string &signallers[]) { // bool result = false; // result = ArraySize(signallers) > 0; if (!result) { return result; } // Copy( signallers, mSignallers); // return result; } // bool SetConfig(X121ProviderInputs &config) { // bool result = false; // PrepareConfig(config); // result = Init(); // return result; } // bool ResetDefaultConfig() { // bool result = SetConfig(providedConfig); // return result; } // bool ShowCleanConfig() { // currentConfig = cleanConfig; // bool result = Init(); // return result; } // bool ShowDefaultConfig() { // currentConfig = providedConfig; // bool result = Init(); // return result; } // bool IsAllowdSignaller( ENUM_X121_SIGNAL_PROVIDERS provider // Signal Provider ) { // bool result = false; // string providerStr = ToString(provider); // result = Contains( providerStr, mSignallers); // return result; } // // Generate Market Sense ... X121MarketConditions GetMarketConditions( int barIndex // Specified Bar Index ) { // X121MarketConditions result; // // Fill Common Data ... result.symbol = mSymbol; result.period = mPeriod; result.barIndex = barIndex; // datetime barTime = GetCandleTime( mSymbol, mPeriod, barIndex); result.barTime = barTime; // int remainedCandle = barIndex > 0 ? barIndex - 1 : barIndex; GetCandleRemainsTime( result.barRemains, mSymbol, mPeriod, remainedCandle); // // Attach Candles Info in XOHCL Model to Conditions ... int mLoopBackBars = mXHKHelper.Loopback(); XOHCL candles[]; GetCandles( candles, mSymbol, mPeriod, 0, mLoopBackBars); Copy( candles, result.candles); Clean(candles); // result.xhkInfo = mXHKHelper.GetInfo(barIndex); result.xtmInfo = mXTMHelper.GetInfo(barIndex); result.xpvInfo = mXPVHelper.GetInfo(barIndex); result.xoscInfo = mXOSCHelper.GetInfo(barIndex); result.xamaInfo = mXAMAHelper.GetInfo(barIndex); result.xmrbInfo = mXMRBHelper.GetInfo(barIndex); result.xcheInfo = mXCHEHelper.GetInfo(barIndex); result.xichInfo = mXICHHelper.GetInfo(barIndex); result.xtrndInfo = mXTRNDHelper.GetInfo(barIndex); result.xsslcInfo = mXSSLCHelper.GetInfo(barIndex); result.xhullInfo = mXHULLHelper.GetInfo(barIndex); result.xstrInfo = mXSTRHelper.GetInfo(barIndex); result.xfbbInfo = mXFBBHelper.GetInfo(barIndex); result.xdemaInfo = mXDEMAHelper.GetInfo(barIndex); // return result; } // bool GuardCheck(XGuard &guards[]) { // bool result = false; // Clean(guards); // // Implement Guards Check ... X121MarketConditions mConditions = GetMarketConditions(1); X121MarketConditions mConditions2 = GetMarketConditions(2); // XOHCL c0 = GetCandle( mSymbol, mPeriod, 0); double c0Price = MathMin(c0.low, c0.close); // double ll1 = GetLowestLow( mSymbol, mPeriod, 3, 1); double ll2 = GetLowestLow( mSymbol, mPeriod, 3, 2); // bool isXAMACrossedUnderXTM = // mConditions.xamaInfo.value < mConditions.xtmInfo.value && mConditions2.xamaInfo.value >= mConditions2.xtmInfo.value // ; // // X786 ... bool canCheckX786 = IsAllowdSignaller(X786); if (canCheckX786) { // } // // X92 ... bool canCheckX92 = IsAllowdSignaller(X92); if (canCheckX92) { } // // X110 ... bool canCheckX110 = IsAllowdSignaller(X110); if (canCheckX110) { // } // // X121 ... bool canCheckX121 = IsAllowdSignaller(X121); if (canCheckX121) { // } // // X128 ... bool canCheckX128 = IsAllowdSignaller(X128); if (canCheckX128) { // } // result = ArraySize(guards) > 0; // return result; } // // Add Specific On SignalConditions Event Handler ... int AddOnSignalConditionEventHandler(TOnSignalConditions handler) { // ArrayResize( mSignalConditionsEventHandlers, ArraySize(mSignalConditionsEventHandlers) + 1); // int result = ArraySize(mSignalConditionsEventHandlers) - 1; mSignalConditionsEventHandlers[result] = handler; // return result; } // // Remove All On Signal Event Handler ... void ReoveOnSignalEventHandlers() { // ArrayFree(mSignalConditionsEventHandlers); } // // Notify a Signal Found on all Event Listeners ... void NotifyOnSignalConditionsEvent(X121MarketConditions &info) { // int listenerCount = ArraySize(mSignalConditionsEventHandlers); if (listenerCount <= 0) { return; } // // Loop Through Listeners ... for (int i = 0; i < listenerCount; i++) { // TOnSignalConditions listener = mSignalConditionsEventHandlers[i]; // listener(info); } } // // PIVOTS ... // void ProccessPivotPoints() { // if (mStartPivotScan) { return; } // mStartPivotScan = true; // int maxLength = GetMaxLength(); int cBars = GetCalculatedBars(); int scanSize = cBars - maxLength - 1; for (int i = 1; i < scanSize; i++) { // UpdatePivotPoints(i); // int pivotsCount = CountPivots(); if (pivotsCount >= mMinPivots) { break; } } } // int CountPivots() { // int pivotSizes[]; int upZoneCount = ArraySize(upZonePivots); if (upZoneCount > 0) { // Add( upZoneCount, pivotSizes); } // int downZoneCount = ArraySize(downZonePivots); if (downZoneCount > 0) { // Add( downZoneCount, pivotSizes); } // int peaksCount = ArraySize(peaksPivots); if (peaksCount > 0) { // Add( peaksCount, pivotSizes); } // int valesCount = ArraySize(valesPivots); if (valesCount > 0) { // Add( valesCount, pivotSizes); } // int fibsCount = ArraySize(fiboPivots); if (fibsCount > 0) { // Add( fibsCount, pivotSizes); } // int ichsCount = ArraySize(ichPivots); if (ichsCount > 0) { // Add( ichsCount, pivotSizes); } // int result = ArraySize(pivotSizes) > 0 ? pivotSizes[ArrayMaximum(pivotSizes)] : 0; // return result; } // // Generate Exists Support and Resistance based on Given Price ... XOHCLSupRes GenerateSupportAndResistance( double price, // Specified Price int count = 10 // Number of Pivots in Each Side ) { // XOHCLSupRes result; // UpdatePivotPoints(0); // double pivots[]; FillPivotPoints(pivots); // // Generate Support and Resistances ... result = ExtractSupportAndResistance( price, pivots, count); // return result; } // // Protected ... protected: // // Private ... private: // // CCandle Timer ... int mCTimerHandler; // // Signal Event Handlers ... TOnSignalConditions mSignalConditionsEventHandlers[]; // // Make Provided Config in Clean Style ... void PrepareConfig(X121ProviderInputs &config) { // cleanConfig = config; // // XCT ... // Candle Timing ... cleanConfig.xctConfig.showCandleTime = false; // // XCC ... // Candle Styling ... cleanConfig.xccConfig.showCandles = true; // // XHK ... // HikenAshi Candle Representing ... cleanConfig.xhkConfig.drawCandles = false; cleanConfig.xhkConfig.drawCandleLines = false; // // XTM ... // Trend Magic ... cleanConfig.xtmConfig.showLine = false; // // XPV ... // Peaks And Vales ... cleanConfig.xpvConfig.showPeaksAndVales = false; cleanConfig.xpvConfig.showLevels = false; cleanConfig.xpvConfig.showFibo1Levels = false; cleanConfig.xpvConfig.showFibo2Levels = false; cleanConfig.xpvConfig.showFibo3Levels = false; // // XAMA ... // Adaptive Moving Average ... cleanConfig.xamaConfig.showLine = false; // // XMRB ... // Moving Average Ribbon ... cleanConfig.xmrbConfig.showFastMa = false; cleanConfig.xmrbConfig.showSlowMa = false; cleanConfig.xmrbConfig.showRibbon = false; // // XCHE ... // Chandelier Exit Points ... cleanConfig.xcheConfig.showLongExit1Line = false; cleanConfig.xcheConfig.showShortExit1Line = false; cleanConfig.xcheConfig.showLongExit2Line = false; cleanConfig.xcheConfig.showShortExit2Line = false; // // XICH ... // Ichimopku Kinko Hyo ... cleanConfig.xichConfig.showTenkanSen = false; cleanConfig.xichConfig.showKijunSen = false; cleanConfig.xichConfig.showKijunSenPlus = false; cleanConfig.xichConfig.showKijunSenNegative = false; cleanConfig.xichConfig.showChikouSpan = false; cleanConfig.xichConfig.showSenkouSpanA = false; cleanConfig.xichConfig.showSenkouSpanB = false; cleanConfig.xichConfig.showKumo = false; // // XTRND ... // Trend Detector ... cleanConfig.xtrndConfig.showConsolidations = false; cleanConfig.xtrndConfig.showTrend = false; cleanConfig.xtrndConfig.showL1Trend = false; cleanConfig.xtrndConfig.showL2Trend = false; cleanConfig.xtrndConfig.showL3Trend = false; // // XSSLC ... // SSL Channel ... cleanConfig.xsslcConfig.showUp = false; cleanConfig.xsslcConfig.showDown = false; // // XHULL ... // Hull Trend Detection Channel ... cleanConfig.xhullConfig.showUpZone = false; cleanConfig.xhullConfig.showDownZone = false; // // XSTR ... cleanConfig.xstrConfig.showTrends = false; cleanConfig.xstrConfig.fillTrends = false; // // XFBB ... cleanConfig.xfbbConfig.showBand = false; cleanConfig.xfbbConfig.showGoldenArea = false; cleanConfig.xfbbConfig.showOthers = false; // // XDEMA ... cleanConfig.xdemaConfig.showDema = false; cleanConfig.xdemaConfig.showEMA = false; cleanConfig.xdemaConfig.showEMAOfEMA = false; // providedConfig = config; currentConfig = config; } // void Calculate(int barIndex) { // mXCTHelper.Calculate(barIndex); mXCCHelper.Calculate(barIndex); mXHKHelper.Calculate(barIndex); mXTMHelper.Calculate(barIndex); mXPVHelper.Calculate(barIndex); mXAMAHelper.Calculate(barIndex); mXMRBHelper.Calculate(barIndex); mXCHEHelper.Calculate(barIndex); mXICHHelper.Calculate(barIndex); mXTRNDHelper.Calculate(barIndex); mXSSLCHelper.Calculate(barIndex); mXHULLHelper.Calculate(barIndex); mXOSCHelper.Calculate(barIndex); mXSTRHelper.Calculate(barIndex); mXFBBHelper.Calculate(barIndex); mXDEMAHelper.Calculate(barIndex); } // int mMinPivots; bool mStartPivotScan; double mLastMomentumStep; // // Find Required Pivots for Support and Resistance ... void UpdatePivotPoints( int barIndex = 1 // Specified Candle ... ) { // Calculate(barIndex); // // Detect Peask and Vales Pivots ... // // Detect Hull Pivots ... // find Hull Trend Changes ... int idx = 1; bool isHullUpChanged = // ( // (XHULL_ZONE_STATES)mXHULLHelper.upStateBuffer[idx] == XHULL_STATE_BULLISH && (XHULL_ZONE_STATES)mXHULLHelper.upStateBuffer[idx + 1] != XHULL_STATE_BULLISH // ) // || // ( // (XHULL_ZONE_STATES)mXHULLHelper.upStateBuffer[idx] == XHULL_STATE_BEARISH && (XHULL_ZONE_STATES)mXHULLHelper.upStateBuffer[idx + 1] != XHULL_STATE_BEARISH // ) // ; // bool isHullDownChanged = // ( // (XHULL_ZONE_STATES)mXHULLHelper.downStateBuffer[idx] == XHULL_STATE_BULLISH && (XHULL_ZONE_STATES)mXHULLHelper.downStateBuffer[idx + 1] != XHULL_STATE_BULLISH // ) // || // ( // (XHULL_ZONE_STATES)mXHULLHelper.downStateBuffer[idx] == XHULL_STATE_BEARISH && (XHULL_ZONE_STATES)mXHULLHelper.downStateBuffer[idx + 1] != XHULL_STATE_BEARISH // ) // ; // // Find Change State ... if (isHullUpChanged || isHullDownChanged) { // AddIfNotExists( mXHULLHelper.upBuffer[idx], upZonePivots); // AddIfNotExists( mXHULLHelper.downBuffer[idx], downZonePivots); } // // Find Momentom Step ... if (isHullUpChanged && isHullDownChanged) { // mLastMomentumStep = MathAbs(mXHULLHelper.upBuffer[idx] - mXHULLHelper.downBuffer[idx]); mLastMomentumStep = NormalizePrice( mLastMomentumStep, mSymbol); } // // Find Peaks and Vales ... double selectedFib1 = mXPVHelper.fl1Buffer[idx]; double selectedFib2 = mXPVHelper.fl2Buffer[idx]; double selectedFib3 = mXPVHelper.fl3Buffer[idx]; double selectedPeak = mXPVHelper.peaksBuffer[idx]; double selectedVale = mXPVHelper.valesBuffer[idx]; // double selectedTenkanSen = mXICHHelper.tenkanSenBuffer[idx]; double selectedKijunSen = mXICHHelper.kijunSenBuffer[idx]; // int fib1Verified = 0; int fib2Verified = 0; int fib3Verified = 0; int peaksVerified = 0; int valesVerified = 0; int kijunSenVerified = 0; int tenkanSenVerified = 0; int senkouSpanAVerified = 0; int senkouSpanBVerified = 0; for (int i = barIndex + 1; i < pvConsequences + barIndex + 1; i++) { // int idx = i - barIndex; // // PEAKS and VALES ... // if (selectedPeak == mXPVHelper.peaksBuffer[idx]) { peaksVerified++; } else { peaksVerified = 0; } // if (selectedVale == mXPVHelper.valesBuffer[idx]) { valesVerified++; } else { valesVerified = 0; } // if (selectedFib1 == mXPVHelper.fl1Buffer[idx]) { fib1Verified++; } else { fib1Verified = 0; } // if (selectedFib2 == mXPVHelper.fl2Buffer[idx]) { fib2Verified++; } else { fib2Verified = 0; } // if (selectedFib3 == mXPVHelper.fl3Buffer[idx]) { fib3Verified++; } else { fib3Verified = 0; } // // ICHIMOKU Kinko Hyo ... // if (selectedTenkanSen == mXICHHelper.tenkanSenBuffer[idx]) { tenkanSenVerified++; } else { tenkanSenVerified = 0; } // if (selectedKijunSen == mXICHHelper.kijunSenBuffer[idx]) { kijunSenVerified++; } else { kijunSenVerified++; } } // if (peaksVerified >= pvConsequences) { // AddIfNotExists( selectedPeak, peaksPivots); } // if (valesVerified >= pvConsequences) { // AddIfNotExists( selectedVale, valesPivots); } // if (fib1Verified >= pvConsequences) { // AddIfNotExists( selectedFib1, fiboPivots); } // if (fib2Verified >= pvConsequences) { // AddIfNotExists( selectedFib2, fiboPivots); } // if (fib3Verified >= pvConsequences) { // AddIfNotExists( selectedFib3, fiboPivots); } // if (tenkanSenVerified >= pvConsequences) { // AddIfNotExists( selectedTenkanSen, ichPivots); } // if (kijunSenVerified >= pvConsequences) { // AddIfNotExists( selectedKijunSen, ichPivots); } // // // if (senkouSpanAVerified >= pvConsequences) // { // // // AddIfNotExists( // selectedSenkouSpanA, // ichPivots); // } // // // if (senkouSpanBVerified >= pvConsequences) // { // // // AddIfNotExists( // selectedSenkouSpanB, // ichPivots); // } } // void FillPivotPoints( double &result[]) { // Clean(result); // int pCount = CountPivots(); if (pCount <= 0) { return; } // AddsIfNotExists( upZonePivots, result); // AddsIfNotExists( downZonePivots, result); // AddsIfNotExists( peaksPivots, result); // AddsIfNotExists( valesPivots, result); // AddsIfNotExists( fiboPivots, result); // AddsIfNotExists( ichPivots, result); } // // Available Signallers ... string mSignallers[]; // // Here we are Capture Conditions and Check Signals ... // The Signals Must be Unique for each providers ... bool ProcessSignals(X121MarketConditions &conditions) { // X121MarketConditions mConditions = GetMarketConditions(1); // // BUY ... // Clean(mConditions.signal); bool hasLongSignal = HasLongSignal(mConditions); if (hasLongSignal) { // NotifyOnSignalEvent( mConditions.signal); NotifyOnSignalConditionsEvent(mConditions); mWaitUntilNewCandle = true; // conditions = mConditions; return true; } // // SELL ... // Clean(mConditions.signal); bool hasShortignal = HasShortSignal(mConditions); if (hasShortignal) { // NotifyOnSignalEvent( mConditions.signal); NotifyOnSignalConditionsEvent(mConditions); mWaitUntilNewCandle = true; // conditions = mConditions; return true; } // return false; } // // Check has Long Signal on Each Strategies ... bool HasLongSignal(X121MarketConditions &conditions) { // bool result = false; // double xTPPoint = 10; // double entry = GetEntry( mSymbol, POSITION_TYPE_BUY); // XOHCL c0 = GetCandle( mSymbol, mPeriod, 0); // double c0SelectedPrice = MathMin(c0.close, c0.low); c0SelectedPrice = MathMin(c0SelectedPrice, c0.open); // XOHCL c1 = GetCandle( mSymbol, mPeriod, 1); bool isC1Bullish = IsBullishCandle(c1); // XOHCL c2 = GetCandle( mSymbol, mPeriod, 2); bool isC2Bullish = IsBullishCandle(c2); // XOHCL c3 = GetCandle( mSymbol, mPeriod, 3); bool isC3Bullish = IsBullishCandle(c3); // double pivots[]; FillPivotPoints(pivots); XOHCLSupRes supRes = ExtractSupportAndResistance( 1, pivots, 15); X121MarketConditions mConditions = GetMarketConditions(1); X121MarketConditions mConditions2 = GetMarketConditions(2); // bool isMRBFastCrossedOverPVFL3 = // mConditions.xmrbInfo.fast > mConditions.xpvInfo.fl3 && mConditions2.xmrbInfo.fast <= mConditions2.xpvInfo.fl3 // ; // bool isMRBFastCrossedUnderPVFL3 = // mConditions.xmrbInfo.fast < mConditions.xpvInfo.fl3 && mConditions2.xmrbInfo.fast >= mConditions2.xpvInfo.fl3 // ; // bool isMRBFastCrossedWithPVFL3 = // isMRBFastCrossedOverPVFL3 || isMRBFastCrossedUnderPVFL3 // ; // bool isPeakHappens = // mConditions.xpvInfo.peak != mConditions2.xpvInfo.peak // ; // bool isHKBullishCandle = mConditions.xhkInfo.open < mConditions.xhkInfo.close; // // DEMA Vale ... double mDemaVale[]; double mDeamPeak[]; ArraySetAsSeries(mDemaVale, true); ArraySetAsSeries(mDeamPeak, true); ArrayCopy( mDemaVale, mXDEMAHelper.demaBuffer, 0, 5); bool isDemaVale = IsInVale( ArraySize(mDemaVale) - 1, mDemaVale); // Clean(mConditions.signal); // // X786 ... bool x786HasSignal = false; bool canCheckX786 = IsAllowdSignaller(X786); if (canCheckX786) { // x786HasSignal = // ( // isPeakHappens && mConditions.xpvInfo.isNewPeak && mConditions.xpvInfo.peak > mConditions2.xpvInfo.peak // ) // && // ( // mConditions.xmrbInfo.isFastOverSlow && ( // mConditions.xmrbInfo.isR1FastOverSlow && (mConditions.xmrbInfo.isR1FastOverSlow || mConditions.xmrbInfo.isR2FastOverSlow) // ) // ) // && // ( // mConditions.xcheInfo.longExit1 != EMPTY_VALUE && mConditions.xcheInfo.longExit2 != EMPTY_VALUE && mConditions2.xcheInfo.longExit1 != EMPTY_VALUE && mConditions2.xcheInfo.longExit2 != EMPTY_VALUE // ) // && // ( // mConditions.xhullInfo.isUpBullish && mConditions.xhullInfo.isDownBullish // ) // && // ( // c1.low > mConditions.xdemaInfo.dema && c2.low > mConditions.xdemaInfo.dema && c3.low > mConditions.xdemaInfo.dema // ) // && // ( // mConditions.xstrInfo.isTrendBullish // ) // ; // if (x786HasSignal) { // Add( ToString(X786), mConditions.signal.providers); // // double slPoint = 15; // double slPrice = PointToPrice( // mConditions.symbol, // slPoint); // double sl = entry - slPrice; // double tpPoint = xTPPoint; double tpPrice = PointToPrice( mConditions.symbol, tpPoint); double tp = entry + tpPrice; // mConditions.signal.r2r = 1; mConditions.signal.riskAmount = 0.01; mConditions.signal.mode = X_ORDER_MODE_MARKET; mConditions.signal.entry = entry; mConditions.signal.sl = 0; mConditions.signal.tp = tp; // mConditions.signal.ignoreSL = true; mConditions.signal.useRiskAmountAsVolume = true; } } // // X92 ... bool x92HasSignal = false; bool canCheckX92 = IsAllowdSignaller(X92); if (canCheckX92) { // x92HasSignal = // mConditions.xtrndInfo.isTrendDownBullish && mConditions.xtrndInfo.isL1TrendDownBullish && mConditions.xtrndInfo.isL2TrendDownBullish // ; // if (x92HasSignal) { // Add( ToString(X92), mConditions.signal.providers); // double tpPoint = xTPPoint; double tpPrice = PointToPrice( mConditions.symbol, tpPoint); double tp = entry + tpPrice; // double sl = 0; // mConditions.signal.sl = sl; mConditions.signal.tp = tp; mConditions.signal.r2r = 1.5; mConditions.signal.entry = entry; mConditions.signal.riskAmount = 0.01; mConditions.signal.mode = X_ORDER_MODE_MARKET; // mConditions.signal.ignoreSL = false; mConditions.signal.ignoreTP = false; mConditions.signal.calculateTP = false; mConditions.signal.useRiskAmountAsVolume = true; } } // // X110 ... bool x110HasSignal = false; bool canCheckX110 = IsAllowdSignaller(X110); if (canCheckX110) { // x110HasSignal = // isMRBFastCrossedWithPVFL3 && mConditions.xtmInfo.isBullish // ; // if (x110HasSignal) { // Add( ToString(X110), mConditions.signal.providers); // // double slPoint = 10; // double slPrice = PointToPrice( // mConditions.symbol, // slPoint); // double sl = entry + slPrice; // double tpPoint = xTPPoint; double tpPrice = PointToPrice( mConditions.symbol, tpPoint); double tp = entry + tpPrice; // mConditions.signal.r2r = 1; mConditions.signal.riskAmount = 0.005; mConditions.signal.mode = X_ORDER_MODE_MARKET; mConditions.signal.entry = entry; mConditions.signal.sl = 0; mConditions.signal.tp = tp; // mConditions.signal.ignoreSL = true; mConditions.signal.useRiskAmountAsVolume = true; } } // // X121 ... bool x121HasSignal = false; bool canCheckX121 = IsAllowdSignaller(X121); if (canCheckX121) { // x121HasSignal = // ( // ( // isC1Bullish && (isC2Bullish || isC3Bullish) // ) // && // c2.open > c3.open && c1.open > c2.open // ) // && // (mConditions.xpvInfo.fl3 == mConditions2.xpvInfo.fl3) // && // ( // c3.low < mConditions.xpvInfo.fl3 && c2.low >= mConditions.xpvInfo.fl3 && ( // c2.high >= mConditions.xpvInfo.fl1 // || // ( // c2.high < mConditions.xpvInfo.fl1 && c2.high > mConditions.xpvInfo.fl2 && c1.low < mConditions.xpvInfo.fl1 && c1.high > mConditions.xpvInfo.fl1 // ) // ) // && // c0SelectedPrice > mConditions.xpvInfo.fl1 // ) // ; // if (x121HasSignal) { // Add( ToString(X121), mConditions.signal.providers); // // double slPoint = 15; // double slPrice = PointToPrice( // mConditions.symbol, // slPoint); // double sl = entry - slPrice; // double tpPoint = xTPPoint; double tpPrice = PointToPrice( mConditions.symbol, tpPoint); double tp = entry + tpPrice; // mConditions.signal.r2r = 1; mConditions.signal.riskAmount = 0.01; mConditions.signal.mode = X_ORDER_MODE_MARKET; mConditions.signal.entry = entry; mConditions.signal.sl = 0; mConditions.signal.tp = tp; // mConditions.signal.ignoreSL = true; mConditions.signal.useRiskAmountAsVolume = true; } } // // X128 ... bool x128HasSignal = false; bool canCheckX128 = IsAllowdSignaller(X128); if (canCheckX128) { // x128HasSignal = // isPeakHappens && mConditions.xamaInfo.value > mConditions.xtmInfo.value // ; // if (x128HasSignal) { // Add( ToString(X128), mConditions.signal.providers); // // double slPoint = 15; // double slPrice = PointToPrice( // mConditions.symbol, // slPoint); // double sl = entry - slPrice; // double tpPoint = xTPPoint; double tpPrice = PointToPrice( mConditions.symbol, tpPoint); double tp = entry + tpPrice; // mConditions.signal.r2r = 1; mConditions.signal.riskAmount = 0.01; mConditions.signal.mode = X_ORDER_MODE_MARKET; mConditions.signal.entry = entry; mConditions.signal.sl = 0; mConditions.signal.tp = tp; // mConditions.signal.ignoreSL = true; mConditions.signal.useRiskAmountAsVolume = true; } } // result = // x786HasSignal // || // x92HasSignal // || // x110HasSignal // || // x121HasSignal // || // x128HasSignal // ; // if (result) { // conditions = mConditions; // conditions.supportResistances = supRes; conditions.momentumStep = mLastMomentumStep; // conditions.signal.symbol = mSymbol; conditions.signal.period = mPeriod; conditions.signal.type = POSITION_TYPE_BUY; // conditions.hasSignal = true; // bool drawVLine = false; if (drawVLine) { // ulong tick = MathRand() * 10000; // DrawVerticalLine( 0, ToString(tick), 0, iTime( mSymbol, mPeriod, 0), clrYellow); } } // return result; } // // Check has Short Signal on Each Strategies ... bool HasShortSignal(X121MarketConditions &conditions) { // bool result = false; // double xTPPoint = 10; // double entry = GetEntry( mSymbol, POSITION_TYPE_SELL); // XOHCL c0 = GetCandle( mSymbol, mPeriod, 0); // double c0SelectedPrice = MathMin(c0.close, c0.low); c0SelectedPrice = MathMin(c0SelectedPrice, c0.open); // XOHCL c1 = GetCandle( mSymbol, mPeriod, 1); bool isC1Bearish = IsBearishCandle(c1); // XOHCL c2 = GetCandle( mSymbol, mPeriod, 2); bool isC2Bearish = IsBearishCandle(c2); // XOHCL c3 = GetCandle( mSymbol, mPeriod, 3); bool isC3Bearish = IsBearishCandle(c3); // double pivots[]; FillPivotPoints(pivots); XOHCLSupRes supRes = ExtractSupportAndResistance( 1, pivots, 15); X121MarketConditions mConditions = GetMarketConditions(1); X121MarketConditions mConditions2 = GetMarketConditions(2); // bool isMRBSlowCrossedOverPVFL3 = // mConditions.xmrbInfo.slow > mConditions.xpvInfo.fl3 && mConditions2.xmrbInfo.slow <= mConditions2.xpvInfo.fl3 // ; // bool isMRBSlowCrossedUnderPVFL3 = // mConditions.xmrbInfo.slow < mConditions.xpvInfo.fl3 && mConditions2.xmrbInfo.slow >= mConditions2.xpvInfo.fl3 // ; // bool isMRBSlowCrossedWithPVFL3 = // isMRBSlowCrossedOverPVFL3 || isMRBSlowCrossedUnderPVFL3 // ; // bool isValeHappens = // mConditions.xpvInfo.vale != mConditions2.xpvInfo.vale // ; // Clean(mConditions.signal); // // X786 ... bool x786HasSignal = false; bool canCheckX786 = IsAllowdSignaller(X786); if (canCheckX786) { // x786HasSignal = // ( // isValeHappens && mConditions.xpvInfo.isNewVale && mConditions.xpvInfo.vale < mConditions2.xpvInfo.vale // ) // && // ( // mConditions.xmrbInfo.isFastUnderSlow && ( // mConditions.xmrbInfo.isR1FastUnderSlow && (mConditions.xmrbInfo.isR1FastUnderSlow || mConditions.xmrbInfo.isR2FastUnderSlow) // ) // ) // && // ( // mConditions.xcheInfo.shortExit1 != EMPTY_VALUE && mConditions.xcheInfo.shortExit2 != EMPTY_VALUE && mConditions2.xcheInfo.shortExit1 != EMPTY_VALUE && mConditions2.xcheInfo.shortExit2 != EMPTY_VALUE // ) // && // ( // mConditions.xhullInfo.isUpBearish && mConditions.xhullInfo.isDownBearish // ) // && // ( // c1.high < mConditions.xdemaInfo.dema && c2.high < mConditions.xdemaInfo.dema && c3.high < mConditions.xdemaInfo.dema // ) // && // ( // mConditions.xstrInfo.isTrendBearish // ) // ; // if (x786HasSignal) { // Add( ToString(X786), mConditions.signal.providers); // // double slPoint = 15; // double slPrice = PointToPrice( // mConditions.symbol, // slPoint); // double sl = entry - slPrice; // double tpPoint = xTPPoint; double tpPrice = PointToPrice( mConditions.symbol, tpPoint); double tp = entry - tpPrice; // mConditions.signal.r2r = 1; mConditions.signal.riskAmount = 0.01; mConditions.signal.mode = X_ORDER_MODE_MARKET; mConditions.signal.entry = entry; mConditions.signal.sl = 0; mConditions.signal.tp = tp; // mConditions.signal.ignoreSL = true; mConditions.signal.useRiskAmountAsVolume = true; } } // // X92 ... bool x92HasSignal = false; bool canCheckX92 = IsAllowdSignaller(X92); if (canCheckX92) { // x92HasSignal = // mConditions.xtrndInfo.isTrendUpBearish && mConditions.xtrndInfo.isL1TrendUpBearish && mConditions.xtrndInfo.isL2TrendUpBearish && false // ; // if (x92HasSignal) { // Add( ToString(X92), mConditions.signal.providers); // double tpPoint = xTPPoint; double tpPrice = PointToPrice( mConditions.symbol, tpPoint); double tp = entry - tpPrice; // mConditions.signal.sl = 0; mConditions.signal.tp = tp; mConditions.signal.r2r = 1.5; mConditions.signal.entry = entry; mConditions.signal.riskAmount = 0.01; mConditions.signal.mode = X_ORDER_MODE_MARKET; // mConditions.signal.ignoreSL = false; mConditions.signal.ignoreTP = false; mConditions.signal.calculateTP = false; mConditions.signal.useRiskAmountAsVolume = true; } } // // X110 ... bool x110HasSignal = false; bool canCheckX110 = IsAllowdSignaller(X110); if (canCheckX110) { // x110HasSignal = // isMRBSlowCrossedWithPVFL3 && mConditions.xtmInfo.isBearish // ; // if (x110HasSignal) { // Add( ToString(X110), mConditions.signal.providers); // // double slPoint = 15; // double slPrice = PointToPrice( // mConditions.symbol, // slPoint); // double sl = entry + slPrice; // double tpPoint = xTPPoint; double tpPrice = PointToPrice( mConditions.symbol, tpPoint); double tp = entry - tpPrice; // mConditions.signal.r2r = 1; mConditions.signal.riskAmount = 0.005; mConditions.signal.mode = X_ORDER_MODE_MARKET; mConditions.signal.entry = entry; mConditions.signal.sl = 0; mConditions.signal.tp = tp; // mConditions.signal.ignoreSL = true; mConditions.signal.useRiskAmountAsVolume = true; } } // // X121 ... bool x121HasSignal = false; bool canCheckX121 = IsAllowdSignaller(X121); if (canCheckX121) { // x121HasSignal = // ( // ( // isC1Bearish && (isC2Bearish || isC3Bearish) // ) // && // c2.open < c3.open && c1.open < c2.open // ) // && // (mConditions.xpvInfo.fl3 == mConditions2.xpvInfo.fl3) // && // ( // c3.high > mConditions.xpvInfo.fl1 && c2.low <= mConditions.xpvInfo.fl1 && ( // c2.low <= mConditions.xpvInfo.fl3 // || // ( // c2.low > mConditions.xpvInfo.fl3 && c2.low < mConditions.xpvInfo.fl2 && c1.high > mConditions.xpvInfo.fl3 && c1.low < mConditions.xpvInfo.fl3 // ) // ) // && // c0SelectedPrice < mConditions.xpvInfo.fl3 // ) // ; // if (x121HasSignal) { // Add( ToString(X121), mConditions.signal.providers); // // double slPoint = 15; // double slPrice = PointToPrice( // mConditions.symbol, // slPoint); // double sl = entry - slPrice; // double tpPoint = xTPPoint; double tpPrice = PointToPrice( mConditions.symbol, tpPoint); double tp = entry - tpPrice; // mConditions.signal.r2r = 1; mConditions.signal.riskAmount = 0.01; mConditions.signal.mode = X_ORDER_MODE_MARKET; mConditions.signal.entry = entry; mConditions.signal.sl = 0; mConditions.signal.tp = tp; // mConditions.signal.ignoreSL = true; mConditions.signal.useRiskAmountAsVolume = true; } } // // X128 ... bool x128HasSignal = false; bool canCheckX128 = IsAllowdSignaller(X128); if (canCheckX128) { // x128HasSignal = // isValeHappens && mConditions.xamaInfo.value < mConditions.xtmInfo.value // ; // if (x128HasSignal) { // Add( ToString(X128), mConditions.signal.providers); // // double slPoint = 15; // double slPrice = PointToPrice( // mConditions.symbol, // slPoint); // double sl = entry + slPrice; // double tpPoint = xTPPoint; double tpPrice = PointToPrice( mConditions.symbol, tpPoint); double tp = entry - tpPrice; // mConditions.signal.r2r = 1; mConditions.signal.riskAmount = 0.005; mConditions.signal.mode = X_ORDER_MODE_MARKET; mConditions.signal.entry = entry; mConditions.signal.sl = 0; mConditions.signal.tp = tp; // mConditions.signal.ignoreSL = true; mConditions.signal.useRiskAmountAsVolume = true; } } // result = // x786HasSignal // || // x92HasSignal // || // x110HasSignal // || // x121HasSignal // || // x128HasSignal // ; // if (result) { // conditions = mConditions; // conditions.supportResistances = supRes; conditions.momentumStep = mLastMomentumStep; // conditions.signal.symbol = mSymbol; conditions.signal.period = mPeriod; conditions.signal.type = POSITION_TYPE_SELL; // conditions.hasSignal = true; } // return result; } }; // // START Definitions ... // // // Model Signal Providers Definitions ... struct X121SignalProvider { // // Provider use Which Symbol ... string symbol; // // Allowed Providers ... string providers[]; // // Provider use Which Time Frame ... ENUM_TIMEFRAMES period; // // Risk Amount Per Trades Related to Time Frames ... // Percent of Available Balance ... double riskAmount; // // Provider ... XSCX121Provider *provider; }; // // END Definitions ... // // // START Usefull Functions ... // // // Add Specific Provider to List ... void Add( X121SignalProvider &item, // item want to add X121SignalProvider &buffer[] // Destination buffer ) { // ArrayResize( buffer, ArraySize(buffer) + 1); // buffer[ArraySize(buffer) - 1] = item; } // // Generate Identifier Tag ... string GenerateTag(X121SignalProvider &descriptor) { // string result = ""; // result = descriptor.symbol + "," + ToString(descriptor.period); // return result; } // // Converts a Signal provider to String ... string ToString(ENUM_X121_SIGNAL_PROVIDERS provider) { return EnumToString(provider); } // // convert an String to Signal provider ... ENUM_X121_SIGNAL_PROVIDERS ToProvider(string provider) { // ENUM_X121_SIGNAL_PROVIDERS result = NONE; // if (ToString(NONE) == provider) { result = NONE; } else if (ToString(X786) == provider) { result = X786; } else if (ToString(X92) == provider) { result = X92; } else if (ToString(X110) == provider) { result = X110; } else if (ToString(X121) == provider) { result = X121; } else if (ToString(X128) == provider) { result = X128; } // return result; } // // Extract Provider Type from Signal Commnet ... ENUM_X121_SIGNAL_PROVIDERS ExtractPositionProvider(XPosition &position) { // ENUM_X121_SIGNAL_PROVIDERS result = NONE; // string providerStr = ExtractString( position.comment, XProviderToken + "(", ")"); if (StringLen(providerStr) <= 0) { return result; } // result = ToProvider(providerStr); // return result; } // // List All Available Providers ... void GetAllProviders( ENUM_X121_SIGNAL_PROVIDERS &result[] // Hold Result ... ) { // Clean(result); // // X786 ... ArrayResize( result, ArraySize(result) + 1); result[ArraySize(result) - 1] = X786; // // X92 ... ArrayResize( result, ArraySize(result) + 1); result[ArraySize(result) - 1] = X92; // // X110 ... ArrayResize( result, ArraySize(result) + 1); result[ArraySize(result) - 1] = X110; // // X121 ... ArrayResize( result, ArraySize(result) + 1); result[ArraySize(result) - 1] = X121; // // X128 ... ArrayResize( result, ArraySize(result) + 1); result[ArraySize(result) - 1] = X128; } // // Lis All Available Providers ... void GetAllProviders( string &result[] // Hold Result ... ) { // Clean(result); // ENUM_X121_SIGNAL_PROVIDERS providers[]; GetAllProviders(providers); int providersCount = ArraySize(providers); if (providersCount <= 0) { return; } // for (int i = 0; i < providersCount; i++) { // ENUM_X121_SIGNAL_PROVIDERS iProvider = providers[i]; // Add( ToString(iProvider), result); } } // // END Usefull Functions ... //