last works ...

This commit is contained in:
2025-10-27 05:02:51 +03:30
parent 8f317a3b1d
commit 31f1abb8d3
11 changed files with 5766 additions and 261 deletions
@@ -2887,7 +2887,7 @@ class XCXFIMAHelperParser : XCBase
//
double values[];
GetBoundaryValuesArray(values, barIndex);
result = GetMax(values);
result = GetMin(values);
//
return result;
@@ -2920,7 +2920,7 @@ class XCXFIMAHelperParser : XCBase
//
double values[];
GetBoundaryValuesArray(values, barIndex);
result = GetMin(values);
result = GetMax(values);
//
return result;
File diff suppressed because it is too large Load Diff
@@ -478,6 +478,174 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
return result;
}
bool DetectXPVZone(
XBoxZone &zone,
int barIndex = 0 //
)
{
//
bool result = false;
//
// Prepare ...
zone.Clean();
//
// Normalize ...
barIndex = fimaParser.NormalizeBarIndex(barIndex);
//
// Validate ...
result = fimaParser.IsValid();
if (!result)
{
return result;
}
//
// Do ...
//
XOHCL bar;
result = bar.Init(fimaParser.symbol, fimaParser.period, barIndex);
if (!result)
{
//
bar.Clean();
return result;
}
//
// Vale ...
bool isValeOverLast = fimaParser.IsValeOverLast(barIndex);
bool isValeUnderLast = fimaParser.IsValeUnderLast(barIndex);
bool isNewVale = isValeOverLast || isValeUnderLast;
//
// Peak ...
bool isPeakOverLast = fimaParser.IsPeakOverLast(barIndex);
bool isPeakUnderLast = fimaParser.IsPeakUnderLast(barIndex);
bool isNewPeak = isPeakOverLast || isPeakUnderLast;
//
// Detect new Peak or Vale ...
result = isNewVale || isNewPeak;
//
// Count Same Peaks and Same Vales from Index of Prev ...
int pIDX = barIndex + 1;
int samePeaks = fimaParser.CountSamePeaks(pIDX);
int sameVales = fimaParser.CountSameVales(pIDX);
result =
result &&
IsValidSize(samePeaks) &&
IsValidSize(sameVales);
//
// Try to Evaluate Zone ...
int peaksStartIndex = pIDX + samePeaks;
int valesStartIndex = pIDX + sameVales;
int fromIDX = MathMin(peaksStartIndex, valesStartIndex);
if (result)
{
//
// Assign Zone Symbol / Period ...
zone.symbol = fimaParser.symbol;
zone.period = fimaParser.period;
//
// Calculate Zone Times ...
zone.to = GetBarTime(
zone.symbol,
zone.period,
barIndex //
);
zone.from = GetBarTime(
zone.symbol,
zone.period,
fromIDX //
);
zone.at = zone.to;
//
// Calculate Upper and Lower ...
zone.upper = fimaHelper.GetPeak(fromIDX);
zone.lower = fimaHelper.GetVale(fromIDX);
//
// Validate Zone Upper and Lower ...
for (int i = pIDX; i <= fromIDX; i++)
{
//
if (isValeUnderLast)
{
zone.lower = MathMin(zone.lower, fimaHelper.GetVale(i));
}
//
if (isPeakOverLast)
{
zone.upper = MathMax(zone.upper, fimaHelper.GetPeak(i));
}
}
//
// Calculate Zone Direction ...
zone.dir =
isValeOverLast
? X_DIRECTION_BULLISH
: isValeUnderLast
? X_DIRECTION_BEARISH
: isPeakOverLast
? X_DIRECTION_BULLISH
: isPeakUnderLast
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
//
// Refine Zone Upper / Lower based on Direction and Bars ...
//
// Detect Highest High / Lowest Low ...
double ll = bar.FindLowest(fromIDX - barIndex, MODE_LOW);
double hh = bar.FindHighest(fromIDX - barIndex, MODE_HIGH);
//
if (isNewVale)
{
zone.upper = MathMin(zone.upper, hh);
}
//
if (isNewPeak)
{
zone.lower = MathMax(zone.lower, ll);
}
//
// Set Zone Type ...
zone.type = ToXString(XFIMA_PIVOT_PV);
//
// Summarize result ...
result = zone.IsValid();
}
//
result = zone.IsValid();
//
// Cleanup ...
if (!result)
{
zone.Clean();
}
bar.Clean();
//
return result;
}
//
// Analysors ...
@@ -1422,6 +1590,105 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
return result;
}
int CollectZonesBoundary(
XPivot &uppers[],
XPivot &lowers[],
XBoxZone &zone //
)
{
//
int result = 0;
//
// Prepare ...
XClean(uppers);
XClean(lowers);
//
// Validate ...
bool has = zone.IsValid() &&
fimaParser.IsValid();
if (!has)
{
return result;
}
//
double iUpper;
double iLower;
datetime iTime;
XPivot upperPivot;
XPivot lowerPivot;
int start = zone.ToIndex();
int end = zone.FromIndex();
for (int i = start; i <= end; i++)
{
//
iUpper = fimaParser.GetBoundaryMax(i);
iLower = fimaParser.GetBoundaryMin(i);
iTime = GetBarTime(zone.symbol, zone.period, i);
//
has =
IsXValid(iTime) &&
NotEmptyZero(iUpper) &&
NotEmptyZero(iLower);
if (has)
{
//
// Upper Pivot ...
upperPivot.Clean();
has = upperPivot.Init(
iUpper,
iTime,
zone.symbol,
zone.dir,
zone.period,
X_PIVOT_TYPE_PEAK //
);
if (has) {
upperPivot.prefix = "XBNDUP";
}
//
// Lower Pivot ...
lowerPivot.Clean();
has = lowerPivot.Init(
iLower,
iTime,
zone.symbol,
zone.dir,
zone.period,
X_PIVOT_TYPE_VALE //
);
if (has) {
lowerPivot.prefix = "XBNDLO";
}
//
has = upperPivot.IsValid() &&
lowerPivot.IsValid();
if (has)
{
//
AddRef(upperPivot, uppers);
AddRef(lowerPivot, lowers);
}
}
}
//
result = MathMin(ArraySize(uppers), ArraySize(lowers));
//
// Cleanup ...
upperPivot.Clean();
lowerPivot.Clean();
//
return result;
}
//
// Others ...