This commit is contained in:
2025-05-11 23:40:52 +03:30
parent c378ce4b4e
commit 1623925eb0
6 changed files with 961 additions and 318 deletions
+624 -48
View File
@@ -433,6 +433,104 @@ int AddGuard(
return result;
}
//
enum ENUM_XCAEA_LQ_TYPES
{
XCAEA_LQ_TYPE_NONE = 0,
XCAEA_LQ_TYPE_PEAK = 1,
XCAEA_LQ_TYPE_VALE = 2,
};
struct XCAEALQSweep
{
//
// Props ...
int length;
datetime to;
string symbol;
datetime from;
double sweeped;
double reverse;
ENUM_TIMEFRAMES period;
ENUM_XCAEA_LQ_TYPES type;
//
// Constructor ...
XCAEALQSweep()
{
Clean();
}
//
// Tools ...
//
// Cleanup ...
void Clean()
{
//
to = NULL;
length = 0;
from = NULL;
sweeped = 0;
reverse = 0;
symbol = NULL;
period = NULL;
type = XCAEA_LQ_TYPE_NONE;
}
//
// Validation ...
bool IsValid()
{
//
bool result = false;
//
result =
//
length > 0 &&
IsValid(to) &&
sweeped > 0 &&
reverse > 0 &&
IsValid(from) &&
IsValid(symbol) &&
IsValid(period) &&
type != XCAEA_LQ_TYPE_NONE
//
;
//
return result;
}
//
string GetTag()
{
//
string result = NULL;
//
if (!IsValid())
{
return result;
}
//
result = symbol +
ToString(period) +
"XLQ" +
(type == XCAEA_LQ_TYPE_PEAK ? "Peak" : "Vale") +
ToString(sweeped);
//
return result;
}
};
//
// Tools ...
//
// Detect Decision Zone ...
bool DetectDecisionZone(
@@ -583,7 +681,7 @@ bool DetectDecisionZone(
XBoxZone ob;
bool isOB = helper
.barAnalyser
.IsOrderBlock(
.IsOB(
cBar,
ob,
false, // Force FVG Bar Type
@@ -962,7 +1060,7 @@ bool DetectDecisionZone(
//
// Custom Senarios ...
//
bool isCond1Bullish =
//
@@ -1071,9 +1169,6 @@ bool DetectDecisionZone(
);
if (has)
{
//
// Style Object ...
Print("Salam");
}
}
@@ -1636,6 +1731,7 @@ bool CanTriggerCond3(
ENUM_X_DIRECTION &dir,
double &sl,
double &tp,
CArrayObj *drawns,
int barIndex = 0,
int loopback = 10 //
)
@@ -1661,54 +1757,532 @@ bool CanTriggerCond3(
}
//
// Detect At Least one Outside Bar ...
// TODO: Complete this ...
bool isBullish = box.IsBullish();
bool isBearish = box.IsBearish();
//
// Add Support for a Breaked Swing as Liquidity ...
// for Improve Validations ...
// TODO: Complete this ...
//
// Detect Block Based Trigger ...
XBoxZone ob;
XOHCL swing;
XOHCL breaker;
XOHCL outSide;
ENUM_X_DIRECTION passedDir;
bool isPassed = helper.IsBlockBasedTriggerBar(
ob,
swing,
breaker,
outSide,
passedDir,
barIndex + 1, // Bar Index ...
30, // Loopback ...
3 // Swing Length ...
bool has = false;
int swingLoopback = 7;
ENUM_TIMEFRAMES period = helper.GetPeriod();
string symbol = helper.GetSymbol();
int toIDX = box.ToIndex(period);
int fromIDX = box.FromIndex(period);
datetime cTime = GetBarTime(
symbol,
period,
barIndex //
);
bool isBullishPassed =
isPassed &&
ob.IsBullish() &&
box.IsBullish() &&
ob.upper < box.upper &&
ob.lower > box.lower;
bool isBearishPassed =
isPassed &&
ob.IsBearish() &&
box.IsBearish() &&
ob.upper < box.upper &&
ob.lower > box.lower;
//
// Detect Box FVG ...
//
// we Have to Detect a Broken Liquidity for Box ...
//
XBoxZone fvg;
XBoxZone fvgs[];
for (int i = fromIDX + loopback; i > barIndex; i--)
{
//
// Initialize iBar ...
XOHCL iBar;
has = iBar.Init(
symbol,
period,
i //
);
if (!has)
{
//
iBar.Clean();
//
break;
}
//
// Check iBar Has FVG ...
XBoxZone iFVG;
has = helper
.barAnalyser
.IsFVG(
iBar,
iFVG,
true //
);
has =
//
// Check FVG Exists ...
has &&
//
// Check FVG Direction ...
iFVG.dir == box.dir &&
//
// Check FVG not Breaked ...
!IsBoxBreaked(
helper,
iFVG,
barIndex //
) &&
//
// Check FVG Placement ...
(iFVG.IsBullish()
? iFVG.lower < box.upper
: iFVG.upper > box.lower);
if (has)
{
//
iFVG.to = cTime;
//
AddRef(
iFVG,
fvgs //
);
}
//
iBar.Clean();
iFVG.Clean();
}
//
// Detecting Target FVG ...
int idx = isBullish
? GetHighest(fvgs)
: GetLowest(fvgs);
has = IsValidIndex(idx);
if (has)
{
//
fvg = fvgs[idx];
//
fvg.to = cTime;
}
//
// Ensure FVG must Exists ...
result = fvg.IsValid();
if (!result)
{
//
fvg.Clean();
Clean(fvgs);
//
return result;
}
//
// Check FVg Break ...
bool isBreaked = IsBoxBreaked(
helper,
fvg,
barIndex //
);
result = !isBreaked;
if (!result)
{
//
// Here We Can Cleanup Decision Zone ...
// since the Conditions Destructed ...
// box.Clean();
//
fvg.Clean();
Clean(fvgs);
//
return result;
}
//
// Draw FVG ...
XCBoxObject *iObj;
has = helper.poiDrawer.DrawBox(
fvg,
iObj //
);
if (has)
{
//
color fvgColor =
isBullish
? clrLime
: clrRed;
//
iObj.BoxWidth(2);
iObj.BoxColor(fvgColor);
iObj.Style(STYLE_SOLID);
//
drawns.Add(iObj);
}
ZeroMemory(iObj);
//
// Detecting Liquiidties ...
XOHCL iBar;
XCAEALQSweep iLQ;
XCAEALQSweep lqs[];
toIDX = fvg.ToIndex();
fromIDX = fvg.FromIndex();
XCAEAConditions iConditions;
double fvgPrice = isBullish
? fvg.upper
: fvg.lower;
double fvgReversePrice = isBullish
? fvg.lower
: fvg.upper;
for (int i = fromIDX; i > toIDX; i--)
{
//
// Initialize iBar ...
has = iBar.Init(
symbol,
period,
i //
);
if (!has)
{
//
iBar.Clean();
iConditions.Clean();
//
continue;
}
//
// Reading Conditions ...
has = helper.GetConditions(
iConditions,
i,
5 //
);
if (!has)
{
//
iBar.Clean();
iConditions.Clean();
//
break;
}
//
double iSweep =
isBullish
? iConditions.valeBuffer[1]
: iConditions.peakBuffer[1];
double iSweepP =
isBullish
? iConditions.valeBuffer[2]
: iConditions.peakBuffer[2];
double iSweepP2 =
isBullish
? iConditions.valeBuffer[3]
: iConditions.peakBuffer[3];
double iReverse =
isBullish
? iConditions.peakBuffer[1]
: iConditions.valeBuffer[1];
//
bool isSweepContinue =
iSweepP == iSweep &&
(isBullish
? iSweep > fvgPrice
: iSweep < fvgPrice);
//
bool isSweepContinueP =
iSweepP2 == iSweepP &&
(isBullish
? iSweepP > fvgPrice
: iSweepP < fvgPrice);
//
bool isSweepStart =
isSweepContinue &&
!isSweepContinueP;
//
bool isSweepFinished =
!isSweepContinue &&
isSweepContinueP;
//
if (isSweepStart)
{
//
iLQ.Clean();
//
iLQ.symbol = iBar.symbol;
iLQ.period = iBar.period;
iLQ.type = isBullish
? XCAEA_LQ_TYPE_VALE
: XCAEA_LQ_TYPE_PEAK;
iLQ.to = iBar.time;
iLQ.from = iBar.time;
//
iLQ.length = 1;
iLQ.sweeped = iSweep;
iLQ.reverse = iReverse;
}
//
if (isSweepContinue)
{
//
iLQ.length++;
iLQ.to = iBar.time;
iLQ.sweeped = iSweep;
iLQ.reverse = MathMin(iLQ.reverse, iReverse);
}
//
if (isSweepFinished)
{
//
AddRef(
iLQ,
lqs //
);
//
iLQ.Clean();
}
//
iBar.Clean();
iConditions.Clean();
}
//
// Retrieve Bar and Conditions ...
has = iBar.Init(
symbol,
period,
barIndex //
);
has = has &&
helper.GetConditions(
iConditions,
barIndex,
loopback //
);
result = has;
if (!result)
{
//
Clean(lqs);
fvg.Clean();
iLQ.Clean();
Clean(fvgs);
iBar.Clean();
iConditions.Clean();
//
return result;
}
//
// Select Peak/Vale Value Based on Box ...
double iPV = isBullish
? iConditions.valeBuffer[1]
: iConditions.peakBuffer[1];
double iPVReverse = isBullish
? iConditions.peakBuffer[1]
: iConditions.valeBuffer[1];
//
// Validate Liquidities Exists ...
result = HasChild(lqs);
if (!result)
{
//
Clean(lqs);
fvg.Clean();
iLQ.Clean();
Clean(fvgs);
iBar.Clean();
iConditions.Clean();
//
return result;
}
//
// Draw Liquidities ...
for (int i = 0; i < ArraySize(lqs); i++)
{
//
iLQ = lqs[i];
//
CChartObjectTrend *iTrend;
iTrend = new CChartObjectTrend();
string itName = iLQ.GetTag();
has = iTrend.Create(
0,
itName,
0,
iLQ.from,
iLQ.sweeped,
iLQ.to,
iLQ.sweeped //
);
if (has)
{
//
color itColor =
isBullish
? clrLime
: clrRed;
//
iTrend.Width(2);
iTrend.Color(itColor);
iTrend.Style(STYLE_SOLID);
//
drawns.Add(iTrend);
}
//
ZeroMemory(iTrend);
}
//
// PV Must go Inside FVG ...
has =
isBullish
? iPV < fvgPrice
: iPV > fvgPrice;
result = has;
if (!result)
{
//
Clean(lqs);
fvg.Clean();
iLQ.Clean();
Clean(fvgs);
iBar.Clean();
iConditions.Clean();
//
return result;
}
//
// Detect a Traget for SL based on Activated FVG ...
XBoxZone slTarget;
double fvgValidatorPrice =
isBullish
? fvg.lower
: fvg.upper;
for (int i = 0; i < ArraySize(fvgs); i++)
{
//
XBoxZone iFVG = fvgs[i];
//
double iFVGPrice =
isBullish
? iFVG.upper
: iFVG.lower;
//
// Validate Placement ...
has = iFVGPrice > fvgValidatorPrice;
if (!has)
{
//
iFVG.Clean();
//
continue;
}
//
// Set slTarget ...
double slTargetPrice = (isBullish
? slTarget.upper
: slTarget.lower);
has =
!slTarget.IsValid()
? true
: (isBullish
? slTargetPrice < iFVGPrice
: slTargetPrice > iFVGPrice);
if (has)
{
slTarget = iFVG;
}
}
//
// Ensure SL Target Exists ...
result = slTarget.IsValid();
if (!result)
{
//
Clean(lqs);
fvg.Clean();
iLQ.Clean();
Clean(fvgs);
iBar.Clean();
iConditions.Clean();
//
return result;
}
//
// Darw SL Target Zone ...
slTarget.to = cTime;
XCBoxObject *iSLObj;
has = helper.poiDrawer.DrawBox(
slTarget,
iSLObj //
);
if (has)
{
//
color slTargetColor =
isBullish
? clrAqua
: clrMagenta;
//
iSLObj.BoxWidth(1);
iSLObj.BoxColor(slTargetColor);
//
drawns.Add(iSLObj);
}
ZeroMemory(iSLObj);
//
// Summarizing ...
//
bool canTriggerLong =
isBullishPassed;
isBullish &&
fvg.IsBullish() &&
slTarget.IsBullish();
//
bool canTriggerShort =
isBearishPassed;
isBearish &&
fvg.IsBearish() &&
slTarget.IsBearish();
//
result = canTriggerLong ||
@@ -1724,9 +2298,9 @@ bool CanTriggerCond3(
// Preparing TP and SL ...
//
sl = canTriggerLong
? ob.lower
: ob.upper;
sl = isBullish
? slTarget.lower
: slTarget.upper;
//
// Since Here TP Must Calculated
@@ -1738,10 +2312,12 @@ bool CanTriggerCond3(
// Cleanup Resources ...
//
ob.Clean();
swing.Clean();
breaker.Clean();
outSide.Clean();
Clean(lqs);
fvg.Clean();
iLQ.Clean();
Clean(fvgs);
iBar.Clean();
iConditions.Clean();
//
return result;