This commit is contained in:
2025-12-31 21:28:54 +03:30
parent ad945b90b2
commit a0876d5a05
12 changed files with 1789 additions and 185 deletions
+585
View File
@@ -0,0 +1,585 @@
/**
* Check Bar Has Signal Based on Strategy 1 ...
*
* Pattern‑based reversal:
* - Detects Pin Bar or Signal Key Bar.
* - Confirms with POI detector.
* - Good for reversals at support/resistance.
*
* @param bar: XOHCL, reference to Bar ...
* @param zone: XBoxZone, reference to holds affected zone ...
* @param targets: XTarget, reference to detected Signal's Targets collections ...
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
*
* @return ( bool )
*/
bool Strategy1HasSignal(
XOHCL &bar,
XBoxZone &zone,
XTarget &targets[],
ENUM_X_DIRECTION &dir //
)
{
//
bool result = false;
//
zone.Clean();
XClean(targets);
dir = X_DIRECTION_NONE;
//
result = bar.IsValid();
if (!result)
{
return result;
}
//
result = poiDetector.IsKISignal(
dir,
bar.Index() //
);
bool isBullish = result &&
IsXBullish(dir);
bool isBearish = result &&
IsXBearish(dir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Detect Nearest Directional ...
int nearestDirectionalSwitchIndex = -1;
if (isBullish)
{
//
isBullish = poiDetector.NearestKIFastSwitchedToBullish(
nearestDirectionalSwitchIndex,
bar.Index() + 2 //
);
}
else
{
//
isBearish = poiDetector.NearestKIFastSwitchedToBearish(
nearestDirectionalSwitchIndex,
bar.Index() + 2 //
);
}
result =
IsValidIndex(nearestDirectionalSwitchIndex) &&
(isBullish ||
isBearish);
if (!result)
{
//
bar.Clean();
return result;
}
//
// Preparing Zone ...
double upper = bar.FindHighest(nearestDirectionalSwitchIndex - bar.Index(), MODE_HIGH);
double lower = bar.FindLowest(nearestDirectionalSwitchIndex - bar.Index(), MODE_LOW);
//
result = zone.Init(
symbol,
period,
upper,
lower,
GetBarTime(symbol, period, nearestDirectionalSwitchIndex),
bar.time,
dir,
"XKI1" //
);
//
// Support and Resistance ...
XBoxZone supports[];
XBoxZone resistances[];
if (result)
{
//
// Supports ...
poiDetector.DetectSupports(
supports,
bar.Index(),
50, // Loopback ...
true, // Force Validation ...
7, // Validation Length ...
symbol, // For Symbol ...
period // For Period ...
);
//
// Resistances ...
poiDetector.DetectResistances(
resistances,
bar.Index(),
50, // Loopback ...
true, // Force Validation ...
7, // Validation Length ...
symbol, // For Symbol ...
period // For Period ...
);
}
//
// TODO: Rempve ...
if (result)
{
//
// Other Drawing Materials ...
XPOIDrawConfig drawConfig;
drawConfig.Default();
//
// this for Selected Zone ...
poiDrawer.DrawZone(zone, drawConfig);
//
// Drawing Supports and Resistances ...
drawConfig.bearishColor = clrRed;
drawConfig.bullishColor = clrLime;
//
if (HasChild(supports))
{
poiDrawer.DrawZones(supports, drawConfig);
}
//
if (HasChild(resistances))
{
poiDrawer.DrawZones(resistances, drawConfig);
}
//
drawConfig.Clean();
//
DebugBreak();
}
//
result =
result &&
zone.IsValid() &&
HasDirection(dir);
//
return result;
}
/**
* Check Bar Has Signal Based on Strategy 1 ...
*
* Pattern‑based reversal:
* - Detects Pin Bar or Signal Key Bar.
* - Confirms with POI detector.
* - Good for reversals at support/resistance.
*
* @param bar: XOHCL, reference to Bar ...
* @param zone: XBoxZone, reference to holds affected zone ...
* @param targets: XTarget, reference to detected Signal's Targets collections ...
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
*
* @return ( bool )
*/
bool Strategy1HasSignal(
XOHCL &bar,
XBoxZone &zone,
XTarget &targets[],
ENUM_X_DIRECTION &dir //
)
{
//
bool result = false;
//
zone.Clean();
XClean(targets);
dir = X_DIRECTION_NONE;
//
result = bar.IsValid();
if (!result)
{
return result;
}
//
result = poiDetector.IsKISignal(
dir,
bar.Index() //
);
bool isBullish = result &&
IsXBullish(dir);
bool isBearish = result &&
IsXBearish(dir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Detect Nearest Directional ...
int nearestDirectionalSwitchIndex = -1;
if (isBullish)
{
//
isBullish = poiDetector.NearestKIFastSwitchedToBullish(
nearestDirectionalSwitchIndex,
bar.Index() + 2 //
);
}
else
{
//
isBearish = poiDetector.NearestKIFastSwitchedToBearish(
nearestDirectionalSwitchIndex,
bar.Index() + 2 //
);
}
result =
IsValidIndex(nearestDirectionalSwitchIndex) &&
(isBullish ||
isBearish);
if (!result)
{
//
bar.Clean();
return result;
}
//
// Preparing Zone ...
double upper = bar.FindHighest(nearestDirectionalSwitchIndex - bar.Index(), MODE_HIGH);
double lower = bar.FindLowest(nearestDirectionalSwitchIndex - bar.Index(), MODE_LOW);
//
result = zone.Init(
symbol,
period,
upper,
lower,
GetBarTime(symbol, period, nearestDirectionalSwitchIndex),
bar.time,
dir,
"XKI1" //
);
//
// Support and Resistance ...
XBoxZone supports[];
XBoxZone resistances[];
XBoxZone minorSupport;
XBoxZone majorSupport;
XBoxZone minorResistance;
XBoxZone majorResistance;
if (result)
{
//
// Supports ...
poiDetector.GetCurrentStructure(
supports,
resistances,
minorSupport,
majorSupport,
minorResistance,
majorResistance,
bar.Index(),
symbol, // For Symbol ...
period, // For Period ...
50, // Loopback ...
7, // Minor Validation Length ...
14 // Major Validation Length ...
);
}
//
// TODO: Rempve ...
if (result)
{
//
// Other Drawing Materials ...
XPOIDrawConfig drawConfig;
drawConfig.Default();
//
// this for Selected Zone ...
poiDrawer.DrawZone(zone, drawConfig);
//
// Drawing Supports and Resistances ...
drawConfig.bearishColor = clrRed;
drawConfig.bullishColor = clrLime;
//
// Minors ...
//
drawConfig.zonesStyle = STYLE_DOT;
if (minorSupport.IsValid())
{
poiDrawer.DrawZone(minorSupport, drawConfig);
}
if (minorResistance.IsValid())
{
poiDrawer.DrawZone(minorResistance, drawConfig);
}
//
// Majors ...
//
drawConfig.zonesStyle = STYLE_DASH;
if (majorSupport.IsValid())
{
poiDrawer.DrawZone(majorSupport, drawConfig);
}
if (majorResistance.IsValid())
{
poiDrawer.DrawZone(majorResistance, drawConfig);
}
// //
// if (HasChild(supports))
// {
// poiDrawer.DrawZones(supports, drawConfig);
// }
// //
// if (HasChild(resistances))
// {
// poiDrawer.DrawZones(resistances, drawConfig);
// }
//
drawConfig.Clean();
//
DebugBreak();
}
//
result =
result &&
zone.IsValid() &&
HasDirection(dir);
//
return result;
}
/**
* Check Bar Has Signal Based on Strategy 1 ...
*
* Pattern‑based reversal:
* - Detects Pin Bar or Signal Key Bar.
* - Confirms with POI detector.
* - Good for reversals at support/resistance.
*
* @param bar: XOHCL, reference to Bar ...
* @param zone: XBoxZone, reference to holds affected zone ...
* @param targets: XTarget, reference to detected Signal's Targets collections ...
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
*
* @return ( bool )
*/
bool Strategy1HasSignal(
XOHCL &bar,
XBoxZone &zone,
XTarget &targets[],
ENUM_X_DIRECTION &dir //
)
{
//
bool result = false;
//
zone.Clean();
XClean(targets);
dir = X_DIRECTION_NONE;
//
result = bar.IsValid();
if (!result)
{
return result;
}
//
result = poiDetector.IsKISignal(
dir,
bar.Index() //
);
bool isBullish = result &&
IsXBullish(dir);
bool isBearish = result &&
IsXBearish(dir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Detect Nearest Directional ...
int nearestDirectionalSwitchIndex = -1;
if (isBullish)
{
//
isBullish = poiDetector.NearestKIFastSwitchedToBullish(
nearestDirectionalSwitchIndex,
bar.Index() + 2 //
);
}
else
{
//
isBearish = poiDetector.NearestKIFastSwitchedToBearish(
nearestDirectionalSwitchIndex,
bar.Index() + 2 //
);
}
result =
IsValidIndex(nearestDirectionalSwitchIndex) &&
(isBullish ||
isBearish);
if (!result)
{
//
bar.Clean();
return result;
}
//
// Preparing Zone ...
double upper = bar.FindHighest(nearestDirectionalSwitchIndex - bar.Index(), MODE_HIGH);
double lower = bar.FindLowest(nearestDirectionalSwitchIndex - bar.Index(), MODE_LOW);
//
result = zone.Init(
symbol,
period,
upper,
lower,
GetBarTime(symbol, period, nearestDirectionalSwitchIndex),
bar.time,
dir,
"XKI1" //
);
//
// Support and Resistance ...
XBoxZone supports[];
XBoxZone resistances[];
XBoxZone minorSupport;
XBoxZone majorSupport;
XBoxZone minorResistance;
XBoxZone majorResistance;
if (result)
{
//
// Supports ...
poiDetector.GetCurrentStructure(
supports,
resistances,
minorSupport,
majorSupport,
minorResistance,
majorResistance,
bar.Index(),
symbol, // For Symbol ...
period, // For Period ...
50, // Loopback ...
7, // Minor Validation Length ...
14 // Major Validation Length ...
);
}
//
// TODO: Rempve ...
if (result)
{
//
// Other Drawing Materials ...
XPOIDrawConfig drawConfig;
drawConfig.Default();
//
// this for Selected Zone ...
poiDrawer.DrawZone(zone, drawConfig);
//
// Drawing Supports and Resistances ...
drawConfig.bearishColor = clrRed;
drawConfig.bullishColor = clrLime;
//
// Minors ...
//
drawConfig.zonesStyle = STYLE_DOT;
if (minorSupport.IsValid())
{
poiDrawer.DrawZone(minorSupport, drawConfig);
}
if (minorResistance.IsValid())
{
poiDrawer.DrawZone(minorResistance, drawConfig);
}
//
// Majors ...
//
drawConfig.zonesStyle = STYLE_DASH;
if (majorSupport.IsValid())
{
poiDrawer.DrawZone(majorSupport, drawConfig);
}
if (majorResistance.IsValid())
{
poiDrawer.DrawZone(majorResistance, drawConfig);
}
// //
// if (HasChild(supports))
// {
// poiDrawer.DrawZones(supports, drawConfig);
// }
// //
// if (HasChild(resistances))
// {
// poiDrawer.DrawZones(resistances, drawConfig);
// }
//
drawConfig.Clean();
//
DebugBreak();
}
//
result =
result &&
zone.IsValid() &&
HasDirection(dir);
//
return result;
}
@@ -0,0 +1,76 @@
if (result)
{
//
XOHCL tmpBar;
int tmpIDX = -1;
bool has = false;
double upper = 0;
double lower = 0;
int length = zone.GetAge();
//
// Support ...
tmpIDX = bar.FindLowestIndex(length, MODE_LOW);
if (IsValidIndex(tmpIDX))
{
//
if (tmpBar.Init(symbol, period, tmpIDX))
{
//
lower = iLow(symbol, period, tmpIDX);
upper = bar.FindLowest(length, MODE_CLOSE);
if (upper <= lower)
{
upper = tmpBar.GetDown();
}
//
has = support.Init(
symbol,
period,
upper,
lower,
tmpBar.time,
bar.time,
X_DIRECTION_BULLISH,
ToXString(X_BAR_PATTERN_SUPPORT) //
);
//
tmpBar.Clean();
}
}
//
// Resistance ...
tmpIDX = bar.FindHighestIndex(length, MODE_HIGH);
if (IsValidIndex(tmpIDX))
{
//
if (tmpBar.Init(symbol, period, tmpIDX))
{
//
upper = iHigh(symbol, period, tmpIDX);
lower = bar.FindHighest(length, MODE_CLOSE);
if (upper <= lower)
{
upper = tmpBar.GetUp();
}
//
has = resistance.Init(
symbol,
period,
upper,
lower,
tmpBar.time,
bar.time,
X_DIRECTION_BEARISH,
ToXString(X_BAR_PATTERN_RESISTANCE) //
);
//
tmpBar.Clean();
}
}
}