last works on Peak and Vales ...

This commit is contained in:
2025-10-06 14:39:44 +03:30
parent 2b48fa569e
commit a03613f4cd
9 changed files with 3806 additions and 769 deletions
@@ -450,9 +450,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
public:
//
// Props ...
CArrayObj barObjects;
CArrayObj zoneObjects;
CArrayObj pivotObjects;
CArrayObj drawnObjects;
XFIMAPatternDetectorConfig analyserConfig;
//
@@ -529,6 +527,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
string iName = NULL;
bool isBullish = false;
bool isBearish = false;
XPatternAnalysis iBarAnalysis;
XFIMAConditions iFIMAConditions;
XFIMAMarketStructure iStructure;
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
@@ -573,211 +572,519 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
);
//
// Draw Market Analysis ...
// has = iStructure.pvAnalysis.IsValid();
// if (has)
// {
// //
// XBoxZone iBox;
// XCBoxObject *iBoxObj;
//
// poiDrawer.RemoveDraws();
// //
// has = iStructure.pvAnalysis.HasSupportBox(iBox);
// if (has)
// {
// //
// iBox.to = iBar.time;
// poiDrawer.DrawBox(
// iBox,
// iBoxObj,
// true,
// iBox.type //
// );
// }
// //
// ZeroMemory(iBoxObj);
// has = iStructure.pvAnalysis.HasResistanceBox(iBox);
// if (has)
// {
// //
// iBox.to = iBar.time;
// poiDrawer.DrawBox(
// iBox,
// iBoxObj,
// true,
// iBox.type //
// );
// }
// }
// //
// // Draw Zones ...
// has = HasChild(iStructure.supports);
// if (has) {
// //
// CArrayObj *iSupportObjs;
// poiDrawer.DrawBoxes(
// iStructure.supports,
// iSupportObjs,
// true //
// );
// }
// //
// has = HasChild(iStructure.resistances);
// if (has) {
// //
// CArrayObj *iResistanceObjs;
// poiDrawer.DrawBoxes(
// iStructure.resistances,
// iResistanceObjs,
// true //
// );
// }
//
// Detecte Fibo Section Changes ...
// //
// has = fimaHelper.IsFiboSectionChanged(iDir, iBar.Index());
// has = has &&
// IsXBullish(iDir) &&
// fimaHelper.IsValeOverLast(iBar.Index());
// //
// has = fimaHelper.IsFiboSectionChanged(iDir, iBar.Index());
// has = has &&
// IsXBearish(iDir) &&
// fimaHelper.IsPeakUnderLast(iBar.Index());
// //
// has = fimaHelper.HasFiboPush(iDir, iBar.Index(), 5);
// //
// XBoxZone fimaZones[];
// int fimaZonesCount = fimaHelper.DetectXFIMAZones(
// fimaZones,
// iBar.Index(),
// true, // Only Valid Zones ...
// 50, // Number of Zones ...
// 4, // Shadow Multiplier ...
// 1, // Strength ...
// 7, // Validation Length ...
// 500 // Loopback ..
// );
//
// XPivot fimaPivots[];
// int fimaPivotsCount = fimaHelper.DetecteXFIMAPivots(
// fimaPivots,
// iBar.Index(),
// 50, // Number of Pivots ...
// 7, // Validation Length ...
// 500 // Loopback ...
// );
// //
// has = IsValidSize(fimaZonesCount);
// if (has)
// {
// //
// // Draw Detected Zones ...
// for (int i = 0; i < fimaZonesCount; i++)
// {
// //
// XCBoxObject *iObj;
// has = poiDrawer.DrawBox(
// fimaZones[i],
// iObj,
// true, // Ignore At ...
// fimaZones[i].type // Specified Name ...
// );
// if (has)
// {
// zoneObjects.Add(iObj);
// }
// }
// }
// //
// has = IsValidSize(fimaPivotsCount);
// if (has)
// {
// //
// // Draw Detected Pivots ...
// for (int i = 0; i < fimaPivotsCount; i++)
// {
// //
// XCBarArrowObject *iObj;
// has = poiDrawer.DrawPivot(
// fimaPivots[i],
// iObj);
// if (has)
// {
// pivotObjects.Add(iObj);
// }
// }
// }
//
// Detect DecisionBars ...
XOHCL decisionBars[];
int decisionBarsCount = 0;
ENUM_X_DIRECTION decisionBarDirs[];
// decisionBarsCount = fimaHelper.DetectXFIMAPOIBars(
// decisionBars,
// decisionBarDirs,
// iBar.Index(),
// X_DIRECTION_ALL, // For Dir ...
// 300 // Required Number of Bars ...
// );
// decisionBarsCount = fimaHelper.DetectXFIMAReversalPOIBars(
// decisionBars,
// decisionBarDirs,
// iBar.Index(),
// true, // Force Touch Boundary ...
// X_DIRECTION_ALL, // For Dir ...
// 300 // Required Number of Bars ...
// );
decisionBarsCount = fimaHelper.DetectXFIMAContinuationalPOIBars(
decisionBars,
decisionBarDirs,
iBar.Index(),
true,
X_DIRECTION_ALL, // For Dir ...
300 // Required Number of Bars ...
// Bar Pattern Analysis Detection Test ...
has = poiDetector.AnalyseBarPatterns(
iBar,
iBarAnalysis
//
// Use Default Config ...
);
//
has = IsValidSize(decisionBarsCount);
if (has)
{
//
for (int i = 0; i < decisionBarsCount; i++)
// Draw Bar Patterns Analysis ...
//
XOHCL patternBar;
XPivot patternPivot;
XBoxZone patternBox;
ENUM_X_BAR_PATTERN pattern;
ENUM_X_DIRECTION patternDir;
//
// Support and Resistance ...
//
// Support ...
isBearish = false;
isBullish = iBarAnalysis.IsSupport();
has = isBullish;
if (has)
{
//
XCBarArrowObject *iObj;
has = poiDrawer.DrawBarArrow(
decisionBars[i],
iObj,
IsXBullish(decisionBarDirs[i]) ? X_PRICE_LOW : X_PRICE_HIGH,
159,
IsXBullish(decisionBarDirs[i]) ? clrAqua : clrMagenta,
5,
IsXBullish(decisionBarDirs[i]) ? ANCHOR_TOP : ANCHOR_BOTTOM,
"XOHCL_" + ToXString(TimeToSeconds(decisionBars[i].time)),
true, // Ignore Bar Tag ...
5 // Threshold ...
pattern = X_BAR_PATTERN_SUPPORT;
patternDir = X_DIRECTION_BULLISH;
has = iBarAnalysis.GetPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
if (has)
{
barObjects.Add(iObj);
//
DrawPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
}
}
//
// Resistance ...
isBullish = false;
isBearish = iBarAnalysis.IsResistance();
has = isBearish;
if (has)
{
//
pattern = X_BAR_PATTERN_SUPPORT;
patternDir = X_DIRECTION_BEARISH;
has = iBarAnalysis.GetPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
if (has)
{
//
DrawPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
}
}
//
// PV: High and Low ...
//
// Low ...
isBearish = false;
isBullish = iBarAnalysis.IsLow();
has = isBullish;
if (has)
{
//
pattern = X_BAR_PATTERN_LOW;
patternDir = X_DIRECTION_BULLISH;
has = iBarAnalysis.GetPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
if (has)
{
//
DrawPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
}
}
//
// High ...
isBullish = false;
isBearish = iBarAnalysis.IsHigh();
has = isBearish;
if (has)
{
//
pattern = X_BAR_PATTERN_HIGH;
patternDir = X_DIRECTION_BEARISH;
has = iBarAnalysis.GetPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
if (has)
{
//
DrawPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
}
}
//
// OB ...
isBullish = iBarAnalysis.IsOB(X_DIRECTION_BULLISH);
isBearish = iBarAnalysis.IsOB(X_DIRECTION_BEARISH);
has = isBullish || isBearish;
if (has)
{
//
pattern = X_BAR_PATTERN_OB;
patternDir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
has = iBarAnalysis.GetPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
if (has)
{
//
DrawPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
}
}
//
// FVG ...
isBullish = iBarAnalysis.IsFVG(X_DIRECTION_BULLISH);
isBearish = iBarAnalysis.IsFVG(X_DIRECTION_BEARISH);
has = isBullish || isBearish;
if (has)
{
//
pattern = X_BAR_PATTERN_FVG;
patternDir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
has = iBarAnalysis.GetPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
if (has)
{
//
DrawPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
}
}
//
// Momentum ...
isBullish = iBarAnalysis.IsMomentum(X_DIRECTION_BULLISH);
isBearish = iBarAnalysis.IsMomentum(X_DIRECTION_BEARISH);
has = isBullish || isBearish;
if (has)
{
//
pattern = X_BAR_PATTERN_MOMENTUM;
patternDir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
has = iBarAnalysis.GetPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
if (has)
{
//
DrawPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
}
}
//
// Engulfed ...
isBullish = iBarAnalysis.IsEngulfed(X_DIRECTION_BULLISH);
isBearish = iBarAnalysis.IsEngulfed(X_DIRECTION_BEARISH);
has = isBullish || isBearish;
if (has)
{
//
pattern = X_BAR_PATTERN_ENGULFED;
patternDir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
has = iBarAnalysis.GetPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
if (has)
{
//
DrawPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
}
}
//
// Pinned ...
isBullish = iBarAnalysis.IsPinned(X_DIRECTION_BULLISH);
isBearish = iBarAnalysis.IsPinned(X_DIRECTION_BEARISH);
has = isBullish || isBearish;
if (has)
{
//
pattern = X_BAR_PATTERN_PINNED;
patternDir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
has = iBarAnalysis.GetPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
if (has)
{
//
DrawPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
}
}
//
// TrueGaped ...
isBullish = iBarAnalysis.IsTrueGaped(X_DIRECTION_BULLISH);
isBearish = iBarAnalysis.IsTrueGaped(X_DIRECTION_BEARISH);
has = isBullish || isBearish;
if (has)
{
//
pattern = X_BAR_PATTERN_TRUE_GAPED;
patternDir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
has = iBarAnalysis.GetPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
if (has)
{
//
DrawPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
}
}
//
// Star ...
isBullish = iBarAnalysis.IsStar(X_DIRECTION_BULLISH);
isBearish = iBarAnalysis.IsStar(X_DIRECTION_BEARISH);
has = isBullish || isBearish;
if (has)
{
//
pattern = X_BAR_PATTERN_STAR;
patternDir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
has = iBarAnalysis.GetPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
if (has)
{
//
DrawPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
}
}
//
// Piercing ...
isBullish = iBarAnalysis.IsPiercing(X_DIRECTION_BULLISH);
isBearish = iBarAnalysis.IsPiercing(X_DIRECTION_BEARISH);
has = isBullish || isBearish;
if (has)
{
//
pattern = X_BAR_PATTERN_PIERCING;
patternDir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
has = iBarAnalysis.GetPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
if (has)
{
//
DrawPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
}
}
//
// Rising ...
isBullish = iBarAnalysis.IsRising(X_DIRECTION_BULLISH);
isBearish = iBarAnalysis.IsRising(X_DIRECTION_BEARISH);
has = isBullish || isBearish;
if (has)
{
//
pattern = X_BAR_PATTERN_RISING;
patternDir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
has = iBarAnalysis.GetPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
if (has)
{
//
DrawPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
}
}
//
// Flag ...
isBullish = iBarAnalysis.IsFlag(X_DIRECTION_BULLISH);
isBearish = iBarAnalysis.IsFlag(X_DIRECTION_BEARISH);
has = isBullish || isBearish;
if (has)
{
//
pattern = X_BAR_PATTERN_FLAG;
patternDir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
has = iBarAnalysis.GetPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
if (has)
{
//
DrawPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
}
}
//
// SignalKey ...
isBullish = iBarAnalysis.IsSignalKey(X_DIRECTION_BULLISH);
isBearish = iBarAnalysis.IsSignalKey(X_DIRECTION_BEARISH);
has = isBullish || isBearish;
if (has)
{
//
pattern = X_BAR_PATTERN_SIGNALKEY;
patternDir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
has = iBarAnalysis.GetPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
if (has)
{
//
DrawPattern(
patternBar,
patternPivot,
patternBox,
pattern,
patternDir //
);
}
}
//
// Cleanup Resources ...
patternBar.Clean();
patternBox.Clean();
patternPivot.Clean();
}
//
@@ -860,6 +1167,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
iZone.Clean();
iSignal.Clean();
iStructure.Clean();
iBarAnalysis.Clean();
iFIMAConditions.Clean();
SpecifiedClean(iTargets);
}
@@ -1360,6 +1668,133 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
return result;
}
//
// Drawer Functions ...
//
void DrawPattern(
XOHCL &_bar,
XPivot &_pivot,
XBoxZone &_zone,
ENUM_X_BAR_PATTERN _pattern,
ENUM_X_DIRECTION _patternDir //
)
{
//
// Validate ...
bool has =
poiDrawer != NULL &&
_bar.IsValid() &&
IsXValid(_pattern) &&
HasDirection(_patternDir);
if (!has)
{
return;
}
//
// Defien Draw Requirements ...
//
int width = 3;
bool ignoreBoxAt = true;
int arrowThreshold = 5;
//
int bullishArrow = 159;
int bearishArrow = 159;
//
ENUM_X_PRICE arrowValePriceType = X_PRICE_LOW;
ENUM_X_PRICE arrowPeakPriceType = X_PRICE_HIGH;
//
color bullishColor = clrAqua;
color bearishColor = clrMagenta;
//
// Draw Bar ...
//
// Draw Pivot ...
if (_pivot.IsValid())
{
//
XCBarArrowObject *iObj;
has = poiDrawer.DrawBarArrow(
_bar,
iObj,
_pivot.IsPeak()
? arrowPeakPriceType
: arrowValePriceType,
IsXBullish(_patternDir)
? bullishArrow
: bearishArrow,
IsXBullish(_patternDir)
? bullishColor
: bearishColor,
width,
IsXBullish(_patternDir)
? ANCHOR_TOP
: ANCHOR_BOTTOM,
_pivot.prefix + "_" + ToXString(TimeToSeconds(_pivot.time)),
true, // Ignore Bar Tag ...
arrowThreshold // Threshold ...
);
if (has)
{
drawnObjects.Add(iObj);
}
//
ZeroMemory(iObj);
}
//
// Draw Box ...
if (_zone.IsValid())
{
//
XCBoxObject *iObj;
has = poiDrawer.DrawBox(
_zone,
iObj,
ignoreBoxAt,
_zone.type + "_" + ToXString(TimeToSeconds(_zone.from)) //
);
if (has)
{
//
XPOIStyle iStyle;
poiDrawer.GetBoxStyle(
iStyle,
_zone.dir //
);
//
iStyle.clr =
IsXBullish(_patternDir)
? bullishColor
: bearishColor;
//
poiDrawer.ApplyBoxStyle(
iObj,
iStyle //
);
//
drawnObjects.Add(iObj);
//
iStyle.Clean();
}
//
ZeroMemory(iObj);
}
}
//
};
@@ -622,7 +622,7 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
if (config.detectStarPattern)
{
//
bool isStarPattern = IsStartPattern(
bool isStarPattern = IsStarPattern(
forBar,
iDir //
);
@@ -1129,7 +1129,7 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
{
//
iPrefix = "Star";
has = IsStartPattern(
has = IsStarPattern(
iBar,
iDir //
);