last works ...
This commit is contained in:
@@ -80,7 +80,7 @@ input int eaPauseSignallingAfterReachesMaxAllowedSLInSecconds = 7200; // Pause S
|
|||||||
// Protection ...
|
// Protection ...
|
||||||
input group "Protection";
|
input group "Protection";
|
||||||
input bool eaAllowHedging = true; // Allow Hedge Positions
|
input bool eaAllowHedging = true; // Allow Hedge Positions
|
||||||
input int eaMinOpenTradesFroHedging = 4; // Minimum Open Positions for Hedging
|
input int eaMinOpenTradesFroHedging = 5; // Minimum Open Positions for Hedging
|
||||||
input double eaHedgingMinVolumeStep = 0.01; // Minimum Volume Step for Hedging
|
input double eaHedgingMinVolumeStep = 0.01; // Minimum Volume Step for Hedging
|
||||||
input double eaHedgeingMinRequiredProfitPerVolumeStep = 1.5; // Minimum Required Profit Per Volume Step for Hedging
|
input double eaHedgeingMinRequiredProfitPerVolumeStep = 1.5; // Minimum Required Profit Per Volume Step for Hedging
|
||||||
|
|
||||||
|
|||||||
@@ -596,7 +596,7 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
|
|||||||
//
|
//
|
||||||
XBarTracker mBarTracker; // Strategy Bar Tracker ...
|
XBarTracker mBarTracker; // Strategy Bar Tracker ...
|
||||||
XBarTracker mGuardBarTracker; // Strategy Guard Bar Tracker ...
|
XBarTracker mGuardBarTracker; // Strategy Guard Bar Tracker ...
|
||||||
XCBarAnalyser mBarAnalyser; // Bar Analyser Instance
|
XCBarAnalyser *mBarAnalyser; // Bar Analyser Instance
|
||||||
|
|
||||||
//
|
//
|
||||||
// Actions ...
|
// Actions ...
|
||||||
@@ -954,6 +954,9 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
|
|||||||
period //
|
period //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
mBarAnalyser = new XCBarAnalyser();
|
||||||
|
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -964,6 +967,7 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
delete mPOIDrawer;
|
delete mPOIDrawer;
|
||||||
|
delete mBarAnalyser;
|
||||||
|
|
||||||
//
|
//
|
||||||
ArrayFree(mTicks);
|
ArrayFree(mTicks);
|
||||||
|
|||||||
@@ -976,8 +976,15 @@ class XC121SMCExpert : public XCBaseExpert
|
|||||||
(XCBaseObject *)signalObject,
|
(XCBaseObject *)signalObject,
|
||||||
objects //
|
objects //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(objects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
signal.Clean();
|
||||||
|
conditions.Clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1305,6 +1312,9 @@ class XC121SMCExpert : public XCBaseExpert
|
|||||||
RegisterStrategy(iX121SMCStrategy);
|
RegisterStrategy(iX121SMCStrategy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(symbols);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -2322,6 +2332,7 @@ class XC121SMCExpert : public XCBaseExpert
|
|||||||
|
|
||||||
//
|
//
|
||||||
Clean(guards);
|
Clean(guards);
|
||||||
|
ArrayFree(guards);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ const string X121SMCStrategyToken = "X121SMC";
|
|||||||
//
|
//
|
||||||
const string X121SMCXTestToken = "X121XTest";
|
const string X121SMCXTestToken = "X121XTest";
|
||||||
const string X121SMCXPZToken = "X121XPZ";
|
const string X121SMCXPZToken = "X121XPZ";
|
||||||
|
const string X121SMCXRSPVIToken = "X121XRSPVI";
|
||||||
const string X121SMCXSTRPVToken = "X121XSTRPV";
|
const string X121SMCXSTRPVToken = "X121XSTRPV";
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -47,6 +48,7 @@ enum ENUM_X_121_SMC_PROVIDERS
|
|||||||
X_121_SMC_PROVIDER_NONE,
|
X_121_SMC_PROVIDER_NONE,
|
||||||
X_121_SMC_PROVIDER_XTEST,
|
X_121_SMC_PROVIDER_XTEST,
|
||||||
X_121_SMC_PROVIDER_XPZ,
|
X_121_SMC_PROVIDER_XPZ,
|
||||||
|
X_121_SMC_PROVIDER_XRSPVI,
|
||||||
X_121_SMC_PROVIDER_XSTRPV,
|
X_121_SMC_PROVIDER_XSTRPV,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -711,6 +713,11 @@ string ToString(ENUM_X_121_SMC_PROVIDERS value)
|
|||||||
result = X121SMCXPZToken;
|
result = X121SMCXPZToken;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_121_SMC_PROVIDER_XRSPVI:
|
||||||
|
result = X121SMCXRSPVIToken;
|
||||||
|
break;
|
||||||
|
|
||||||
//
|
//
|
||||||
case X_121_SMC_PROVIDER_XSTRPV:
|
case X_121_SMC_PROVIDER_XSTRPV:
|
||||||
result = X121SMCXSTRPVToken;
|
result = X121SMCXSTRPVToken;
|
||||||
@@ -748,6 +755,10 @@ ENUM_X_121_SMC_PROVIDERS ParseProvider(string value)
|
|||||||
{
|
{
|
||||||
result = X_121_SMC_PROVIDER_XPZ;
|
result = X_121_SMC_PROVIDER_XPZ;
|
||||||
}
|
}
|
||||||
|
else if (Contains(X121SMCXRSPVIToken, value))
|
||||||
|
{
|
||||||
|
result = X_121_SMC_PROVIDER_XRSPVI;
|
||||||
|
}
|
||||||
else if (Contains(X121SMCXSTRPVToken, value))
|
else if (Contains(X121SMCXSTRPVToken, value))
|
||||||
{
|
{
|
||||||
result = X_121_SMC_PROVIDER_XSTRPV;
|
result = X_121_SMC_PROVIDER_XSTRPV;
|
||||||
|
|||||||
@@ -1,662 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// SaherElm IT Center MQL5 X121 SMC Signal Class
|
|
||||||
// -------------------------------------------------
|
|
||||||
// Name:
|
|
||||||
// Description: provide all Signalling functions ...
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Maintainer:
|
|
||||||
// ------------
|
|
||||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Global Properties ...
|
|
||||||
#property library
|
|
||||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
|
||||||
#property link "https://www.saherelm.ir"
|
|
||||||
#property version "1.00"
|
|
||||||
#property strict
|
|
||||||
|
|
||||||
//
|
|
||||||
// Imports ...
|
|
||||||
#include "../Classes/x-121.smc.market.cycle.helper.class.mq5"
|
|
||||||
#include "../Libraries/x-121.smc.lib.mq5"
|
|
||||||
|
|
||||||
//
|
|
||||||
// Definitions ...
|
|
||||||
struct X121SMCStrategyTestSignalConditions
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Props ...
|
|
||||||
|
|
||||||
//
|
|
||||||
string symbol;
|
|
||||||
ENUM_TIMEFRAMES period;
|
|
||||||
|
|
||||||
//
|
|
||||||
double sl;
|
|
||||||
double target;
|
|
||||||
ENUM_X_DIRECTION dir;
|
|
||||||
ENUM_X_POSITION_TYPES type;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Setup Props ...
|
|
||||||
|
|
||||||
//
|
|
||||||
datetime setupTime;
|
|
||||||
datetime triggerTime;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Constructor ...
|
|
||||||
X121SMCStrategyTestSignalConditions()
|
|
||||||
{
|
|
||||||
Clean();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Tools ...
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cleaning Up ...
|
|
||||||
*/
|
|
||||||
void Clean()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
sl = 0;
|
|
||||||
target = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
dir = X_DIRECTION_NONE;
|
|
||||||
type = X_POSITION_TYPE_NONE;
|
|
||||||
|
|
||||||
//
|
|
||||||
symbol = NULL;
|
|
||||||
period = NULL;
|
|
||||||
setupTime = NULL;
|
|
||||||
triggerTime = NULL;
|
|
||||||
|
|
||||||
//
|
|
||||||
ExtensionClean();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check Condition is Setting Up ...
|
|
||||||
*
|
|
||||||
* @param dir: ENUM_X_DIRECTION member, Setting Up Direction ...
|
|
||||||
*
|
|
||||||
* @return ( bool )
|
|
||||||
*/
|
|
||||||
bool IsSetuped()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
result = IsValid(setupTime) &&
|
|
||||||
HasDirection(dir);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate Setup Age ...
|
|
||||||
*
|
|
||||||
* @return ( int )
|
|
||||||
*/
|
|
||||||
int GetSetupAge()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
if (!IsSetuped())
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
result = (int)(TimeCurrent() - setupTime) / PeriodSeconds(period);
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Detect How we Can Trigger Signal ...
|
|
||||||
*
|
|
||||||
* @return ( bool )
|
|
||||||
*/
|
|
||||||
bool CanTrigger()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
result =
|
|
||||||
//
|
|
||||||
sl > 0 &&
|
|
||||||
IsValid(symbol) &&
|
|
||||||
IsValid(period) &&
|
|
||||||
IsValid(triggerTime) &&
|
|
||||||
type != X_POSITION_TYPE_ALL &&
|
|
||||||
type != X_POSITION_TYPE_NONE
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Extensions ...
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clean Additional Properties ...
|
|
||||||
*/
|
|
||||||
void ExtensionClean()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Extension Functions ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// Detect Setup Conditions ...
|
|
||||||
bool DetectX121SMCTestSiganlSetup(
|
|
||||||
string _symbol,
|
|
||||||
ENUM_TIMEFRAMES _period,
|
|
||||||
//
|
|
||||||
X121SMCStrategyTestSignalConditions &conditions,
|
|
||||||
//
|
|
||||||
XC121SMCCycleHelper *triggerCycleHelper,
|
|
||||||
XC121SMCCycleHelper *decisionCycleHelper,
|
|
||||||
XC121SMCCycleHelper *analyseCycleHelper,
|
|
||||||
XC121SMCCycleHelper *verificationCycleHelper,
|
|
||||||
XC121SMCCycleHelper *consolidationCycleHelper,
|
|
||||||
XC121SMCCycleHelper *visionCycleHelper
|
|
||||||
//
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isBullish = false;
|
|
||||||
bool isBearish = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
int zIndex = 0;
|
|
||||||
int cIndex = zIndex + 1;
|
|
||||||
int pIndex = cIndex + 1;
|
|
||||||
int ppIndex = pIndex + 1;
|
|
||||||
|
|
||||||
//
|
|
||||||
int loopback = 10;
|
|
||||||
|
|
||||||
//
|
|
||||||
string symbol = _symbol;
|
|
||||||
ENUM_TIMEFRAMES period = _period;
|
|
||||||
|
|
||||||
//
|
|
||||||
conditions.symbol = symbol;
|
|
||||||
conditions.period = period;
|
|
||||||
|
|
||||||
//
|
|
||||||
XOHCL zBar;
|
|
||||||
result = zBar.Init(
|
|
||||||
symbol,
|
|
||||||
period,
|
|
||||||
zIndex //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
XOHCL cBar;
|
|
||||||
result = cBar.Init(
|
|
||||||
symbol,
|
|
||||||
period,
|
|
||||||
cIndex //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
double ask = GetAsk(symbol);
|
|
||||||
double bid = GetBid(symbol);
|
|
||||||
datetime cTime = TimeCurrent();
|
|
||||||
|
|
||||||
//
|
|
||||||
double ll = cBar.FindLowest(9, MODE_LOW);
|
|
||||||
double hh = cBar.FindHighest(9, MODE_HIGH);
|
|
||||||
|
|
||||||
//
|
|
||||||
int zoneValidationDivider = 10;
|
|
||||||
int validPivotRepetition = 10;
|
|
||||||
|
|
||||||
//
|
|
||||||
double selectedSL = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Cycles Conditions ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// Trigger ...
|
|
||||||
ENUM_XPOI_EVENTS triggerPoiEvents[];
|
|
||||||
ENUM_X_CYCLE_EVENTS triggerCycleEvents[];
|
|
||||||
X121SMCCycleConditions triggerConditions;
|
|
||||||
result = triggerCycleHelper.GetConditions(
|
|
||||||
triggerCycleEvents,
|
|
||||||
triggerPoiEvents,
|
|
||||||
triggerConditions,
|
|
||||||
zIndex,
|
|
||||||
loopback //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Decision ...
|
|
||||||
ENUM_XPOI_EVENTS decisionPoiEvents[];
|
|
||||||
ENUM_X_CYCLE_EVENTS decisionCycleEvents[];
|
|
||||||
X121SMCCycleConditions decisionConditions;
|
|
||||||
result = decisionCycleHelper.GetConditions(
|
|
||||||
decisionCycleEvents,
|
|
||||||
decisionPoiEvents,
|
|
||||||
decisionConditions,
|
|
||||||
zIndex,
|
|
||||||
loopback //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Analyse ...
|
|
||||||
ENUM_XPOI_EVENTS analysePoiEvents[];
|
|
||||||
ENUM_X_CYCLE_EVENTS analyseCycleEvents[];
|
|
||||||
X121SMCCycleConditions analyseConditions;
|
|
||||||
result = analyseCycleHelper.GetConditions(
|
|
||||||
analyseCycleEvents,
|
|
||||||
analysePoiEvents,
|
|
||||||
analyseConditions,
|
|
||||||
zIndex,
|
|
||||||
loopback //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Verification ...
|
|
||||||
ENUM_XPOI_EVENTS verificationPoiEvents[];
|
|
||||||
ENUM_X_CYCLE_EVENTS verificationCycleEvents[];
|
|
||||||
X121SMCCycleConditions verificationConditions;
|
|
||||||
result = verificationCycleHelper.GetConditions(
|
|
||||||
verificationCycleEvents,
|
|
||||||
verificationPoiEvents,
|
|
||||||
verificationConditions,
|
|
||||||
zIndex,
|
|
||||||
loopback //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Consolidation ...
|
|
||||||
ENUM_XPOI_EVENTS consolidationPoiEvents[];
|
|
||||||
ENUM_X_CYCLE_EVENTS consolidationCycleEvents[];
|
|
||||||
X121SMCCycleConditions consolidationConditions;
|
|
||||||
result = consolidationCycleHelper.GetConditions(
|
|
||||||
consolidationCycleEvents,
|
|
||||||
consolidationPoiEvents,
|
|
||||||
consolidationConditions,
|
|
||||||
zIndex,
|
|
||||||
loopback //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Vision ...
|
|
||||||
ENUM_XPOI_EVENTS visionPoiEvents[];
|
|
||||||
ENUM_X_CYCLE_EVENTS visionCycleEvents[];
|
|
||||||
X121SMCCycleConditions visionConditions;
|
|
||||||
result = visionCycleHelper.GetConditions(
|
|
||||||
visionCycleEvents,
|
|
||||||
visionPoiEvents,
|
|
||||||
visionConditions,
|
|
||||||
zIndex,
|
|
||||||
loopback //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Cycles POI States ...
|
|
||||||
XPOIState triggerState = triggerConditions.state;
|
|
||||||
XPOIState decisionState = decisionConditions.state;
|
|
||||||
XPOIState analyseState = analyseConditions.state;
|
|
||||||
XPOIState verificationState = verificationConditions.state;
|
|
||||||
XPOIState consolidationState = consolidationConditions.state;
|
|
||||||
XPOIState visionState = visionConditions.state;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Setup Conditions ...
|
|
||||||
|
|
||||||
//
|
|
||||||
isBullish =
|
|
||||||
//
|
|
||||||
false
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
isBearish =
|
|
||||||
//
|
|
||||||
false
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
result = isBullish ||
|
|
||||||
isBearish;
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Clean Conditions for Regenerate ...
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
conditions.setupTime = cTime;
|
|
||||||
conditions.dir =
|
|
||||||
isBullish
|
|
||||||
? X_DIRECTION_BULLISH
|
|
||||||
: X_DIRECTION_BEARISH;
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Detect Trigger Conditions ...
|
|
||||||
bool DetectX121SMCTestSiganlTrigger(
|
|
||||||
//
|
|
||||||
X121SMCStrategyTestSignalConditions &conditions,
|
|
||||||
//
|
|
||||||
string _symbol,
|
|
||||||
ENUM_TIMEFRAMES _period,
|
|
||||||
//
|
|
||||||
XC121SMCCycleHelper *triggerCycleHelper,
|
|
||||||
XC121SMCCycleHelper *decisionCycleHelper,
|
|
||||||
XC121SMCCycleHelper *analyseCycleHelper,
|
|
||||||
XC121SMCCycleHelper *verificationCycleHelper,
|
|
||||||
XC121SMCCycleHelper *consolidationCycleHelper,
|
|
||||||
XC121SMCCycleHelper *visionCycleHelper,
|
|
||||||
//
|
|
||||||
int maxAllowedSetupAge = 60 //
|
|
||||||
//
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
result = conditions.IsSetuped();
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
datetime setupTime = conditions.setupTime;
|
|
||||||
ENUM_X_DIRECTION setupDir = conditions.dir;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isBullish = false;
|
|
||||||
bool isBearish = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
int zIndex = 0;
|
|
||||||
int cIndex = zIndex + 1;
|
|
||||||
int pIndex = cIndex + 1;
|
|
||||||
int ppIndex = pIndex + 1;
|
|
||||||
|
|
||||||
//
|
|
||||||
int loopback = 10;
|
|
||||||
|
|
||||||
//
|
|
||||||
string symbol = _symbol;
|
|
||||||
ENUM_TIMEFRAMES period = _period;
|
|
||||||
|
|
||||||
//
|
|
||||||
XOHCL zBar;
|
|
||||||
result = zBar.Init(
|
|
||||||
symbol,
|
|
||||||
period,
|
|
||||||
zIndex //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
XOHCL cBar;
|
|
||||||
result = cBar.Init(
|
|
||||||
symbol,
|
|
||||||
period,
|
|
||||||
cIndex //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
double ask = GetAsk(symbol);
|
|
||||||
double bid = GetBid(symbol);
|
|
||||||
datetime cTime = TimeCurrent();
|
|
||||||
|
|
||||||
//
|
|
||||||
double ll = cBar.FindLowest(9, MODE_LOW);
|
|
||||||
double hh = cBar.FindHighest(9, MODE_HIGH);
|
|
||||||
|
|
||||||
//
|
|
||||||
int zoneValidationDivider = 10;
|
|
||||||
int validPivotRepetition = 10;
|
|
||||||
|
|
||||||
//
|
|
||||||
double selectedSL = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Cycles Conditions ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// Trigger ...
|
|
||||||
ENUM_XPOI_EVENTS triggerPoiEvents[];
|
|
||||||
ENUM_X_CYCLE_EVENTS triggerCycleEvents[];
|
|
||||||
X121SMCCycleConditions triggerConditions;
|
|
||||||
result = triggerCycleHelper.GetConditions(
|
|
||||||
triggerCycleEvents,
|
|
||||||
triggerPoiEvents,
|
|
||||||
triggerConditions,
|
|
||||||
zIndex,
|
|
||||||
loopback //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Decision ...
|
|
||||||
ENUM_XPOI_EVENTS decisionPoiEvents[];
|
|
||||||
ENUM_X_CYCLE_EVENTS decisionCycleEvents[];
|
|
||||||
X121SMCCycleConditions decisionConditions;
|
|
||||||
result = decisionCycleHelper.GetConditions(
|
|
||||||
decisionCycleEvents,
|
|
||||||
decisionPoiEvents,
|
|
||||||
decisionConditions,
|
|
||||||
zIndex,
|
|
||||||
loopback //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Analyse ...
|
|
||||||
ENUM_XPOI_EVENTS analysePoiEvents[];
|
|
||||||
ENUM_X_CYCLE_EVENTS analyseCycleEvents[];
|
|
||||||
X121SMCCycleConditions analyseConditions;
|
|
||||||
result = analyseCycleHelper.GetConditions(
|
|
||||||
analyseCycleEvents,
|
|
||||||
analysePoiEvents,
|
|
||||||
analyseConditions,
|
|
||||||
zIndex,
|
|
||||||
loopback //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Verification ...
|
|
||||||
ENUM_XPOI_EVENTS verificationPoiEvents[];
|
|
||||||
ENUM_X_CYCLE_EVENTS verificationCycleEvents[];
|
|
||||||
X121SMCCycleConditions verificationConditions;
|
|
||||||
result = verificationCycleHelper.GetConditions(
|
|
||||||
verificationCycleEvents,
|
|
||||||
verificationPoiEvents,
|
|
||||||
verificationConditions,
|
|
||||||
zIndex,
|
|
||||||
loopback //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Consolidation ...
|
|
||||||
ENUM_XPOI_EVENTS consolidationPoiEvents[];
|
|
||||||
ENUM_X_CYCLE_EVENTS consolidationCycleEvents[];
|
|
||||||
X121SMCCycleConditions consolidationConditions;
|
|
||||||
result = consolidationCycleHelper.GetConditions(
|
|
||||||
consolidationCycleEvents,
|
|
||||||
consolidationPoiEvents,
|
|
||||||
consolidationConditions,
|
|
||||||
zIndex,
|
|
||||||
loopback //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Vision ...
|
|
||||||
ENUM_XPOI_EVENTS visionPoiEvents[];
|
|
||||||
ENUM_X_CYCLE_EVENTS visionCycleEvents[];
|
|
||||||
X121SMCCycleConditions visionConditions;
|
|
||||||
result = visionCycleHelper.GetConditions(
|
|
||||||
visionCycleEvents,
|
|
||||||
visionPoiEvents,
|
|
||||||
visionConditions,
|
|
||||||
zIndex,
|
|
||||||
loopback //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Cycles POI States ...
|
|
||||||
XPOIState triggerState = triggerConditions.state;
|
|
||||||
XPOIState decisionState = decisionConditions.state;
|
|
||||||
XPOIState analyseState = analyseConditions.state;
|
|
||||||
XPOIState verificationState = verificationConditions.state;
|
|
||||||
XPOIState consolidationState = consolidationConditions.state;
|
|
||||||
XPOIState visionState = visionConditions.state;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Trigger Conditions ...
|
|
||||||
|
|
||||||
//
|
|
||||||
isBullish =
|
|
||||||
//
|
|
||||||
false
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
isBearish =
|
|
||||||
//
|
|
||||||
false
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
result = isBullish ||
|
|
||||||
isBearish;
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Cleanup Setup Conditions ...
|
|
||||||
int setupAge = conditions.GetSetupAge();
|
|
||||||
if (IsValidSize(setupAge) &&
|
|
||||||
IsValidSize(maxAllowedSetupAge) &&
|
|
||||||
setupAge >= maxAllowedSetupAge)
|
|
||||||
{
|
|
||||||
conditions.Clean();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
conditions.triggerTime = cTime;
|
|
||||||
conditions.sl = isBullish
|
|
||||||
? 0
|
|
||||||
: 0;
|
|
||||||
conditions.type = isBullish
|
|
||||||
? X_POSITION_TYPE_LONG
|
|
||||||
: X_POSITION_TYPE_SHORT;
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
@@ -761,17 +761,6 @@ bool DetectX121SMCXPZSiganlSetup(
|
|||||||
? X_DIRECTION_BULLISH
|
? X_DIRECTION_BULLISH
|
||||||
: X_DIRECTION_BEARISH;
|
: X_DIRECTION_BEARISH;
|
||||||
|
|
||||||
//
|
|
||||||
XCBaseObject *drawnObjects[];
|
|
||||||
int drawnObjectsCount = triggerCycleHelper
|
|
||||||
.mPOIDetector
|
|
||||||
.mDrawer
|
|
||||||
.DrawPriceZone(
|
|
||||||
analysePriceZone,
|
|
||||||
drawnObjects,
|
|
||||||
pzDir //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
conditions.priceZone = analysePriceZone;
|
conditions.priceZone = analysePriceZone;
|
||||||
conditions.isPriceZoneValidForPeak = isAnalysePriceZoneValidForPeak;
|
conditions.isPriceZoneValidForPeak = isAnalysePriceZoneValidForPeak;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
#include "../Signals/x-121.smc.xpz.signal.lib.mq5"
|
#include "../Signals/x-121.smc.xpz.signal.lib.mq5"
|
||||||
|
#include "../Signals/x-121.smc.xrspvi.signal.lib.mq5"
|
||||||
#include "../Signals/x-121.smc.xstrpv.signal.lib.mq5"
|
#include "../Signals/x-121.smc.xstrpv.signal.lib.mq5"
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -43,6 +44,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
//
|
//
|
||||||
// Props ...
|
// Props ...
|
||||||
bool useXPZSignal;
|
bool useXPZSignal;
|
||||||
|
bool useXRSPVISignal;
|
||||||
bool useXSTRPVSignal;
|
bool useXSTRPVSignal;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -64,7 +66,10 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
Destroy();
|
Destroy();
|
||||||
|
|
||||||
|
//
|
||||||
ArrayFree(mXPZConditionsCollection);
|
ArrayFree(mXPZConditionsCollection);
|
||||||
|
ArrayFree(mXRSPVIConditionsCollection);
|
||||||
ArrayFree(mXSTRPVConditionsCollection);
|
ArrayFree(mXSTRPVConditionsCollection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,10 +196,11 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
|
|
||||||
//
|
//
|
||||||
bool hasXPZSignal = false;
|
bool hasXPZSignal = false;
|
||||||
|
bool hasXRSPVISignal = false;
|
||||||
bool hasXSTRPVSignal = false;
|
bool hasXSTRPVSignal = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
// XOBGPV Signal ...
|
// XPZ Signal ...
|
||||||
if (useXPZSignal && !hasSignal)
|
if (useXPZSignal && !hasSignal)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -202,6 +208,15 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
hasSignal = hasXPZSignal;
|
hasSignal = hasXPZSignal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// XRSPVI Signal ...
|
||||||
|
if (useXRSPVISignal && !hasSignal)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
hasXRSPVISignal = DetectXRSPVISignal(conditions);
|
||||||
|
hasSignal = hasXRSPVISignal;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// XSTRPV Signal ...
|
// XSTRPV Signal ...
|
||||||
if (useXSTRPVSignal && !hasSignal)
|
if (useXSTRPVSignal && !hasSignal)
|
||||||
@@ -400,6 +415,23 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// XRSPVI Guard Detection ...
|
||||||
|
if (useXRSPVISignal)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool hasGuard = DetectX121SMCXRSPVIGuards(
|
||||||
|
guards,
|
||||||
|
positions,
|
||||||
|
mTriggerCycleHelper,
|
||||||
|
mDecisionCycleHelper,
|
||||||
|
mAnalyseCycleHelper,
|
||||||
|
mVerificationCycleHelper,
|
||||||
|
mConsolidationCycleHelper,
|
||||||
|
mVisionCycleHelper //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
count = ArraySize(guards);
|
count = ArraySize(guards);
|
||||||
result = IsValidSize(count);
|
result = IsValidSize(count);
|
||||||
@@ -634,14 +666,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
1 //
|
1 //
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
|
||||||
XCBaseObject *objects[];
|
|
||||||
DrawX121SMCXSTRPVConditions(
|
|
||||||
mConditions,
|
|
||||||
objects,
|
|
||||||
mPOIDrawer //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check Signal Direction ...
|
// Check Signal Direction ...
|
||||||
isBullish = IsBullish(mConditions.dir);
|
isBullish = IsBullish(mConditions.dir);
|
||||||
@@ -861,11 +885,221 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
XCBaseObject *objects[];
|
// Check Signal Direction ...
|
||||||
DrawX121SMCXPZConditions(
|
isBullish = IsBullish(mConditions.dir);
|
||||||
mConditions,
|
isBearish = IsBearish(mConditions.dir);
|
||||||
objects,
|
result = isBullish ||
|
||||||
mPOIDrawer //
|
isBearish;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Issues Signal on Conditions ...
|
||||||
|
conditions.sl = mConditions.sl;
|
||||||
|
conditions.provider = providerStr;
|
||||||
|
conditions.signalDir = mConditions.dir;
|
||||||
|
conditions.target = mConditions.target;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// XRSPVI Signal ...
|
||||||
|
bool DetectXRSPVISignal(
|
||||||
|
X121SMCStrategyConditions &conditions //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBullish = false;
|
||||||
|
bool isBearish = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
int zIndex = 0;
|
||||||
|
int cIndex = zIndex + 1;
|
||||||
|
int pIndex = cIndex + 1;
|
||||||
|
int ppIndex = pIndex + 1;
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = GetSymbol();
|
||||||
|
ENUM_TIMEFRAMES period = GetPeriod();
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL zBar;
|
||||||
|
result = zBar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
zIndex //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL cBar;
|
||||||
|
result = cBar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
cIndex //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL pBar;
|
||||||
|
result = pBar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
pIndex //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double cLL = cBar.FindLowest(7, MODE_LOW);
|
||||||
|
double cHH = cBar.FindHighest(7, MODE_HIGH);
|
||||||
|
|
||||||
|
//
|
||||||
|
datetime cTime = TimeCurrent();
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XRSPVI;
|
||||||
|
string providerStr = ToString(provider);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Setup Conditions ...
|
||||||
|
datetime setupTime = mXRSPVIConditions.setupTime;
|
||||||
|
bool isSetuped = mXRSPVIConditions.IsSetuped();
|
||||||
|
ENUM_X_DIRECTION setupDir = mXRSPVIConditions.dir;
|
||||||
|
if (!isSetuped)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Detect Signal Setup ...
|
||||||
|
isSetuped = DetectX121SMCXRSPVISiganlSetup(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
mXRSPVIConditions,
|
||||||
|
mTriggerCycleHelper,
|
||||||
|
mDecisionCycleHelper,
|
||||||
|
mAnalyseCycleHelper,
|
||||||
|
mVerificationCycleHelper,
|
||||||
|
mConsolidationCycleHelper,
|
||||||
|
mVisionCycleHelper //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
setupDir = mXRSPVIConditions.dir;
|
||||||
|
setupTime = mXRSPVIConditions.setupTime;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (isSetuped)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int items = AddX121SMCXRSPVIConditionsIfNotExists(
|
||||||
|
mXRSPVIConditions,
|
||||||
|
mXRSPVIConditionsCollection //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
mXRSPVIConditions.Clean();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int conditionsCount = ArraySize(mXRSPVIConditionsCollection);
|
||||||
|
result = IsValidSize(conditionsCount);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Looking For Conditions ...
|
||||||
|
int selectedIndex = 0;
|
||||||
|
X121SMCStrategyXRSPVISignalConditions mTmpConditions[];
|
||||||
|
Copy(
|
||||||
|
mXRSPVIConditionsCollection,
|
||||||
|
mTmpConditions //
|
||||||
|
);
|
||||||
|
X121SMCStrategyXRSPVISignalConditions mConditions;
|
||||||
|
for (int i = 0; i < conditionsCount; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Check Triggers ...
|
||||||
|
bool canTrigger = mTmpConditions[i].CanTrigger();
|
||||||
|
datetime triggerTime = mTmpConditions[i].triggerTime;
|
||||||
|
if (!canTrigger)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Detect Signal Trigger ...
|
||||||
|
canTrigger = DetectX121SMCXRSPVISiganlTrigger(
|
||||||
|
mTmpConditions[i],
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
mTriggerCycleHelper,
|
||||||
|
mDecisionCycleHelper,
|
||||||
|
mAnalyseCycleHelper,
|
||||||
|
mVerificationCycleHelper,
|
||||||
|
mConsolidationCycleHelper,
|
||||||
|
mVisionCycleHelper //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = canTrigger;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool isISetuped = mTmpConditions[i].IsSetuped();
|
||||||
|
if (!isISetuped)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ArrayRemove(
|
||||||
|
mXRSPVIConditionsCollection,
|
||||||
|
i,
|
||||||
|
1 //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
triggerTime = mTmpConditions[i].triggerTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (canTrigger)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
selectedIndex = i;
|
||||||
|
mConditions = mTmpConditions[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = IsValid(mConditions.setupTime) &&
|
||||||
|
HasDirection(mConditions.dir);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Remove Selected Index from Main Collection ...
|
||||||
|
ArrayRemove(
|
||||||
|
mXRSPVIConditionsCollection,
|
||||||
|
selectedIndex,
|
||||||
|
1 //
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -906,6 +1140,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
useXPZSignal = true;
|
useXPZSignal = true;
|
||||||
|
useXRSPVISignal = true;
|
||||||
useXSTRPVSignal = true;
|
useXSTRPVSignal = true;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user