This commit is contained in:
2025-06-03 20:51:46 +03:30
parent 078dc35ae0
commit 043c635812
4 changed files with 666 additions and 90 deletions
@@ -910,6 +910,40 @@ bool FindBoxIndex(
return result;
}
/**
* Check a BaxHas Valid Place for Specified Bar ...
*
* @param bar: XOHCL instance reference, Specified Bar ...
* #param box: XBoxZone instance reference, Specified Box ...
*
* @return ( bool )
*/
bool IsBoxPlaceValidForBar(
XOHCL &bar,
XBoxZone &box //
)
{
//
bool result = false;
//
result = bar.IsValid() &&
box.IsValid();
if (!result)
{
return result;
}
//
result =
box.IsBullish()
? bar.low > box.upper
: bar.high < box.upper;
//
return result;
}
/**
* Check Source Box is Below Dest ...
*
@@ -2054,6 +2088,70 @@ int GetOldest(
result = i;
selected = iBox;
}
//
iBox.Clean();
}
//
selected.Clean();
//
return result;
}
int GetOldest(
XOHCL &bar,
XBoxZone &source[] //
)
{
//
int result = -1;
//
if (!bar.IsValid())
{
return result;
}
//
int count = ArraySize(source);
if (!IsValidSize(count))
{
return result;
}
//
XBoxZone selected;
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox = source[i];
//
bool isBoxValidForBar = IsBoxPlaceValidForBar(bar, iBox);
if (!isBoxValidForBar)
{
//
iBox.Clean();
//
continue;
}
//
bool canSet =
!selected.IsValid()
? true
: selected.from > iBox.from;
if (canSet)
{
//
result = i;
selected = iBox;
}
//
iBox.Clean();
}
//
@@ -2102,6 +2200,70 @@ int GetYoungest(
result = i;
selected = iBox;
}
//
iBox.Clean();
}
//
selected.Clean();
//
return result;
}
int GetYoungest(
XOHCL &bar,
XBoxZone &source[] //
)
{
//
int result = -1;
//
if (!bar.IsValid())
{
return result;
}
//
int count = ArraySize(source);
if (!IsValidSize(count))
{
return result;
}
//
XBoxZone selected;
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox = source[i];
//
bool isBoxValidForBar = IsBoxPlaceValidForBar(bar, iBox);
if (!isBoxValidForBar)
{
//
iBox.Clean();
//
continue;
}
//
bool canSet =
!selected.IsValid()
? true
: selected.from < iBox.from;
if (canSet)
{
//
result = i;
selected = iBox;
}
//
iBox.Clean();
}
//
@@ -2150,6 +2312,70 @@ int GetHighest(
result = i;
selected = iBox;
}
//
iBox.Clean();
}
//
selected.Clean();
//
return result;
}
int GetHighest(
XOHCL &bar,
XBoxZone &source[] //
)
{
//
int result = -1;
//
if (!bar.IsValid())
{
return result;
}
//
int count = ArraySize(source);
if (!IsValidSize(count))
{
return result;
}
//
XBoxZone selected;
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox = source[i];
//
bool isBoxValidForBar = IsBoxPlaceValidForBar(bar, iBox);
if (!isBoxValidForBar)
{
//
iBox.Clean();
//
continue;
}
//
bool canSet =
!selected.IsValid()
? true
: selected.upper < iBox.upper;
if (canSet)
{
//
result = i;
selected = iBox;
}
//
iBox.Clean();
}
//
@@ -2198,6 +2424,70 @@ int GetLowest(
result = i;
selected = iBox;
}
//
iBox.Clean();
}
//
selected.Clean();
//
return result;
}
int GetLowest(
XOHCL &bar,
XBoxZone &source[] //
)
{
//
int result = -1;
//
if (!bar.IsValid())
{
return result;
}
//
int count = ArraySize(source);
if (!IsValidSize(count))
{
return result;
}
//
XBoxZone selected;
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox = source[i];
//
bool isBoxValidForBar = IsBoxPlaceValidForBar(bar, iBox);
if (!isBoxValidForBar)
{
//
iBox.Clean();
//
continue;
}
//
bool canSet =
!selected.IsValid()
? true
: selected.lower > iBox.lower;
if (canSet)
{
//
result = i;
selected = iBox;
}
//
iBox.Clean();
}
//
+2 -4
View File
@@ -542,7 +542,7 @@ class XCXCATBEASignaller : XCBase
{
//
cPeak.to = cTime;
drawer.DrawBox(cPeak);
// drawer.DrawBox(cPeak);
}
//
@@ -551,7 +551,7 @@ class XCXCATBEASignaller : XCBase
{
//
cVale.to = cTime;
drawer.DrawBox(cVale);
// drawer.DrawBox(cVale);
}
//
@@ -702,8 +702,6 @@ class XCXCATBEASignaller : XCBase
//
// Detect Signalling Zone ...
result = DetectSignalZone(
cPeak,
cVale,
helper,
drawer,
detector,
+158 -9
View File
@@ -180,13 +180,13 @@ class XCXCATBEAPOIDrawer : public XCBase
//
// MT ...
mtBullishPivotStyle = defaultBearishStyle;
mtBearishPivotStyle = defaultBullishStyle;
mtBullishPivotStyle = defaultBullishStyle;
mtBearishPivotStyle = defaultBearishStyle;
//
// OB ...
obBullishPivotStyle = defaultBearishStyle;
obBearishPivotStyle = defaultBullishStyle;
obBullishPivotStyle = defaultBullishStyle;
obBearishPivotStyle = defaultBearishStyle;
}
//
@@ -993,12 +993,155 @@ class XCXCATBEAPOIDrawer : public XCBase
}
//
// Protected ...
protected:
//
// Props ...
// Styling Tools ...
//
/**
* Apply Default Bullish Style ...
*
* @param object: XCBaseObject pointer, Specified Object to Apply Styling ...
*/
void ApplyBullishStyle(XCBoxObject *&object)
{
//
// Validate Args ...
if (object == NULL)
{
return;
}
//
ApplyPivotStyle(object, defaultBullishStyle);
}
/**
* Apply Default Bearish Style ...
*
* @param object: XCBaseObject pointer, Specified Object to Apply Styling ...
*/
void ApplyBearishStyle(XCBoxObject *&object)
{
//
// Validate Args ...
if (object == NULL)
{
return;
}
//
ApplyPivotStyle(object, defaultBearishStyle);
}
/**
* Apply Peak Style ...
*
* @param object: XCBaseObject pointer, Specified Object to Apply Styling ...
*/
void ApplyPeakPivotStyle(XCBoxObject *&object)
{
//
// Validate Args ...
if (object == NULL)
{
return;
}
//
ApplyPivotStyle(object, peakPivotStyle);
}
/**
* Apply Vale Style ...
*
* @param object: XCBaseObject pointer, Specified Object to Apply Styling ...
*/
void ApplyValePivotStyle(XCBoxObject *&object)
{
//
// Validate Args ...
if (object == NULL)
{
return;
}
//
ApplyPivotStyle(object, valePivotStyle);
}
/**
* Apply MT Bullish Style ...
*
* @param object: XCBaseObject pointer, Specified Object to Apply Styling ...
*/
void ApplyMTBullishPivotStyle(XCBoxObject *&object)
{
//
// Validate Args ...
if (object == NULL)
{
return;
}
//
ApplyPivotStyle(object, mtBullishPivotStyle);
}
/**
* Apply MT Bearish Style ...
*
* @param object: XCBaseObject pointer, Specified Object to Apply Styling ...
*/
void ApplyMTBearishPivotStyle(XCBoxObject *&object)
{
//
// Validate Args ...
if (object == NULL)
{
return;
}
//
ApplyPivotStyle(object, mtBearishPivotStyle);
}
/**
* Apply OB Bullish Style ...
*
* @param object: XCBaseObject pointer, Specified Object to Apply Styling ...
*/
void ApplyOBBullishPivotStyle(XCBoxObject *&object)
{
//
// Validate Args ...
if (object == NULL)
{
return;
}
//
ApplyPivotStyle(object, obBullishPivotStyle);
}
/**
* Apply OB Bearish Style ...
*
* @param object: XCBaseObject pointer, Specified Object to Apply Styling ...
*/
void ApplyOBBearishPivotStyle(XCBoxObject *&object)
{
//
// Validate Args ...
if (object == NULL)
{
return;
}
//
ApplyPivotStyle(object, obBearishPivotStyle);
}
/**
* Apply Pivot Style to Specified Object ...
*/
void ApplyPivotStyle(
XCBoxObject *&object,
XCATBPivotStyle &style //
@@ -1016,6 +1159,12 @@ class XCXCATBEAPOIDrawer : public XCBase
object.BoxStyle(style.style);
}
//
// Protected ...
protected:
//
// Props ...
//
// Prrivate ...
private:
+216 -77
View File
@@ -352,8 +352,6 @@ bool ToSignal(
* @return ( bool )
*/
bool DetectSignalZone(
XBoxZone &peak,
XBoxZone &vale,
XCX121XCatbHelper *helper,
XCXCATBEAPOIDrawer *drawer,
XCXCATBEAPOIDetector *detector,
@@ -377,8 +375,6 @@ bool DetectSignalZone(
//
// Validate Args ...
result =
peak.IsValid() &&
vale.IsValid() &&
helper != NULL &&
detector != NULL &&
barAnalyser != NULL;
@@ -406,9 +402,13 @@ bool DetectSignalZone(
int p4IDX = p3IDX + 1;
//
XBoxZone iOB;
XBoxZone iMT;
int idx = -1;
XBoxZone iPeak;
XBoxZone iVale;
XBoxZone iOBBull;
XBoxZone iOBBear;
XBoxZone iMTBull;
XBoxZone iMTBear;
bool has = false;
bool isBullish = false;
bool isBearish = false;
@@ -425,6 +425,154 @@ bool DetectSignalZone(
ENUM_TIMEFRAMES iPeriod = NULL;
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
//
// Select MT Block ...
if (result)
{
//
// New MT Pivot Detected ...
if (detector.newMTBullishPivotDetected)
{
//
idx = GetYoungest(detector.mtBullishPivots);
if (IsValidIndex(idx))
{
iMTBull = detector.mtBullishPivots[idx];
}
}
else if (detector.newMTBearishPivotDetected)
{
//
idx = GetYoungest(detector.mtBearishPivots);
if (IsValidIndex(idx))
{
iMTBear = detector.mtBearishPivots[idx];
}
}
//
// Draw MT ...
//
// Bullish ...
has = iMTBull.IsValid();
if (has)
{
//
iMTBull.to = conditions.bars[zIDX].time;
//
XCBoxObject *iObj;
has = drawer
.drawer
.DrawBox(
iMTBull,
iObj //
);
if (has)
{
drawer.ApplyMTBullishPivotStyle(iObj);
}
}
//
// Bearish ...
has = iMTBear.IsValid();
if (has)
{
//
iMTBear.to = conditions.bars[zIDX].time;
//
XCBoxObject *iObj;
has = drawer
.drawer
.DrawBox(
iMTBear,
iObj //
);
if (has)
{
drawer.ApplyMTBearishPivotStyle(iObj);
}
}
}
//
// Select Peak and Vale ...
// this used to Signalling Better ...
if (result)
{
//
// Select Peak ...
idx = GetLowest(
conditions.bars[cIDX],
detector.peakPivots //
);
if (IsValidIndex(idx))
{
//
iPeak = detector.peakPivots[idx];
iPeak.to = conditions.bars[zIDX].time;
}
//
// Select Vale ...
idx = GetHighest(
conditions.bars[cIDX],
detector.valePivots //
);
if (IsValidIndex(idx))
{
//
iVale = detector.valePivots[idx];
iVale.to = conditions.bars[zIDX].time;
}
//
// Checkig Result ...
result =
iPeak.IsValid() &&
iVale.IsValid();
//
// Draw Peak and Vales ...
if (result)
{
//
// Object Definitions ...
XCBoxObject *iObj;
//
// Draw Peak ...
has = drawer
.drawer
.DrawBox(
iPeak,
iObj //
);
if (has)
{
drawer.ApplyPeakPivotStyle(iObj);
}
ZeroMemory(iObj);
//
// Draw Vale ...
has = drawer
.drawer
.DrawBox(
iVale,
iObj //
);
if (has)
{
drawer.ApplyValePivotStyle(iObj);
}
ZeroMemory(iObj);
}
}
//
// Signalling ...
if (result)
@@ -878,9 +1026,9 @@ bool DetectSignalZone(
// Conditions 1:
// --------------
// Descriptions:
// using Parabolic Sar Trending Start Conditions
// then attached others ..
// ----------------------------------
// - [] Detect Parabolic Sar Start ...
// - [] Convert is to Box ...
// ------------------------------------
//
bool isCond1Bullish =
@@ -943,52 +1091,62 @@ bool DetectSignalZone(
//
// Validate Some Other Requirements ...
//
// We Have to Detect Youngest Order Block ...
// or Mitigation Block ...
if (isCond1Bullish)
{
//
// OB ...
idx = GetYoungest(detector.obBullishPivots);
has = IsValidIndex(idx);
if (has)
{
iOB = detector.obBullishPivots[idx];
}
// //
// // We Have to Detect Youngest Order Block ...
// // or Mitigation Block ...
// if (isCond1Bullish)
// {
// // //
// // // OB ...
// // idx = GetYoungest(detector.obBullishPivots);
// // has = IsValidIndex(idx);
// // if (has)
// // {
// // iOB = detector.obBullishPivots[idx];
// // }
//
// MT ...
idx = GetYoungest(detector.mtBullishPivots);
has = IsValidIndex(idx);
if (has)
{
iOB = detector.mtBullishPivots[idx];
}
}
else if (isCond1Bearish)
{
//
// OB
idx = GetYoungest(detector.obBearishPivots);
has = IsValidIndex(idx);
if (has)
{
iOB = detector.obBearishPivots[idx];
}
// //
// // MT ...
// idx = GetYoungest(detector.mtBullishPivots);
// has = IsValidIndex(idx);
// if (has)
// {
// iOB = detector.mtBullishPivots[idx];
// }
// }
// else if (isCond1Bearish)
// {
// //
// // OB
// // idx = GetYoungest(detector.obBearishPivots);
// // has = IsValidIndex(idx);
// // if (has)
// // {
// // iOB = detector.obBearishPivots[idx];
// // }
//
// MT
idx = GetYoungest(detector.mtBearishPivots);
has = IsValidIndex(idx);
if (has)
{
iMT = detector.mtBearishPivots[idx];
}
}
// //
// // MT
// idx = GetYoungest(detector.mtBearishPivots);
// has = IsValidIndex(idx);
// if (has)
// {
// iMT = detector.mtBearishPivots[idx];
// }
// }
//
// Now we can Do some Verifications Using these ...
// //
// // Now we can Do some Verifications Using these ...
// result =
// isCond1Bullish
// ? iMT.IsBullish()
// : iMT.IsBearish();
// if (!result)
// {
// //
// isCond1Bullish = false;
// isCond1Bearish = false;
// }
//
// All Requirements based on Cond 1 ...
@@ -1069,29 +1227,6 @@ bool DetectSignalZone(
drawer.DrawBox(signalZone);
}
//
// Draw MT and OB if Exists ...
if (iOB.IsValid())
{
//
drawer.DrawBox(
iOB,
conditions.bars[zIDX].time,
false, // Draw Middle ...
true // Ignore Type ...
);
}
if (iMT.IsValid())
{
//
drawer.DrawBox(
iMT,
conditions.bars[zIDX].time,
false, // Draw Middle ...
true // Ignore Type ...
);
}
//
Print("Conditions ...");
}
@@ -1104,8 +1239,12 @@ bool DetectSignalZone(
// Cleanup Resources ...
//
iOB.Clean();
iMT.Clean();
iPeak.Clean();
iVale.Clean();
iOBBull.Clean();
iOBBear.Clean();
iMTBull.Clean();
iMTBear.Clean();
//
if (!result)