last ...
This commit is contained in:
@@ -38,8 +38,8 @@ input string eaLogSuffix = ""; // Log Suffix
|
|||||||
//
|
//
|
||||||
// Symbols ...
|
// Symbols ...
|
||||||
input group "Symbols";
|
input group "Symbols";
|
||||||
input bool eaMultiSymbol = false; // Use Multi Symbol
|
input bool eaMultiSymbol = false; // Use Multi Symbol
|
||||||
input string eaSymbols = "EURUSDb,GBPUSDb,USDCHFb,USDJPYb,XAUUSDb"; // Trading Symbols
|
input string eaSymbols = "EURUSDb,GBPUSDb,USDCHFb,USDJPYb"; // Trading Symbols
|
||||||
|
|
||||||
//
|
//
|
||||||
// Signalling ...
|
// Signalling ...
|
||||||
@@ -82,9 +82,9 @@ input int eaPauseSignallingAfterReachesMaxAllowedSLInSecconds = 10800; // Pause
|
|||||||
// 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 = 3; // Minimum Open Positions for Hedging
|
input int eaMinOpenTradesFroHedging = 2; // 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.0; // Minimum Required Profit Per Volume Step for Hedging
|
input double eaHedgeingMinRequiredProfitPerVolumeStep = 2.0; // Minimum Required Profit Per Volume Step for Hedging
|
||||||
|
|
||||||
//
|
//
|
||||||
// Alert ...
|
// Alert ...
|
||||||
|
|||||||
@@ -166,7 +166,6 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
XBoxZone signalBox;
|
XBoxZone signalBox;
|
||||||
bool hasPriority = false;
|
bool hasPriority = false;
|
||||||
int activatedFVGIDX = -1;
|
int activatedFVGIDX = -1;
|
||||||
int activatedBoxIDX = -1;
|
|
||||||
int activatedZoneIDX = -1;
|
int activatedZoneIDX = -1;
|
||||||
double amountPercent = -1;
|
double amountPercent = -1;
|
||||||
bool hasSignalBox = false;
|
bool hasSignalBox = false;
|
||||||
@@ -283,113 +282,66 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
// Detect Signal Box ...
|
// Detect Signal Box ...
|
||||||
|
|
||||||
//
|
//
|
||||||
bool isZoneActivated =
|
// TODO: Check This ...
|
||||||
hasWorkingZone &&
|
// bool isZoneActivated =
|
||||||
hasWaitingZones &&
|
// hasWorkingZone &&
|
||||||
workingZone.IsZoneActivated(
|
// hasWaitingZones &&
|
||||||
activatedZoneIDX,
|
// workingZone.IsZoneActivated(
|
||||||
activatedFVGIDX,
|
// activatedZoneIDX,
|
||||||
provider,
|
// activatedFVGIDX,
|
||||||
zIndex //
|
// provider,
|
||||||
);
|
// zIndex //
|
||||||
|
// );
|
||||||
//
|
|
||||||
bool isBoxActivated =
|
|
||||||
hasWorkingZone &&
|
|
||||||
hasWaitingBoxes &&
|
|
||||||
workingZone.IsBoxActivated(
|
|
||||||
activatedBoxIDX,
|
|
||||||
provider,
|
|
||||||
zIndex //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
hasSignalBox =
|
hasSignalBox =
|
||||||
isBoxActivated ||
|
hasWorkingZone &&
|
||||||
isZoneActivated;
|
hasWaitingBoxes &&
|
||||||
|
workingZone.IsBoxActivated(
|
||||||
|
signalBox,
|
||||||
|
signalBoxDir,
|
||||||
|
signalProvider,
|
||||||
|
provider,
|
||||||
|
zIndex //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
if (hasSignalBox)
|
if (hasSignalBox)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
signalBox.Clean();
|
if (hasWaitingBoxes)
|
||||||
|
|
||||||
//
|
|
||||||
if (isZoneActivated)
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
XOBFVG iOBFVG = workingZone.waitingZones[activatedZoneIDX];
|
int idx = FindIndex(
|
||||||
XCFVG *activatedFVG = iOBFVG.fvgs[activatedFVGIDX];
|
|
||||||
hasSignalBox = ToBox(
|
|
||||||
signalBox,
|
signalBox,
|
||||||
activatedFVG //
|
workingZone.waitingBoxes //
|
||||||
);
|
);
|
||||||
|
bool has = IsValidIndex(idx);
|
||||||
//
|
if (has)
|
||||||
signalProvider = X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE;
|
|
||||||
|
|
||||||
//
|
|
||||||
ArrayRemove(
|
|
||||||
workingZone.waitingZones[activatedZoneIDX].fvgs,
|
|
||||||
activatedFVGIDX,
|
|
||||||
1 //
|
|
||||||
);
|
|
||||||
bool isValid = workingZone.waitingZones[activatedZoneIDX].IsValid();
|
|
||||||
if (!isValid)
|
|
||||||
{
|
{
|
||||||
//
|
|
||||||
AddRef(
|
|
||||||
workingZone.waitingZones[activatedZoneIDX],
|
|
||||||
workingZone.unavailableZones //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
ArrayRemove(
|
ArrayRemove(
|
||||||
workingZone.waitingZones,
|
workingZone.waitingBoxes,
|
||||||
activatedZoneIDX,
|
idx,
|
||||||
1 //
|
1 //
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
iOBFVG.Clean();
|
|
||||||
ZeroMemory(activatedFVG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
if (isBoxActivated)
|
AddRef(
|
||||||
{
|
signalBox,
|
||||||
//
|
workingZone.unavailableBoxes //
|
||||||
signalBox = workingZone.waitingBoxes[activatedBoxIDX];
|
);
|
||||||
|
|
||||||
//
|
|
||||||
signalProvider = X121SMC_XWZ_PROVIDER_ACTIVATED_BOX;
|
|
||||||
|
|
||||||
//
|
|
||||||
AddRef(
|
|
||||||
signalBox,
|
|
||||||
workingZone.unavailableBoxes //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
ArrayRemove(
|
|
||||||
workingZone.waitingBoxes,
|
|
||||||
activatedBoxIDX,
|
|
||||||
1 //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
if (hasSignalBox)
|
signalBox.to = cTime;
|
||||||
{
|
|
||||||
//
|
|
||||||
signalBox.to = cTime;
|
|
||||||
signalBoxDir = signalBox.dir;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// Remove Invalidate Zones ...
|
// Remove Invalidate Zones ...
|
||||||
if (hasWaitingZones)
|
if (hasWaitingZones)
|
||||||
@@ -499,25 +451,48 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
// iSL = signalBox.lower + (signalBox.upper - signalBox.lower) / 2;
|
// iSL = signalBox.lower + (signalBox.upper - signalBox.lower) / 2;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// //
|
//
|
||||||
// if (provider == X121SMC_XWZ_PROVIDER_PV_ZONE)
|
if (signalProvider == X121SMC_XWZ_PROVIDER_ACTIVATED_MA)
|
||||||
// {
|
{
|
||||||
// }
|
//
|
||||||
|
// Default SL ...
|
||||||
|
iSL = pivot;
|
||||||
|
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iSL,
|
||||||
|
sls //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (signalProvider == X121SMC_XWZ_PROVIDER_ACTIVATED_BOX)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Default SL ...
|
||||||
|
iSL = pivot;
|
||||||
|
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iSL,
|
||||||
|
sls //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (signalProvider == X121SMC_XWZ_PROVIDER_ACTIVATED_AREA)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Default SL ...
|
||||||
|
iSL = pivot;
|
||||||
|
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iSL,
|
||||||
|
sls //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
double iAtr = provider.decisionXConditions.atrBuffer[1];
|
double iAtr = provider.decisionXConditions.atrBuffer[1];
|
||||||
iAtr *= 1.5;
|
iAtr *= 1.5;
|
||||||
|
|
||||||
//
|
|
||||||
// Default SL ...
|
|
||||||
iSL = pivot;
|
|
||||||
|
|
||||||
//
|
|
||||||
Add(
|
|
||||||
iSL,
|
|
||||||
sls //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Select Condition SL ...
|
// Select Condition SL ...
|
||||||
|
|
||||||
@@ -538,16 +513,30 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
// Targets ...
|
// Targets ...
|
||||||
|
|
||||||
//
|
//
|
||||||
// Force Add TP 2 as Target ...
|
|
||||||
double risk = MathAbs(entry - sl);
|
double risk = MathAbs(entry - sl);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Checking risk ...
|
||||||
|
if (risk >= maxAllowedSLDistanceInPoint)
|
||||||
|
{
|
||||||
|
// Print("Max Aloowed Risk Point Reached ...");
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
double reward2 = 2 * risk;
|
double reward2 = 2 * risk;
|
||||||
// double iTP2 = isBullish
|
double reward3 = 3 * risk;
|
||||||
// ? entry + reward2
|
double iTP2 = isBullish
|
||||||
// : entry - reward2;
|
? entry + reward2
|
||||||
// Add(
|
: entry - reward2;
|
||||||
// iTP2,
|
double iTP3 = isBullish
|
||||||
// targets //
|
? entry + reward3
|
||||||
// );
|
: entry - reward3;
|
||||||
|
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
iTP2,
|
||||||
|
targets //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Based On Priority ...
|
// Based On Priority ...
|
||||||
@@ -984,18 +973,10 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
bool result = false;
|
bool result = false;
|
||||||
return false;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
Clean(guards);
|
Clean(guards);
|
||||||
|
|
||||||
//
|
|
||||||
bool isCycleHelpersValid =
|
|
||||||
//
|
|
||||||
provider.IsValid()
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set Provider for Common Guards ...
|
// Set Provider for Common Guards ...
|
||||||
string signalProvider = ToString(X_121_SMC_PROVIDER_XWZ);
|
string signalProvider = ToString(X_121_SMC_PROVIDER_XWZ);
|
||||||
@@ -1006,6 +987,9 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
int pIndex = cIndex + 1;
|
int pIndex = cIndex + 1;
|
||||||
int ppIndex = pIndex + 1;
|
int ppIndex = pIndex + 1;
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL cBar;
|
||||||
|
|
||||||
//
|
//
|
||||||
int loopback = 10;
|
int loopback = 10;
|
||||||
|
|
||||||
@@ -1016,14 +1000,18 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
double points = GetPoints(symbol);
|
double points = GetPoints(symbol);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check Cycle Helpers Validation ...
|
// Cycles Conditions ...
|
||||||
result = isCycleHelpersValid &&
|
result = provider.IsValid();
|
||||||
provider.Prepare(
|
result =
|
||||||
zIndex,
|
result &&
|
||||||
loopback //
|
provider.Prepare(
|
||||||
);
|
zIndex,
|
||||||
|
loopback //
|
||||||
|
);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
provider.Clean();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1117,18 +1105,18 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
// Get Global and Common Guards ...
|
// Get Global and Common Guards ...
|
||||||
|
|
||||||
//
|
//
|
||||||
ENUM_X_121_SMC_GUARD_ACTIONS ignoreGuards[1] = {
|
// ENUM_X_121_SMC_GUARD_ACTIONS ignoreGuards[1] = {
|
||||||
X_121_SMC_GUARD_ACTION_TRAIL_STOP //
|
// X_121_SMC_GUARD_ACTION_TRAIL_STOP //
|
||||||
};
|
// };
|
||||||
result = DetectX121SMCGuards(
|
// result = DetectX121SMCGuards(
|
||||||
signalProvider,
|
// signalProvider,
|
||||||
guards,
|
// guards,
|
||||||
positions,
|
// positions,
|
||||||
provider,
|
// provider,
|
||||||
//
|
// //
|
||||||
ignoreGuards
|
// ignoreGuards
|
||||||
//
|
// //
|
||||||
);
|
// );
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -1178,6 +1166,70 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XBoxZone bullishBox;
|
||||||
|
bool hasBullishBox = false;
|
||||||
|
bool isBullishBoxBreaked = false;
|
||||||
|
if (!hasBullishBox)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCOrderBlock *ob = NULL;
|
||||||
|
idx = GetYoungest(provider.analyseState.bullishOrderBlocks);
|
||||||
|
has = IsValidIndex(idx);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ob = provider.analyseState.bullishOrderBlocks[idx];
|
||||||
|
|
||||||
|
//
|
||||||
|
hasBullishBox = ToBox(
|
||||||
|
bullishBox,
|
||||||
|
ob //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!hasBullishBox)
|
||||||
|
{
|
||||||
|
bullishBox.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ZeroMemory(ob);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XBoxZone bearishBox;
|
||||||
|
bool hasBearishBox = false;
|
||||||
|
bool isBearishBoxBreaked = false;
|
||||||
|
if (!hasBearishBox)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCOrderBlock *ob = NULL;
|
||||||
|
idx = GetYoungest(provider.analyseState.bearishOrderBlocks);
|
||||||
|
has = IsValidIndex(idx);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ob = provider.analyseState.bearishOrderBlocks[idx];
|
||||||
|
|
||||||
|
//
|
||||||
|
hasBearishBox = ToBox(
|
||||||
|
bearishBox,
|
||||||
|
ob //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!hasBearishBox)
|
||||||
|
{
|
||||||
|
bearishBox.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ZeroMemory(ob);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Here We Have all Requirements for Guarding Positions ...
|
// Here We Have all Requirements for Guarding Positions ...
|
||||||
|
|
||||||
@@ -1216,12 +1268,32 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
//
|
//
|
||||||
// X_121_SMC_GUARD_ACTION_TRAIL_STOP:
|
// X_121_SMC_GUARD_ACTION_TRAIL_STOP:
|
||||||
// Trail Stop Specified Position on Specified Conditions ...
|
// Trail Stop Specified Position on Specified Conditions ...
|
||||||
|
bool handleStoptrailingBasedOnBoxes = true;
|
||||||
bool handleStoptrailingBasedOnConsolidationZones = true;
|
bool handleStoptrailingBasedOnConsolidationZones = true;
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
XPosition iPosition = ownPositions[i];
|
XPosition iPosition = ownPositions[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isInited = cBar.Init(
|
||||||
|
iPosition.symbol,
|
||||||
|
iPosition.period,
|
||||||
|
cIndex //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullishBoxBreaked =
|
||||||
|
isInited &&
|
||||||
|
hasBullishBox &&
|
||||||
|
cBar.high < bullishBox.lower;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearishBoxBreaked =
|
||||||
|
isInited &&
|
||||||
|
hasBearishBox &&
|
||||||
|
cBar.low > bearishBox.upper;
|
||||||
|
|
||||||
//
|
//
|
||||||
bool isLong = IsLong(iPosition.type);
|
bool isLong = IsLong(iPosition.type);
|
||||||
bool isInProfit = iPosition.profit > 0;
|
bool isInProfit = iPosition.profit > 0;
|
||||||
@@ -1272,6 +1344,90 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
canTraiLonglUsingCZone ||
|
canTraiLonglUsingCZone ||
|
||||||
canTraiShortlUsingCZone;
|
canTraiShortlUsingCZone;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Trail Stop Using Boxes ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canTraiLonglUsingBox =
|
||||||
|
//
|
||||||
|
handleStoptrailingBasedOnBoxes &&
|
||||||
|
//
|
||||||
|
(isLong &&
|
||||||
|
isInProfit &&
|
||||||
|
hasBullishBox &&
|
||||||
|
bullishBox.lower > iPosition.sl &&
|
||||||
|
bullishBox.lower > iPosition.entry)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (canTraiLonglUsingBox)
|
||||||
|
{
|
||||||
|
sl = bullishBox.lower;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canTraiShortlUsingBox =
|
||||||
|
//
|
||||||
|
handleStoptrailingBasedOnBoxes &&
|
||||||
|
//
|
||||||
|
(!isLong &&
|
||||||
|
isInProfit &&
|
||||||
|
hasBearishBox &&
|
||||||
|
bearishBox.upper < iPosition.sl &&
|
||||||
|
bearishBox.upper < iPosition.entry)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (canTraiShortlUsingBox)
|
||||||
|
{
|
||||||
|
sl = bearishBox.upper;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canTrailUsingBox =
|
||||||
|
canTraiLonglUsingBox ||
|
||||||
|
canTraiShortlUsingBox;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canTraiLonglUsingBreakedBox =
|
||||||
|
//
|
||||||
|
handleStoptrailingBasedOnBoxes &&
|
||||||
|
//
|
||||||
|
(isLong &&
|
||||||
|
isInProfit &&
|
||||||
|
isBearishBoxBreaked &&
|
||||||
|
bearishBox.upper > iPosition.sl &&
|
||||||
|
bearishBox.upper > iPosition.entry)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (canTraiLonglUsingBreakedBox)
|
||||||
|
{
|
||||||
|
sl = bearishBox.upper;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canTraiShortlUsingBreakedBox =
|
||||||
|
//
|
||||||
|
handleStoptrailingBasedOnBoxes &&
|
||||||
|
//
|
||||||
|
(!isLong &&
|
||||||
|
isInProfit &&
|
||||||
|
isBullishBoxBreaked &&
|
||||||
|
bullishBox.lower < iPosition.sl &&
|
||||||
|
bullishBox.lower < iPosition.entry)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (canTraiShortlUsingBreakedBox)
|
||||||
|
{
|
||||||
|
sl = bullishBox.lower;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canTrailUsingBreakedBox =
|
||||||
|
canTraiLonglUsingBreakedBox ||
|
||||||
|
canTraiShortlUsingBreakedBox;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summarize SL ...
|
||||||
|
|
||||||
//
|
//
|
||||||
bool isSLPassed =
|
bool isSLPassed =
|
||||||
sl > 0 &&
|
sl > 0 &&
|
||||||
@@ -1282,7 +1438,9 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
//
|
//
|
||||||
bool canTrail =
|
bool canTrail =
|
||||||
isSLPassed &&
|
isSLPassed &&
|
||||||
canTrailUsingCZone;
|
(canTrailUsingBox ||
|
||||||
|
canTrailUsingCZone ||
|
||||||
|
canTrailUsingBreakedBox);
|
||||||
if (canTrail)
|
if (canTrail)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1319,9 +1477,20 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
//
|
//
|
||||||
// Cleanup Collections ...
|
// Cleanup Collections ...
|
||||||
|
|
||||||
|
//
|
||||||
|
cBar.Clean();
|
||||||
|
|
||||||
//
|
//
|
||||||
provider.Clean();
|
provider.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
bullishBox.Clean();
|
||||||
|
bearishBox.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
bullishConsolidationZone.Clean();
|
||||||
|
bearishConsolidationZone.Clean();
|
||||||
|
|
||||||
//
|
//
|
||||||
count = ArraySize(guards);
|
count = ArraySize(guards);
|
||||||
result = IsValidSize(count);
|
result = IsValidSize(count);
|
||||||
|
|||||||
@@ -30,7 +30,9 @@
|
|||||||
enum ENUM_X121SMC_XWZ_PROVIDERS
|
enum ENUM_X121SMC_XWZ_PROVIDERS
|
||||||
{
|
{
|
||||||
X121SMC_XWZ_PROVIDER_NONE,
|
X121SMC_XWZ_PROVIDER_NONE,
|
||||||
|
X121SMC_XWZ_PROVIDER_ACTIVATED_MA,
|
||||||
X121SMC_XWZ_PROVIDER_ACTIVATED_BOX,
|
X121SMC_XWZ_PROVIDER_ACTIVATED_BOX,
|
||||||
|
X121SMC_XWZ_PROVIDER_ACTIVATED_AREA,
|
||||||
X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE,
|
X121SMC_XWZ_PROVIDER_ACTIVATED_ZONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -656,40 +658,32 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
if (hasNewAnalyseOrderBlock)
|
if (hasNewAnalyseOrderBlock)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
XCBaseObject *iObj;
|
XOHCL obStartedBar;
|
||||||
has = provider
|
bool isOBStartedBodyOut = false;
|
||||||
.visionCycleHelper
|
bool isOBStarted = analyseOB.IsStarted(
|
||||||
.mPOIDrawer
|
analyseOB.GetDirection(),
|
||||||
.CreateOrderBlock(
|
obStartedBar,
|
||||||
analyseOB,
|
isOBStartedBodyOut //
|
||||||
iObj //
|
);
|
||||||
);
|
|
||||||
|
//
|
||||||
|
has = isOBStarted &&
|
||||||
|
isOBStartedBodyOut;
|
||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
XOHCL obStartedBar;
|
analyseOBBox.from =
|
||||||
bool isOBStartedBodyOut = false;
|
obStartedBar.NextAt();
|
||||||
bool isOBStarted = analyseOB.IsStarted(
|
|
||||||
analyseOB.GetDirection(),
|
|
||||||
obStartedBar,
|
|
||||||
isOBStartedBodyOut //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
has = isOBStarted &&
|
has = IsExists(analyseOBBox);
|
||||||
isOBStartedBodyOut;
|
if (!has)
|
||||||
if (has)
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
has = IsExists(analyseOBBox);
|
AddRef(
|
||||||
if (!has)
|
analyseOBBox,
|
||||||
{
|
waitingBoxes //
|
||||||
//
|
);
|
||||||
AddRef(
|
|
||||||
analyseOBBox,
|
|
||||||
waitingBoxes //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -881,6 +875,8 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
bool IsZoneActivated(
|
bool IsZoneActivated(
|
||||||
int &zoneIDX,
|
int &zoneIDX,
|
||||||
int &fvgIDX,
|
int &fvgIDX,
|
||||||
|
ENUM_X_DIRECTION &dir,
|
||||||
|
ENUM_X121SMC_XWZ_PROVIDERS &signalProvider,
|
||||||
X121SMCStrategySignalProviderData &provider,
|
X121SMCStrategySignalProviderData &provider,
|
||||||
int barIndex = 0 //
|
int barIndex = 0 //
|
||||||
)
|
)
|
||||||
@@ -888,11 +884,11 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
//
|
//
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
//
|
|
||||||
zoneIDX = -1;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
fvgIDX = -1;
|
fvgIDX = -1;
|
||||||
|
zoneIDX = -1;
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
signalProvider = X121SMC_XWZ_PROVIDER_NONE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Normalize Bar Index ...
|
// Normalize Bar Index ...
|
||||||
@@ -1119,7 +1115,9 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
|
|
||||||
//
|
//
|
||||||
bool IsBoxActivated(
|
bool IsBoxActivated(
|
||||||
int &boxIDX,
|
XBoxZone &box,
|
||||||
|
ENUM_X_DIRECTION &dir,
|
||||||
|
ENUM_X121SMC_XWZ_PROVIDERS &signalProviderl,
|
||||||
X121SMCStrategySignalProviderData &provider,
|
X121SMCStrategySignalProviderData &provider,
|
||||||
int barIndex = 0 //
|
int barIndex = 0 //
|
||||||
)
|
)
|
||||||
@@ -1128,7 +1126,9 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
boxIDX = -1;
|
box.Clean();
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
signalProviderl = X121SMC_XWZ_PROVIDER_NONE;
|
||||||
|
|
||||||
//
|
//
|
||||||
if (barIndex < 0)
|
if (barIndex < 0)
|
||||||
@@ -1147,6 +1147,7 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
//
|
//
|
||||||
XOHCL bar;
|
XOHCL bar;
|
||||||
XOHCL cBar;
|
XOHCL cBar;
|
||||||
|
XOHCL pBar;
|
||||||
result = bar.Init(
|
result = bar.Init(
|
||||||
symbol,
|
symbol,
|
||||||
period,
|
period,
|
||||||
@@ -1155,6 +1156,9 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
result =
|
result =
|
||||||
result &&
|
result &&
|
||||||
bar.GetPreviousBar(cBar);
|
bar.GetPreviousBar(cBar);
|
||||||
|
result =
|
||||||
|
result &&
|
||||||
|
cBar.GetPreviousBar(pBar);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1169,6 +1173,8 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
// Retrieve Some Required Data ...
|
// Retrieve Some Required Data ...
|
||||||
|
|
||||||
//
|
//
|
||||||
|
double peakZ = provider.decisionXConditions.peaksBuffer[0];
|
||||||
|
double valeZ = provider.decisionXConditions.valesBuffer[0];
|
||||||
double peak = provider.decisionXConditions.peaksBuffer[1];
|
double peak = provider.decisionXConditions.peaksBuffer[1];
|
||||||
double vale = provider.decisionXConditions.valesBuffer[1];
|
double vale = provider.decisionXConditions.valesBuffer[1];
|
||||||
|
|
||||||
@@ -1230,6 +1236,19 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
provider.visionBearishScore > provider.visionBullishScore;
|
provider.visionBearishScore > provider.visionBullishScore;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
bool isScoreBullish =
|
||||||
|
isVisionScoreBullish &&
|
||||||
|
isAnalyseScoreBullish &&
|
||||||
|
isConsolidationScoreBullish;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isScoreBearish =
|
||||||
|
isVisionScoreBearish &&
|
||||||
|
isAnalyseScoreBearish &&
|
||||||
|
isConsolidationScoreBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Waiting Boxes ...
|
||||||
int count = CountWaitingBoxes();
|
int count = CountWaitingBoxes();
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
@@ -1237,6 +1256,38 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
XBoxZone iBox = waitingBoxes[i];
|
XBoxZone iBox = waitingBoxes[i];
|
||||||
bool isBullish = iBox.IsBullish();
|
bool isBullish = iBox.IsBullish();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Score ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isScorePassed =
|
||||||
|
isBullish
|
||||||
|
? isScoreBullish
|
||||||
|
: isScoreBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bar Insides ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isPBarInside =
|
||||||
|
(pBar.high <= iBox.upper &&
|
||||||
|
pBar.low >= iBox.lower) ||
|
||||||
|
(isBullish
|
||||||
|
? pBar.low < iBox.upper &&
|
||||||
|
pBar.GetDown() < iBox.upper
|
||||||
|
: pBar.high > iBox.lower &&
|
||||||
|
pBar.GetUp() > iBox.lower);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isCBarInside =
|
||||||
|
(cBar.high <= iBox.upper &&
|
||||||
|
cBar.low >= iBox.lower) ||
|
||||||
|
(isBullish
|
||||||
|
? cBar.low < iBox.upper &&
|
||||||
|
cBar.GetDown() < iBox.upper
|
||||||
|
: cBar.high > iBox.lower &&
|
||||||
|
cBar.GetUp() > iBox.lower);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Checking Rejection ...
|
// Checking Rejection ...
|
||||||
|
|
||||||
@@ -1255,12 +1306,7 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
cBar.GetUp() < iBox.lower;
|
cBar.GetUp() < iBox.lower;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Rejection ...
|
// Check Breaktion ...
|
||||||
bool isRejected = isBullishRejected ||
|
|
||||||
isBearishRejected;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Checking Breaktion ...
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Bullish ...
|
// Bullish ...
|
||||||
@@ -1279,27 +1325,655 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
cBar.high <= iBox.upper;
|
cBar.high <= iBox.upper;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Breaktion ...
|
// Checking PV Pass ...
|
||||||
bool isBreaked = isBullishBreaked ||
|
|
||||||
isBearishBreaked;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
result = isRejected ||
|
bool isBullishPVPassed =
|
||||||
isBreaked;
|
isBullish &&
|
||||||
|
vale == valeZ &&
|
||||||
|
vale > iBox.lower &&
|
||||||
|
vale < iBox.upper;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBearishPVPassed =
|
||||||
|
!isBullish &&
|
||||||
|
peak == peakZ &&
|
||||||
|
peak > iBox.lower &&
|
||||||
|
peak < iBox.upper;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summarise ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Rejection ...
|
||||||
|
bool isRejected = isBullishRejected ||
|
||||||
|
isBearishRejected;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Breaktion ...
|
||||||
|
bool isBreaked =
|
||||||
|
isPBarInside &&
|
||||||
|
(isBullishBreaked ||
|
||||||
|
isBearishBreaked);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isPVPassed =
|
||||||
|
(isBullishPVPassed ||
|
||||||
|
isBearishPVPassed);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Trend Conditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isX3MABullish =
|
||||||
|
provider.decisionXConditions.isX3MaFastOverMid &&
|
||||||
|
provider.decisionXConditions.x3maMidBuffer[1] > provider.decisionXConditions.x3maSlowBuffer[1];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isX3MABearish =
|
||||||
|
provider.decisionXConditions.isX3MaFastUnderMid &&
|
||||||
|
provider.decisionXConditions.x3maMidBuffer[1] < provider.decisionXConditions.x3maSlowBuffer[1];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isVWapBullish =
|
||||||
|
provider.decisionXConditions.isVWapFastOverMid &&
|
||||||
|
provider.decisionXConditions.vwapMidBuffer[1] > provider.decisionXConditions.vwapSlowBuffer[1];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isVWapBearish =
|
||||||
|
provider.decisionXConditions.isX3MaFastUnderMid &&
|
||||||
|
provider.decisionXConditions.vwapMidBuffer[1] < provider.decisionXConditions.vwapSlowBuffer[1];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isTrendBullish =
|
||||||
|
isX3MABullish &&
|
||||||
|
isVWapBullish;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isTrendBearish =
|
||||||
|
isX3MABearish &&
|
||||||
|
isVWapBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isTrendPassed =
|
||||||
|
isBullish
|
||||||
|
? isTrendBullish
|
||||||
|
: isTrendBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summarize Conditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
//
|
||||||
|
// isBreaked ||
|
||||||
|
// isRejected ||
|
||||||
|
isPVPassed &&
|
||||||
|
isRejected &&
|
||||||
|
isTrendPassed &&
|
||||||
|
isScorePassed
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
//
|
//
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
boxIDX = i;
|
box = iBox;
|
||||||
|
dir = iBox.dir;
|
||||||
|
signalProviderl = X121SMC_XWZ_PROVIDER_ACTIVATED_BOX;
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.Clean();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// MA Trends ...
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = provider.analyseState.HasOrderBlocks();
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Trend Conditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isX3MABullish =
|
||||||
|
provider.decisionXConditions.isX3MaFastCrossedOverMid;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isX3MABearish =
|
||||||
|
provider.decisionXConditions.isX3MaFastCrossedUnderMid;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isVWapBullish =
|
||||||
|
provider.decisionXConditions.isVWapFastCrossedOverMid;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isVWapBearish =
|
||||||
|
provider.decisionXConditions.isVWapFastCrossedUnderMid;
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isTrendBullish =
|
||||||
|
(isX3MABullish ||
|
||||||
|
isVWapBullish) &&
|
||||||
|
provider.decisionXConditions.isNewPeakOverLast;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isTrendBearish =
|
||||||
|
(isX3MABearish ||
|
||||||
|
isVWapBearish) &&
|
||||||
|
provider.decisionXConditions.isNewValeUnderLast;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = isTrendBullish ||
|
||||||
|
isTrendBearish;
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Select Signal Box ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isScorePassed =
|
||||||
|
isTrendBullish
|
||||||
|
? isScoreBullish
|
||||||
|
: isScoreBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
XBoxZone tmpBoxes[];
|
||||||
|
ToBox(
|
||||||
|
provider.analyseState.orderBlocks,
|
||||||
|
tmpBoxes //
|
||||||
|
);
|
||||||
|
Copy(
|
||||||
|
waitingBoxes,
|
||||||
|
tmpBoxes,
|
||||||
|
false //
|
||||||
|
);
|
||||||
|
int idx = -1;
|
||||||
|
// bool has = false;
|
||||||
|
while (HasChild(tmpBoxes))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isTrendBullish)
|
||||||
|
{
|
||||||
|
idx = GetHighest(tmpBoxes);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
idx = GetLowest(tmpBoxes);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = IsValidIndex(idx);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XBoxZone iBox = tmpBoxes[idx];
|
||||||
|
|
||||||
|
//
|
||||||
|
ArrayRemove(
|
||||||
|
tmpBoxes,
|
||||||
|
idx,
|
||||||
|
1 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
int insideIDX = -1;
|
||||||
|
bool hasInsideBox = HasInsideBox(
|
||||||
|
insideIDX,
|
||||||
|
iBox,
|
||||||
|
tmpBoxes //
|
||||||
|
);
|
||||||
|
if (hasInsideBox)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
hasInsideBox =
|
||||||
|
isTrendBullish
|
||||||
|
? iBox.lower < tmpBoxes[insideIDX].lower
|
||||||
|
: iBox.upper > tmpBoxes[insideIDX].upper;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBullishPlacePassed =
|
||||||
|
// !hasInsideBox &&
|
||||||
|
isTrendBullish &&
|
||||||
|
iBox.IsBullish() &&
|
||||||
|
bar.low >= iBox.upper &&
|
||||||
|
cBar.low >= iBox.upper &&
|
||||||
|
provider.decisionXConditions.x3maMin >= iBox.lower &&
|
||||||
|
provider.decisionXConditions.vwapMin >= iBox.lower;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBearishPlacePassed =
|
||||||
|
// !hasInsideBox &&
|
||||||
|
isTrendBearish &&
|
||||||
|
iBox.IsBearish() &&
|
||||||
|
bar.high <= iBox.lower &&
|
||||||
|
cBar.high <= iBox.lower &&
|
||||||
|
provider.decisionXConditions.x3maMax <= iBox.upper &&
|
||||||
|
provider.decisionXConditions.vwapMax <= iBox.upper;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = isScorePassed &&
|
||||||
|
(isBullishPlacePassed ||
|
||||||
|
isBearishPlacePassed);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
box = iBox;
|
||||||
|
iBox.Clean();
|
||||||
|
dir =
|
||||||
|
isTrendBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
signalProviderl = X121SMC_XWZ_PROVIDER_ACTIVATED_MA;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
}
|
||||||
|
Clean(tmpBoxes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Supply and Demand ...
|
||||||
|
if (false && !result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int idx = -1;
|
||||||
|
bool has = false;
|
||||||
|
XBoxZone tmpBoxes[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detecting Youngest Zones ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XBoxZone bullishBox;
|
||||||
|
bool hasBullishBox = false;
|
||||||
|
if (!hasBullishBox)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCOrderBlock *ob = NULL;
|
||||||
|
idx = GetYoungest(provider.analyseState.bullishOrderBlocks);
|
||||||
|
has = IsValidIndex(idx);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ob = provider.analyseState.bullishOrderBlocks[idx];
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL startedBar;
|
||||||
|
bool isBodyOut = false;
|
||||||
|
bool isStarted = ob.IsStarted(
|
||||||
|
ob.GetDirection(),
|
||||||
|
startedBar,
|
||||||
|
isBodyOut //
|
||||||
|
);
|
||||||
|
has = isStarted &&
|
||||||
|
isBodyOut;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
hasBullishBox = ToBox(
|
||||||
|
bullishBox,
|
||||||
|
ob //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!hasBullishBox)
|
||||||
|
{
|
||||||
|
bullishBox.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ZeroMemory(ob);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XBoxZone bearishBox;
|
||||||
|
bool hasBearishBox = false;
|
||||||
|
if (!hasBearishBox)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCOrderBlock *ob = NULL;
|
||||||
|
idx = GetYoungest(provider.analyseState.bearishOrderBlocks);
|
||||||
|
has = IsValidIndex(idx);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ob = provider.analyseState.bearishOrderBlocks[idx];
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL startedBar;
|
||||||
|
bool isBodyOut = false;
|
||||||
|
bool isStarted = ob.IsStarted(
|
||||||
|
ob.GetDirection(),
|
||||||
|
startedBar,
|
||||||
|
isBodyOut //
|
||||||
|
);
|
||||||
|
has = isStarted &&
|
||||||
|
isBodyOut;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
hasBearishBox = ToBox(
|
||||||
|
bearishBox,
|
||||||
|
ob //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!hasBearishBox)
|
||||||
|
{
|
||||||
|
bearishBox.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ZeroMemory(ob);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XBoxZone bullishCZBox;
|
||||||
|
bool hasBullishConsolidationZone = false;
|
||||||
|
XConsolidationZone bullishConsolidationZone;
|
||||||
|
hasBullishConsolidationZone = provider.decisionState.HasBullishConsolidationZones();
|
||||||
|
if (hasBullishConsolidationZone)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
idx = GetYoungest(provider.decisionState.bullishConsolidationZones);
|
||||||
|
hasBullishConsolidationZone = IsValidIndex(idx);
|
||||||
|
if (hasBullishConsolidationZone)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bullishConsolidationZone = provider.decisionState.bullishConsolidationZones[idx];
|
||||||
|
if (hasBullishConsolidationZone)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
hasBullishConsolidationZone = ToBox(
|
||||||
|
bullishCZBox,
|
||||||
|
bullishConsolidationZone //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XBoxZone bearishCZBox;
|
||||||
|
bool hasBearishConsolidationZone = false;
|
||||||
|
XConsolidationZone bearishConsolidationZone;
|
||||||
|
hasBearishConsolidationZone = provider.decisionState.HasBearishConsolidationZones();
|
||||||
|
if (hasBearishConsolidationZone)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
idx = GetYoungest(provider.decisionState.bearishConsolidationZones);
|
||||||
|
hasBearishConsolidationZone = IsValidIndex(idx);
|
||||||
|
if (hasBearishConsolidationZone)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bearishConsolidationZone = provider.decisionState.bearishConsolidationZones[idx];
|
||||||
|
if (hasBearishConsolidationZone)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
hasBearishConsolidationZone = ToBox(
|
||||||
|
bearishCZBox,
|
||||||
|
bearishConsolidationZone //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// Supply Zone ...
|
||||||
|
has = provider.visionState.HasSupplyZones();
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ToBox(
|
||||||
|
provider.visionState.supplyZones,
|
||||||
|
tmpBoxes //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
while (HasChild(tmpBoxes))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
idx = GetYoungest(tmpBoxes);
|
||||||
|
has = IsValidIndex(idx);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XBoxZone iBox = tmpBoxes[idx];
|
||||||
|
ArrayRemove(
|
||||||
|
tmpBoxes,
|
||||||
|
idx,
|
||||||
|
1 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Price Must Be Inside a Zonne More Than 5 Bar ...
|
||||||
|
bool isPriceInside =
|
||||||
|
//
|
||||||
|
bar.high < iBox.upper &&
|
||||||
|
bar.low > iBox.lower &&
|
||||||
|
//
|
||||||
|
cBar.high < iBox.upper &&
|
||||||
|
cBar.low > iBox.lower &&
|
||||||
|
//
|
||||||
|
pBar.high < iBox.upper &&
|
||||||
|
pBar.low > iBox.lower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBearishBoxPassed =
|
||||||
|
hasBearishBox &&
|
||||||
|
IsBoxInside(
|
||||||
|
bearishBox,
|
||||||
|
iBox //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBearishCZBoxPassed =
|
||||||
|
hasBearishConsolidationZone &&
|
||||||
|
IsBoxInside(
|
||||||
|
bearishCZBox,
|
||||||
|
iBox //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = isPriceInside &&
|
||||||
|
(isBearishBoxPassed ||
|
||||||
|
isBearishCZBoxPassed);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isBearishBoxPassed)
|
||||||
|
{
|
||||||
|
box = bearishBox;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
box = bearishCZBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.to = TimeCurrent();
|
||||||
|
XCBoxObject *iObj;
|
||||||
|
provider.visionCycleHelper.mPOIDrawer.DrawBox(
|
||||||
|
iBox,
|
||||||
|
iObj //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
dir = X_DIRECTION_BEARISH;
|
||||||
|
signalProviderl = X121SMC_XWZ_PROVIDER_ACTIVATED_AREA;
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(tmpBoxes);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Demand Zone ...
|
||||||
|
has = provider.visionState.HasDemandZones();
|
||||||
|
if (!result && has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ToBox(
|
||||||
|
provider.visionState.demandZones,
|
||||||
|
tmpBoxes //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
while (HasChild(tmpBoxes))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
idx = GetYoungest(tmpBoxes);
|
||||||
|
has = IsValidIndex(idx);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XBoxZone iBox = tmpBoxes[idx];
|
||||||
|
ArrayRemove(
|
||||||
|
tmpBoxes,
|
||||||
|
idx,
|
||||||
|
1 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Price Must Be Inside a Zonne More Than 5 Bar ...
|
||||||
|
bool isPriceInside =
|
||||||
|
//
|
||||||
|
bar.high < iBox.upper &&
|
||||||
|
bar.low > iBox.lower &&
|
||||||
|
//
|
||||||
|
cBar.high < iBox.upper &&
|
||||||
|
cBar.low > iBox.lower &&
|
||||||
|
//
|
||||||
|
pBar.high < iBox.upper &&
|
||||||
|
pBar.low > iBox.lower
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBullishBoxPassed =
|
||||||
|
hasBullishBox &&
|
||||||
|
IsBoxInside(
|
||||||
|
bullishBox,
|
||||||
|
iBox //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBullishCZBoxPassed =
|
||||||
|
hasBullishConsolidationZone &&
|
||||||
|
IsBoxInside(
|
||||||
|
bullishCZBox,
|
||||||
|
iBox //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = isPriceInside &&
|
||||||
|
(isBullishBoxPassed ||
|
||||||
|
isBullishCZBoxPassed);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isBullishBoxPassed)
|
||||||
|
{
|
||||||
|
box = bullishBox;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
box = bullishCZBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.to = TimeCurrent();
|
||||||
|
XCBoxObject *iObj;
|
||||||
|
provider.visionCycleHelper.mPOIDrawer.DrawBox(
|
||||||
|
iBox,
|
||||||
|
iObj //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
dir = X_DIRECTION_BULLISH;
|
||||||
|
signalProviderl = X121SMC_XWZ_PROVIDER_ACTIVATED_AREA;
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(tmpBoxes);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Clean(tmpBoxes);
|
||||||
|
|
||||||
|
//
|
||||||
|
bullishBox.Clean();
|
||||||
|
bearishBox.Clean();
|
||||||
|
bullishCZBox.Clean();
|
||||||
|
bearishCZBox.Clean();
|
||||||
|
bullishConsolidationZone.Clean();
|
||||||
|
bearishConsolidationZone.Clean();
|
||||||
|
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
bar.Clean();
|
bar.Clean();
|
||||||
cBar.Clean();
|
cBar.Clean();
|
||||||
|
pBar.Clean();
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user