This commit is contained in:
2024-12-29 17:46:35 +03:30
parent e831ce8a91
commit c92f2570c7
12 changed files with 944 additions and 864 deletions
@@ -89,6 +89,13 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
return mPeriod;
}
/**
* Retrieve POI Drawer Instance Pointer ...
**/
XCPOIDrawer* GetDrawer() {
return mPOIDrawer;
}
/**
* Check Strategy is Disabled or not ...
*
@@ -727,66 +734,6 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
//
// Draw Functions ...
/**
* Draw Specified Signal ...
*
* @param signal: XSignal instance ...
*/
void DrawSignal(XSignal &signal)
{
//
if (!signal.IsValid())
{
return;
}
//
// DrawConditions(conditions);
//
string name = signal.GetTag();
RemoveObject(name);
//
XCSignalObject *iObj;
iObj = new XCSignalObject();
//
bool isCreated = iObj.Create(
ChartIdentification(),
name,
SubWindowIdentification(),
signal //
);
if (!isCreated)
{
return;
}
//
iObj.TPWidth(1);
iObj.TPColor(clrGreen);
iObj.TPWidth(STYLE_DOT);
//
iObj.SLWidth(1);
iObj.SLColor(clrRed);
iObj.SLWidth(STYLE_DOT);
//
iObj.TargetWidth(1);
iObj.TargetColor(clrLightBlue);
iObj.TargetWidth(STYLE_DOT);
//
iObj.EntryWidth(1);
iObj.EntryColor(clrYellow);
iObj.EntryWidth(STYLE_DOT);
//
// mDrawnObjects.Add(iObj);
}
/**
* Clear all Drawn Objects ...
*/
@@ -26,6 +26,7 @@
#include "../../Classes/x-saherelm.x-alert.class.mq5"
#include "../../Classes/x-saherelm.x-bar.analyser.class.mq5"
#include "../../Classes/x-saherelm.x-trade.class.mq5"
#include "../../Classes/x-saherelm.x-poi.drawer.class.mq5"
//
// Definitions ...
@@ -2204,6 +2205,32 @@ class XC121SMCTradeHandler : public XCBaseAlert
mHedgeingMinRequiredProfitPerVolumeStep = value;
}
/**
* Get POI Drawer instance Pointer ...
*/
XCPOIDrawer *GetDrawer()
{
return mDrawer;
}
/**
* Get POI Drawer instance Pointer ...
*/
void SetDrawer(XCPOIDrawer *drawer)
{
mDrawer = drawer;
}
/**
* Check Darwer Exists Before Draw anything ...
*
* @return ( bool )
*/
bool CanDraw()
{
return mDrawer != NULL;
}
//
// Actions ...
@@ -3133,6 +3160,12 @@ class XC121SMCTradeHandler : public XCBaseAlert
//
// Add XTradeHandler Data ...
Add(signal);
if (CanDraw())
{
//
XCSignalObject *iObj;
mDrawer.DrawSignal(signal, iObj);
}
//
// Handle Last Executed Signal ...
@@ -3607,6 +3640,7 @@ class XC121SMCTradeHandler : public XCBaseAlert
//
XCBarAnalyser mBarAnalyser;
XCPOIDrawer *mDrawer;
//
// Common Functions ...
@@ -1033,6 +1033,7 @@ class XC121SMCExpert : public XCBaseExpert
//
// Parsers ...
XSymbolParser _symbolParser;
XCPOIDrawer *poiDrawer = NULL;
//
// Single Symbol ...
@@ -1049,6 +1050,14 @@ class XC121SMCExpert : public XCBaseExpert
_Period //
);
//
if (poiDrawer == NULL)
{
//
poiDrawer = iX121SMCStrategy
.GetDrawer();
}
//
iX121SMCStrategy.AddXSignalEventHandler(OnSignalEventListener);
@@ -1114,6 +1123,14 @@ class XC121SMCExpert : public XCBaseExpert
_Period //
);
//
if (poiDrawer == NULL)
{
//
poiDrawer = iX121SMCStrategy
.GetDrawer();
}
//
iX121SMCStrategy.AddXSignalEventHandler(OnSignalEventListener);
@@ -1125,6 +1142,12 @@ class XC121SMCExpert : public XCBaseExpert
}
}
//
if (poiDrawer != NULL)
{
mTradeHandler.SetDrawer(poiDrawer);
}
//
return result;
}
File diff suppressed because it is too large Load Diff
@@ -1,995 +0,0 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 X121 SMC Signal Lib
// -------------------------------------------------
// 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 X121SMCStrategyXPVDPSignalConditions
{
//
// 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;
//
double peak;
double vale;
//
// Constructor ...
X121SMCStrategyXPVDPSignalConditions()
{
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()
{
//
peak = 0;
vale = 0;
}
//
};
//
// Extension Functions ...
//
// Detect Setup Conditions ...
bool DetectX121SMCXPVDPSiganlSetup(
string _symbol,
ENUM_TIMEFRAMES _period,
//
X121SMCStrategyXPVDPSignalConditions &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 = triggerCycleHelper.mX121Helper
.GetDonChainLength();
//
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 ...
//
// Detect Market Trend ...
ENUM_X_DIRECTION trend;
bool hasTrend = consolidationCycleHelper
.DetectTrend(trend);
bool hasBullishTrend = hasTrend &&
IsBullish(trend);
bool hasBearishTrend = hasTrend &&
IsBearish(trend);
result = hasBullishTrend ||
hasBearishTrend;
if (!result)
{
return result;
}
//
// Select Source State ...
XPOIState state = decisionState;
//
// Detect High Equals to Peaks or Low Equals to Vale ...
//
// Peak ...
double peak = triggerConditions.x121Conditions.peaksBuffer[1];
bool isNewPeak = triggerConditions.x121Conditions.isNewPeak;
bool isNewPeakOverLast = triggerConditions.x121Conditions.isNewPeakOverLast;
bool isNewPeakUnderLast = triggerConditions.x121Conditions.isNewPeakUnderLast;
//
// Vale ...
double vale = triggerConditions.x121Conditions.valesBuffer[1];
bool isNewVale = triggerConditions.x121Conditions.isNewVale;
bool isNewValeOverLast = triggerConditions.x121Conditions.isNewValeOverLast;
bool isNewValeUnderLast = triggerConditions.x121Conditions.isNewValeUnderLast;
//
bool isHighEqualsToPeak =
isNewPeak &&
peak == cBar.high;
//
bool isLowEqualsToVale =
isNewVale &&
vale == cBar.low;
//
result = isHighEqualsToPeak ||
isLowEqualsToVale;
if (!result)
{
return result;
}
//
// Now We Have To Check DONChain Status ...
//
double donCUpper = triggerConditions.x121Conditions.donCloseUpperBuffer[1];
double donCUpperPrev = triggerConditions.x121Conditions.donCloseUpperBuffer[2];
//
double donCLower = triggerConditions.x121Conditions.donCloseLowerBuffer[1];
double donCLowerPrev = triggerConditions.x121Conditions.donCloseLowerBuffer[2];
//
double donOUpper = triggerConditions.x121Conditions.donOpenUpperBuffer[1];
double donOUpperPrev = triggerConditions.x121Conditions.donOpenUpperBuffer[2];
//
double donOLower = triggerConditions.x121Conditions.donOpenLowerBuffer[1];
double donOLowerPrev = triggerConditions.x121Conditions.donOpenLowerBuffer[2];
//
bool isDonUpperBullish = donCUpper > donOUpper;
bool isDonUpperBullishPrev = donCUpperPrev > donOUpperPrev;
//
bool isDonUpperBearish = donCUpper < donOUpper;
bool isDonUpperBearishPrev = donCUpperPrev < donOUpperPrev;
//
bool isDonUpperSwitchedToBullish = isDonUpperBullish &&
!isDonUpperBullishPrev;
//
bool isDonUpperSwitchedToBearish = isDonUpperBearish &&
!isDonUpperBearishPrev;
//
bool isDonLowerBullish = donCLower > donOLower;
bool isDonLowerBullishPrev = donCLowerPrev > donOLowerPrev;
//
bool isDonLowerBearish = donCLower < donOLower;
bool isDonLowerBearishPrev = donCLowerPrev < donOLowerPrev;
//
bool isDonLowerSwitchedToBullish = isDonLowerBullish &&
!isDonLowerBullishPrev;
//
bool isDonLowerSwitchedToBearish = isDonLowerBearish &&
!isDonLowerBearishPrev;
//
// Calculate State ...
//
bool isDonInBullishState =
//
// Upper ...
(isDonUpperBullish ||
isDonUpperSwitchedToBullish)
//
&&
//
// Lower ...
(isDonLowerBullish ||
isDonLowerSwitchedToBullish)
//
;
//
bool isDonInBearishState =
//
// Upper ...
(isDonUpperBearish ||
isDonUpperSwitchedToBearish)
//
&&
//
// Lower ...
(isDonLowerBearish ||
isDonLowerSwitchedToBearish)
//
;
//
// Summary DonChain State ...
//
isBullish =
//
hasBullishTrend
//
&&
//
isDonInBullishState
//
&&
//
(isHighEqualsToPeak ||
isLowEqualsToVale)
//
;
//
isBearish =
//
hasBearishTrend
//
&&
//
isDonInBearishState
//
&&
//
(isHighEqualsToPeak ||
isLowEqualsToVale)
//
;
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Check VWap Conditions ...
//
double vwapFast = triggerConditions.x121Conditions.vwapFastBuffer[1];
double vwapMid = triggerConditions.x121Conditions.vwapMidBuffer[1];
double vwapSlow = triggerConditions.x121Conditions.vwapSlowBuffer[1];
//
double vwaps[3] = {
vwapFast,
vwapMid,
vwapSlow,
};
double vwapMax = GetMax(vwaps);
double vwapMin = GetMin(vwaps);
//
bool isCloseOverVwapMax =
//
ask > vwapMax &&
bid > vwapMax &&
(cBar.low > vwapMax ||
cBar.close > vwapMax)
//
;
//
bool isCloseUnderVwapMin =
//
ask < vwapMin &&
bid < vwapMin &&
(cBar.high < vwapMin ||
cBar.close < vwapMin)
//
;
//
bool isVWapFastBullish = triggerConditions.x121Conditions.isVWapFastBullish;
bool isVWapFastBearish = triggerConditions.x121Conditions.isVWapFastBearish;
bool isVWapMidBullish = triggerConditions.x121Conditions.isVWapMidBullish;
bool isVWapMidBearish = triggerConditions.x121Conditions.isVWapMidBearish;
bool isVWapSlowBullish = triggerConditions.x121Conditions.isVWapSlowBullish;
bool isVWapSlowBearish = triggerConditions.x121Conditions.isVWapSlowBearish;
bool isVWapFastOverMid = triggerConditions.x121Conditions.isVWapFastOverMid;
bool isVWapMidOverSlow = triggerConditions.x121Conditions.isVWapMidOverSlow;
bool isVWapFastUnderMid = triggerConditions.x121Conditions.isVWapFastUnderMid;
bool isVWapMidUnderSlow = triggerConditions.x121Conditions.isVWapMidUnderSlow;
//
bool isVwapBullishFormed =
//
// Order ...
(isVWapFastOverMid ||
isVWapMidOverSlow ||
(isVWapFastOverMid &&
isVWapMidOverSlow))
//
&&
// State ...
((isVWapFastBullish &&
isVWapMidBullish) ||
(isVWapMidBullish &&
isVWapSlowBullish) ||
(isVWapFastBullish &&
isVWapMidBullish &&
isVWapSlowBullish))
//
;
//
bool isVwapBearishFormed =
//
// Order ...
(isVWapFastUnderMid ||
isVWapMidUnderSlow ||
(isVWapFastUnderMid &&
isVWapMidUnderSlow))
//
&&
// State ...
((isVWapFastBearish &&
isVWapMidBearish) ||
(isVWapMidBearish &&
isVWapSlowBearish) ||
(isVWapFastBearish &&
isVWapMidBearish &&
isVWapSlowBearish))
//
;
//
// Summar VWap State ...
//
isBullish =
isBullish &&
isCloseOverVwapMax &&
isVwapBullishFormed;
//
isBearish =
isBearish &&
isCloseUnderVwapMin &&
isVwapBearishFormed;
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Check Sar State ...
double sar = triggerConditions.x121Conditions.sarBuffer[1];
//
bool isSarBullish = triggerConditions.x121Conditions.isSarBullish;
bool isSarSwitchedToBullish = triggerConditions.x121Conditions.isSarSwitchedToBullish;
//
bool isSarBearish = triggerConditions.x121Conditions.isSarBearish;
bool isSarSwitchedToBearish = triggerConditions.x121Conditions.isSarSwitchedToBearish;
//
// Summary Sar ...
//
bool isSarBullishFormed = isSarBullish ||
isSarSwitchedToBullish;
//
bool isSarBearishFormed = isSarBearish ||
isSarSwitchedToBearish;
//
isBullish =
isBullish &&
isSarBullishFormed;
//
isBearish =
isBearish &&
isSarBearishFormed;
//
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
conditions.setupTime = cTime;
conditions.dir =
isBullish
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
return result;
}
//
// Detect Trigger Conditions ...
bool DetectX121SMCXPVDPSiganlTrigger(
//
X121SMCStrategyXPVDPSignalConditions &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 = triggerCycleHelper.mX121Helper
.GetDonChainLength();
//
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 ...
//
double vwapFast = triggerConditions.x121Conditions.vwapFastBuffer[1];
double vwapMid = triggerConditions.x121Conditions.vwapMidBuffer[1];
double vwapSlow = triggerConditions.x121Conditions.vwapSlowBuffer[1];
//
double vwaps[3] = {
vwapFast,
vwapMid,
vwapSlow,
};
double vwapMax = GetMax(vwaps);
double vwapMin = GetMin(vwaps);
//
double sar = triggerConditions.x121Conditions.sarBuffer[1];
//
isBullish =
//
IsBullish(setupDir)
//
;
//
isBearish =
//
IsBearish(setupDir)
//
;
//
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
? MathMin(sar, vwapMin)
: MathMin(sar, vwapMax);
conditions.type = isBullish
? X_POSITION_TYPE_LONG
: X_POSITION_TYPE_SHORT;
//
return result;
}
//
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -52,6 +52,20 @@ struct X121SMCStrategyXTWPVSignalConditions
double point;
XPVPivot pivot;
//
bool hasSupportZone;
bool hasResistanceZone;
bool hasSupplyZone;
bool hasDemandZone;
bool hasOrderBlock;
bool hasFairValueGap;
XCSupportZone *supportZone;
XCResistanceZone *resistanceZone;
XCSupplyZone *supplyZone;
XCDemandZone *demandZone;
XCOrderBlock *orderBlock;
XCFVG *fairValueGap;
//
// Constructor ...
X121SMCStrategyXTWPVSignalConditions()
@@ -169,8 +183,161 @@ struct X121SMCStrategyXTWPVSignalConditions
//
point = 0;
pivot.Clean();
//
CleanPriceInsideZones();
}
/**
* Clean Price Insie Zones ...
*/
void CleanPriceInsideZones()
{
//
hasSupportZone = false;
hasResistanceZone = false;
hasSupplyZone = false;
hasDemandZone = false;
hasOrderBlock = false;
hasFairValueGap = false;
//
supportZone = NULL;
resistanceZone = NULL;
supplyZone = NULL;
demandZone = NULL;
orderBlock = NULL;
fairValueGap = NULL;
}
/**
* Count Price Inside Zones ...
*
* @return ( int )
*/
int CountPriceInsideZones()
{
//
int result = 0;
//
if (hasSupportZone)
{
result++;
}
//
if (hasResistanceZone)
{
result++;
}
//
if (hasSupplyZone)
{
result++;
}
//
if (hasDemandZone)
{
result++;
}
//
if (hasOrderBlock)
{
result++;
}
//
if (hasFairValueGap)
{
result++;
}
//
return result;
}
/**
* Check Conditions Has Price Inside Zones ...
*
* @return ( bool )
*/
bool HasPriceInsideZones()
{
//
bool result = false;
//
result = IsValidSize(CountPriceInsideZones());
//
return result;
}
/**
* Check Conditions Has Bullish Price Inside Zone ...
*
* @return ( bool )
*/
bool HasBullishPriceInsideZone()
{
//
bool result = false;
//
result =
//
HasPriceInsideZones() &&
//
(hasDemandZone ||
hasSupportZone ||
(hasOrderBlock &&
orderBlock.IsBullish()) ||
(hasFairValueGap &&
fairValueGap.IsBullish()))
//
;
//
return result;
}
/**
* Check Conditions Has Bearish Price Inside Zone ...
*
* @return ( bool )
*/
bool HasBearishPriceInsideZone()
{
//
bool result = false;
//
result =
//
HasPriceInsideZones() &&
//
(hasSupplyZone ||
hasResistanceZone ||
(hasOrderBlock &&
orderBlock.IsBearish()) ||
(hasFairValueGap &&
fairValueGap.IsBearish()))
//
;
//
return result;
}
/**
* Check has Vald Pivot or not ...
*
* @return ( bool )
*/
bool HasPivot()
{
return pivot.IsValid();
@@ -555,6 +722,36 @@ bool DetectX121SMCXTWPVSiganlSetup(
conditions.point = conditions.pivot.lower;
}
//
// Detect a Zone Which Price Inside it ...
conditions.CleanPriceInsideZones();
bool hasPriceInsideZones = conditions.HasPriceInsideZones();
int priceInsideZonesCount = conditions.CountPriceInsideZones();
if (!hasPriceInsideZones)
{
//
hasPriceInsideZones = DetectPriceInsideZones(
verificationState,
cBar,
priceInsideZonesCount,
conditions.hasSupportZone,
conditions.supportZone,
conditions.hasResistanceZone,
conditions.resistanceZone,
conditions.hasSupplyZone,
conditions.supplyZone,
conditions.hasDemandZone,
conditions.demandZone,
conditions.hasOrderBlock,
conditions.orderBlock,
conditions.hasFairValueGap,
conditions.fairValueGap //
);
//
priceInsideZonesCount = conditions.CountPriceInsideZones();
}
//
double donCloseUpper = helperConditions.x121Conditions.donCloseUpperBuffer[1];
double donCloseLower = helperConditions.x121Conditions.donCloseLowerBuffer[1];
@@ -588,9 +785,8 @@ bool DetectX121SMCXTWPVSiganlSetup(
//
isBearish =
//
bearishConditions1
// ||
// bearishConditions2
bearishConditions1 ||
bearishConditions2
//
;
@@ -1003,6 +1199,72 @@ bool DetectX121SMCXTWPVSiganlTrigger(
);
}
//
double peak = analyseConditions.x121Conditions.peaksBuffer[1];
double vale = analyseConditions.x121Conditions.valesBuffer[1];
//
bool isBasedOnPeak = conditions.point == peak;
bool isBasedOnVale = conditions.point == vale;
//
bool hasPriceInsideZones = conditions.HasPriceInsideZones();
bool hasBullishPriceInsideZone = conditions.HasBullishPriceInsideZone();
bool hasBearishPriceInsideZone = conditions.HasBearishPriceInsideZone();
//
if (
isBearish &&
isBasedOnPeak &&
hasPriceInsideZones &&
hasBearishPriceInsideZone //
)
{
//
// Supply ...
if (conditions.hasSupplyZone)
{
//
Add(
conditions.supplyZone.Upper(),
sls //
);
}
//
// Resistance ...
if (conditions.hasResistanceZone)
{
//
Add(
conditions.resistanceZone.Upper(),
sls //
);
}
//
// Order Block ...
if (conditions.hasOrderBlock)
{
//
Add(
conditions.orderBlock.Upper(),
sls //
);
}
//
// Fair Value Gap ...
if (conditions.hasFairValueGap)
{
//
Add(
conditions.fairValueGap.Upper(),
sls //
);
}
}
//
double slsMin = GetMin(sls);
double slsMax = GetMax(sls);
@@ -1035,4 +1297,204 @@ bool DetectX121SMCXTWPVSiganlTrigger(
return result;
}
/**
* Drw Conditions Price Inside Zones ...
*
* @param conditions: X121SMCStrategyXTWPVSignalConditions instance Reference ...
* @param drawer: XCPOIDrawer pointer ...
* @param drawnObjects: XCBaseObject instance Reference Collection ...
*
* @return ( int )
*/
int DrawPriceInsideZones(
X121SMCStrategyXTWPVSignalConditions &conditions,
XCPOIDrawer *drawer,
XCBaseObject *&drawnObjects[] //
)
{
//
int result = 0;
//
Clean(drawnObjects);
//
if (
drawer == NULL ||
!conditions.HasPriceInsideZones())
{
return result;
}
//
// Support ...
if (conditions.hasSupportZone)
{
//
XCSupportZoneObject *iObj;
bool isCreated = drawer.CreateSupportZone(
conditions.supportZone,
iObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObj,
drawnObjects //
);
}
}
//
// Resistance ...
if (conditions.hasResistanceZone)
{
//
XCResistanceZoneObject *iObj;
bool isCreated = drawer.CreateResistanceZone(
conditions.resistanceZone,
iObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObj,
drawnObjects //
);
}
}
//
// Supply ...
if (conditions.hasSupplyZone)
{
//
XCSupplyZoneObject *iObj;
bool isCreated = drawer.CreateSupplyZone(
conditions.supplyZone,
iObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObj,
drawnObjects //
);
}
}
//
// Demand ...
if (conditions.hasDemandZone)
{
//
XCDemandZoneObject *iObj;
bool isCreated = drawer.CreateDemandZone(
conditions.demandZone,
iObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObj,
drawnObjects //
);
}
}
//
// Order Block ...
if (conditions.hasOrderBlock)
{
//
bool isBullish = conditions.orderBlock.IsBullish();
if (isBullish)
{
//
XCBullishOrderBlockObject *iObj;
bool isCreated = drawer.CreateBullishOrderBlock(
conditions.orderBlock,
iObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObj,
drawnObjects //
);
}
}
else
{
//
XCBearishOrderBlockObject *iObj;
bool isCreated = drawer.CreateBearishOrderBlock(
conditions.orderBlock,
iObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObj,
drawnObjects //
);
}
}
}
//
// FairValueGap ...
if (conditions.hasFairValueGap)
{
//
bool isBullish = conditions.fairValueGap.IsBullish();
if (isBullish)
{
//
XCBullishFairValueGapObject *iObj;
bool isCreated = drawer.CreateBullishFairValueGap(
conditions.fairValueGap,
iObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObj,
drawnObjects //
);
}
}
else
{
//
XCBearishFairValueGapObject *iObj;
bool isCreated = drawer.CreateBearishFairValueGap(
conditions.fairValueGap,
iObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iObj,
drawnObjects //
);
}
}
}
//
result = ArraySize(drawnObjects);
//
return result;
}
//
File diff suppressed because it is too large Load Diff
+20 -801
View File
@@ -28,12 +28,7 @@
//
#include "../Signals/x-121.smc.test.signal.lib.mq5"
#include "../Signals/x-121.smc.xoepv.signal.lib.mq5"
#include "../Signals/x-121.smc.xpvdp.signal.lib.mq5"
#include "../Signals/x-121.smc.xpvob.signal.lib.mq5"
#include "../Signals/x-121.smc.xpvsupdem.signal.lib.mq5"
#include "../Signals/x-121.smc.xtwpv.signal.lib.mq5"
#include "../Signals/x-121.smc.xvwpb.signal.lib.mq5"
//
// Definitions ...
@@ -161,21 +156,11 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
bool useTestSignal = false;
bool useXPVOBSignal = false;
bool useXPVDPSignal = false;
bool useXVWPBSignal = false;
bool useXTWPVSignal = true;
bool useXOEPVSignal = false;
bool useXPVSUPDEMSignal = false;
//
bool hasTestSignal = false;
bool hasXPVOBSignal = false;
bool hasXPVDPSignal = false;
bool hasXVWPBSignal = false;
bool hasXTWPVSignal = false;
bool hasXOEPVSignal = false;
bool hasXPVSUPDEMSignal = false;
//
// Test Signal ...
@@ -186,33 +171,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
hasSignal = hasTestSignal;
}
//
// XPVOB Signal ...
if (useXPVOBSignal && !hasSignal)
{
//
hasXPVOBSignal = DetectXPVOBSignal(conditions);
hasSignal = hasXPVOBSignal;
}
//
// XPVDP Signal ...
if (useXPVDPSignal && !hasSignal)
{
//
hasXPVDPSignal = DetectXPVDPSignal(conditions);
hasSignal = hasXPVDPSignal;
}
//
// XVWPB Signal ...
if (useXVWPBSignal && !hasSignal)
{
//
hasXVWPBSignal = DetectXVWPBSignal(conditions);
hasSignal = hasXVWPBSignal;
}
//
// XTWPV Signal ...
if (useXTWPVSignal && !hasSignal)
@@ -222,24 +180,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
hasSignal = hasXTWPVSignal;
}
//
// XOEPV Signal ...
if (useXOEPVSignal && !hasSignal)
{
//
hasXOEPVSignal = DetectXOEPVSignal(conditions);
hasSignal = hasXOEPVSignal;
}
//
// XPVSUPDEM Signal ...
if (useXPVSUPDEMSignal && !hasSignal)
{
//
hasXPVSUPDEMSignal = DetectXPVSUPDEMSignal(conditions);
hasSignal = hasXPVSUPDEMSignal;
}
//
result = hasSignal;
if (!result)
@@ -338,51 +278,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
signal.target = tp;
}
//
// Configure Signal Protecting ...
// if (hasXPVOBSignal ||
// hasXPVDPSignal ||
// hasXPVSUPDEMSignal)
// {
// //
// signal.fullTPLevel = r2r;
// signal.partialCloseOnTPLevel = 2;
// signal.partialCloseMultiplier = 0.5;
// //
// signal.riskFreeOnBreakEven = true;
// signal.tpLevelForBreakEven = 1;
// //
// signal.trailSL = true;
// signal.trailSLStartOnReachTPLevel = 3;
// }
//
// Configure Signal Protecting ...
// if (hasXVWPBSignal)
// {
// //
// signal.fullTPLevel = r2r;
// signal.partialCloseOnTPLevel = 2;
// signal.partialCloseMultiplier = 0.5;
// //
// signal.riskFreeOnBreakEven = true;
// signal.tpLevelForBreakEven = 1;
// //
// signal.trailSL = true;
// signal.trailSLStartOnReachTPLevel = 2;
// }
//
result = PrepareSignal(signal);
if (result)
{
DrawSignal(signal);
}
//
hasLong = false;
hasShort = false;
@@ -759,390 +657,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
return result;
}
//
// XPVOB Signal ...
X121SMCStrategyXPVOBSignalConditions mXPVOBConditions;
bool DetectXPVOBSignal(
X121SMCStrategyConditions &conditions //
)
{
//
bool result = false;
//
bool isBullish = false;
bool isBearish = false;
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
datetime cTime = TimeCurrent();
//
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XPVOB;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXPVOBConditions.setupTime;
bool isSetuped = mXPVOBConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXPVOBConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXPVOBSiganlSetup(
symbol,
period,
mXPVOBConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = isSetuped;
if (!result)
{
return result;
}
//
setupDir = mXPVOBConditions.dir;
setupTime = mXPVOBConditions.setupTime;
}
//
// Draw Conditions Active FVG ...
// if (isSetuped)
// {
// //
// XCFVG *iFVG = mXPVOBConditions.activeFVG;
// if (iFVG != NULL && iFVG.IsValid())
// {
// //
// ClearDraws();
// iFVG.To(cTime);
// if (IsBullish(setupDir) && iFVG.IsBullish())
// {
// //
// XCBullishFairValueGapObject *iObj;
// bool isCreated = mPOIDrawer.CreateBullishFairValueGap(
// iFVG,
// iObj //
// );
// if (isCreated)
// {
// AddObjectIfNotExists(iObj);
// }
// }
// else if (IsBearish(setupDir) && iFVG.IsBearish())
// {
// //
// XCBearishFairValueGapObject *iObj;
// bool isCreated = mPOIDrawer.CreateBearishFairValueGap(
// iFVG,
// iObj //
// );
// if (isCreated)
// {
// AddObjectIfNotExists(iObj);
// }
// }
// }
// }
//
// Detect Trigger Conditions ...
bool canTrigger = mXPVOBConditions.CanTrigger();
datetime triggerTime = mXPVOBConditions.triggerTime;
if (!canTrigger)
{
//
// Detect Signal Trigger ...
canTrigger = DetectX121SMCXPVOBSiganlTrigger(
mXPVOBConditions,
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
return result;
}
//
triggerTime = mXPVOBConditions.triggerTime;
}
//
// Check Signal Direction ...
//
isBullish = IsBullish(setupDir);
isBearish = IsBearish(setupDir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Issues Signal on Conditions ...
conditions.signalDir = setupDir;
conditions.provider = providerStr;
conditions.sl = mXPVOBConditions.sl;
conditions.target = mXPVOBConditions.target;
//
mXPVOBConditions.Clean();
//
return result;
}
//
// XPVDP Signal ...
X121SMCStrategyXPVDPSignalConditions mXPVDPConditions;
bool DetectXPVDPSignal(
X121SMCStrategyConditions &conditions //
)
{
//
bool result = false;
//
bool isBullish = false;
bool isBearish = false;
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
datetime cTime = TimeCurrent();
//
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XPVDP;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXPVDPConditions.setupTime;
bool isSetuped = mXPVDPConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXPVDPConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXPVDPSiganlSetup(
symbol,
period,
mXPVDPConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
setupDir = mXPVDPConditions.dir;
setupTime = mXPVDPConditions.setupTime;
}
result = isSetuped;
if (!result)
{
return result;
}
//
// Detect Trigger Conditions ...
bool canTrigger = mXPVDPConditions.CanTrigger();
datetime triggerTime = mXPVDPConditions.triggerTime;
if (!canTrigger)
{
//
// Detect Signal Trigger ...
canTrigger = DetectX121SMCXPVDPSiganlTrigger(
mXPVDPConditions,
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
return result;
}
//
triggerTime = mXPVDPConditions.triggerTime;
}
//
// Check Signal Direction ...
//
isBullish = IsBullish(setupDir);
isBearish = IsBearish(setupDir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Issues Signal on Conditions ...
conditions.signalDir = setupDir;
conditions.provider = providerStr;
conditions.sl = mXPVDPConditions.sl;
conditions.target = mXPVDPConditions.target;
//
mXPVDPConditions.Clean();
//
return result;
}
//
// XVWPB Signal ...
X121SMCStrategyXVWPBSignalConditions mXVWPBConditions;
bool DetectXVWPBSignal(
X121SMCStrategyConditions &conditions //
)
{
//
bool result = false;
//
bool isBullish = false;
bool isBearish = false;
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
datetime cTime = TimeCurrent();
//
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XVWPB;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXVWPBConditions.setupTime;
bool isSetuped = mXVWPBConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXVWPBConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXVWPBSiganlSetup(
symbol,
period,
mXVWPBConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
setupDir = mXVWPBConditions.dir;
setupTime = mXVWPBConditions.setupTime;
}
result = isSetuped;
if (!result)
{
return result;
}
//
// Detect Trigger Conditions ...
bool canTrigger = mXVWPBConditions.CanTrigger();
datetime triggerTime = mXVWPBConditions.triggerTime;
if (!canTrigger)
{
//
// Detect Signal Trigger ...
canTrigger = DetectX121SMCXVWPBSiganlTrigger(
mXVWPBConditions,
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
return result;
}
//
triggerTime = mXVWPBConditions.triggerTime;
}
//
// Check Signal Direction ...
//
isBullish = IsBullish(setupDir);
isBearish = IsBearish(setupDir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Issues Signal on Conditions ...
conditions.signalDir = setupDir;
conditions.provider = providerStr;
conditions.sl = mXVWPBConditions.sl;
conditions.target = mXVWPBConditions.target;
//
mXVWPBConditions.Clean();
//
return result;
}
//
// XTWPV Signal ...
X121SMCStrategyXTWPVSignalConditions mXTWPVConditions;
@@ -1192,39 +706,26 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
setupDir = mXTWPVConditions.dir;
setupTime = mXTWPVConditions.setupTime;
// //
// if (!isSetuped)
// {
// //
// bool hasParent = mXTWPVConditions.HasParentPivot();
// if (hasParent)
// {
// //
// XCBaseObject *objs[];
// mPOIDrawer.DrawPivot(
// mXTWPVConditions.parentPivot,
// objs,
// true, // Drawing State ...
// true // Drawing Ticks Zone ...
// );
// AddObjectsIfNotExists(objs);
// }
// //
// bool hasChild = mXTWPVConditions.HasChildPivot();
// if (hasChild)
// {
// //
// XCBaseObject *objs[];
// mPOIDrawer.DrawPivot(
// mXTWPVConditions.childPivot,
// objs //
// );
// AddObjectsIfNotExists(objs);
// }
// }
}
//
// Draw Price Inside Zones ...
if (mXTWPVConditions.HasPriceInsideZones())
{
//
ClearDraws();
//
XCBaseObject *drawnObjects[];
int drawnObjectsCount = DrawPriceInsideZones(
mXTWPVConditions,
mPOIDrawer,
drawnObjects //
);
AddObjectsIfNotExists(drawnObjects);
}
//
result = isSetuped;
if (!result)
{
@@ -1289,288 +790,6 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
return result;
}
//
// XOEPV Signal ...
X121SMCStrategyXOEPVSignalConditions mXOEPVConditions;
bool DetectXOEPVSignal(
X121SMCStrategyConditions &conditions //
)
{
//
bool result = false;
//
bool isBullish = false;
bool isBearish = false;
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
datetime cTime = TimeCurrent();
//
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XOEPV;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXOEPVConditions.setupTime;
bool isSetuped = mXOEPVConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXOEPVConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXOEPVSiganlSetup(
symbol,
period,
mXOEPVConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
setupDir = mXOEPVConditions.dir;
setupTime = mXOEPVConditions.setupTime;
}
//
result = isSetuped;
if (!result)
{
return result;
}
//
// Detect Trigger Conditions ...
bool canTrigger = mXOEPVConditions.CanTrigger();
datetime triggerTime = mXOEPVConditions.triggerTime;
if (!canTrigger)
{
//
// Detect Signal Trigger ...
canTrigger = DetectX121SMCXOEPVSiganlTrigger(
mXOEPVConditions,
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
return result;
}
//
triggerTime = mXOEPVConditions.triggerTime;
}
//
// Check Signal Direction ...
//
isBullish = IsBullish(setupDir);
isBearish = IsBearish(setupDir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Issues Signal on Conditions ...
conditions.signalDir = setupDir;
conditions.provider = providerStr;
conditions.sl = mXOEPVConditions.sl;
conditions.target = mXOEPVConditions.target;
//
mXOEPVConditions.Clean();
//
return result;
}
//
// XPVSUPDEM Signal ...
X121SMCStrategyXPVSUPDEMSignalConditions mXPVSUPDEMConditions;
bool DetectXPVSUPDEMSignal(
X121SMCStrategyConditions &conditions //
)
{
//
bool result = false;
//
bool isBullish = false;
bool isBearish = false;
//
string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod();
//
datetime cTime = TimeCurrent();
//
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XPVSUPDEM;
string providerStr = ToString(provider);
//
// Detect Setup Conditions ...
datetime setupTime = mXPVSUPDEMConditions.setupTime;
bool isSetuped = mXPVSUPDEMConditions.IsSetuped();
ENUM_X_DIRECTION setupDir = mXPVSUPDEMConditions.dir;
if (!isSetuped)
{
//
// Detect Signal Setup ...
isSetuped = DetectX121SMCXPVSUPDEMSiganlSetup(
symbol,
period,
mXPVSUPDEMConditions,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
setupDir = mXPVSUPDEMConditions.dir;
setupTime = mXPVSUPDEMConditions.setupTime;
}
// ClearDraws();
// ENUM_X_DIRECTION activeZoneDir;
// bool hasTicksZone = mXPVSUPDEMConditions.HasTicksZone();
// bool hasActiveZone = mXPVSUPDEMConditions.HasActiveZone(activeZoneDir);
// if (hasActiveZone)
// {
// //
// if (IsBullish(activeZoneDir))
// {
// //
// mXPVSUPDEMConditions.activeDemandZone.To(cTime);
// XCDemandZoneObject *iObj;
// bool isCreated = mPOIDrawer.CreateDemandZone(
// mXPVSUPDEMConditions.activeDemandZone,
// iObj //
// );
// if (isCreated)
// {
// AddObjectIfNotExists(iObj);
// }
// }
// else
// {
// //
// mXPVSUPDEMConditions.activeSupplyZone.To(cTime);
// XCSupplyZoneObject *iObj;
// bool isCreated = mPOIDrawer.CreateSupplyZone(
// mXPVSUPDEMConditions.activeSupplyZone,
// iObj //
// );
// if (isCreated)
// {
// AddObjectIfNotExists(iObj);
// }
// }
// }
// if (hasTicksZone)
// {
// //
// XCTicksZoneObject *iObj;
// bool isCreated = mPOIDrawer.CreateTicksZone(
// mXPVSUPDEMConditions.ticksZone,
// iObj //
// );
// if (isCreated)
// {
// AddObjectIfNotExists(iObj);
// }
// }
//
result = isSetuped;
if (!result)
{
return result;
}
//
// Detect Trigger Conditions ...
bool canTrigger = mXPVSUPDEMConditions.CanTrigger();
datetime triggerTime = mXPVSUPDEMConditions.triggerTime;
if (!canTrigger)
{
//
// Detect Signal Trigger ...
canTrigger = DetectX121SMCXPVSUPDEMSiganlTrigger(
mXPVSUPDEMConditions,
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
return result;
}
//
triggerTime = mXPVSUPDEMConditions.triggerTime;
}
//
// Check Signal Direction ...
//
isBullish = IsBullish(setupDir);
isBearish = IsBearish(setupDir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Issues Signal on Conditions ...
conditions.signalDir = setupDir;
conditions.provider = providerStr;
conditions.sl = mXPVSUPDEMConditions.sl;
conditions.target = mXPVSUPDEMConditions.target;
//
mXPVSUPDEMConditions.Clean();
//
return result;
}
//
// Private ...
private: