586 lines
15 KiB
Plaintext
586 lines
15 KiB
Plaintext
/**
|
||
* 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;
|
||
}
|