diff --git a/Indicators/x-saherelm.x121.xcatb.v1.mq5 b/Indicators/x-saherelm.x121.xcatb.v1.mq5 index 13f83674..427175fb 100644 --- a/Indicators/x-saherelm.x121.xcatb.v1.mq5 +++ b/Indicators/x-saherelm.x121.xcatb.v1.mq5 @@ -647,13 +647,40 @@ XCBarAnalyser *mBarAnalyser; // // Temparory ... int mCount = 0; +XSignal mSignal; bool mHas = false; +XBoxZone mSignalBox; ENUM_X_DIRECTION mDir; bool mHasSignal = false; bool mIsBullish = false; bool mIsBearish = false; XDirectionShift mDirShift; -string mTriggerBarConditions; +string mArrowNamePrefix = NULL; + +// +// Signals ... + +// +bool mDrawSignals = false; +bool mDrawSignalBoxes = true; +bool mDrawSignalArrows = true; +bool mDrawSignalBoxAtLines = false; + +// +int _bullishArrowCode = 225; +int _bearishArrowCode = 226; + +// +color _bullishArrowColor = clrLime; +color _bearishArrowColor = clrRed; + +// +XPOIStyle mBullishSignalBoxStyle; +XPOIStyle mBearishSignalBoxStyle; + +// +ENUM_ARROW_ANCHOR mBullishAnchor = ANCHOR_TOP; +ENUM_ARROW_ANCHOR mBearishAnchor = ANCHOR_BOTTOM; // // POI(s) ... @@ -1028,7 +1055,22 @@ int OnInit() mBarAnalyser = new XCBarAnalyser(); // - // Preparing POI Styles ... + // Preparing Styles ... + + // + // Signals ... + + // + // Bullish ... + mBullishSignalBoxStyle.width = 1; + mBullishSignalBoxStyle.clr = clrAqua; + mBullishSignalBoxStyle.style = STYLE_DOT; + + // + // Bearish ... + mBearishSignalBoxStyle.width = 1; + mBearishSignalBoxStyle.style = STYLE_DOT; + mBearishSignalBoxStyle.clr = clrMagenta; // // Liquidities ... @@ -1105,7 +1147,9 @@ void OnDeinit(const int reason) IndicatorRelease(trendHandler); // + mSignal.Clean(); mDirShift.Clean(); + mSignalBox.Clean(); // Clean(mBullishKIChanges); @@ -1125,6 +1169,10 @@ void OnDeinit(const int reason) Clean(mBullishRangeBreakes); Clean(mBearishRangeBreakes); + // + mBullishSignalBoxStyle.Clean(); + mBearishSignalBoxStyle.Clean(); + // mBullishLiquidityStyle.Clean(); mBearishLiquidityStyle.Clean(); @@ -3415,7 +3463,7 @@ void PrepareMarketConditions( IsBearish(mDir); if (isTriggerBarCond1) { - mTriggerBarConditions += "1"; + mArrowNamePrefix += "1"; } // @@ -3441,7 +3489,7 @@ void PrepareMarketConditions( IsBearish(mDir); if (isTriggerBarCond2) { - mTriggerBarConditions += ",2"; + mArrowNamePrefix += ",2"; } // @@ -3467,7 +3515,7 @@ void PrepareMarketConditions( IsBearish(mDir); if (isTriggerBarCond3) { - mTriggerBarConditions += ",3"; + mArrowNamePrefix += ",3"; } // @@ -3493,7 +3541,7 @@ void PrepareMarketConditions( IsBearish(mDir); if (isTriggerBarCond4) { - mTriggerBarConditions += ",4"; + mArrowNamePrefix += ",4"; } // @@ -3519,7 +3567,7 @@ void PrepareMarketConditions( IsBearish(mDir); if (isTriggerBarCond5) { - mTriggerBarConditions += ",5"; + mArrowNamePrefix += ",5"; } // @@ -3545,7 +3593,7 @@ void PrepareMarketConditions( IsBearish(mDir); if (isTriggerBarCond6) { - mTriggerBarConditions += ",6"; + mArrowNamePrefix += ",6"; } // @@ -3571,7 +3619,7 @@ void PrepareMarketConditions( IsBearish(mDir); if (isTriggerBarCond7) { - mTriggerBarConditions += ",7"; + mArrowNamePrefix += ",7"; } // @@ -5121,6 +5169,225 @@ void DoProcess( const long &tickVolume[] // ) { + // + // Here we Can Detect Conditions ... + + // + // Check Some Requirements ... + int lastBarIndex = barIndex + 1; + int maxBarIndex = startCalculationForLastBars > 0 + ? startCalculationForLastBars + : ratesTotal; + bool isFirstBar = + startCalculationForLastBars > 0 + ? barIndex == startCalculationForLastBars + : barIndex == firstBarIndex; + + // + // Recieve Bar ... + XOHCL iBar; + XOHCL iPBar; + mHas = iBar.Init( + _Symbol, + _Period, + barIndex + // + ); + mHas = + mHas && + iBar.GetPreviousBar(iPBar); + if (!mHas) + { + return; + } + + // + // Bullish ... + mIsBullish = + // + isTriggerBarBullish + // + ; + + // + // Bearish ... + mIsBearish = + // + isTriggerBarBearish + // + ; + + // + // Signal Summarize ... + mHasSignal = + mIsBullish || + mIsBearish; + + // + // Handling Signal ... + if (mHasSignal) + { + // + // Creating Signal Box ... + mSignalBox.type = "XSGB"; + mSignalBox.at = iBar.time; + mSignalBox.to = iBar.time; + mSignalBox.symbol = _Symbol; + mSignalBox.period = _Period; + mSignalBox.lower = iPBar.low; + mSignalBox.from = iPBar.time; + mSignalBox.upper = iPBar.high; + mSignalBox.dir = + mIsBullish + ? X_DIRECTION_BULLISH + : X_DIRECTION_BEARISH; + + // + // Converting Box to Signal ... + double rrs[] = { + 1, + 1.5, + 2, + 3 // + }; + mHas = ToSignal( + mSignalBox, + mSignal, + rrs, // Risk To Reward Ratios ... + 0 // Additional SL ... + ); + + // + // Draw Signal Box ... + if (mDrawSignalBoxes) + { + // + mHas = mSignalBox.IsValid(); + if (mHas) + { + // + XCBoxObject *iSignalBoxObj; + mHas = mDrawer.DrawBox( + mSignalBox, + iSignalBoxObj, + !mDrawSignalBoxAtLines // + ); + + // + if (mHas) + { + // + // Styling Object ... + if (mSignalBox.IsBullish()) + { + // + mDrawer.ApplyStyle( + iSignalBoxObj, + mBullishSignalBoxStyle // + ); + } + else + { + // + mDrawer.ApplyStyle( + iSignalBoxObj, + mBearishSignalBoxStyle // + ); + } + + // + // Storing Object ... + mObjects.Add(iSignalBoxObj); + } + + // + ZeroMemory(iSignalBoxObj); + } + } + + // + // Draw Signal ... + if (mDrawSignals) + { + // + mHas = mSignal.IsValid(); + if (mHas) + { + // + XCSignalObject *iSignalObj; + mHas = mDrawer.DrawSignal( + mSignal, + iSignalObj, + 3 // + ); + + // + if (mHas) + { + mObjects.Add(iSignalObj); + } + + // + ZeroMemory(iSignalObj); + } + } + + // + // Draw Arrows ... + if (mDrawSignalArrows) + { + // + int arrowWidth = 3; + int arrowCode = + mIsBullish + ? _bullishArrowCode + : _bearishArrowCode; + ENUM_X_PRICE arrowPriceType = + mIsBullish + ? X_PRICE_LOW + : X_PRICE_HIGH; + color arrowColor = + mIsBullish + ? _bullishArrowColor + : _bearishArrowColor; + ENUM_ARROW_ANCHOR arrowAnchor = + mIsBullish + ? mBullishAnchor + : mBearishAnchor; + + // + XCBarArrowObject *iSignalArrowObj; + mHas = mDrawer.CreateBarArrow( + iBar, + iSignalArrowObj, + arrowPriceType, + arrowCode, + arrowColor, + arrowWidth, + arrowAnchor, + mArrowNamePrefix // + ); + if (mHas) + { + mObjects.Add(iSignalArrowObj); + } + + // + ZeroMemory(iSignalArrowObj); + } + } + + // + // Cleanup Resources ... + + // + iBar.Clean(); + iPBar.Clean(); + mSignal.Clean(); + mSignalBox.Clean(); + + // + mArrowNamePrefix = NULL; } // \ No newline at end of file