This commit is contained in:
2025-09-29 16:22:30 +03:30
parent 57be148292
commit fd82d07995
5 changed files with 4238 additions and 215 deletions
File diff suppressed because it is too large Load Diff
+16 -6
View File
@@ -453,11 +453,15 @@ void OnTick()
} }
// //
// fima1Signaller.OnTick(); // Bar Index ...
fima2Signaller.OnTick(); int barIndex = 1;
// //
AnalyseMarket(1); // fima1Signaller.OnTick(barIndex);
fima2Signaller.OnTick(barIndex);
//
// AnalyseMarket(barIndex);
} }
// //
@@ -613,7 +617,7 @@ void OnSignalTriggered(XSignal &signal)
// //
// TODO: Fix this ... // TODO: Fix this ...
return; // return;
// //
// Draw Signal on Chart ... // Draw Signal on Chart ...
@@ -627,6 +631,12 @@ void OnSignalTriggered(XSignal &signal)
// //
if (has) if (has)
{ {
//
ENUM_X_SIGNAL_EXECUTION_RESULT result;
eaExpert.eaTrader.ExecuteSignal(
signal,
result //
);
Print("Signal Issued: ", signal.GetObjectID()); Print("Signal Issued: ", signal.GetObjectID());
} }
@@ -923,8 +933,8 @@ void AnalyseMarket(int barIndex = 0)
); );
// //
// XFIMASIgballer2First(bar); XFIMASIgballer2First(bar);
HandleLookupSignal(bar); // HandleLookupSignal(bar);
// //
bar.Clean(); bar.Clean();
@@ -83,6 +83,10 @@ bool IsValid(string value)
// //
return result; return result;
} }
bool IsXValid(string value)
{
return IsValid(value);
}
bool IsSpecifiedValid(string value) bool IsSpecifiedValid(string value)
{ {
return IsValid(value); return IsValid(value);
@@ -106,6 +110,10 @@ bool IsValid(datetime value)
// //
return result; return result;
} }
bool IsXValid(datetime value)
{
return IsValid(value);
}
bool IsSpecifiedValid(datetime value) bool IsSpecifiedValid(datetime value)
{ {
return IsValid(value); return IsValid(value);
@@ -133,6 +141,11 @@ bool IsValid(ENUM_TIMEFRAMES value)
// //
return result; return result;
} }
bool IsXValid(ENUM_TIMEFRAMES value)
{
//
return IsValid(value);
}
bool IsSpecifiedValid(ENUM_TIMEFRAMES value) bool IsSpecifiedValid(ENUM_TIMEFRAMES value)
{ {
// //
@@ -171,6 +184,16 @@ bool IsValid(
// //
return result; return result;
} }
bool IsXValid(
ENUM_X_PERIOD_METHOD mMethod,
ENUM_TIMEFRAMES mPeriod //
)
{
return IsValid(
mMethod,
mPeriod //
);
}
bool IsSpecifiedValid( bool IsSpecifiedValid(
ENUM_X_PERIOD_METHOD mMethod, ENUM_X_PERIOD_METHOD mMethod,
ENUM_TIMEFRAMES mPeriod // ENUM_TIMEFRAMES mPeriod //
+34
View File
@@ -346,6 +346,10 @@ bool IsValid(ENUM_X_BOUNDARY_PRICE value)
// //
return result; return result;
} }
bool IsXValid(ENUM_X_BOUNDARY_PRICE value)
{
return IsValid(value);
}
bool IsSpecifiedValid(ENUM_X_BOUNDARY_PRICE value) bool IsSpecifiedValid(ENUM_X_BOUNDARY_PRICE value)
{ {
return IsValid(value); return IsValid(value);
@@ -417,6 +421,10 @@ bool IsValid(ENUM_X_DIRECTION value)
// //
return result; return result;
} }
bool IsXValid(ENUM_X_DIRECTION value)
{
return IsValid(value);
}
bool IsSpecifiedValid(ENUM_X_DIRECTION value) bool IsSpecifiedValid(ENUM_X_DIRECTION value)
{ {
return IsValid(value); return IsValid(value);
@@ -460,6 +468,17 @@ bool IsBullish(ENUM_X_DIRECTION value)
// //
return result; return result;
} }
bool IsXBullish(ENUM_X_DIRECTION value)
{
//
bool result = false;
//
result = value == X_DIRECTION_BULLISH;
//
return result;
}
bool IsSpecifiedBullish(ENUM_X_DIRECTION value) bool IsSpecifiedBullish(ENUM_X_DIRECTION value)
{ {
// //
@@ -490,6 +509,17 @@ bool IsBearish(ENUM_X_DIRECTION value)
// //
return result; return result;
} }
bool IsXBearish(ENUM_X_DIRECTION value)
{
//
bool result = false;
//
result = value == X_DIRECTION_BEARISH;
//
return result;
}
bool IsSpecifiedBearish(ENUM_X_DIRECTION value) bool IsSpecifiedBearish(ENUM_X_DIRECTION value)
{ {
// //
@@ -943,6 +973,10 @@ bool IsValid(ENUM_X_MARKET_CYCLES value)
// //
return result; return result;
} }
bool IsXValid(ENUM_X_MARKET_CYCLES value)
{
return IsValid(value);
}
bool IsSpecifiedValid(ENUM_X_MARKET_CYCLES value) bool IsSpecifiedValid(ENUM_X_MARKET_CYCLES value)
{ {
return IsValid(value); return IsValid(value);
@@ -617,7 +617,7 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
XBoxZone iZone; XBoxZone iZone;
int count = 0; int count = 0;
bool has = false; bool has = false;
int cIdx = barIndex + 1; int cIdx = 0;
int pIdx = cIdx + 1; int pIdx = cIdx + 1;
string iName = NULL; string iName = NULL;
XBoxZone supports[]; XBoxZone supports[];
@@ -625,10 +625,12 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
bool isBullish = false; bool isBullish = false;
bool isBearish = false; bool isBearish = false;
double iPrice = EMPTY_VALUE; double iPrice = EMPTY_VALUE;
double iPriceEdge = EMPTY_VALUE;
XFIMAMarketStructure structure; XFIMAMarketStructure structure;
XFIMAConditions fimaConditions; XFIMAConditions fimaConditions;
ENUM_X_PRICE iPriceType = X_PRICE_NONE; ENUM_X_PRICE iPriceType = X_PRICE_NONE;
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE; ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
ENUM_X_PRICE iPriceEdgeType = X_PRICE_NONE;
// //
XPivot pvPivots[]; XPivot pvPivots[];
@@ -647,7 +649,7 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
has = bar.Init( has = bar.Init(
symbol, symbol,
period, period,
cIdx // barIndex //
); );
if (!has) if (!has)
{ {
@@ -681,118 +683,6 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
analyserConfig // analyserConfig //
); );
//
// Check Required Pattern Exists ...
bool hasPinnedBar = HasDirection(structure.pinnedDir);
bool hasEngulfedBar = HasDirection(structure.engulfedDir);
bool hasFlagPattern = HasDirection(structure.flagPatternDir);
bool hasStarPattern = HasDirection(structure.starPatternDir);
bool hasRisingPattern = HasDirection(structure.risingPatternDir);
bool hasPiercingPattern = HasDirection(structure.piercingPatternDir);
bool hasSignalKeyBar = HasDirection(structure.signalKeyBarPatternDir);
//
// 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 = structure.pinnedDir;
iName = "XPinned_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasEngulfedBar)
{
//
iDir = structure.engulfedDir;
iName = "XEngulfed_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasFlagPattern)
{
//
iDir = structure.flagPatternDir;
iName = "XFlag_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasStarPattern)
{
//
iDir = structure.starPatternDir;
iName = "XStar_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasSignalKeyBar)
{
//
iDir = structure.risingPatternDir;
iName = "XRising_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasRisingPattern)
{
//
iDir = structure.piercingPatternDir;
iName = "XPiercing_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasPiercingPattern)
{
//
iDir = structure.signalKeyBarPatternDir;
iName = "XSignalKey_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
//
isBullish = IsSpecifiedBullish(iDir);
isBearish = IsSpecifiedBearish(iDir);
//
// Retrieve Price Type for Validate ...
iPriceType = isBullish
? X_PRICE_LOW
: X_PRICE_HIGH;
iPrice = bar.GetPrice(iPriceType);
//
has = HasDirection(iDir);
}
//
// Chekc Bullish or Bearish Starter Conditions Exists ...
has =
isBullish ||
isBearish;
if (has)
{
//
// Do Conditions Validating ...
//
// Retrieve MA Band for Validation ...
double iMABandUpper = fimaHelper.GetMABandUpper(barIndex);
double iMABandLower = fimaHelper.GetMABandLower(barIndex);
//
// Validate ...
has = isBullish
? iPrice < iMABandLower
: iPrice > iMABandUpper;
if (!has)
{
//
isBullish = false;
isBearish = false;
iDir = X_DIRECTION_NONE;
}
}
// //
// Collect Support and Resistance Zones and Validate by them ... // Collect Support and Resistance Zones and Validate by them ...
@@ -813,26 +703,6 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
supportBox, supportBox,
supports // supports //
); );
// has = poiDrawer.DrawBox(
// supportBox,
// iSupportObj,
// true, // Ignore At ...
// supportBox.type // Name ...
// );
// if (has)
// {
// //
// XPOIStyle iStyle;
// poiDrawer.GetBoxStyle(
// iStyle,
// supportBox.dir //
// );
// poiDrawer.ApplyBoxStyle(
// iSupportObj,
// iStyle //
// );
// iStyle.Clean();
// }
} }
// //
@@ -847,26 +717,6 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
resistanceBox, resistanceBox,
supports // supports //
); );
// has = poiDrawer.DrawBox(
// resistanceBox,
// iResistanceObj,
// true, // Ignore At ...
// resistanceBox.type // Name ...
// );
// if (has)
// {
// //
// XPOIStyle iStyle;
// poiDrawer.GetBoxStyle(
// iStyle,
// resistanceBox.dir //
// );
// poiDrawer.ApplyBoxStyle(
// iResistanceObj,
// iStyle //
// );
// iStyle.Clean();
// }
} }
// //
@@ -1296,15 +1146,6 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
structure.support, structure.support,
supports // supports //
); );
// //
// XCBoxObject *iObj;
// has = fima2Signaller.poiDrawer.DrawBox(
// structure.support,
// iObj);
// if (has)
// {
// }
} }
// //
@@ -1317,53 +1158,99 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
structure.resistance, structure.resistance,
resistances // resistances //
); );
// //
// XCBoxObject *iObj;
// has = fima2Signaller.poiDrawer.DrawBox(
// structure.resistance,
// iObj);
// if (has)
// {
// }
} }
// //
// Validate Positions Support and Resistance Zone ... // Check Required Pattern Exists ...
int insideZoneIDX = -1; bool hasPinnedBar = HasDirection(structure.pinnedDir);
has = has && bool hasEngulfedBar = HasDirection(structure.engulfedDir);
(isBullish bool hasFlagPattern = HasDirection(structure.flagPatternDir);
? HasInside( bool hasStarPattern = HasDirection(structure.starPatternDir);
insideZoneIDX, bool hasRisingPattern = HasDirection(structure.risingPatternDir);
bar, bool hasPiercingPattern = HasDirection(structure.piercingPatternDir);
supports // bool hasSignalKeyBar = HasDirection(structure.signalKeyBarPatternDir);
)
: HasInside(
insideZoneIDX,
bar,
resistances //
));
// //
// Validate Selected Inside Zone ... // Check Bar Pattern Exists ...
// whith Bars Edge ... // and Select Pattern Direction and Price and Price Type ...
has = IsValidIndex(insideZoneIDX); has = hasPinnedBar ||
hasEngulfedBar ||
hasFlagPattern ||
hasStarPattern ||
hasSignalKeyBar ||
hasRisingPattern ||
hasPiercingPattern;
if (has) if (has)
{ {
// //
if (isBullish) if (hasPinnedBar)
{ {
iZone = supports[insideZoneIDX]; //
iDir = structure.pinnedDir;
iName = "XPinned_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
} }
else else if (hasEngulfedBar)
{ {
iZone = resistances[insideZoneIDX]; //
iDir = structure.engulfedDir;
iName = "XEngulfed_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasFlagPattern)
{
//
iDir = structure.flagPatternDir;
iName = "XFlag_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasStarPattern)
{
//
iDir = structure.starPatternDir;
iName = "XStar_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasSignalKeyBar)
{
//
iDir = structure.risingPatternDir;
iName = "XRising_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasRisingPattern)
{
//
iDir = structure.piercingPatternDir;
iName = "XPiercing_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
}
else if (hasPiercingPattern)
{
//
iDir = structure.signalKeyBarPatternDir;
iName = "XSignalKey_" + ToXString(iDir) + ToXString(TimeToSeconds(bar.time));
} }
// //
has = isBullish isBullish = IsSpecifiedBullish(iDir);
? bar.high > supports[insideZoneIDX].upper isBearish = IsSpecifiedBearish(iDir);
: bar.low < resistances[insideZoneIDX].lower;
//
// Retrieve Price Type for Validate ...
iPriceType = isBullish
? X_PRICE_DOWN
: X_PRICE_UP;
iPriceEdgeType = isBullish
? X_PRICE_LOW
: X_PRICE_HIGH;
//
iPrice = bar.GetPrice(iPriceType);
iPriceEdge = bar.GetPrice(iPriceEdgeType);
//
// Validate Calculations ...
has = HasDirection(iDir) &&
(isBullish ||
isBearish) &&
NotEmptyZero(iPrice) &&
NotEmptyZero(iPriceEdge) &&
iPrice != iPriceEdge;
if (!has) if (!has)
{ {
// //
@@ -1372,21 +1259,24 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
iDir = X_DIRECTION_NONE; iDir = X_DIRECTION_NONE;
} }
} }
else
{
//
isBullish = false;
isBearish = false;
iDir = X_DIRECTION_NONE;
}
// //
// Checking Liquidities ... // Strategy 1 ...
has = Strategy1HasSignal(
bar,
iZone,
iName,
supports,
resistances,
iDir,
structure,
fimaConditions //
);
// //
// Do all Draws Here ... // Do all Draws Here ...
bool canDraw = false; bool canDraw = true;
if (canDraw) if (canDraw && has)
{ {
// //
int iWidth = 2; int iWidth = 2;
@@ -1548,7 +1438,7 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
has = poiDrawer.DrawBarArrow( has = poiDrawer.DrawBarArrow(
bar, bar,
iPatternObj, iPatternObj,
iPriceType, iPriceEdgeType,
iCode, iCode,
iClr, iClr,
iWidth, iWidth,
@@ -1561,8 +1451,6 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
} }
// //
// Check Signal Founded ...
has = HasDirection(iDir);
if (has) if (has)
{ {
// //
@@ -1638,6 +1526,270 @@ class XCXFIMAStrategy2Signaller : public XCXFIMABaseSignaller
// //
// Props ... // Props ...
//
// Implementing Strategies ...
/**
* Validate a Pattern based on MA Band ...
*
* @param bar: XOHCL, reference to Pattern Bar ...
* @param patternName: string, detected pattern's name ...
* @param patternDir: ENUM_X_DIRECTION, detected pattern's direction ...
* @param fimaConditions: XFIMAConditions, reference to Bar Specified XFIMA Conditions ...
*
* @return ( bool )
*/
bool ValidatePatternBasedOnMABand(
XOHCL &bar,
string patternName,
ENUM_X_DIRECTION patternDir,
XFIMAConditions &fimaConditions //
)
{
//
bool result = false;
//
// Validate ...
result = bar.IsValid() &&
IsXValid(patternName) &&
HasDirection(patternDir);
if (!result)
{
return result;
}
//
// Define Requirements ...
bool isBullish = false;
bool isBearish = false;
double iPrice = EMPTY_VALUE;
double iPriceEdge = EMPTY_VALUE;
ENUM_X_PRICE iPriceType = X_PRICE_NONE;
ENUM_X_PRICE iPriceEdgeType = X_PRICE_NONE;
//
// Calculating Price and Price Types ...
//
isBullish = IsXBullish(patternDir);
isBearish = IsXBearish(patternDir);
//
iPriceType = isBullish
? X_PRICE_DOWN
: X_PRICE_UP;
//
iPriceEdgeType = isBullish
? X_PRICE_LOW
: X_PRICE_HIGH;
//
iPrice = bar.GetPrice(iPriceType);
iPriceEdge = bar.GetPrice(iPriceEdgeType);
//
// Validate ...
result =
NotEmptyZero(iPrice) &&
IsXValid(iPriceType) &&
NotEmptyZero(iPriceEdge) &&
IsXValid(iPriceEdgeType) &&
((isBullish && !isBearish) ||
(isBearish && !isBullish));
if (!result)
{
return result;
}
//
// Validate Pattern based on MA Band ...
//
// Retrieve MA Band for Validation ...
double iMABandUpper = fimaConditions.maBandUpperBuffer[0];
double iMABandLower = fimaConditions.maBandLowerBuffer[0];
//
// Validate by Edge Price ...
result =
NotEmptyZero(iMABandUpper) &&
NotEmptyZero(iMABandLower) &&
(isBullish
? iPriceEdge < iMABandLower
: iPriceEdge > iMABandUpper);
if (!result)
{
return result;
}
//
return result;
}
/**
* Check Pattern Has Signal Based on Strategy 1 ...
*
* @param bar: XOHCL, reference to Pattern Bar ...
* @param iZone: XBoxZone, reference to holds affected zone ...
* @param patternName: string, detected pattern's name ...
* @param supports: XBoxZone, array reference to Provide Exists Supports ...
* @param resistances: XBoxZone, array reference to Provide Exists Resistances ...
* @param patternDir: ENUM_X_DIRECTION, detected pattern's direction ...
* @param structure: XFIMAMarketStructure, refrence to Provides Market Structure ...
* @param fimaConditions: XFIMAConditions, reference to Bar Specified XFIMA Conditions ...
*
* @return ( bool )
*/
bool Strategy1HasSignal(
XOHCL &bar,
XBoxZone &iZone,
string patternName,
XBoxZone &supports[],
XBoxZone &resistances[],
ENUM_X_DIRECTION patternDir,
XFIMAMarketStructure &structure,
XFIMAConditions &fimaConditions //
)
{
//
bool result = false;
//
// Prepare ...
iZone.Clean();
//
// Validate ...
result = bar.IsValid() &&
IsXValid(patternName) &&
HasDirection(patternDir);
if (!result)
{
return result;
}
//
// Validate Pattern Based on MA Band ...
result = ValidatePatternBasedOnMABand(
bar,
patternName,
patternDir,
fimaConditions //
);
if (!result)
{
return result;
}
//
// Check Affected Zone ...
// Select a Support or Resistance ...
int insideZoneIDX = -1;
result =
(IsXBullish(patternDir)
? HasInside(
insideZoneIDX,
bar,
supports //
)
: IsXBearish(patternDir)
? HasInside(
insideZoneIDX,
bar,
resistances //
)
: false //
);
if (!result)
{
return result;
}
//
// Filling Affected Zone ...
// and Validate it ...
if (IsXBullish(patternDir))
{
iZone = supports[insideZoneIDX];
}
else if (IsXBearish(patternDir))
{
iZone = resistances[insideZoneIDX];
}
result = iZone.IsValid();
if (!result)
{
return result;
}
//
// Validate affected Zone based on Pattern's Bar ...
result = IsXBullish(patternDir)
? bar.high > iZone.upper
: IsXBearish(patternDir)
? bar.low < iZone.lower
: false;
//
// Cleanup Resources ...
if (!result)
{
iZone.Clean();
}
//
return result;
}
/**
* Check Pattern Has Signal Based on Strategy 1 ...
*
* @param bar: XOHCL, reference to Pattern Bar ...
* @param iZone: XBoxZone, reference to holds affected zone ...
* @param patternName: string, detected pattern's name ...
* @param supports: XBoxZone, array reference to Provide Exists Supports ...
* @param resistances: XBoxZone, array reference to Provide Exists Resistances ...
* @param patternDir: ENUM_X_DIRECTION, detected pattern's direction ...
* @param fimaConditions: XFIMAConditions, reference to Bar Specified XFIMA Conditions ...
* @param fimaMarketStructure: XFIMAMarketStructure, refrence to Provides Market Structure ...
*
* @return ( bool )
*/
bool Strategy2HasSignal(
XOHCL &bar,
XBoxZone &iZone,
string patternName,
XBoxZone &supports[],
XBoxZone &resistances[],
ENUM_X_DIRECTION patternDir,
XFIMAMarketStructure &structure,
XFIMAConditions &fimaConditions,
XFIMAMarketStructure &fimaMarketStructure //
)
{
//
bool result = false;
//
// Prepare ...
//
// Validate ...
//
// Do Detection ...
//
// Validate result ...
//
// Cleanup Resources ...
//
return result;
}
// //
}; };