This commit is contained in:
2025-01-03 20:25:00 +03:30
parent 5f2a2f822e
commit a9ab5a6258
10 changed files with 8609 additions and 4449 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+240
View File
@@ -1851,6 +1851,222 @@ class XCX121Helper : public XCBaseHelper
);
}
//
//
//
//
double GetHigherPeak(
double peak, // Peak Source
int barIndex = 0, // Bar Index
int loopback = 576 // Max Allowed Loopback
)
{
//
double result = 0;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
if (loopback < 576)
{
loopback = 576;
}
//
if (peak <= 0)
{
return result;
}
//
double iValue = 0;
int index = barIndex;
bool canContinue = true;
while (canContinue)
{
//
iValue = GetPeak(index);
if (iValue > peak)
{
//
result = iValue;
break;
}
//
canContinue = index < barIndex + loopback;
index++;
}
//
return result;
}
//
double GetLowerPeak(
double peak, // Peak Source
int barIndex = 0, // Bar Index
int loopback = 576 // Max Allowed Loopback
)
{
//
double result = 0;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
if (loopback < 576)
{
loopback = 576;
}
//
if (peak <= 0)
{
return result;
}
//
double iValue = 0;
int index = barIndex;
bool canContinue = true;
while (canContinue)
{
//
iValue = GetPeak(index);
if (iValue < peak)
{
//
result = iValue;
break;
}
//
canContinue = index < barIndex + loopback;
index++;
}
//
return result;
}
//
double GetHigherVale(
double vale, // Vale Source
int barIndex = 0, // Bar Index
int loopback = 576 // Max Allowed Loopback
)
{
//
double result = 0;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
if (loopback < 576)
{
loopback = 576;
}
//
if (vale <= 0)
{
return result;
}
//
double iValue = 0;
int index = barIndex;
bool canContinue = true;
while (canContinue)
{
//
iValue = GetVale(index);
if (iValue > vale)
{
//
result = iValue;
break;
}
//
canContinue = index > barIndex + loopback;
index++;
}
//
return result;
}
//
double GetLowerVale(
double vale, // Vale Source
int barIndex = 0, // Bar Index
int loopback = 576 // Max Allowed Loopback
)
{
//
double result = 0;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
if (loopback < 576)
{
loopback = 576;
}
//
if (vale <= 0)
{
return result;
}
//
double iValue = 0;
int index = barIndex;
bool canContinue = true;
while (canContinue)
{
//
iValue = GetVale(index);
if (iValue < vale)
{
//
result = iValue;
break;
}
//
canContinue = index > barIndex + loopback;
index++;
}
//
return result;
}
//
//
//
//
double GetLowestPeak(
int barIndex,
@@ -1872,6 +2088,12 @@ class XCX121Helper : public XCBaseHelper
barIndex = 0;
}
//
if (loopback < 576)
{
loopback = 576;
}
//
Calculate();
@@ -1921,6 +2143,12 @@ class XCX121Helper : public XCBaseHelper
barIndex = 0;
}
//
if (loopback < 576)
{
loopback = 576;
}
//
Calculate();
@@ -1970,6 +2198,12 @@ class XCX121Helper : public XCBaseHelper
barIndex = 0;
}
//
if (loopback < 576)
{
loopback = 576;
}
//
Calculate();
@@ -2019,6 +2253,12 @@ class XCX121Helper : public XCBaseHelper
barIndex = 0;
}
//
if (loopback < 576)
{
loopback = 576;
}
//
Calculate();
File diff suppressed because it is too large Load Diff
@@ -27,6 +27,7 @@
#include "../../Classes/x-saherelm.x-bar.analyser.class.mq5"
#include "../../Classes/x-saherelm.x-poi.drawer.class.mq5"
#include "../../Classes/x-saherelm.x-trade.class.mq5"
#include "../Libraries/x-121.smc.lib.mq5"
//
// Definitions ...
@@ -3196,6 +3197,120 @@ class XC121SMCTradeHandler : public XCBaseAlert
return result;
}
/**
* Execute Specific Signal using Trade Handler ...
*
* @param signal: XSignal instance Reference ...
* @param state: ENUM_X_SIGNAL_EXECUTION_RESULT Reference for olding Signal Execution Result Reason ...
* @param ignorePolicies: Boolean ...
*
* @return ( bool )
*/
bool ExecuteSignal(
XSignal &signal, // Signal for Execution
X121SMCStrategyConditions &conditions, // Signal Conditions
ENUM_X_SIGNAL_EXECUTION_RESULT &state, // Execution State
bool ignorePolicies = false // Ignore Execution Policies
)
{
//
bool result = false;
//
// Check Signal Validation ...
result = signal.IsValid() &&
conditions.IsValid();
if (!result)
{
return result;
}
//
// Check Policies ...
if (!ignorePolicies)
{
//
// Filter Signals if Necessary ...
result = CanExecute(
signal,
state //
);
if (!result)
{
//
AlertSignalExecutionFailed(
signal,
state //
);
//
return result;
}
}
//
// Apply Additional Volume to Signal if Provided ...
double additionalVolume = AdditionalVolume();
if (additionalVolume > 0)
{
signal.volume += mAdditionalVolume;
}
//
// Execute Signal ...
result = mTrader.ExecuteSignal(
signal,
state //
);
if (result)
{
//
// Add XTradeHandler Data ...
Add(signal);
if (CanDraw())
{
//
XCSignalObject *iObj;
mDrawer.DrawSignal(signal, iObj);
//
XCBaseObject *conditionsObjects[];
DrawX121SMCStrategyConditions(
conditions,
conditionsObjects,
mDrawer //
);
}
//
// Handle Last Executed Signal ...
HandleSignalExecuted(signal);
//
// Alert Executed Signal ...
string msg = (signal.type == POSITION_TYPE_BUY ? "Long" : "Short") +
" Signal Provided by: " + signal.provider +
(signal.pushers > 1 ? " Pushers: " + ToString(signal.pushers) : "") +
" on: " + signal.symbol +
" in: " + ToString(signal.period) +
" Executed Successfully ...";
Alert(msg);
}
//
if (!result)
{
//
AlertSignalExecutionFailed(
signal,
state //
);
}
//
return result;
}
//
// Timing Actions ...
@@ -810,6 +810,7 @@ class XC121SMCExpert : public XCBaseExpert
ENUM_X_SIGNAL_EXECUTION_RESULT state;
bool isExecuted = mTradeHandler.ExecuteSignal(
signal,
conditions,
state,
false // ignore Policies ...
);
+118 -57
View File
@@ -22,6 +22,7 @@
//
// Imports ...
#include "../../Classes/x-saherelm.base.class.mq5"
#include "../../Classes/x-saherelm.x-poi.drawer.class.mq5"
#include "../../Helpers/x-saherelm.x121.helper.mq5"
#include "../../Libraries/x-saherelm.common.lib.mq5"
#include "../../Libraries/x-saherelm.x-poi.lib.mq5"
@@ -35,12 +36,7 @@ const string X121SMCStrategyToken = "X121SMC";
//
const string X121SMCXTestToken = "X121XTest";
const string X121SMCXPVOBToken = "X121XPVOB";
const string X121SMCXPVDPToken = "X121XPVDP";
const string X121SMCXVWPBToken = "X121XVWPB";
const string X121SMCXTWPVToken = "X121XTWPV";
const string X121SMCXOEPVToken = "X121XOEPV";
const string X121SMCXPVSupDemToken = "X121XPVSUPDEM";
//
// X121 SMC Providers ...
@@ -49,12 +45,7 @@ enum ENUM_X_121_SMC_PROVIDERS
//
X_121_SMC_PROVIDER_NONE,
X_121_SMC_PROVIDER_XTEST,
X_121_SMC_PROVIDER_XPVOB,
X_121_SMC_PROVIDER_XPVDP,
X_121_SMC_PROVIDER_XVWPB,
X_121_SMC_PROVIDER_XTWPV,
X_121_SMC_PROVIDER_XOEPV,
X_121_SMC_PROVIDER_XPVSUPDEM,
};
//
@@ -264,9 +255,11 @@ struct X121SMCStrategyConditions
double target;
string provider;
ENUM_X_DIRECTION signalDir;
ENUM_X_DIRECTION marketStructureDir;
//
XPriceZones priceZones;
XPriceZones decisionZones;
XMarketStructure marketStructure;
//
void X121SMCStrategyConditions()
@@ -292,7 +285,11 @@ struct X121SMCStrategyConditions
tp = 0;
provider = NULL;
signalDir = X_DIRECTION_NONE;
marketStructureDir = X_DIRECTION_NONE;
//
priceZones.Clean();
decisionZones.Clean();
marketStructure.Clean();
}
/**
@@ -503,6 +500,115 @@ struct X121SMCStrategyConditions
//
};
/**
* Draw X121 SMC Conditions ...
*
* @param conditions: X121SMCStrategyConditions instance Reference ...
* @param drawMarketStructure: Boolean ...
* @param drawPriceZones: Boolean ...
* @param drawDecisionZones: Boolean ...
*
* @return ( int )
*/
int DrawX121SMCStrategyConditions(
X121SMCStrategyConditions &conditions,
XCBaseObject *&drawnObjects[],
XCPOIDrawer *drawer,
bool drawMarketStructure = true,
bool drawPriceZones = true,
bool drawDecisionZones = true //
)
{
//
int result = 0;
//
Clean(drawnObjects);
//
if (drawer == NULL ||
!conditions.IsValid() ||
!HasDirection(conditions.signalDir))
{
return result;
}
//
bool isBullish = IsBullish(conditions.signalDir);
//
bool hasPriceZones = conditions.priceZones.IsValid();
if (hasPriceZones &&
drawPriceZones)
{
//
XCBaseObject *objects[];
int objectsCount = drawer.DrawPriceZone(
conditions.priceZones,
objects //
);
if (IsValidSize(objectsCount))
{
//
Copy(
objects,
drawnObjects,
false //
);
}
}
//
bool hasDecisionZones = conditions.decisionZones.IsValid();
if (hasDecisionZones &&
drawDecisionZones)
{
//
XCBaseObject *objects[];
int objectsCount = drawer.DrawPriceZone(
conditions.decisionZones,
objects //
);
if (IsValidSize(objectsCount))
{
//
Copy(
objects,
drawnObjects,
false //
);
}
}
//
bool hasMarketStructure = conditions.marketStructure.IsValid();
if (hasMarketStructure &&
drawMarketStructure)
{
//
XCBaseObject *objects[];
int objectsCount = drawer.DrawMarketStructure(
conditions.marketStructure,
objects //
);
if (IsValidSize(objectsCount))
{
//
Copy(
objects,
drawnObjects,
false //
);
}
}
//
result = ArraySize(drawnObjects);
//
return result;
}
//
//
//
@@ -560,35 +666,10 @@ string ToString(ENUM_X_121_SMC_PROVIDERS value)
result = X121SMCXTestToken;
break;
//
case X_121_SMC_PROVIDER_XPVOB:
result = X121SMCXPVOBToken;
break;
//
case X_121_SMC_PROVIDER_XPVDP:
result = X121SMCXPVDPToken;
break;
//
case X_121_SMC_PROVIDER_XVWPB:
result = X121SMCXVWPBToken;
break;
//
case X_121_SMC_PROVIDER_XTWPV:
result = X121SMCXTWPVToken;
break;
//
case X_121_SMC_PROVIDER_XOEPV:
result = X121SMCXOEPVToken;
break;
//
case X_121_SMC_PROVIDER_XPVSUPDEM:
result = X121SMCXPVSupDemToken;
break;
}
//
@@ -618,30 +699,10 @@ ENUM_X_121_SMC_PROVIDERS ParseProvider(string value)
{
result = X_121_SMC_PROVIDER_XTEST;
}
else if (Contains(X121SMCXPVOBToken, value))
{
result = X_121_SMC_PROVIDER_XPVOB;
}
else if (Contains(X121SMCXPVDPToken, value))
{
result = X_121_SMC_PROVIDER_XPVDP;
}
else if (Contains(X121SMCXVWPBToken, value))
{
result = X_121_SMC_PROVIDER_XVWPB;
}
else if (Contains(X121SMCXTWPVToken, value))
{
result = X_121_SMC_PROVIDER_XTWPV;
}
else if (Contains(X121SMCXOEPVToken, value))
{
result = X_121_SMC_PROVIDER_XOEPV;
}
else if (Contains(X121SMCXPVSupDemToken, value))
{
result = X_121_SMC_PROVIDER_XPVSUPDEM;
}
//
return result;
File diff suppressed because it is too large Load Diff
+15 -79
View File
@@ -285,9 +285,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
{
//
// TODO: Remove this ...
XCSignalObject *iObj;
mPOIDrawer.DrawSignal(signal, iObj);
Print("");
// XCSignalObject *iObj;
// mPOIDrawer.DrawSignal(signal, iObj);
// Print("");
}
//
@@ -495,82 +495,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
setupDir = mXTWPVConditions.dir;
setupTime = mXTWPVConditions.setupTime;
}
//
// Handle Required Drawings ...
bool hasPivot = mXTWPVConditions.HasPivot();
bool hasPriceInsideZone = mXTWPVConditions.HasPriceInsideZones();
bool hasConsolidationZone = mXTWPVConditions.HasConsolidationZone();
bool canDraw = hasPivot ||
hasPriceInsideZone ||
hasConsolidationZone;
if (canDraw)
{
//
ClearDraws();
//
// Draw Consolidation Zone ...
if (hasConsolidationZone)
{
//
XCConsolidationZoneObject *iObj;
bool isCreated = mPOIDrawer.CreateConsolidationZone(
mXTWPVConditions.consolidationZone,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
//
// Draw Pivot Zone ...
if (hasPivot)
{
//
XCBaseObject *drawnObjects[];
int drawnObjectsCount = DrawXTWPVPivotZone(
mXTWPVConditions,
mPOIDrawer,
drawnObjects,
false, // Draw State ...
false, // Draw Ticks Zone ...
true, // Ignore SwingHighs ...
true, // Ignore SwingLows ...
true, // Ignore SupportZones ...
true, // Ignore ResistanceZones ...
true, // Ignore SupplyZones ...
true, // Ignore DemandZones ...
true, // Ignore BullishOrderBlocks ...
true, // Ignore BearishOrderBlocks ...
true, // Ignore BullishFairValueGaps ...
true, // Ignore BearishFairValueGaps ...
true, // Ignore BullishRejectionBars ...
true, // Ignore BearishRejectionBars ...
true, // Ignore BullishMomentumBars ...
true // Ignore BearishMomentumBars ...
);
AddObjectsIfNotExists(drawnObjects);
}
//
// Draw Price Inside Zones ...
if (hasPriceInsideZone)
{
//
XCBaseObject *drawnObjects[];
int drawnObjectsCount = DrawTWPVPriceInsideZones(
mXTWPVConditions,
mPOIDrawer,
drawnObjects //
);
AddObjectsIfNotExists(drawnObjects);
}
}
//
result = isSetuped;
if (!result)
{
@@ -628,6 +552,18 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
conditions.sl = mXTWPVConditions.sl;
conditions.target = mXTWPVConditions.target;
//
conditions.decisionZones = mXTWPVConditions.decisionZone;
conditions.marketStructure = mXTWPVConditions.analyseMarketStructure;
if (isBullish)
{
conditions.priceZones = mXTWPVConditions.valePriceZone;
}
else
{
conditions.priceZones = mXTWPVConditions.peakPriceZone;
}
//
mXTWPVConditions.Clean();