This commit is contained in:
2024-11-17 06:46:34 +03:30
parent 9cbe7a248f
commit 649e373163
7 changed files with 1429 additions and 82 deletions
+6
View File
@@ -182,6 +182,12 @@ struct X3MAConditions
bool isSwitchedToBullishOrdered; bool isSwitchedToBullishOrdered;
bool isSwitchedToBearishOrdered; bool isSwitchedToBearishOrdered;
//
void X3MAConditions()
{
Clean();
}
// //
void Clean() void Clean()
{ {
+6
View File
@@ -214,6 +214,12 @@ struct X3VWAPConditions
bool isSwitchedToBearishState; bool isSwitchedToBearishState;
bool isSwitchedToNeuturalState; bool isSwitchedToNeuturalState;
//
void X3VWAPConditions()
{
Clean();
}
// //
void Clean() void Clean()
{ {
+4 -4
View File
@@ -374,6 +374,10 @@ double hcLLColorBuffer[];
// //
// Variables, Properties and etc ... // Variables, Properties and etc ...
//
// this counts Available Bars ...
int limit;
// //
int maxLength; int maxLength;
@@ -496,10 +500,6 @@ int OnCalculate(
ArraySetAsSeries(volume, true); ArraySetAsSeries(volume, true);
ArraySetAsSeries(spread, true); ArraySetAsSeries(spread, true);
//
// this counts Available Bars ...
int limit;
// //
limit = (prev_calculated > rates_total || prev_calculated <= 0) ? rates_total : (rates_total - prev_calculated) + 1; limit = (prev_calculated > rates_total || prev_calculated <= 0) ? rates_total : (rates_total - prev_calculated) + 1;
File diff suppressed because it is too large Load Diff
@@ -559,7 +559,7 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
// //
XBarTracker mBarTracker; // Strategy Time Tracker ... XBarTracker mBarTracker; // Strategy Time Tracker ...
XCBarAnalyser mBarAnalyser; // Bar Analyser Instance XCBarAnalyser mBarAnalyser; // Bar Analyser Instance
X121SMCStrategyConditions mConditions; // Market Conditions ... // X121SMCStrategyConditions mConditions; // Market Conditions ...
// //
// Actions ... // Actions ...
+13
View File
@@ -22,6 +22,9 @@
// //
// Imports ... // Imports ...
#include "../../Classes/x-saherelm.base.class.mq5" #include "../../Classes/x-saherelm.base.class.mq5"
#include "../../Helpers/x-saherelm.xpv.helper.mq5"
#include "../../Helpers/x-saherelm.x3ma.helper.mq5"
#include "../../Helpers/x-saherelm.x3vwap.helper.mq5"
#include "../../Libraries/x-saherelm.common.lib.mq5" #include "../../Libraries/x-saherelm.common.lib.mq5"
#include "../../Libraries/x-saherelm.x-poi.lib.mq5" #include "../../Libraries/x-saherelm.x-poi.lib.mq5"
#include "../../Libraries/x-saherelm.x-trade.lib.mq5" #include "../../Libraries/x-saherelm.x-trade.lib.mq5"
@@ -40,6 +43,11 @@ struct X121SMCStrategyConditions
ENUM_TIMEFRAMES period; ENUM_TIMEFRAMES period;
datetime time; datetime time;
//
XPVConditions xpvConditions;
X3MAConditions x3maConditions;
X3VWAPConditions x3vwapConditions;
// //
// D1 ... // D1 ...
@@ -150,6 +158,11 @@ struct X121SMCStrategyConditions
period = NULL; period = NULL;
time = NULL; time = NULL;
//
xpvConditions.Clean();
x3maConditions.Clean();
x3vwapConditions.Clean();
// //
// D1 ... // D1 ...
@@ -174,9 +174,53 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
return result; return result;
} }
//
conditions.symbol = _symbol;
conditions.period = _period;
conditions.time = TimeCurrent();
//
int conditionsLoopback = 7;
//
// XPV ...
result = xpvHelper.GetConditions(
conditions.xpvConditions,
cIndex,
conditionsLoopback //
);
if (!result)
{
return result;
}
//
// X3MA ...
result = x3maHelper.GetConditions(
conditions.x3maConditions,
cIndex,
conditionsLoopback //
);
if (!result)
{
return result;
}
//
// X3VWAP ...
result = x3vwapHelper.GetConditions(
conditions.x3vwapConditions,
cIndex,
conditionsLoopback //
);
if (!result)
{
return result;
}
// //
// Try to Implement SMC Based Conditions ... // Try to Implement SMC Based Conditions ...
result = DetectConditions(); result = DetectConditions(conditions);
if (!result) if (!result)
{ {
return result; return result;
@@ -320,140 +364,120 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
* *
* @return ( bool ) * @return ( bool )
*/ */
bool DetectConditions() bool DetectConditions(
X121SMCStrategyConditions &conditions //
)
{ {
// //
bool result = false; bool result = false;
//
mConditions.Clean();
mConditions.symbol = GetSymbol();
mConditions.period = GetPeriod();
mConditions.time = TimeCurrent();
// //
// Detect Market Structures ... // Detect Market Structures ...
// //
// 1D ... // 1D ...
mConditions.d1State = _1DState; conditions.d1State = _1DState;
result = DetectMarketStructure( result = DetectMarketStructure(
mConditions.d1MarketDirection, conditions.d1MarketDirection,
mConditions.d1SupportZones, conditions.d1SupportZones,
mConditions.d1ResistanceZones, conditions.d1ResistanceZones,
_1DState // _1DState //
); );
if (!result) if (!result)
{ {
//
mConditions.Clean();
return result; return result;
} }
// //
// 4H ... // 4H ...
mConditions.h4State = _4HState; conditions.h4State = _4HState;
result = DetectMarketStructure( result = DetectMarketStructure(
mConditions.h4MarketDirection, conditions.h4MarketDirection,
mConditions.h4SupportZones, conditions.h4SupportZones,
mConditions.h4ResistanceZones, conditions.h4ResistanceZones,
_4HState // _4HState //
); );
if (!result) if (!result)
{ {
//
mConditions.Clean();
return result; return result;
} }
// //
// 2H ... // 2H ...
mConditions.h2State = _2HState; conditions.h2State = _2HState;
result = DetectMarketStructure( result = DetectMarketStructure(
mConditions.h2MarketDirection, conditions.h2MarketDirection,
mConditions.h2SupportZones, conditions.h2SupportZones,
mConditions.h2ResistanceZones, conditions.h2ResistanceZones,
_2HState // _2HState //
); );
if (!result) if (!result)
{ {
//
mConditions.Clean();
return result; return result;
} }
// //
// 1H ... // 1H ...
mConditions.h1State = _1HState; conditions.h1State = _1HState;
result = DetectMarketStructure( result = DetectMarketStructure(
mConditions.h1MarketDirection, conditions.h1MarketDirection,
mConditions.h1SupportZones, conditions.h1SupportZones,
mConditions.h1ResistanceZones, conditions.h1ResistanceZones,
_1HState // _1HState //
); );
if (!result) if (!result)
{ {
//
mConditions.Clean();
return result; return result;
} }
// //
// 15M ... // 15M ...
mConditions.m15State = _15MState; conditions.m15State = _15MState;
result = DetectMarketStructure( result = DetectMarketStructure(
mConditions.m15MarketDirection, conditions.m15MarketDirection,
mConditions.m15SupportZones, conditions.m15SupportZones,
mConditions.m15ResistanceZones, conditions.m15ResistanceZones,
_15MState // _15MState //
); );
if (!result) if (!result)
{ {
//
mConditions.Clean();
return result; return result;
} }
// //
// 5M ... // 5M ...
mConditions.m5State = _5MState; conditions.m5State = _5MState;
result = DetectMarketStructure( result = DetectMarketStructure(
mConditions.m5MarketDirection, conditions.m5MarketDirection,
mConditions.m5SupportZones, conditions.m5SupportZones,
mConditions.m5ResistanceZones, conditions.m5ResistanceZones,
_5MState // _5MState //
); );
if (!result) if (!result)
{ {
//
mConditions.Clean();
return result; return result;
} }
// //
// 1M ... // 1M ...
mConditions.m1State = _1MState; conditions.m1State = _1MState;
result = DetectMarketStructure( result = DetectMarketStructure(
mConditions.m1MarketDirection, conditions.m1MarketDirection,
mConditions.m1SupportZones, conditions.m1SupportZones,
mConditions.m1ResistanceZones, conditions.m1ResistanceZones,
_1MState // _1MState //
); );
if (!result) if (!result)
{ {
//
mConditions.Clean();
return result; return result;
} }
// //
// 1H-15M-5M ... // 1H-15M-5M ...
ENUM_X_DIRECTION marketStructure = X_DIRECTION_NONE; ENUM_X_DIRECTION marketStructure = X_DIRECTION_NONE;
result = mConditions.HasMarketStructure(marketStructure); result = conditions.HasMarketStructure(marketStructure);
if (!result) if (!result)
{ {
//
mConditions.Clean();
return result; return result;
} }
@@ -472,14 +496,14 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
XCResistanceZone *h1ResistanceZone = NULL; XCResistanceZone *h1ResistanceZone = NULL;
// //
count = ArraySize(mConditions.h1SupportZones); count = ArraySize(conditions.h1SupportZones);
if (IsValidSize(count)) if (IsValidSize(count))
{ {
// //
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
// //
XCSupportZone *item = mConditions.h1SupportZones[i]; XCSupportZone *item = conditions.h1SupportZones[i];
// //
bool canSelect = bool canSelect =
@@ -495,7 +519,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
{ {
// //
// Detect Swings ... // Detect Swings ...
count = ArraySize(mConditions.h1State.swingLows); count = ArraySize(conditions.h1State.swingLows);
if (IsValidSize(count)) if (IsValidSize(count))
{ {
// //
@@ -506,7 +530,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
// //
XCSwing *item = mConditions.h1State.swingLows[i]; XCSwing *item = conditions.h1State.swingLows[i];
// //
XOHCL iBar; XOHCL iBar;
@@ -558,14 +582,14 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
} }
// //
count = ArraySize(mConditions.h1ResistanceZones); count = ArraySize(conditions.h1ResistanceZones);
if (IsValidSize(count)) if (IsValidSize(count))
{ {
// //
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
// //
XCResistanceZone *item = mConditions.h1ResistanceZones[i]; XCResistanceZone *item = conditions.h1ResistanceZones[i];
// //
bool canSelect = bool canSelect =
@@ -581,7 +605,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
{ {
// //
// Detect Swings ... // Detect Swings ...
count = ArraySize(mConditions.h1State.swingHighs); count = ArraySize(conditions.h1State.swingHighs);
if (IsValidSize(count)) if (IsValidSize(count))
{ {
// //
@@ -592,7 +616,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
// //
XCSwing *item = mConditions.h1State.swingHighs[i]; XCSwing *item = conditions.h1State.swingHighs[i];
// //
XOHCL iBar; XOHCL iBar;
@@ -648,14 +672,14 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
// //
XCSupportZone *m15SupportZone = NULL; XCSupportZone *m15SupportZone = NULL;
count = ArraySize(mConditions.m15SupportZones); count = ArraySize(conditions.m15SupportZones);
if (IsValidSize(count)) if (IsValidSize(count))
{ {
// //
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
// //
XCSupportZone *item = mConditions.m15SupportZones[i]; XCSupportZone *item = conditions.m15SupportZones[i];
// //
bool canSelect = bool canSelect =
@@ -683,14 +707,14 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
// //
XCResistanceZone *m15ResistanceZone = NULL; XCResistanceZone *m15ResistanceZone = NULL;
count = ArraySize(mConditions.m15ResistanceZones); count = ArraySize(conditions.m15ResistanceZones);
if (IsValidSize(count)) if (IsValidSize(count))
{ {
// //
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
// //
XCResistanceZone *item = mConditions.m15ResistanceZones[i]; XCResistanceZone *item = conditions.m15ResistanceZones[i];
// //
bool canSelect = bool canSelect =
@@ -721,14 +745,14 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
// //
XCSupportZone *m5SupportZone = NULL; XCSupportZone *m5SupportZone = NULL;
count = ArraySize(mConditions.m5SupportZones); count = ArraySize(conditions.m5SupportZones);
if (IsValidSize(count)) if (IsValidSize(count))
{ {
// //
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
// //
XCSupportZone *item = mConditions.m5SupportZones[i]; XCSupportZone *item = conditions.m5SupportZones[i];
// //
bool canSelect = bool canSelect =
@@ -756,14 +780,14 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
// //
XCResistanceZone *m5ResistanceZone = NULL; XCResistanceZone *m5ResistanceZone = NULL;
count = ArraySize(mConditions.m5ResistanceZones); count = ArraySize(conditions.m5ResistanceZones);
if (IsValidSize(count)) if (IsValidSize(count))
{ {
// //
for (int i = 0; i < count; i++) for (int i = 0; i < count; i++)
{ {
// //
XCResistanceZone *item = mConditions.m5ResistanceZones[i]; XCResistanceZone *item = conditions.m5ResistanceZones[i];
// //
bool canSelect = bool canSelect =
@@ -1038,23 +1062,23 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
// //
// Short ... // Short ...
ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_MANUALLY; // How to Find Period
ENUM_TIMEFRAMES scPeriod = NULL; // Time Period ENUM_TIMEFRAMES scPeriod = PERIOD_M15; // Time Period
// //
// Medium ... // Medium ...
ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_MANUALLY; // How to Find Period
ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period ENUM_TIMEFRAMES mcPeriod = PERIOD_M30; // Time Period
// //
// Long ... // Long ...
ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_MANUALLY; // How to Find Period
ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period ENUM_TIMEFRAMES lcPeriod = PERIOD_H1; // Time Period
// //
// Hind ... // Hind ...
ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_MANUALLY; // How to Find Period
ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period ENUM_TIMEFRAMES hcPeriod = PERIOD_H2; // Time Period
// //
// XPV ... // XPV ...