This commit is contained in:
2025-09-28 19:25:29 +03:30
parent ca1b313e4c
commit aebb2a5244
+307 -155
View File
@@ -920,6 +920,8 @@ void HandleSignalLookup(XOHCL &bar)
} }
// //
XBoxZone iZone;
XSignal iSignal;
string iName = NULL; string iName = NULL;
XBoxZone supports[]; XBoxZone supports[];
XBoxZone resistances[]; XBoxZone resistances[];
@@ -933,6 +935,10 @@ void HandleSignalLookup(XOHCL &bar)
// Check Required Pattern Exists ... // Check Required Pattern Exists ...
bool hasPinnedBar = HasDirection(marketStructure.pinnedDir); bool hasPinnedBar = HasDirection(marketStructure.pinnedDir);
bool hasEngulfedBar = HasDirection(marketStructure.engulfedDir); 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); bool hasSignalKeyBar = HasDirection(marketStructure.signalKeyBarPatternDir);
// //
@@ -1222,73 +1228,73 @@ void HandleSignalLookup(XOHCL &bar)
{ {
// //
// Support ... // Support ...
// XBoxZone supportBox; XBoxZone supportBox;
// XCBoxObject *iSupportObj; XCBoxObject *iSupportObj;
// has = marketStructure.zigzagAnalysis.HasSupportBox(supportBox); has = marketStructure.zigzagAnalysis.HasSupportBox(supportBox);
// if (has) if (has)
// { {
// // //
// supportBox.to = bar.time; supportBox.to = bar.time;
// AddIfNotExists( AddIfNotExists(
// supportBox, supportBox,
// supports // supports //
// ); );
// has = fima2Signaller.poiDrawer.DrawBox( has = fima2Signaller.poiDrawer.DrawBox(
// supportBox, supportBox,
// iSupportObj, iSupportObj,
// true, // Ignore At ... true, // Ignore At ...
// supportBox.type // Name ... supportBox.type // Name ...
// ); );
// if (has) if (has)
// { {
// // //
// XPOIStyle iStyle; XPOIStyle iStyle;
// fima2Signaller.poiDrawer.GetBoxStyle( fima2Signaller.poiDrawer.GetBoxStyle(
// iStyle, iStyle,
// supportBox.dir // supportBox.dir //
// ); );
// fima2Signaller.poiDrawer.ApplyBoxStyle( fima2Signaller.poiDrawer.ApplyBoxStyle(
// iSupportObj, iSupportObj,
// iStyle // iStyle //
// ); );
// iStyle.Clean(); iStyle.Clean();
// } }
// } }
// //
// Resistance ... // Resistance ...
// XBoxZone resistanceBox; XBoxZone resistanceBox;
// XCBoxObject *iResistanceObj; XCBoxObject *iResistanceObj;
// has = marketStructure.zigzagAnalysis.HasResistanceBox(resistanceBox); has = marketStructure.zigzagAnalysis.HasResistanceBox(resistanceBox);
// if (has) if (has)
// { {
// // //
// resistanceBox.to = bar.time; resistanceBox.to = bar.time;
// AddIfNotExists( AddIfNotExists(
// resistanceBox, resistanceBox,
// supports // supports //
// ); );
// has = fima2Signaller.poiDrawer.DrawBox( has = fima2Signaller.poiDrawer.DrawBox(
// resistanceBox, resistanceBox,
// iResistanceObj, iResistanceObj,
// true, // Ignore At ... true, // Ignore At ...
// resistanceBox.type // Name ... resistanceBox.type // Name ...
// ); );
// if (has) if (has)
// { {
// // //
// XPOIStyle iStyle; XPOIStyle iStyle;
// fima2Signaller.poiDrawer.GetBoxStyle( fima2Signaller.poiDrawer.GetBoxStyle(
// iStyle, iStyle,
// resistanceBox.dir // resistanceBox.dir //
// ); );
// fima2Signaller.poiDrawer.ApplyBoxStyle( fima2Signaller.poiDrawer.ApplyBoxStyle(
// iResistanceObj, iResistanceObj,
// iStyle // iStyle //
// ); );
// iStyle.Clean(); iStyle.Clean();
// } }
// } }
// //
// Pivots ... // Pivots ...
@@ -1484,31 +1490,103 @@ void HandleSignalLookup(XOHCL &bar)
} }
// //
// Selecting Price Type of Bar based on Dir ... // Support ...
bool hasSupport = marketStructure.support.IsValid();
if (hasSupport)
{
//
AddIfNotExists(
marketStructure.support,
supports //
);
//
XCBoxObject *iObj;
has = fima2Signaller.poiDrawer.DrawBox(
marketStructure.support,
iObj);
if (has)
{
}
}
//
// Resistance ...
bool hasResistance = marketStructure.resistance.IsValid();
if (hasResistance)
{
//
AddIfNotExists(
marketStructure.resistance,
resistances //
);
//
XCBoxObject *iObj;
has = fima2Signaller.poiDrawer.DrawBox(
marketStructure.resistance,
iObj);
if (has)
{
}
}
//
// Check Bar Pattern Exists ...
has = hasPinnedBar || has = hasPinnedBar ||
hasEngulfedBar || hasEngulfedBar ||
hasSignalKeyBar; hasFlagPattern ||
hasStarPattern ||
hasSignalKeyBar ||
hasRisingPattern ||
hasPiercingPattern;
//
// Select Pattern Direction and Price and Price Type ...
if (has) if (has)
{ {
// //
// Retrieve Direction ...
if (hasPinnedBar) if (hasPinnedBar)
{ {
// //
iDir = marketStructure.pinnedDir; iDir = marketStructure.pinnedDir;
iName = "XPin_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time)); iName = "pinned" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
} }
else if (hasEngulfedBar) else if (hasEngulfedBar)
{ {
// //
iDir = marketStructure.engulfedDir; iDir = marketStructure.engulfedDir;
iName = "XEngulf_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time)); 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) 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; iDir = marketStructure.signalKeyBarPatternDir;
iName = "SignalKey_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time)); iName = "signalKeyBarPattern" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
} }
// //
@@ -1521,6 +1599,14 @@ void HandleSignalLookup(XOHCL &bar)
: X_PRICE_HIGH; : X_PRICE_HIGH;
iPrice = bar.GetPrice(iPriceType); iPrice = bar.GetPrice(iPriceType);
//
has = HasDirection(iDir);
}
//
// Validate Patterns based on MA Band ...
if (has)
{
// //
// Retrieve MA Band for Validation ... // Retrieve MA Band for Validation ...
double iMABandUpper = fima2Signaller.fimaHelper.GetMABandUpper(barIndex); double iMABandUpper = fima2Signaller.fimaHelper.GetMABandUpper(barIndex);
@@ -1531,111 +1617,177 @@ void HandleSignalLookup(XOHCL &bar)
has = isBullish has = isBullish
? iPrice < iMABandLower ? iPrice < iMABandLower
: iPrice > iMABandUpper; : iPrice > iMABandUpper;
}
// //
// Check Support and Resistance ... // Select a Zone which Price inside it ...
//
// Validate Happens in Zone ...
int insideZoneIDX = -1;
has = has &&
(isBullish
? HasInside(
insideZoneIDX,
bar,
supports //
)
: HasInside(
insideZoneIDX,
bar,
resistances //
));
//
// Validate Selected Inside Zone ...
// whith Bars Edge ...
has = IsValidIndex(insideZoneIDX);
if (has)
{
// //
// Support ... if (isBullish)
bool hasSupport = marketStructure.support.IsValid();
if (hasSupport)
{ {
// iZone = supports[insideZoneIDX];
AddIfNotExists( }
marketStructure.support, else
supports // {
); iZone = resistances[insideZoneIDX];
//
XCBoxObject *iObj;
has = fima2Signaller.poiDrawer.DrawBox(
marketStructure.support,
iObj);
if (has)
{
}
} }
// //
// Resistance ... has = isBullish
bool hasResistance = marketStructure.resistance.IsValid(); ? bar.high > supports[insideZoneIDX].upper
if (hasResistance) : bar.low < resistances[insideZoneIDX].lower;
{
//
AddIfNotExists(
marketStructure.resistance,
resistances //
);
//
XCBoxObject *iObj;
has = fima2Signaller.poiDrawer.DrawBox(
marketStructure.resistance,
iObj);
if (has)
{
}
}
//
// Validate Happens in Zone ...
int insideZoneIDX = -1;
has = has &&
(isBullish
? HasInside(
insideZoneIDX,
bar,
supports //
)
: HasInside(
insideZoneIDX,
bar,
resistances //
)) &&
IsValidIndex(insideZoneIDX);
//
if (has)
{
//
int iWidth = 1;
int iCode = 159;
color iClr = isBullish
? clrYellow
: clrDarkOrange;
ENUM_ARROW_ANCHOR iAnchor = isBullish
? ANCHOR_TOP
: ANCHOR_BOTTOM;
XCBarArrowObject *iObj;
has = fima2Signaller.poiDrawer.DrawBarArrow(
bar,
iObj,
iPriceType,
iCode,
iClr,
iWidth,
iAnchor,
iName,
true, // Ignore Bar Tag ...
10 // Threshold ...
);
if (has)
{
}
}
} }
// //
// Checking Liquidities ... // Checking Liquidities ...
// //
// Draw Selected and Validated Bar and Selected Zone ...
if (has) if (has)
{ {
//
int iWidth = 1;
int iCode = 159;
color iClr = isBullish
? clrYellow
: clrDarkOrange;
ENUM_ARROW_ANCHOR iAnchor = isBullish
? ANCHOR_TOP
: ANCHOR_BOTTOM;
//
XCBoxObject *iZoneObj;
XCBarArrowObject *iPatternObj;
//
has = fima2Signaller.poiDrawer.DrawBarArrow(
bar,
iPatternObj,
iPriceType,
iCode,
iClr,
iWidth,
iAnchor,
iName,
true, // Ignore Bar Tag ...
10 // Threshold ...
);
if (has)
{
}
//
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); Print("Detect a Potential Place for Price Movement: ", ToXString(iDir), ", Time: ", bar.time);
} }
// //
// Cleanup Resources ... // Cleanup Resources ...
iZone.Clean();
iSignal.Clean();
SpecifiedClean(supports); SpecifiedClean(supports);
SpecifiedClean(resistances); SpecifiedClean(resistances);
} }