This commit is contained in:
2025-10-01 00:26:07 +03:30
parent 32b218afbc
commit cfba2b3e3a
6 changed files with 285 additions and 108 deletions
@@ -639,6 +639,8 @@ void OnSignalTriggered(XSignal &signal)
signal, signal,
result // result //
); );
//
Print("Signal Issued: ", signal.GetObjectID()); Print("Signal Issued: ", signal.GetObjectID());
} }
+127 -17
View File
@@ -1254,13 +1254,128 @@ class XCXFIMAHelper : public XCBaseHelper
return result; return result;
} }
/**
* Check Specified Bar has MA Cross or not ...
*
* @param dir: reference for holds cross Direction ...
* @param barIndex: int, Specified Bar Index ...
* @param validCrossDiffMultiplier: double, validate diff between MAs on Cross happens ...
*
* @return ( bool )
*/
bool HasMACross(
ENUM_X_DIRECTION &dir,
int barIndex = 0,
double validCrossDiffMultiplier = 1 //
)
{
//
bool result = false;
//
// Prepare ...
dir = X_DIRECTION_NONE;
//
// Normalize ...
barIndex = NormalizeInt(barIndex, 0);
validCrossDiffMultiplier = NormalizeDouble(validCrossDiffMultiplier, 0);
//
double fast[];
double slow[];
double upper[];
double lower[];
int count = ReadMAValues(
fast,
slow,
upper,
lower,
barIndex,
2 //
);
//
bool isBullish = false;
bool isBearish = false;
//
// Validate Readed Values ...
result = IsValidSize(count) && count >= 2;
if (result)
{
//
// Detect Direction Change ...
//
bool notEmpty =
NotEmptyZero(fast[0]) &&
NotEmptyZero(fast[1]) &&
NotEmptyZero(slow[0]) &&
NotEmptyZero(slow[1]);
//
isBullish =
notEmpty &&
fast[0] > slow[0] &&
fast[1] < slow[1];
//
isBearish =
notEmpty &&
fast[0] < slow[0] &&
fast[1] > slow[1];
//
result =
isBullish ||
isBearish;
//
// Validate Direction Change ...
if (result &&
validCrossDiffMultiplier > 0)
{
//
double _points = GetPoints(GetSymbol());
double diff = MathAbs(fast[0] - slow[0]);
//
result = diff >= (validCrossDiffMultiplier * _points);
}
}
//
if (result)
{
//
// Setting Direction ...
dir =
isBullish
? X_DIRECTION_BULLISH
: isBearish
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
}
//
// Cleanup Resources ...
XClean(fast);
XClean(slow);
XClean(upper);
XClean(lower);
//
return result;
}
/** /**
* Extract Specified Kind of Pivots ... * Extract Specified Kind of Pivots ...
* *
* @param pivots: XPivot, refrence Collection to hold Extracted pivots ... * @param pivots: XPivot, refrence Collection to hold Extracted pivots ...
* @param barIndex: int, Specified Bar Index ... * @param barIndex: int, Specified Bar Index ...
* @param requiredNumberOFPivots: int, Specified which Number of Pivots must be Extracted ... * @param requiredNumberOFPivots: int, Specified which Number of Pivots must be Extracted ...
* @param validationLength: int, Specified Pivots Validation Length ignore if <= 0 ... * @param validCrossDiffMultiplier: double, validate diff between MAs on Cross happens ...
* @param maxAllowedLoopbackLength: int, Specified Maximum Loopback Length for Pivot Extraction ... * @param maxAllowedLoopbackLength: int, Specified Maximum Loopback Length for Pivot Extraction ...
* *
* @return ( int ) * @return ( int )
@@ -1269,7 +1384,7 @@ class XCXFIMAHelper : public XCBaseHelper
XPivot &pivots[], XPivot &pivots[],
int barIndex = 0, int barIndex = 0,
int requiredNumberOFPivots = 50, int requiredNumberOFPivots = 50,
int validationLength = 0, double validCrossDiffMultiplier = 1,
int maxAllowedLoopbackLength = 1500 // int maxAllowedLoopbackLength = 1500 //
) )
{ {
@@ -1283,9 +1398,9 @@ class XCXFIMAHelper : public XCBaseHelper
// //
// Normalize ... // Normalize ...
barIndex = NormalizeInt(barIndex, 0); barIndex = NormalizeInt(barIndex, 0);
validationLength = NormalizeInt(validationLength, 0);
requiredNumberOFPivots = NormalizeInt(requiredNumberOFPivots, 2); requiredNumberOFPivots = NormalizeInt(requiredNumberOFPivots, 2);
maxAllowedLoopbackLength = NormalizeInt(maxAllowedLoopbackLength, 50); maxAllowedLoopbackLength = NormalizeInt(maxAllowedLoopbackLength, 50);
validCrossDiffMultiplier = NormalizeDouble(validCrossDiffMultiplier, 0);
// //
// Validate ... // Validate ...
@@ -1362,7 +1477,13 @@ class XCXFIMAHelper : public XCBaseHelper
// //
// Validate Value ... // Validate Value ...
has = NotEmptyZero(iFValue) && has =
HasMACross(
iDir,
idx,
validCrossDiffMultiplier //
) &&
NotEmptyZero(iFValue) &&
NotEmptyZero(iSValue) && NotEmptyZero(iSValue) &&
NotEmptyZero(pFValue) && NotEmptyZero(pFValue) &&
NotEmptyZero(pSValue); NotEmptyZero(pSValue);
@@ -1370,10 +1491,8 @@ class XCXFIMAHelper : public XCBaseHelper
{ {
// //
// Check Direction Changed ... // Check Direction Changed ...
isSwitchedToBullish = iFValue > iSValue && isSwitchedToBullish = IsXBullish(iDir);
pFValue < pSValue; isSwitchedToBearish = IsXBearish(iDir);
isSwitchedToBearish = iFValue < iSValue &&
pFValue > pSValue;
has = has =
isSwitchedToBullish || isSwitchedToBullish ||
isSwitchedToBearish; isSwitchedToBearish;
@@ -1400,15 +1519,6 @@ class XCXFIMAHelper : public XCBaseHelper
has = has && has = has &&
HasDirection(iDir); HasDirection(iDir);
//
// Check Validation ...
if (has &&
validationLength > 0)
{
//
// Validate ...
}
// //
if (has) if (has)
{ {
@@ -4096,6 +4096,11 @@ void SpecifiedClean(T &buffer[])
{ {
Clean(buffer); Clean(buffer);
} }
template <typename T>
void XClean(T &buffer[])
{
Clean(buffer);
}
// //
// Copy Whole Content of Source to Dest array ... // Copy Whole Content of Source to Dest array ...
@@ -569,7 +569,11 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
{ {
// //
// Configure Detector ... // Configure Detector ...
//
analyserConfig.Default(); analyserConfig.Default();
analyserConfig.validMACrossDiffMultiplier = 4;
//
analyserConfig.FullDetect(); analyserConfig.FullDetect();
} }
@@ -1165,94 +1169,101 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
// //
// Testing Bar Zones ... // Testing Bar Zones ...
XBoxZone barZones[]; // XBoxZone barZones[];
int barCounts = fima2Signaller.fimaHelper.ExtractBarZones( // int barCounts = fima2Signaller.fimaHelper.ExtractBarZones(
barZones, // barZones,
1, // Bar Index ... // 1, // Bar Index ...
50, // Number of Zones ... // 50, // Number of Zones ...
3, // Break Validation Length ... // 3, // Break Validation Length ...
true, // Validate Fake Breakes ... // true, // Validate Fake Breakes ...
5, // Shadow Multiplier ... // 5, // Shadow Multiplier ...
1, // Strength ... // 1, // Strength ...
14 // Validation Length ... // 14 // Validation Length ...
); // );
if (IsValidSize(barCounts)) // if (IsValidSize(barCounts))
{ // {
//
XCBoxObject *iObj;
for (int i = 0; i < barCounts; i++)
{
//
iObj = NULL;
bool isCreated = fima2Signaller.poiDrawer.DrawBox(
barZones[i],
iObj,
true, // Ignore At ...
barZones[i].type // Name ...
);
//
ZeroMemory(iObj);
}
// // // //
// Print("Bar Zones Detected ..."); // // XCBoxObject *iObj;
} // // for (int i = 0; i < barCounts; i++)
// // {
// // //
// // iObj = NULL;
// // bool isCreated = fima2Signaller.poiDrawer.DrawBox(
// // barZones[i],
// // iObj,
// // true, // Ignore At ...
// // barZones[i].type // Name ...
// // );
// // //
// // ZeroMemory(iObj);
// // }
// // //
// // Print("Bar Zones Detected ...");
// }
// //
// Testing HK Zones ... // Testing HK Zones ...
XBoxZone hkZones[]; // XBoxZone hkZones[];
int hkCounts = fima2Signaller.fimaHelper.ExtractHKZones( // int hkCounts = fima2Signaller.fimaHelper.ExtractHKZones(
hkZones, // hkZones,
1, // Bar Index ... // 1, // Bar Index ...
50, // Number of Zones ... // 50, // Number of Zones ...
5, // Shadow Multiplier ... // 5, // Shadow Multiplier ...
1, // Strength ... // 1, // Strength ...
14 // Validation Length ... // 14 // Validation Length ...
);
if (IsValidSize(hkCounts))
{
// //
// XCBoxObject *iObj;
// for (int i = 0; i < hkCounts; i++)
// {
// //
// iObj = NULL;
// bool isCreated = fima2Signaller.poiDrawer.DrawBox(
// hkZones[i],
// iObj,
// true, // Ignore At ...
// hkZones[i].type // Name ...
// ); // );
// if (IsValidSize(hkCounts))
// {
// // //
// // XCBoxObject *iObj;
// // for (int i = 0; i < hkCounts; i++)
// // {
// // //
// // iObj = NULL;
// // bool isCreated = fima2Signaller.poiDrawer.DrawBox(
// // hkZones[i],
// // iObj,
// // true, // Ignore At ...
// // hkZones[i].type // Name ...
// // );
// // // // //
// ZeroMemory(iObj); // // ZeroMemory(iObj);
// // }
// // //
// // Print("HK Zones Detected ...");
// } // }
// //
// Print("HK Zones Detected ...");
}
// //
// Testing XFIMA MA Pivots ... // Testing XFIMA MA Pivots ...
XPivot maPivots[]; // XPivot maPivots[];
int maPivotsCount = fimaHelper.ExtractMAPivots( // int maPivotsCount = fimaHelper.ExtractMAPivots(
maPivots, // maPivots,
1, // Bar Index ... // 1, // Bar Index ...
50, // Number of Pivots ... // 50, // Number of Pivots ...
0 // Validation Length ... // 1 // Validation Diff ...
); // );
if (IsValidSize(maPivotsCount)) // if (IsValidSize(maPivotsCount))
{ // {
// // //
CArrayObj *iPivotsObj; // // CArrayObj *iPivotsObj;
maPivotsCount = poiDrawer.DrawPivots( // // maPivotsCount = poiDrawer.DrawPivots(
maPivots, // // maPivots,
iPivotsObj // // // iPivotsObj //
); // // );
// //
// // Print("MA Pivots Detected ...");
// }
// //
Print("MA Pivots Detected ..."); bool hasMACross = HasDirection(structure.maCrossDir);
if (hasMACross)
{
Print(ToXString(structure.maCrossDir), " MaCross Detected ...");
} }
// //
@@ -1357,16 +1368,17 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
// //
// Strategy 1 ... // Strategy 1 ...
has = Strategy1HasSignal( has = false;
bar, // has = Strategy1HasSignal(
iZone, // bar,
iName, // iZone,
supports, // iName,
resistances, // supports,
iDir, // resistances,
structure, // iDir,
fimaConditions // // structure,
); // fimaConditions //
// );
// //
// Do all Draws Here ... // Do all Draws Here ...
@@ -916,6 +916,28 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
resistance.Clean(); resistance.Clean();
} }
//
// Detecting MA Crosses ...
if (config.detectMACrosses)
{
//
idx = forBar.Index();
has = fimaHelper.HasMACross(
structure.maCrossDir,
idx,
config.validMACrossDiffMultiplier //
);
//
fimaHelper.ExtractMAPivots(
structure.maCrosses,
idx,
config.recentlyPatternsMaxAllowedCollecting,
config.validMACrossDiffMultiplier,
config.recentlyPatternsMaxLookupLength //
);
}
// //
// Analysers ... // Analysers ...
@@ -69,6 +69,10 @@ struct XFIMAPatternDetectorConfig
bool analyseFIMASARPivots; bool analyseFIMASARPivots;
bool analyseFIMAZigZagPivots; bool analyseFIMAZigZagPivots;
//
bool detectMACrosses;
double validMACrossDiffMultiplier;
// //
// Configs ... // Configs ...
@@ -159,6 +163,10 @@ struct XFIMAPatternDetectorConfig
analyseFIMASARPivots = false; analyseFIMASARPivots = false;
analyseFIMAZigZagPivots = false; analyseFIMAZigZagPivots = false;
//
detectMACrosses = false;
validMACrossDiffMultiplier = 0;
// //
obLoopback = 0; obLoopback = 0;
fvgLoopback = 0; fvgLoopback = 0;
@@ -226,6 +234,10 @@ struct XFIMAPatternDetectorConfig
analyseFIMASARPivots = false; analyseFIMASARPivots = false;
analyseFIMAZigZagPivots = false; analyseFIMAZigZagPivots = false;
//
detectMACrosses = true;
validMACrossDiffMultiplier = 1;
// //
// OB / FVg ... // OB / FVg ...
obLoopback = 5; obLoopback = 5;
@@ -314,6 +326,9 @@ struct XFIMAPatternDetectorConfig
analyseFIMAPVPivots = true; analyseFIMAPVPivots = true;
analyseFIMASARPivots = true; analyseFIMASARPivots = true;
analyseFIMAZigZagPivots = true; analyseFIMAZigZagPivots = true;
//
detectMACrosses = true;
} }
/** /**
@@ -352,6 +367,9 @@ struct XFIMAPatternDetectorConfig
analyseFIMAPVPivots = false; analyseFIMAPVPivots = false;
analyseFIMASARPivots = false; analyseFIMASARPivots = false;
analyseFIMAZigZagPivots = false; analyseFIMAZigZagPivots = false;
//
detectMACrosses = false;
} }
// //
@@ -428,6 +446,10 @@ struct XFIMAMarketStructure
ENUM_X_DIRECTION piercingPatternDir; ENUM_X_DIRECTION piercingPatternDir;
ENUM_X_DIRECTION signalKeyBarPatternDir; ENUM_X_DIRECTION signalKeyBarPatternDir;
//
ENUM_X_DIRECTION maCrossDir;
XPivot maCrosses[];
// //
// Constructor ... // Constructor ...
XFIMAMarketStructure() XFIMAMarketStructure()
@@ -473,6 +495,10 @@ struct XFIMAMarketStructure
piercingPatternDir = X_DIRECTION_NONE; piercingPatternDir = X_DIRECTION_NONE;
signalKeyBarPatternDir = X_DIRECTION_NONE; signalKeyBarPatternDir = X_DIRECTION_NONE;
//
maCrossDir = X_DIRECTION_NONE;
SpecifiedClean(maCrosses);
// //
SpecifiedClean(obs); SpecifiedClean(obs);
SpecifiedClean(fvgs); SpecifiedClean(fvgs);