This commit is contained in:
2025-06-07 09:27:02 +03:30
parent c5ad6e50c2
commit 739464f6ee
2 changed files with 220 additions and 4 deletions
+97 -1
View File
@@ -171,6 +171,9 @@ class XCXCATBEASignaller : XCBase
// //
// Props ... // Props ...
//
int maxAllowedSetupAge; // Maximum Allowed Setup Age for Living
// //
bool allowSignallingBasedOnConditions; // Signalling Based on Market Conditions bool allowSignallingBasedOnConditions; // Signalling Based on Market Conditions
bool allowSignallingBasedOnTriggerBlocks; // Signalling Based on Trigger Blocks bool allowSignallingBasedOnTriggerBlocks; // Signalling Based on Trigger Blocks
@@ -1450,7 +1453,7 @@ class XCXCATBEASignaller : XCBase
* Detect Trigger Conditions for Specified Signal ... * Detect Trigger Conditions for Specified Signal ...
* *
* @param conditions: XCATBEAStrategyConditions instance Reference, Specified Signal Conditions ... * @param conditions: XCATBEAStrategyConditions instance Reference, Specified Signal Conditions ...
* @param maxAllowedSetupAge: specified Setup Age for Expiration (if bigger than Zero) ... * @param barIndex: int, Bar Index ...
* *
* @return ( bool ) * @return ( bool )
*/ */
@@ -1582,6 +1585,77 @@ class XCXCATBEASignaller : XCBase
// Check atleast 3 Bars Close Outside of applied Edge ... // Check atleast 3 Bars Close Outside of applied Edge ...
// Check Current Bar is a Trigger Bar ... // Check Current Bar is a Trigger Bar ...
// TODO: Complete this ... // TODO: Complete this ...
//
// Checking Score ...
double bullishScore = 0;
double bearishScore = 0;
cConditions
.GenerateScore(
bullishScore,
bearishScore //
);
bool isScorePassed =
true;
// isBullish
// ? bullishScore > bearishScore
// : bearishScore > bullishScore;
//
// Check Bar is Inside Zone ...
bool isBarInside =
(isBullish
? (cConditions.bars[1].low < conditions.pivotZone.upper &&
cConditions.bars[1].low > conditions.pivotZone.lower)
: (cConditions.bars[1].high > conditions.pivotZone.lower &&
cConditions.bars[1].high < conditions.pivotZone.upper));
//
isBullish =
isBullish &&
isBarInside &&
isScorePassed &&
isBullishTriggerBar;
//
isBearish =
isBearish &&
isBarInside &&
isScorePassed &&
isBearishTriggerBar;
//
result = isBullish ||
isBearish;
if (result)
{
//
// Check Bar is Touched Zone Middle or not ...
double mid = conditions.pivotZone.GetMid();
bool isMiddlePassed =
isBullish
? (cConditions.bars[1].low < mid &&
(cConditions.bars[1].GetDown() > mid ||
cConditions.bars[1].close > mid))
: (cConditions.bars[1].high > mid &&
(cConditions.bars[1].GetUp() < mid ||
cConditions.bars[1].close < mid));
//
result =
result &&
isMiddlePassed;
//
if (result)
{
//
Print("Trigger Bar Detected ...");
conditions.triggerTime = TimeCurrent();
}
}
// //
} }
@@ -1602,9 +1676,30 @@ class XCXCATBEASignaller : XCBase
// //
// Validate Pivot Zone Based Setups ... // Validate Pivot Zone Based Setups ...
if (isBasedOnPivotZone)
{
//
// Check Box Breaked ...
has = IsSignalZoneBreaked(
helper,
conditions.pivotZone,
barIndex //
);
if (has)
{
conditions.Clean();
}
}
// //
// Validate Setup Age ... // Validate Setup Age ...
int age = conditions.GetSetupAge();
bool has = maxAllowedSetupAge > 0 &&
age <= maxAllowedSetupAge;
if (!has)
{
conditions.Clean();
}
} }
// //
@@ -1675,6 +1770,7 @@ class XCXCATBEASignaller : XCBase
void Init(XCATBEASignallerInputs &inputs) void Init(XCATBEASignallerInputs &inputs)
{ {
// //
maxAllowedSetupAge = 288;
maxAllowedCollection = 100; maxAllowedCollection = 100;
// //
+123 -3
View File
@@ -1365,11 +1365,12 @@ bool DetectSignalZone(
// //
// Summarize Result ... // Summarize Result ...
int requiredPushers = 1;
result = result =
(isBullish && (isBullish &&
longPushers >= 3) || longPushers >= requiredPushers) ||
(isBearish && (isBearish &&
shortPushers >= 3); shortPushers >= requiredPushers);
// //
// Preparing Signal Zone ... // Preparing Signal Zone ...
@@ -1443,7 +1444,7 @@ bool DetectSignalZone(
// //
Print("Conditions ..."); Print("Conditions ...");
signalZone.Clean(); // signalZone.Clean();
} }
// //
@@ -1467,4 +1468,123 @@ bool DetectSignalZone(
return result; return result;
} }
/**
* Check a Signal Zone is Breaked or Not ...
*
* @param helper: XCX121XCatbHelper instance pointer ...
* @param box: XBoxZone instance reference ...
* @param barIndex: int, Bar Index ...
*
* @return ( bool )
*/
bool IsSignalZoneBreaked(
XCX121XCatbHelper *helper,
XBoxZone &box,
int barIndex = 0 //
)
{
//
bool result = false;
//
// Normalize Args ...
barIndex = NormalizeInt(barIndex, 0);
//
// Validate Args ...
result =
box.IsValid() &&
helper != NULL;
if (!result)
{
//
// Assume Box Invalid and Breaked
// When Args not Valid ...
result = true;
return result;
}
//
bool isBullish = box.IsBullish();
bool isBearish = box.IsBearish();
//
// Extract Bars ...
//
XOHCL cBar;
XOHCL pBar;
XOHCL p2Bar;
XOHCL p3Bar;
//
result = cBar.Init(
box.symbol,
box.period,
barIndex + 1 //
);
result = result &&
cBar.GetPreviousBar(pBar);
result = result &&
pBar.GetPreviousBar(p2Bar);
result = result &&
p2Bar.GetPreviousBar(p3Bar);
if (!result)
{
//
cBar.Clean();
pBar.Clean();
p2Bar.Clean();
p3Bar.Clean();
//
// Assume Box Invalid and Breaked
// When Args not Valid ...
result = true;
//
return result;
}
//
// Check Box is Breaked or not ...
// a Box Assume Breakes when at least 3 Bars Close over / under applied Price ...
//
double appliedPrice =
isBullish
? box.lower
: box.upper;
//
bool isBullishBreaked =
isBullish &&
cBar.close < appliedPrice &&
pBar.close < appliedPrice &&
p2Bar.close < appliedPrice;
//
bool isBearishBreaked =
isBearish &&
cBar.close > appliedPrice &&
pBar.close > appliedPrice &&
p2Bar.close > appliedPrice;
//
result = isBullishBreaked ||
isBearishBreaked;
//
// Cleanup Resources ...
//
cBar.Clean();
pBar.Clean();
p2Bar.Clean();
p3Bar.Clean();
//
return result;
}
// //