This commit is contained in:
2025-06-21 18:55:52 +03:30
parent b2310badea
commit 760fa98b38
+276 -9
View File
@@ -647,13 +647,40 @@ XCBarAnalyser *mBarAnalyser;
// //
// Temparory ... // Temparory ...
int mCount = 0; int mCount = 0;
XSignal mSignal;
bool mHas = false; bool mHas = false;
XBoxZone mSignalBox;
ENUM_X_DIRECTION mDir; ENUM_X_DIRECTION mDir;
bool mHasSignal = false; bool mHasSignal = false;
bool mIsBullish = false; bool mIsBullish = false;
bool mIsBearish = false; bool mIsBearish = false;
XDirectionShift mDirShift; 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) ... // POI(s) ...
@@ -1028,7 +1055,22 @@ int OnInit()
mBarAnalyser = new XCBarAnalyser(); 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 ... // Liquidities ...
@@ -1105,7 +1147,9 @@ void OnDeinit(const int reason)
IndicatorRelease(trendHandler); IndicatorRelease(trendHandler);
// //
mSignal.Clean();
mDirShift.Clean(); mDirShift.Clean();
mSignalBox.Clean();
// //
Clean(mBullishKIChanges); Clean(mBullishKIChanges);
@@ -1125,6 +1169,10 @@ void OnDeinit(const int reason)
Clean(mBullishRangeBreakes); Clean(mBullishRangeBreakes);
Clean(mBearishRangeBreakes); Clean(mBearishRangeBreakes);
//
mBullishSignalBoxStyle.Clean();
mBearishSignalBoxStyle.Clean();
// //
mBullishLiquidityStyle.Clean(); mBullishLiquidityStyle.Clean();
mBearishLiquidityStyle.Clean(); mBearishLiquidityStyle.Clean();
@@ -3415,7 +3463,7 @@ void PrepareMarketConditions(
IsBearish(mDir); IsBearish(mDir);
if (isTriggerBarCond1) if (isTriggerBarCond1)
{ {
mTriggerBarConditions += "1"; mArrowNamePrefix += "1";
} }
// //
@@ -3441,7 +3489,7 @@ void PrepareMarketConditions(
IsBearish(mDir); IsBearish(mDir);
if (isTriggerBarCond2) if (isTriggerBarCond2)
{ {
mTriggerBarConditions += ",2"; mArrowNamePrefix += ",2";
} }
// //
@@ -3467,7 +3515,7 @@ void PrepareMarketConditions(
IsBearish(mDir); IsBearish(mDir);
if (isTriggerBarCond3) if (isTriggerBarCond3)
{ {
mTriggerBarConditions += ",3"; mArrowNamePrefix += ",3";
} }
// //
@@ -3493,7 +3541,7 @@ void PrepareMarketConditions(
IsBearish(mDir); IsBearish(mDir);
if (isTriggerBarCond4) if (isTriggerBarCond4)
{ {
mTriggerBarConditions += ",4"; mArrowNamePrefix += ",4";
} }
// //
@@ -3519,7 +3567,7 @@ void PrepareMarketConditions(
IsBearish(mDir); IsBearish(mDir);
if (isTriggerBarCond5) if (isTriggerBarCond5)
{ {
mTriggerBarConditions += ",5"; mArrowNamePrefix += ",5";
} }
// //
@@ -3545,7 +3593,7 @@ void PrepareMarketConditions(
IsBearish(mDir); IsBearish(mDir);
if (isTriggerBarCond6) if (isTriggerBarCond6)
{ {
mTriggerBarConditions += ",6"; mArrowNamePrefix += ",6";
} }
// //
@@ -3571,7 +3619,7 @@ void PrepareMarketConditions(
IsBearish(mDir); IsBearish(mDir);
if (isTriggerBarCond7) if (isTriggerBarCond7)
{ {
mTriggerBarConditions += ",7"; mArrowNamePrefix += ",7";
} }
// //
@@ -5121,6 +5169,225 @@ void DoProcess(
const long &tickVolume[] // 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;
} }
// //