From b9a53670ee53f3540f05e9464d2af884d1000023 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Mon, 6 Oct 2025 22:39:33 +0330 Subject: [PATCH] last works on Position ... --- Classes/x-saherelm.x-cobject.class.mq5 | 223 +++- .../x-saherelm.x-position.drawer.class.mq5 | 100 +- Experts/x-saherelm.xfima.backtester.ea.mq5 | 16 +- .../x-saherelm.xfima.signaller.class.mq5 | 1061 +++++++++-------- 4 files changed, 833 insertions(+), 567 deletions(-) diff --git a/Classes/x-saherelm.x-cobject.class.mq5 b/Classes/x-saherelm.x-cobject.class.mq5 index eeeeab03..ba1c8f0e 100644 --- a/Classes/x-saherelm.x-cobject.class.mq5 +++ b/Classes/x-saherelm.x-cobject.class.mq5 @@ -522,8 +522,9 @@ bool XUpdatePosition( // // Global Chart Objects ... -// -// Bas Chart Object ... +/** + * Base Chart Object ... + **/ class XCBaseObject : public CChartObject { // @@ -591,8 +592,9 @@ class XCBaseObject : public CChartObject // }; -// -// Bar Arrow Object ... +/** + * Bar Arrow Object ... + **/ class XCBarArrowObject : public XCBaseObject { // @@ -749,8 +751,9 @@ class XCBarArrowObject : public XCBaseObject // }; -// -// Signal ... +/** + * Signal Object ... + **/ class XCSignalObject : public XCBaseObject { // @@ -1147,8 +1150,9 @@ class XCSignalObject : public XCBaseObject CArrayObj mTargetTrends; }; -// -// XRR Object ... +/** + * XRR Object ... + **/ class XCRRObject : public XCSignalObject { // @@ -1229,8 +1233,9 @@ class XCRRObject : public XCSignalObject } }; -// -// OHCL, Bar Object ... +/** + * XOHCL Object ... + **/ class XCOHCLObject : public XCBaseObject { // @@ -1575,8 +1580,9 @@ class XCOHCLObject : public XCBaseObject CChartObjectRectangle mLowShadowRect; }; -// -// Box Object ...k +/** + * Box Object ... + **/ class XCBoxObject : public XCBaseObject { // @@ -1786,16 +1792,35 @@ class XCBoxObject : public XCBaseObject CChartObjectRectangle mRect; }; +/** + * Position Object ... + **/ class XCPositionObject : public XCBaseObject { // // Public ... public: // + XPOIStyle riskStyle; // Risk Box Style ... + color inProfitColor; // In Profit Price Box Color ... + color inDrawdownColor; // In Drawdown Price Box Color ... + XPOIStyle rewardStyle; // Reward Box Style ... + ENUM_LINE_STYLE priceStyle; // Price Box Style ... // // Creators ... + /** + * Create a Position Object by Signal reference ... + * + * @param chart_id: Long, Specified Chart ID ... + * @param window: Integer, Specified Chart Window ID ... + * @param signal: XSignal, reference to Provided Signal ... + * @param magic: ulong, Specified Position Magic Number ... + * @param ticket: ulong, Specified Position Ticket ... + * + * @return ( bool ) + */ bool Create( long chart_id, int window, @@ -1883,14 +1908,22 @@ class XCPositionObject : public XCBaseObject * Update Position if Belongs to ... * * @param position: XPosition, reference to Specified Position ... + * @param barIndex: int, Specified Bar Index ... * * @return ( bool ) */ - bool Update(XPosition &position) + bool Update( + XPosition &position, + int barIndex = 0 // + ) { // bool result = false; + // + // Normalize ... + barIndex = NormalizeInt(barIndex, 0); + // // Validate ... result = @@ -1905,14 +1938,31 @@ class XCPositionObject : public XCBaseObject return result; } + // + datetime _toTime = GetBarTime( + position.symbol, + position.period, + barIndex // + ); + // // Validate Chart Info ... - result = XUpdatePosition(position); + result = UpdatePosition( + position, + _toTime // + ); // return result; } + /** + * Update Position if Belongs to ... + * + * @param barIndex: int, Specified Bar Index ... + * + * @return ( bool ) + */ bool Update(int barIndex = 0) { // @@ -1939,7 +1989,10 @@ class XCPositionObject : public XCBaseObject } // - result = Update(mPosition); + result = Update( + mPosition, + barIndex // + ); // return result; @@ -2056,6 +2109,66 @@ class XCPositionObject : public XCBaseObject // // Stylers ... + /** + * Apply Styles based on Current Style Configurations ... + */ + void ApplyStyle() + { + // + bool has = HasPosition(); + if (!has) + { + return; + } + + // + // Risk Style ... + mRiskBoxObj.BoxColor(riskStyle.clr); + mRiskBoxObj.BoxFill(riskStyle.fill); + mRiskBoxObj.BoxStyle(riskStyle.style); + mRiskBoxObj.BoxWidth(riskStyle.width); + + // + // Reward Style ... + mRewardBoxObj.BoxColor(rewardStyle.clr); + mRewardBoxObj.BoxFill(rewardStyle.fill); + mRewardBoxObj.BoxStyle(rewardStyle.style); + mRewardBoxObj.BoxWidth(rewardStyle.width); + + // + // Check Position in Profit ... + bool isInProfit = mPosition.profit > 0; + XPOIStyle _priceStyle; + if (isInProfit) + { + // + _priceStyle = rewardStyle; + _priceStyle.clr = inProfitColor; + } + else + { + // + _priceStyle = riskStyle; + _priceStyle.clr = inDrawdownColor; + } + + // + // Apply Profit Based Styles ... + _priceStyle.fill = true; + _priceStyle.style = priceStyle; + + // + // Price Style .. + mPriceBoxObj.BoxColor(_priceStyle.clr); + mPriceBoxObj.BoxFill(_priceStyle.fill); + mPriceBoxObj.BoxStyle(_priceStyle.style); + mPriceBoxObj.BoxWidth(_priceStyle.width); + + // + // Cleanup Resources ... + _priceStyle.Clean(); + } + // void ApplyStyle( XPOIStyle &bullishStyle, @@ -2096,24 +2209,24 @@ class XCPositionObject : public XCBaseObject if (mPriceBox.IsValid()) { // - XPOIStyle priceStyle; + XPOIStyle _priceStyle; if (mPriceBox.IsBullish()) { - priceStyle = bullishStyle; + _priceStyle = bullishStyle; } else { - priceStyle = bearishStyle; + _priceStyle = bearishStyle; } // - mPriceBoxObj.BoxColor(priceStyle.clr); - mPriceBoxObj.BoxFill(priceStyle.fill); - mPriceBoxObj.BoxStyle(priceStyle.style); - mPriceBoxObj.BoxWidth(priceStyle.width); + mPriceBoxObj.BoxColor(_priceStyle.clr); + mPriceBoxObj.BoxFill(_priceStyle.fill); + mPriceBoxObj.BoxStyle(_priceStyle.style); + mPriceBoxObj.BoxWidth(_priceStyle.width); // - priceStyle.Clean(); + _priceStyle.Clean(); } } @@ -2129,11 +2242,18 @@ class XCPositionObject : public XCBaseObject } // - bool UpdatePosition(XPosition &_position) + bool UpdatePosition( + XPosition &_position, + datetime _toTime = NULL // + ) { // bool result = false; + // + // Normalize ... + _toTime = NormalizeTime(_toTime); + // // Validate ... result = _position.IsValid() && @@ -2148,18 +2268,22 @@ class XCPositionObject : public XCBaseObject // mPosition = _position; - result = UpdateZones(); + result = UpdateZones(_toTime); // return result; } // - bool UpdateZones() + bool UpdateZones(datetime _toTime = NULL) { // bool result = false; + // + // Normalize ... + _toTime = NormalizeTime(_toTime); + // // Validate ... result = HasPosition(); @@ -2175,7 +2299,12 @@ class XCPositionObject : public XCBaseObject // datetime iAt = mPosition.openAt; datetime iFrom = mPosition.openAt; - datetime iTo = iFrom + (PeriodSeconds(iPeriod) * 3); + + // + datetime _defaultToTime = iFrom + (PeriodSeconds(iPeriod) * 3); + datetime iTo = _toTime <= _defaultToTime + ? _defaultToTime + : _toTime; // double iTP = mPosition.tp; @@ -2333,9 +2462,14 @@ class XCPositionObject : public XCBaseObject isRiskCreated && isPriceCreated && isRewardCreated; - if (!result) + if (result) { + // ObjName(iName); + + // + // Apply Styles ... + ApplyStyle(); } // @@ -3585,4 +3719,37 @@ void RemoveObjects( ChartRedraw(); } +// +// Color Manipulation Functions ... + +/** + * Apply Alph to Color ... + * + * @param _clr: Specified Color ... + * @param _alpha: Specified Alpha to Apply ... + * + * @return ( color ) + */ +color ApplyAlpha( + color _clr, + uchar _alpha = 255 // +) +{ + // + color result = _clr; + + // + // Normalize ... + _alpha = (uchar)NormalizeInt(_alpha, 0, 255); + + // + uchar alpha = _alpha / 255; + + // + uint uintColor = ColorToARGB(_clr, alpha); + result = (color)uintColor; + + // + return result; +} // \ No newline at end of file diff --git a/Classes/x-saherelm.x-position.drawer.class.mq5 b/Classes/x-saherelm.x-position.drawer.class.mq5 index c63a7136..0ceddd3f 100644 --- a/Classes/x-saherelm.x-position.drawer.class.mq5 +++ b/Classes/x-saherelm.x-position.drawer.class.mq5 @@ -40,11 +40,16 @@ class XCPositionDrawer : public XCBase public: // // Props ... - int window; - ulong chartID; - XCTrade *trader; - CArrayObj positionObjects; - CArrayObj finalizedObjects; + int window; // Window ID of Chart ... + ulong chartID; // Chart ID ... + XCTrade *trader; // XCTrade Instance ... + XPOIStyle riskStyle; // Risk Box Style ... + color inProfitColor; // In Profit Price Box Color ... + color inDrawdownColor; // In Drawdown Price Box Color ... + ENUM_LINE_STYLE priceStyle; // Price Box Style ... + XPOIStyle rewardStyle; // Reward Box Style ... + CArrayObj positionObjects; // Drawn Positions Object Instances Collection ... + CArrayObj finalizedObjects; // Finalized Drawn Positions Object Instances Collection ... // // Constructor ... @@ -72,6 +77,13 @@ class XCPositionDrawer : public XCBase // // Tools ... + /** + * Initialize Class Instance ... + * + * @param _trader: XCTrade, reference Pointer to Trader Instance Class ... + * @param _chartID: ulong, Specified Chart ID ... + * @param _window: int, Specified Chart Window ID ... + */ void Init( XCTrade *_trader, ulong _chartID = 0, @@ -93,12 +105,48 @@ class XCPositionDrawer : public XCBase trader = _trader; window = _window; chartID = _chartID; + + // + // Prepare Default Styles ... + + // + // Risk Style ... + riskStyle.width = 1; + riskStyle.fill = false; + riskStyle.clr = clrRed; + riskStyle.style = STYLE_DASH; + + // + // Reward Style ... + rewardStyle.width = 1; + rewardStyle.fill = false; + rewardStyle.clr = clrLime; + rewardStyle.style = STYLE_DASH; + + // + // Price Style ... + priceStyle = STYLE_SOLID; + inProfitColor = ApplyAlpha(clrAqua, 100); + inDrawdownColor = ApplyAlpha(clrMagenta, 100); } + /** + * Destroy Instance ... + */ void Destroy() { + // + riskStyle.Clean(); + rewardStyle.Clean(); + // positionObjects + // finalizedObjects } + /** + * Validate Instance ... + * + * @return ( bool ) + */ bool IsValid() { // @@ -112,6 +160,11 @@ class XCPositionDrawer : public XCBase return result; } + /** + * Update Positions ... + * + * @param barIndex: int, Specified Bar Index ... + */ void Update(int barIndex = 0) { // @@ -138,6 +191,7 @@ class XCPositionDrawer : public XCBase has = IsValidSize(drawingsCount); if (has) { + // for (int i = 0; i < positionsCount; i++) { // @@ -148,7 +202,9 @@ class XCPositionDrawer : public XCBase has = ((XCPositionObject *)positionObjects.At(j)).IsBelong(positions[i]); if (has) { - ((XCPositionObject *)positionObjects.At(j)).Update(positions[i]); + // + // Update Position Object ... + has = ((XCPositionObject *)positionObjects.At(j)).Update(positions[i]); } } } @@ -174,7 +230,7 @@ class XCPositionDrawer : public XCBase { // // Manully Update Position ... - ((XCPositionObject *)positionObjects.At(i)).Update(barIndex); + has = ((XCPositionObject *)positionObjects.At(i)).Update(barIndex); } } @@ -230,12 +286,26 @@ class XCPositionDrawer : public XCBase if (has) { // - XCPositionObject *iObj; + XCPositionObject *iObj = new XCPositionObject(); has = iObj.Create( chartID, window, iPosition // ); + if (has) + { + // + // Set Stylers to Position ... + iObj.riskStyle = riskStyle; + iObj.priceStyle = priceStyle; + iObj.rewardStyle = rewardStyle; + iObj.inProfitColor = inProfitColor; + iObj.inDrawdownColor = inDrawdownColor; + + // + // Add to Collection ... + positionObjects.Add(iObj); + } } // @@ -284,7 +354,12 @@ class XCPositionDrawer : public XCBase protected: // - // + /** + * Finalize Specified Position ... + * Remove it From Position Objects and add it to Finalized Objects Cllection ... + * + * @param ticket: ulong, Specified Position Ticket ... + */ void Finalize(ulong ticket) { // @@ -301,6 +376,13 @@ class XCPositionDrawer : public XCBase finalizedObjects.Add(iObj); } + /** + * Find Specified Position Index ... + * + * @param ticket: ulong, Specified Position Ticket ... + * + * @return ( int ) + */ int FindIndex(ulong ticket) { // diff --git a/Experts/x-saherelm.xfima.backtester.ea.mq5 b/Experts/x-saherelm.xfima.backtester.ea.mq5 index 75512225..47aa7402 100644 --- a/Experts/x-saherelm.xfima.backtester.ea.mq5 +++ b/Experts/x-saherelm.xfima.backtester.ea.mq5 @@ -642,14 +642,14 @@ void DestroyTimer() */ void OnSignalTriggered(XSignal &signal) { - // - // Draw Signal on Chart ... - XCSignalObject *iSignalObj; - bool has = fima1Signaller.poiDrawer.DrawSignal( - signal, - iSignalObj, - 7 // - ); + // // + // // Draw Signal on Chart ... + // XCSignalObject *iSignalObj; + // bool has = fima1Signaller.poiDrawer.DrawSignal( + // signal, + // iSignalObj, + // 7 // + // ); // eaExpert.HandleOnSignalTriggered(signal); diff --git a/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 b/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 index c5f834fb..9ac4a7fe 100644 --- a/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 +++ b/XFIMAEA/Classes/x-saherelm.xfima.signaller.class.mq5 @@ -579,519 +579,6 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller // // Use Default Config ... ); - if (has) - { - // - // Draw Bar Patterns Analysis ... - - // - XOHCL patternBar; - XPivot patternPivot; - XBoxZone patternBox; - ENUM_X_BAR_PATTERN pattern; - ENUM_X_DIRECTION patternDir; - - // - // Support and Resistance ... - - // - // Support ... - isBearish = false; - isBullish = iBarAnalysis.IsSupport(); - has = isBullish; - if (has) - { - // - pattern = X_BAR_PATTERN_SUPPORT; - patternDir = X_DIRECTION_BULLISH; - has = iBarAnalysis.GetPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - if (has) - { - // - DrawPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - } - } - - // - // Resistance ... - isBullish = false; - isBearish = iBarAnalysis.IsResistance(); - has = isBearish; - if (has) - { - // - pattern = X_BAR_PATTERN_SUPPORT; - patternDir = X_DIRECTION_BEARISH; - has = iBarAnalysis.GetPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - if (has) - { - // - DrawPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - } - } - - // - // PV: High and Low ... - - // - // Low ... - isBearish = false; - isBullish = iBarAnalysis.IsLow(); - has = isBullish; - if (has) - { - // - pattern = X_BAR_PATTERN_LOW; - patternDir = X_DIRECTION_BULLISH; - has = iBarAnalysis.GetPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - if (has) - { - // - DrawPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - } - } - - // - // High ... - isBullish = false; - isBearish = iBarAnalysis.IsHigh(); - has = isBearish; - if (has) - { - // - pattern = X_BAR_PATTERN_HIGH; - patternDir = X_DIRECTION_BEARISH; - has = iBarAnalysis.GetPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - if (has) - { - // - DrawPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - } - } - - // - // OB ... - isBullish = iBarAnalysis.IsOB(X_DIRECTION_BULLISH); - isBearish = iBarAnalysis.IsOB(X_DIRECTION_BEARISH); - has = isBullish || isBearish; - if (has) - { - // - pattern = X_BAR_PATTERN_OB; - patternDir = - isBullish - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - has = iBarAnalysis.GetPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - if (has) - { - // - DrawPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - } - } - - // - // FVG ... - isBullish = iBarAnalysis.IsFVG(X_DIRECTION_BULLISH); - isBearish = iBarAnalysis.IsFVG(X_DIRECTION_BEARISH); - has = isBullish || isBearish; - if (has) - { - // - pattern = X_BAR_PATTERN_FVG; - patternDir = - isBullish - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - has = iBarAnalysis.GetPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - if (has) - { - // - DrawPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - } - } - - // - // Momentum ... - isBullish = iBarAnalysis.IsMomentum(X_DIRECTION_BULLISH); - isBearish = iBarAnalysis.IsMomentum(X_DIRECTION_BEARISH); - has = isBullish || isBearish; - if (has) - { - // - pattern = X_BAR_PATTERN_MOMENTUM; - patternDir = - isBullish - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - has = iBarAnalysis.GetPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - if (has) - { - // - DrawPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - } - } - - // - // Engulfed ... - isBullish = iBarAnalysis.IsEngulfed(X_DIRECTION_BULLISH); - isBearish = iBarAnalysis.IsEngulfed(X_DIRECTION_BEARISH); - has = isBullish || isBearish; - if (has) - { - // - pattern = X_BAR_PATTERN_ENGULFED; - patternDir = - isBullish - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - has = iBarAnalysis.GetPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - if (has) - { - // - DrawPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - } - } - - // - // Pinned ... - isBullish = iBarAnalysis.IsPinned(X_DIRECTION_BULLISH); - isBearish = iBarAnalysis.IsPinned(X_DIRECTION_BEARISH); - has = isBullish || isBearish; - if (has) - { - // - pattern = X_BAR_PATTERN_PINNED; - patternDir = - isBullish - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - has = iBarAnalysis.GetPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - if (has) - { - // - DrawPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - } - } - - // - // TrueGaped ... - isBullish = iBarAnalysis.IsTrueGaped(X_DIRECTION_BULLISH); - isBearish = iBarAnalysis.IsTrueGaped(X_DIRECTION_BEARISH); - has = isBullish || isBearish; - if (has) - { - // - pattern = X_BAR_PATTERN_TRUE_GAPED; - patternDir = - isBullish - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - has = iBarAnalysis.GetPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - if (has) - { - // - DrawPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - } - } - - // - // Star ... - isBullish = iBarAnalysis.IsStar(X_DIRECTION_BULLISH); - isBearish = iBarAnalysis.IsStar(X_DIRECTION_BEARISH); - has = isBullish || isBearish; - if (has) - { - // - pattern = X_BAR_PATTERN_STAR; - patternDir = - isBullish - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - has = iBarAnalysis.GetPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - if (has) - { - // - DrawPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - } - } - - // - // Piercing ... - isBullish = iBarAnalysis.IsPiercing(X_DIRECTION_BULLISH); - isBearish = iBarAnalysis.IsPiercing(X_DIRECTION_BEARISH); - has = isBullish || isBearish; - if (has) - { - // - pattern = X_BAR_PATTERN_PIERCING; - patternDir = - isBullish - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - has = iBarAnalysis.GetPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - if (has) - { - // - DrawPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - } - } - - // - // Rising ... - isBullish = iBarAnalysis.IsRising(X_DIRECTION_BULLISH); - isBearish = iBarAnalysis.IsRising(X_DIRECTION_BEARISH); - has = isBullish || isBearish; - if (has) - { - // - pattern = X_BAR_PATTERN_RISING; - patternDir = - isBullish - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - has = iBarAnalysis.GetPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - if (has) - { - // - DrawPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - } - } - - // - // Flag ... - isBullish = iBarAnalysis.IsFlag(X_DIRECTION_BULLISH); - isBearish = iBarAnalysis.IsFlag(X_DIRECTION_BEARISH); - has = isBullish || isBearish; - if (has) - { - // - pattern = X_BAR_PATTERN_FLAG; - patternDir = - isBullish - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - has = iBarAnalysis.GetPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - if (has) - { - // - DrawPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - } - } - - // - // SignalKey ... - isBullish = iBarAnalysis.IsSignalKey(X_DIRECTION_BULLISH); - isBearish = iBarAnalysis.IsSignalKey(X_DIRECTION_BEARISH); - has = isBullish || isBearish; - if (has) - { - // - pattern = X_BAR_PATTERN_SIGNALKEY; - patternDir = - isBullish - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - has = iBarAnalysis.GetPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - if (has) - { - // - DrawPattern( - patternBar, - patternPivot, - patternBox, - pattern, - patternDir // - ); - } - } - - // - // Cleanup Resources ... - patternBar.Clean(); - patternBox.Clean(); - patternPivot.Clean(); - } - - // - if (has) - { - Print("Draw Zones ..."); - } // // Disable Signallers ... @@ -1101,14 +588,14 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller // // Strategy 1 ... // Works on Support or Resistances Areas ... - // has = Strategy1HasSignal( - // iBar, - // iZone, - // iTargets, - // iDir, - // iFIMAConditions, - // iStructure // - // ); + has = Strategy1HasSignal( + iBar, + iZone, + iTargets, + iDir, + iFIMAConditions, + iStructure // + ); // // Strategy 2 ... @@ -1671,7 +1158,15 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller // // Drawer Functions ... - // + /** + * Draw Specified Pattern info ... + * + * @param _bar: XOHCL, reference to Pattern's Bar ... + * @param _pivot: XPivot, reference to Pattern's Pivot ... + * @param _zone: XBoxZone, reference to Pattern's Zone ... + * @param _pattern: ENUM_X_BAR_PATTERN, Specified Bar Pattern ... + * @param _patternDir: ENUM_X_DIRECTION, Specified Bar Pattern's Direction ... + */ void DrawPattern( XOHCL &_bar, XPivot &_pivot, @@ -1795,6 +1290,528 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller } } + /** + * Draw Specified Bar Pattern Analysis ... + * + * @param barAnalysis: XPatternAnalysis, reference to Specified Bar Pattern Analysis ... + */ + void DrawBarPatternAnalysis(XPatternAnalysis &barAnalysis) + { + // + bool has = barAnalysis.IsValid(); + if (!has) + { + return; + } + + // + // Draw Bar Patterns Analysis ... + + // + bool isBullish; + bool isBearish; + XOHCL patternBar; + XPivot patternPivot; + XBoxZone patternBox; + ENUM_X_BAR_PATTERN pattern; + ENUM_X_DIRECTION patternDir; + + // + // Support and Resistance ... + + // + // Support ... + isBearish = false; + isBullish = barAnalysis.IsSupport(); + has = isBullish; + if (has) + { + // + pattern = X_BAR_PATTERN_SUPPORT; + patternDir = X_DIRECTION_BULLISH; + has = barAnalysis.GetPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + if (has) + { + // + DrawPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + } + } + + // + // Resistance ... + isBullish = false; + isBearish = barAnalysis.IsResistance(); + has = isBearish; + if (has) + { + // + pattern = X_BAR_PATTERN_SUPPORT; + patternDir = X_DIRECTION_BEARISH; + has = barAnalysis.GetPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + if (has) + { + // + DrawPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + } + } + + // + // PV: High and Low ... + + // + // Low ... + isBearish = false; + isBullish = barAnalysis.IsLow(); + has = isBullish; + if (has) + { + // + pattern = X_BAR_PATTERN_LOW; + patternDir = X_DIRECTION_BULLISH; + has = barAnalysis.GetPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + if (has) + { + // + DrawPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + } + } + + // + // High ... + isBullish = false; + isBearish = barAnalysis.IsHigh(); + has = isBearish; + if (has) + { + // + pattern = X_BAR_PATTERN_HIGH; + patternDir = X_DIRECTION_BEARISH; + has = barAnalysis.GetPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + if (has) + { + // + DrawPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + } + } + + // + // OB ... + isBullish = barAnalysis.IsOB(X_DIRECTION_BULLISH); + isBearish = barAnalysis.IsOB(X_DIRECTION_BEARISH); + has = isBullish || isBearish; + if (has) + { + // + pattern = X_BAR_PATTERN_OB; + patternDir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + has = barAnalysis.GetPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + if (has) + { + // + DrawPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + } + } + + // + // FVG ... + isBullish = barAnalysis.IsFVG(X_DIRECTION_BULLISH); + isBearish = barAnalysis.IsFVG(X_DIRECTION_BEARISH); + has = isBullish || isBearish; + if (has) + { + // + pattern = X_BAR_PATTERN_FVG; + patternDir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + has = barAnalysis.GetPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + if (has) + { + // + DrawPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + } + } + + // + // Momentum ... + isBullish = barAnalysis.IsMomentum(X_DIRECTION_BULLISH); + isBearish = barAnalysis.IsMomentum(X_DIRECTION_BEARISH); + has = isBullish || isBearish; + if (has) + { + // + pattern = X_BAR_PATTERN_MOMENTUM; + patternDir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + has = barAnalysis.GetPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + if (has) + { + // + DrawPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + } + } + + // + // Engulfed ... + isBullish = barAnalysis.IsEngulfed(X_DIRECTION_BULLISH); + isBearish = barAnalysis.IsEngulfed(X_DIRECTION_BEARISH); + has = isBullish || isBearish; + if (has) + { + // + pattern = X_BAR_PATTERN_ENGULFED; + patternDir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + has = barAnalysis.GetPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + if (has) + { + // + DrawPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + } + } + + // + // Pinned ... + isBullish = barAnalysis.IsPinned(X_DIRECTION_BULLISH); + isBearish = barAnalysis.IsPinned(X_DIRECTION_BEARISH); + has = isBullish || isBearish; + if (has) + { + // + pattern = X_BAR_PATTERN_PINNED; + patternDir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + has = barAnalysis.GetPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + if (has) + { + // + DrawPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + } + } + + // + // TrueGaped ... + isBullish = barAnalysis.IsTrueGaped(X_DIRECTION_BULLISH); + isBearish = barAnalysis.IsTrueGaped(X_DIRECTION_BEARISH); + has = isBullish || isBearish; + if (has) + { + // + pattern = X_BAR_PATTERN_TRUE_GAPED; + patternDir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + has = barAnalysis.GetPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + if (has) + { + // + DrawPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + } + } + + // + // Star ... + isBullish = barAnalysis.IsStar(X_DIRECTION_BULLISH); + isBearish = barAnalysis.IsStar(X_DIRECTION_BEARISH); + has = isBullish || isBearish; + if (has) + { + // + pattern = X_BAR_PATTERN_STAR; + patternDir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + has = barAnalysis.GetPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + if (has) + { + // + DrawPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + } + } + + // + // Piercing ... + isBullish = barAnalysis.IsPiercing(X_DIRECTION_BULLISH); + isBearish = barAnalysis.IsPiercing(X_DIRECTION_BEARISH); + has = isBullish || isBearish; + if (has) + { + // + pattern = X_BAR_PATTERN_PIERCING; + patternDir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + has = barAnalysis.GetPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + if (has) + { + // + DrawPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + } + } + + // + // Rising ... + isBullish = barAnalysis.IsRising(X_DIRECTION_BULLISH); + isBearish = barAnalysis.IsRising(X_DIRECTION_BEARISH); + has = isBullish || isBearish; + if (has) + { + // + pattern = X_BAR_PATTERN_RISING; + patternDir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + has = barAnalysis.GetPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + if (has) + { + // + DrawPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + } + } + + // + // Flag ... + isBullish = barAnalysis.IsFlag(X_DIRECTION_BULLISH); + isBearish = barAnalysis.IsFlag(X_DIRECTION_BEARISH); + has = isBullish || isBearish; + if (has) + { + // + pattern = X_BAR_PATTERN_FLAG; + patternDir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + has = barAnalysis.GetPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + if (has) + { + // + DrawPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + } + } + + // + // SignalKey ... + isBullish = barAnalysis.IsSignalKey(X_DIRECTION_BULLISH); + isBearish = barAnalysis.IsSignalKey(X_DIRECTION_BEARISH); + has = isBullish || isBearish; + if (has) + { + // + pattern = X_BAR_PATTERN_SIGNALKEY; + patternDir = + isBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + has = barAnalysis.GetPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + if (has) + { + // + DrawPattern( + patternBar, + patternPivot, + patternBox, + pattern, + patternDir // + ); + } + } + + // + // Cleanup Resources ... + patternBar.Clean(); + patternBox.Clean(); + patternPivot.Clean(); + } + // };