This commit is contained in:
2025-06-16 01:43:17 +03:30
parent 4cb5e47616
commit 80b452fff4
3 changed files with 479 additions and 162 deletions
+413 -91
View File
@@ -642,10 +642,22 @@ XCPOIDrawer *mDrawer;
XCBarAnalyser *mBarAnalyser;
//
XBoxZone mBullishBreakes[];
XBoxZone mBearishBreakes[];
int mSamePeakCount = 0;
int mSameValeCount = 0;
//
double mSamePeakGolden = 0;
double mSameValeGolden = 0;
//
bool mDetectLiquidities = false;
bool mDetectRangeBreakes = true;
//
XBoxZone mBullishLiquidities[];
XBoxZone mBearishLiquidities[];
XBoxZone mBullishRangeBreakes[];
XBoxZone mBearishRangeBreakes[];
//
// Event Handlers ...
@@ -910,6 +922,14 @@ int OnCalculate(
return prev_calculated;
}
//
if (prev_calculated == 0)
{
//
string message = "History Started ...";
Print(message);
}
//
// Main Loop ...
for (int i = limit - 1; i >= 0 && !IsStopped(); i--)
@@ -3218,6 +3238,11 @@ void DoProcess(
isBearishTriggerBar
//
;
//
isTriggerBar = false;
isBullishTriggerBar = false;
isBearishTriggerBar = false;
}
//
@@ -3408,6 +3433,14 @@ void DetectPOIs(
? barIndex == startCalculationForLastBars
: barIndex == firstBarIndex;
//
// Handle Minimum Required Bars ...
bool isPassedRequiredBars = barIndex < maxBarIndex - 3;
if (!isPassedRequiredBars)
{
return;
}
//
// Recieve Bar ...
XOHCL iBar;
@@ -3427,124 +3460,317 @@ void DetectPOIs(
}
//
bool isBullish = false;
bool isBearish = false;
int maxAllowedPOIs = 50;
//
ENUM_X_DIRECTION iDir;
//
// Detecting Liquidity ...
bool isLiquidity =
mBarAnalyser
.IsRejected(
iBar,
iDir,
true,
true //
);
bool isBullishLiquiditySweeped =
isLiquidity &&
IsBullish(iDir);
bool isBearishLiquiditySweeped =
isLiquidity &&
IsBearish(iDir);
if (isLiquidity)
if (mDetectLiquidities)
{
//
XBoxZone iLiq;
//
iLiq.dir = iDir;
iLiq.type = "XLIQ";
iLiq.upper =
isBullishLiquiditySweeped
? iBar.GetDown()
: iBar.high;
iLiq.lower =
isBullishLiquiditySweeped
? iBar.low
: iBar.GetUp();
iLiq.from = iBar.time;
iLiq.symbol = _Symbol;
iLiq.period = _Period;
iLiq.to = ((datetime)((int)iBar.time + (PeriodSeconds(_Period))));
//
if (iLiq.IsValid())
bool isLiquidity =
mBarAnalyser
.IsRejected(
iBar,
iDir,
true,
true //
);
bool isBullishLiquiditySweeped =
isLiquidity &&
IsBullish(iDir);
bool isBearishLiquiditySweeped =
isLiquidity &&
IsBearish(iDir);
if (isLiquidity)
{
//
if (isBullishLiquiditySweeped)
{
//
has = AddBoxIfNotExists(
iLiq,
mBullishLiquidities //
);
if (has)
{
//
SortBoxes(
mBullishLiquidities,
maxAllowedPOIs //
);
}
}
else
{
//
has = AddBoxIfNotExists(
iLiq,
mBearishLiquidities //
);
if (has)
{
//
SortBoxes(
mBearishLiquidities,
maxAllowedPOIs //
);
}
}
}
XBoxZone iLiq;
//
iLiq.Clean();
//
iLiq.dir = iDir;
iLiq.type = "XLIQ";
iLiq.upper =
isBullishLiquiditySweeped
? iBar.GetDown()
: iBar.high;
iLiq.lower =
isBullishLiquiditySweeped
? iBar.low
: iBar.GetUp();
iLiq.at = iBar.time;
iLiq.from = iBar.time;
iLiq.symbol = _Symbol;
iLiq.period = _Period;
iLiq.to = ((datetime)((int)iBar.time + (PeriodSeconds(_Period))));
//
if (iLiq.IsValid())
{
//
if (isBullishLiquiditySweeped)
{
//
has = AddBoxIfNotExists(
iLiq,
mBullishLiquidities //
);
if (has)
{
//
SortBoxes(
mBullishLiquidities,
maxAllowedPOIs //
);
}
}
else
{
//
has = AddBoxIfNotExists(
iLiq,
mBearishLiquidities //
);
if (has)
{
//
SortBoxes(
mBearishLiquidities,
maxAllowedPOIs //
);
}
}
}
//
iLiq.Clean();
}
}
//
// Detecting Bullish and Bearish Breakes ...
//
bool isPeakSame = false;
bool isPPeakSame = false;
//
bool isPeakOverLast = false;
bool isPPeakOverLast = false;
bool isPeakSame = peakBuffer[barIndex] == peakBuffer[barIndex + 1];
bool isPPeakSame = peakBuffer[barIndex + 1] == peakBuffer[barIndex + 2];
//
bool isPeakUnderLast = false;
bool isPPeakUnderLast = false;
bool isPeakOverLast = peakBuffer[barIndex] > peakBuffer[barIndex + 1];
bool isPPeakOverLast = peakBuffer[barIndex + 1] > peakBuffer[barIndex + 2];
//
bool isSamePeakOverLast = false;
bool isSamePeakUnderLast = false;
bool isPeakUnderLast = peakBuffer[barIndex] < peakBuffer[barIndex + 1];
bool isPPeakUnderLast = peakBuffer[barIndex + 1] < peakBuffer[barIndex + 2];
//
bool isValeSame = false;
bool isPValeSame = false;
bool isSamePeakOverLast =
isPPeakSame &&
isPeakOverLast;
bool isSamePeakUnderLast =
isPPeakSame &&
isPeakUnderLast;
//
bool isValeOverLast = false;
bool isPValeOverLast = false;
bool isValeSame = valeBuffer[barIndex] == valeBuffer[barIndex + 1];
bool isPValeSame = valeBuffer[barIndex + 1] == valeBuffer[barIndex + 2];
//
bool isValeUnderLast = false;
bool isPValeUnderLast = false;
bool isValeOverLast = valeBuffer[barIndex] > valeBuffer[barIndex + 1];
bool isPValeOverLast = valeBuffer[barIndex + 1] > valeBuffer[barIndex + 2];
//
bool isSameValeOverLast = false;
bool isSameValeUnderLast = false;
bool isValeUnderLast = valeBuffer[barIndex] < valeBuffer[barIndex + 1];
bool isPValeUnderLast = valeBuffer[barIndex + 1] < valeBuffer[barIndex + 2];
//
bool isSameValeOverLast =
isPValeSame &&
isValeOverLast;
bool isSameValeUnderLast =
isPValeSame &&
isValeUnderLast;
//
// Detecting Range Breakes ...
if (mDetectRangeBreakes)
{
//
isBullish = isSamePeakOverLast
// || isSameValeOverLast
;
isBearish =
isSameValeUnderLast
// || isSamePeakUnderLast
;
//
bool basedOnPeak =
isSamePeakOverLast
// || isSamePeakUnderLast
;
//
bool basedOnVale =
isSameValeUnderLast
// isSameValeOverLast ||
;
//
has = isBullish ||
isBearish;
//
if (has)
{
//
XBoxZone iRNGBreak;
//
iDir =
isBullish
? X_DIRECTION_BULLISH
: isBearish
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
//
iRNGBreak.dir = iDir;
iRNGBreak.at = iBar.time;
iRNGBreak.type = "XRNGB";
iRNGBreak.to = iBar.time;
iRNGBreak.symbol = _Symbol;
iRNGBreak.period = _Period;
//
int fromIDX =
iBar.Index() +
(basedOnPeak
? mSamePeakCount
: basedOnVale
? mSameValeCount
: 0);
datetime from = GetBarTime(
_Symbol,
_Period,
fromIDX //
);
iRNGBreak.from = from;
//
double upper =
isBullish
? basedOnPeak
? peakBuffer[barIndex]
: basedOnVale
? mSameValeGolden
: 0
: isBearish
? basedOnPeak
? peakBuffer[barIndex]
: basedOnVale
? mSameValeGolden
: 0
: 0;
//
double lower =
isBullish
? basedOnPeak
? mSamePeakGolden
: basedOnVale
? valeBuffer[barIndex]
: 0
: isBearish
? basedOnPeak
? mSamePeakGolden
: basedOnVale
? valeBuffer[barIndex]
: 0
: 0;
//
iRNGBreak.upper = upper;
iRNGBreak.lower = lower;
//
// Adding POI ...
has = iRNGBreak.IsValid();
if (has)
{
//
if (isBullish)
{
//
has = AddBoxIfNotExists(
iRNGBreak,
mBullishRangeBreakes //
);
if (has)
{
//
SortBoxes(
mBullishRangeBreakes,
maxAllowedPOIs //
);
}
}
else if (isBearish)
{
//
has = AddBoxIfNotExists(
iRNGBreak,
mBearishRangeBreakes //
);
if (has)
{
//
SortBoxes(
mBearishRangeBreakes,
maxAllowedPOIs //
);
}
}
}
}
}
//
if (isPeakSame)
{
//
mSamePeakGolden =
mSamePeakGolden == 0
? iBar.GetUp()
: MathMax(mSamePeakGolden, iBar.GetUp());
mSamePeakCount++;
}
else
{
//
mSamePeakCount = 0;
mSamePeakGolden = 0;
}
//
if (isValeSame)
{
//
mSameValeGolden =
mSameValeGolden == 0
? iBar.GetDown()
: MathMin(mSameValeGolden, iBar.GetDown());
mSameValeCount++;
}
else
{
//
mSameValeCount = 0;
mSameValeGolden = 0;
}
//
// Cleanup Resources ...
@@ -3606,6 +3832,39 @@ void ValidatePOIs(
barsLength //
);
}
//
// Range Breaks ...
//
// Bullish ...
count = ArraySize(mBullishRangeBreakes);
has = IsValidSize(count);
if (has)
{
//
ValidateBoxes(
mBullishRangeBreakes,
barIndex,
barsLength //
);
}
//
// Bearish ...
count = ArraySize(mBearishRangeBreakes);
has = IsValidSize(count);
if (has)
{
//
ValidateBoxes(
mBearishRangeBreakes,
barIndex,
barsLength //
);
}
//
}
//
@@ -3688,6 +3947,69 @@ void DrawPOIs(
iBox.Clean();
}
}
//
// Range Breaks ...
//
// Bullish ...
count = ArraySize(mBullishRangeBreakes);
has = IsValidSize(count);
if (has)
{
//
for (int i = 0; i < count; i++)
{
//
iBox = mBullishRangeBreakes[i];
iBox.to = to;
//
XCBoxObject *iObj;
has = mDrawer.DrawBox(
iBox,
iObj //
);
if (has)
{
mObjects.Add(iObj);
}
//
iBox.Clean();
}
}
//
// Bearish ...
count = ArraySize(mBearishRangeBreakes);
has = IsValidSize(count);
if (has)
{
//
for (int i = 0; i < count; i++)
{
//
iBox = mBearishRangeBreakes[i];
iBox.to = to;
//
XCBoxObject *iObj;
has = mDrawer.DrawBox(
iBox,
iObj //
);
if (has)
{
mObjects.Add(iObj);
}
//
iBox.Clean();
}
}
//
}
//