This commit is contained in:
2025-09-07 19:25:16 +03:30
parent 5987194e51
commit 4b333d7f76
4 changed files with 239 additions and 118 deletions
+33 -21
View File
@@ -195,6 +195,18 @@ int OnInit()
eaExpert.eaSaveLosts = eaSaveLosts; eaExpert.eaSaveLosts = eaSaveLosts;
eaExpert.eaSaveRestrictions = eaSaveRestrictions; eaExpert.eaSaveRestrictions = eaSaveRestrictions;
//
// Attach Event Handlers ...
eaExpert.AddOnDealsChangedEventHandler(OnDealsChanged);
eaExpert.AddOnStopLossEventHandler(OnStopLossTriggered);
eaExpert.AddOnOrdersChangedEventHandler(OnOrdersChanged);
eaExpert.AddOnTakeProfitEventHandler(OnTakeProfitTriggered);
eaExpert.AddOnModifyPositionEventHandler(OnPositionModified);
eaExpert.AddOnPositionsChangedEventHandler(OnPositionsChanged);
eaExpert.AddOnTradeStateChangedEventHandler(OnTradeStateChanged);
eaExpert.AddOnForceClosePositionEventHandler(OnPositionForceClosed);
eaExpert.AddOnPartialClosePositionEventHandler(OnPositionPartialClosed);
// //
// Try to Initialize eaExpert ... // Try to Initialize eaExpert ...
bool isInited = eaExpert.HandleOnInit(); bool isInited = eaExpert.HandleOnInit();
@@ -278,7 +290,7 @@ void OnChartEvent(
*/ */
void OnStopLossTriggered(const XDeal &deal) void OnStopLossTriggered(const XDeal &deal)
{ {
// eaExpert.HandleOnStopLossTriggered(deal); eaExpert.HandleOnStopLossTriggered(deal);
} }
/** /**
@@ -288,7 +300,7 @@ void OnStopLossTriggered(const XDeal &deal)
*/ */
void OnTakeProfitTriggered(const XDeal &deal) void OnTakeProfitTriggered(const XDeal &deal)
{ {
// eaExpert.HandleOnTakeProfitTriggered(deal); eaExpert.HandleOnTakeProfitTriggered(deal);
} }
/** /**
@@ -305,11 +317,11 @@ void OnPositionForceClosed(
) )
{ {
// //
// eaExpert.HandleOnPositionForceClosed( eaExpert.HandleOnPositionForceClosed(
// ticket, ticket,
// position, position,
// comment // comment //
// ); );
} }
/** /**
@@ -319,7 +331,7 @@ void OnPositionForceClosed(
*/ */
void OnDealsChanged(int count) void OnDealsChanged(int count)
{ {
// eaExpert.HandleOnDealsChanged(count); eaExpert.HandleOnDealsChanged(count);
} }
/** /**
@@ -329,7 +341,7 @@ void OnDealsChanged(int count)
*/ */
void OnOrdersChanged(int count) void OnOrdersChanged(int count)
{ {
// eaExpert.HandleOnOrdersChanged(count); eaExpert.HandleOnOrdersChanged(count);
} }
/** /**
@@ -339,7 +351,7 @@ void OnOrdersChanged(int count)
*/ */
void OnPositionsChanged(int count) void OnPositionsChanged(int count)
{ {
// eaExpert.HandleOnPositionsChanged(count); eaExpert.HandleOnPositionsChanged(count);
} }
/** /**
@@ -356,11 +368,11 @@ void OnPositionModified(
) )
{ {
// //
// eaExpert.HandleOnPositionModified( eaExpert.HandleOnPositionModified(
// ticket, ticket,
// profit, profit,
// comment // comment //
// ); );
} }
/** /**
@@ -377,11 +389,11 @@ void OnPositionPartialClosed(
) )
{ {
// //
// eaExpert.HandleOnPositionPartialClosed( eaExpert.HandleOnPositionPartialClosed(
// ticket, ticket,
// profit, profit,
// comment // comment //
// ); );
} }
/** /**
@@ -391,7 +403,7 @@ void OnPositionPartialClosed(
*/ */
void OnTradeStateChanged(const XOnTradeHandlerState &state) void OnTradeStateChanged(const XOnTradeHandlerState &state)
{ {
// eaExpert.HandleOnTradeStateChanged(state); eaExpert.HandleOnTradeStateChanged(state);
} }
// //
+1 -1
View File
@@ -543,7 +543,7 @@ class XCXOM1EAExpert : public XCBase
// Configure Indicator ... // Configure Indicator ...
XOM1Inputs iDZoneOMInputs; XOM1Inputs iDZoneOMInputs;
iDZoneOMInputs.Default(); iDZoneOMInputs.Default();
iDZoneOMInputs.showFiboZone = false; iDZoneOMInputs.showFiboZone = true;
// //
// Configure Signaller ... // Configure Signaller ...
+191 -68
View File
@@ -257,85 +257,209 @@ class XCXOM1SignallerBase
int p2Idx = pIdx + 1; int p2Idx = pIdx + 1;
// //
// Check New Peak or Vale Happens ... // Check Zones Flags ...
// New Peak Under Last ... bool checkPVZones = false;
// New Vale Over Last ... bool checkMAZones = true;
bool isValeReason = iConditions.valeBuffer[cIdx] > iConditions.valeBuffer[pIdx];
bool isPeakReason = iConditions.peakBuffer[cIdx] < iConditions.peakBuffer[pIdx]; //
has = isValeReason || isPeakReason; // Check PV Zones ...
if (!has) if (checkPVZones)
{ {
// //
iBar.Clean(); // Check New Peak or Vale Happens ...
iConditions.Clean();
return; //
// New Vale Over Last ...
bool isValeReason = iConditions.valeBuffer[cIdx] > iConditions.valeBuffer[pIdx];
//
// New Peak Under Last ...
bool isPeakReason = iConditions.peakBuffer[cIdx] < iConditions.peakBuffer[pIdx];
//
has = isValeReason || isPeakReason;
if (has)
{
//
// Prepare Reason ...
ENUM_XOM1_ZONE_REASON iReason = isValeReason
? X_OM1_ZONE_REASON_VALE
: X_OM1_ZONE_REASON_PEAK;
//
// Extract Upper / Lower Values ...
double iUpper = iConditions.peakBuffer[pIdx];
double iLower = iConditions.valeBuffer[pIdx];
//
// Calculate Mid Range ...
double iMiddle = iLower + ((iUpper - iLower) / 2);
if (iMiddle > 0)
{
iMiddle = NormalizePrice(iMiddle, symbol);
}
//
// Detect Reason Price ...
double iPrice =
isValeReason
? iConditions.valeBuffer[cIdx]
: iConditions.peakBuffer[cIdx];
if (iPrice > 0)
{
iPrice = NormalizePrice(iPrice, symbol);
}
//
// Detect Reason Direction ...
ENUM_X_DIRECTION iDir = iPrice > iMiddle
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
// Try to Initialize Zone ...
XOM1Zone iZone;
has = iZone.Init(
symbol,
period,
name, // Signaller Name ...
iUpper,
iLower,
iPrice,
iDir,
iReason,
iConditions.bars[pIdx].time, // From ...
iConditions.bars[cIdx].time // To
);
if (has)
{
//
// Add New Detected Zone to Zones ...
AddRef(
iZone,
zones //
);
}
//
iZone.Clean();
}
} }
// //
// Prepare Reason ... // Check MA Zones ...
ENUM_XOM1_ZONE_REASON iReason = isValeReason if (checkMAZones)
? X_OM1_ZONE_REASON_VALE
: X_OM1_ZONE_REASON_PEAK;
//
// Extract Upper / Lower Values ...
double iUpper = iConditions.peakBuffer[pIdx];
double iLower = iConditions.valeBuffer[pIdx];
//
// Calculate Mid Range ...
double iMiddle = iLower + ((iUpper - iLower) / 2);
if (iMiddle > 0)
{
iMiddle = NormalizePrice(iMiddle, symbol);
}
//
// Detect Reason Price ...
double iPrice =
isValeReason
? iConditions.valeBuffer[cIdx]
: iConditions.peakBuffer[cIdx];
if (iPrice > 0)
{
iPrice = NormalizePrice(iPrice, symbol);
}
//
// Detect Reason Direction ...
ENUM_X_DIRECTION iDir = iPrice > iMiddle
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
// Try to Initialize Zone ...
XOM1Zone iZone;
has = iZone.Init(
symbol,
period,
name, // Signaller Name ...
iUpper,
iLower,
iPrice,
iDir,
iReason,
iConditions.bars[pIdx].time, // From ...
iConditions.bars[cIdx].time // To
);
if (has)
{ {
// //
// Add New Detected Zone to Zones ... // Crossed Over ...
AddRef( bool isFastCrossedOverSlow = iConditions.maFastBuffer[cIdx] > iConditions.maSlowBuffer[cIdx] &&
iZone, !(iConditions.maFastBuffer[pIdx] >= iConditions.maSlowBuffer[pIdx]);
zones //
); //
// Crossed Under ...
bool isFastCrossedUnderSlow = iConditions.maFastBuffer[cIdx] < iConditions.maSlowBuffer[cIdx] &&
!(iConditions.maFastBuffer[pIdx] <= iConditions.maSlowBuffer[pIdx]);
//
double iFast = iConditions.maFastBuffer[cIdx];
double iSlow = iConditions.maSlowBuffer[cIdx];
double iFibUpper = iConditions.fiboUpperBuffer[cIdx];
double iFibLower = iConditions.fiboLowerBuffer[cIdx];
//
double iValues[] = {
iFast,
iSlow,
iFibUpper,
iFibLower //
};
//
// Extract Upper / Lower Values ...
double iUpper = GetMax(iValues);
double iLower = GetMin(iValues);
//
has = isFastCrossedOverSlow || isFastCrossedUnderSlow;
//
// Validate Cross Between Zone ...
if (has)
{
//
has = iFast >= iLower &&
iFast <= iUpper &&
iSlow >= iLower &&
iSlow <= iUpper;
}
//
if (has)
{
//
// Prepare Reason ...
ENUM_XOM1_ZONE_REASON iReason = isFastCrossedOverSlow
? X_OM1_ZONE_REASON_FCOS
: X_OM1_ZONE_REASON_FCUS;
//
// Calculate Mid Range ...
double iMiddle = iLower + ((iUpper - iLower) / 2);
if (iMiddle > 0)
{
iMiddle = NormalizePrice(iMiddle, symbol);
}
//
// Detect Reason Price ...
double iPrice = iConditions.maFastBuffer[cIdx];
if (iPrice > 0)
{
iPrice = NormalizePrice(iPrice, symbol);
}
//
// Detect Reason Direction ...
ENUM_X_DIRECTION iDir = isFastCrossedOverSlow
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
// Try to Initialize Zone ...
XOM1Zone iZone;
has = iZone.Init(
symbol,
period,
name, // Signaller Name ...
iUpper,
iLower,
iPrice,
iDir,
iReason,
iConditions.bars[pIdx].time, // From ...
iConditions.bars[cIdx].time // To
);
if (has)
{
//
// Add New Detected Zone to Zones ...
AddRef(
iZone,
zones //
);
}
//
iZone.Clean();
}
//
Clean(iValues);
} }
// //
// Clean Resources ... // Clean Resources ...
iBar.Clean(); iBar.Clean();
iZone.Clean();
iConditions.Clean(); iConditions.Clean();
} }
@@ -419,7 +543,6 @@ class XCXOM1SignallerBase
// //
} }
} }
}; };
// //
+14 -28
View File
@@ -32,9 +32,11 @@
// Zone Creation Reason ... // Zone Creation Reason ...
enum ENUM_XOM1_ZONE_REASON enum ENUM_XOM1_ZONE_REASON
{ {
X_OM1_ZONE_REASON_NONE, X_OM1_ZONE_REASON_NONE, // NONE
X_OM1_ZONE_REASON_PEAK, X_OM1_ZONE_REASON_PEAK, // PEAK
X_OM1_ZONE_REASON_VALE X_OM1_ZONE_REASON_VALE, // VALE
X_OM1_ZONE_REASON_FCOS, // FCOS
X_OM1_ZONE_REASON_FCUS, // FCUS
}; };
/** /**
@@ -65,31 +67,7 @@ bool IsXValid(ENUM_XOM1_ZONE_REASON value)
*/ */
string ToXString(ENUM_XOM1_ZONE_REASON value) string ToXString(ENUM_XOM1_ZONE_REASON value)
{ {
// return EnumToString(value);
string result = NULL;
//
if (!IsXValid(value))
{
return result;
}
//
switch (value)
{
//
case X_OM1_ZONE_REASON_PEAK:
result = "PEAK";
break;
//
case X_OM1_ZONE_REASON_VALE:
result = "VALE";
break;
}
//
return result;
} }
/** /**
@@ -123,6 +101,14 @@ ENUM_XOM1_ZONE_REASON FromXString(string value)
{ {
result = X_OM1_ZONE_REASON_VALE; result = X_OM1_ZONE_REASON_VALE;
} }
else if (value == ToXString(X_OM1_ZONE_REASON_FCOS))
{
result = X_OM1_ZONE_REASON_FCOS;
}
else if (value == ToXString(X_OM1_ZONE_REASON_FCUS))
{
result = X_OM1_ZONE_REASON_FCUS;
}
// //
return result; return result;