This commit is contained in:
2025-09-28 19:25:29 +03:30
parent ca1b313e4c
commit aebb2a5244
+277 -125
View File
@@ -920,6 +920,8 @@ void HandleSignalLookup(XOHCL &bar)
}
//
XBoxZone iZone;
XSignal iSignal;
string iName = NULL;
XBoxZone supports[];
XBoxZone resistances[];
@@ -933,6 +935,10 @@ void HandleSignalLookup(XOHCL &bar)
// Check Required Pattern Exists ...
bool hasPinnedBar = HasDirection(marketStructure.pinnedDir);
bool hasEngulfedBar = HasDirection(marketStructure.engulfedDir);
bool hasFlagPattern = HasDirection(marketStructure.flagPatternDir);
bool hasStarPattern = HasDirection(marketStructure.starPatternDir);
bool hasRisingPattern = HasDirection(marketStructure.risingPatternDir);
bool hasPiercingPattern = HasDirection(marketStructure.piercingPatternDir);
bool hasSignalKeyBar = HasDirection(marketStructure.signalKeyBarPatternDir);
//
@@ -1222,73 +1228,73 @@ void HandleSignalLookup(XOHCL &bar)
{
//
// Support ...
// XBoxZone supportBox;
// XCBoxObject *iSupportObj;
// has = marketStructure.zigzagAnalysis.HasSupportBox(supportBox);
// if (has)
// {
// //
// supportBox.to = bar.time;
// AddIfNotExists(
// supportBox,
// supports //
// );
// has = fima2Signaller.poiDrawer.DrawBox(
// supportBox,
// iSupportObj,
// true, // Ignore At ...
// supportBox.type // Name ...
// );
// if (has)
// {
// //
// XPOIStyle iStyle;
// fima2Signaller.poiDrawer.GetBoxStyle(
// iStyle,
// supportBox.dir //
// );
// fima2Signaller.poiDrawer.ApplyBoxStyle(
// iSupportObj,
// iStyle //
// );
// iStyle.Clean();
// }
// }
XBoxZone supportBox;
XCBoxObject *iSupportObj;
has = marketStructure.zigzagAnalysis.HasSupportBox(supportBox);
if (has)
{
//
supportBox.to = bar.time;
AddIfNotExists(
supportBox,
supports //
);
has = fima2Signaller.poiDrawer.DrawBox(
supportBox,
iSupportObj,
true, // Ignore At ...
supportBox.type // Name ...
);
if (has)
{
//
XPOIStyle iStyle;
fima2Signaller.poiDrawer.GetBoxStyle(
iStyle,
supportBox.dir //
);
fima2Signaller.poiDrawer.ApplyBoxStyle(
iSupportObj,
iStyle //
);
iStyle.Clean();
}
}
//
// Resistance ...
// XBoxZone resistanceBox;
// XCBoxObject *iResistanceObj;
// has = marketStructure.zigzagAnalysis.HasResistanceBox(resistanceBox);
// if (has)
// {
// //
// resistanceBox.to = bar.time;
// AddIfNotExists(
// resistanceBox,
// supports //
// );
// has = fima2Signaller.poiDrawer.DrawBox(
// resistanceBox,
// iResistanceObj,
// true, // Ignore At ...
// resistanceBox.type // Name ...
// );
// if (has)
// {
// //
// XPOIStyle iStyle;
// fima2Signaller.poiDrawer.GetBoxStyle(
// iStyle,
// resistanceBox.dir //
// );
// fima2Signaller.poiDrawer.ApplyBoxStyle(
// iResistanceObj,
// iStyle //
// );
// iStyle.Clean();
// }
// }
XBoxZone resistanceBox;
XCBoxObject *iResistanceObj;
has = marketStructure.zigzagAnalysis.HasResistanceBox(resistanceBox);
if (has)
{
//
resistanceBox.to = bar.time;
AddIfNotExists(
resistanceBox,
supports //
);
has = fima2Signaller.poiDrawer.DrawBox(
resistanceBox,
iResistanceObj,
true, // Ignore At ...
resistanceBox.type // Name ...
);
if (has)
{
//
XPOIStyle iStyle;
fima2Signaller.poiDrawer.GetBoxStyle(
iStyle,
resistanceBox.dir //
);
fima2Signaller.poiDrawer.ApplyBoxStyle(
iResistanceObj,
iStyle //
);
iStyle.Clean();
}
}
//
// Pivots ...
@@ -1483,58 +1489,6 @@ void HandleSignalLookup(XOHCL &bar)
SpecifiedClean(pivots);
}
//
// Selecting Price Type of Bar based on Dir ...
has = hasPinnedBar ||
hasEngulfedBar ||
hasSignalKeyBar;
if (has)
{
//
// Retrieve Direction ...
if (hasPinnedBar)
{
//
iDir = marketStructure.pinnedDir;
iName = "XPin_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasEngulfedBar)
{
//
iDir = marketStructure.engulfedDir;
iName = "XEngulf_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasSignalKeyBar)
{
//
iDir = marketStructure.signalKeyBarPatternDir;
iName = "SignalKey_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
//
isBullish = IsSpecifiedBullish(iDir);
//
// Retrieve Price Type for Validate ...
iPriceType = isBullish
? X_PRICE_LOW
: X_PRICE_HIGH;
iPrice = bar.GetPrice(iPriceType);
//
// Retrieve MA Band for Validation ...
double iMABandUpper = fima2Signaller.fimaHelper.GetMABandUpper(barIndex);
double iMABandLower = fima2Signaller.fimaHelper.GetMABandLower(barIndex);
//
// Validate ...
has = isBullish
? iPrice < iMABandLower
: iPrice > iMABandUpper;
//
// Check Support and Resistance ...
//
// Support ...
bool hasSupport = marketStructure.support.IsValid();
@@ -1577,6 +1531,97 @@ void HandleSignalLookup(XOHCL &bar)
}
}
//
// Check Bar Pattern Exists ...
has = hasPinnedBar ||
hasEngulfedBar ||
hasFlagPattern ||
hasStarPattern ||
hasSignalKeyBar ||
hasRisingPattern ||
hasPiercingPattern;
//
// Select Pattern Direction and Price and Price Type ...
if (has)
{
//
if (hasPinnedBar)
{
//
iDir = marketStructure.pinnedDir;
iName = "pinned" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasEngulfedBar)
{
//
iDir = marketStructure.engulfedDir;
iName = "engulfed" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasFlagPattern)
{
//
iDir = marketStructure.flagPatternDir;
iName = "flagPattern" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasStarPattern)
{
//
iDir = marketStructure.starPatternDir;
iName = "starPattern" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasSignalKeyBar)
{
//
iDir = marketStructure.risingPatternDir;
iName = "risingPattern" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasRisingPattern)
{
//
iDir = marketStructure.piercingPatternDir;
iName = "piercingPattern" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasPiercingPattern)
{
//
iDir = marketStructure.signalKeyBarPatternDir;
iName = "signalKeyBarPattern" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
//
isBullish = IsSpecifiedBullish(iDir);
//
// Retrieve Price Type for Validate ...
iPriceType = isBullish
? X_PRICE_LOW
: X_PRICE_HIGH;
iPrice = bar.GetPrice(iPriceType);
//
has = HasDirection(iDir);
}
//
// Validate Patterns based on MA Band ...
if (has)
{
//
// Retrieve MA Band for Validation ...
double iMABandUpper = fima2Signaller.fimaHelper.GetMABandUpper(barIndex);
double iMABandLower = fima2Signaller.fimaHelper.GetMABandLower(barIndex);
//
// Validate ...
has = isBullish
? iPrice < iMABandLower
: iPrice > iMABandUpper;
}
//
// Select a Zone which Price inside it ...
//
// Validate Happens in Zone ...
int insideZoneIDX = -1;
@@ -1591,10 +1636,35 @@ void HandleSignalLookup(XOHCL &bar)
insideZoneIDX,
bar,
resistances //
)) &&
IsValidIndex(insideZoneIDX);
));
//
// Validate Selected Inside Zone ...
// whith Bars Edge ...
has = IsValidIndex(insideZoneIDX);
if (has)
{
//
if (isBullish)
{
iZone = supports[insideZoneIDX];
}
else
{
iZone = resistances[insideZoneIDX];
}
//
has = isBullish
? bar.high > supports[insideZoneIDX].upper
: bar.low < resistances[insideZoneIDX].lower;
}
//
// Checking Liquidities ...
//
// Draw Selected and Validated Bar and Selected Zone ...
if (has)
{
//
@@ -1606,10 +1676,15 @@ void HandleSignalLookup(XOHCL &bar)
ENUM_ARROW_ANCHOR iAnchor = isBullish
? ANCHOR_TOP
: ANCHOR_BOTTOM;
XCBarArrowObject *iObj;
//
XCBoxObject *iZoneObj;
XCBarArrowObject *iPatternObj;
//
has = fima2Signaller.poiDrawer.DrawBarArrow(
bar,
iObj,
iPatternObj,
iPriceType,
iCode,
iClr,
@@ -1622,20 +1697,97 @@ void HandleSignalLookup(XOHCL &bar)
if (has)
{
}
}
}
//
// Checking Liquidities ...
//
has = fima2Signaller.poiDrawer.DrawBox(
iZone,
iZoneObj,
true, // Ignore At ...
iZone.type // Name ...
);
if (has)
{
//
XPOIStyle iStyle;
fima2Signaller.poiDrawer.GetBoxStyle(
iStyle,
iZone.dir //
);
iStyle.width = 2;
iStyle.clr = iClr;
fima2Signaller.poiDrawer.ApplyBoxStyle(
iZoneObj,
iStyle //
);
}
}
//
// Preparing Signal ...
if (has)
{
//
iSignal.time = bar.time;
iSignal.provider = "XFima";
iSignal.symbol = bar.symbol;
iSignal.period = bar.period;
iSignal.mode = X_ORDER_MODE_MARKET;
iSignal.entry = GetEntry(bar.symbol, iDir);
iSignal.type = isBullish
? POSITION_TYPE_BUY
: POSITION_TYPE_SELL;
//
iSignal.volume = 0.01;
//
double _r2r = 2.0;
double _slDistanceInPoint = 5;
double _point = GetPoints(iSignal.symbol);
double _riskDistance = _slDistanceInPoint * _point;
double _risk = _riskDistance + MathAbs((isBullish ? iZone.lower : iZone.upper) - iSignal.entry);
double _reward = GetSpread(iSignal.symbol) + (_risk * _r2r);
//
double sl = isBullish
? iSignal.entry - _risk
: iSignal.entry + _risk;
double tp = isBullish
? iSignal.entry + _reward
: iSignal.entry - _reward;
//
iSignal.sl = sl;
iSignal.tp = tp;
//
has = iSignal.IsValid();
if (has)
{
//
XCSignalObject *iSignalObj;
has = fima2Signaller.poiDrawer.DrawSignal(
iSignal,
iSignalObj,
7 //
);
}
}
//
// For Logging ...
if (has)
{
//
ENUM_X_SIGNAL_EXECUTION_RESULT eResult;
has = eaExpert.eaTrader.ExecuteSignal(iSignal, eResult);
Print("Detect a Potential Place for Price Movement: ", ToXString(iDir), ", Time: ", bar.time);
}
//
// Cleanup Resources ...
iZone.Clean();
iSignal.Clean();
SpecifiedClean(supports);
SpecifiedClean(resistances);
}