last ...
This commit is contained in:
@@ -2448,6 +2448,184 @@ class XCBarAnalyser : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
/**
|
||||
* Check a Bar is Valid for Specified Direction of Positions ...
|
||||
*
|
||||
* @param bar: XOHCL instance, Start Bar ...
|
||||
* @param dir: ENUM_X_DIRECTION member, Provide Direction ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValidForPosition(
|
||||
XOHCL &bar,
|
||||
ENUM_X_DIRECTION &dir //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int loopback = 3;
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// DOJI ...
|
||||
ENUM_X_DIRECTION dojiDir;
|
||||
bool isDoji = IsDoji(
|
||||
bar,
|
||||
dojiDir //
|
||||
);
|
||||
bool isBullishDoji =
|
||||
isDoji &&
|
||||
IsBullish(dojiDir);
|
||||
bool isBearishDoji =
|
||||
isDoji &&
|
||||
IsBearish(dojiDir);
|
||||
|
||||
//
|
||||
// SWING ...
|
||||
ENUM_X_DIRECTION swingDir;
|
||||
bool isSwing = IsSwing(
|
||||
bar,
|
||||
swingDir //
|
||||
);
|
||||
bool isBullishSwing =
|
||||
isSwing &&
|
||||
IsBullish(swingDir);
|
||||
bool isBearishSwing =
|
||||
isSwing &&
|
||||
IsBearish(swingDir);
|
||||
|
||||
//
|
||||
// HAMMER ...
|
||||
ENUM_X_DIRECTION hammerDir;
|
||||
bool isHammer = IsHammer(
|
||||
bar,
|
||||
hammerDir //
|
||||
);
|
||||
bool isBullishHammer =
|
||||
isHammer &&
|
||||
IsBullish(hammerDir);
|
||||
bool isBearishHammer =
|
||||
isHammer &&
|
||||
IsBearish(hammerDir);
|
||||
|
||||
//
|
||||
// ENGULF ...
|
||||
ENUM_X_DIRECTION engulfDir;
|
||||
bool isEngulfed = IsEngulfed(
|
||||
bar,
|
||||
engulfDir //
|
||||
);
|
||||
bool isBullishEngulfed =
|
||||
isEngulfed &&
|
||||
IsBullish(engulfDir);
|
||||
bool isBearishEngulfed =
|
||||
isEngulfed &&
|
||||
IsBearish(engulfDir);
|
||||
|
||||
//
|
||||
// REJECTED ...
|
||||
ENUM_X_DIRECTION rejectedDir;
|
||||
bool isRejected = IsRejected(
|
||||
bar,
|
||||
rejectedDir //
|
||||
);
|
||||
bool isBullishRejected =
|
||||
isRejected &&
|
||||
IsBullish(rejectedDir);
|
||||
bool isBearishRejected =
|
||||
isRejected &&
|
||||
IsBearish(rejectedDir);
|
||||
|
||||
//
|
||||
// MOMENTUM ...
|
||||
ENUM_X_DIRECTION momentumDir;
|
||||
bool isMomentum = IsMomentum(
|
||||
bar,
|
||||
momentumDir //
|
||||
);
|
||||
bool isBullishMomentum =
|
||||
isMomentum &&
|
||||
IsBullish(momentumDir);
|
||||
bool isBearishMomentum =
|
||||
isMomentum &&
|
||||
IsBearish(momentumDir);
|
||||
|
||||
//
|
||||
// PULLBACK ...
|
||||
ENUM_X_DIRECTION pullbackDir;
|
||||
bool isPullback = IsPullback(
|
||||
bar,
|
||||
pullbackDir //
|
||||
);
|
||||
bool isBullishPullback =
|
||||
isPullback &&
|
||||
IsBullish(pullbackDir);
|
||||
bool isBearishPullback =
|
||||
isPullback &&
|
||||
IsBearish(pullbackDir);
|
||||
|
||||
//
|
||||
// Summarize Conditions ...
|
||||
|
||||
//
|
||||
bool isBullishOr =
|
||||
isBullishDoji ||
|
||||
isBullishSwing ||
|
||||
isBullishHammer ||
|
||||
isBullishEngulfed ||
|
||||
isBullishRejected ||
|
||||
isBullishMomentum ||
|
||||
isBullishPullback;
|
||||
|
||||
//
|
||||
bool isBearishOr =
|
||||
isBearishDoji ||
|
||||
isBearishSwing ||
|
||||
isBearishHammer ||
|
||||
isBearishEngulfed ||
|
||||
isBearishRejected ||
|
||||
isBearishMomentum ||
|
||||
isBearishPullback;
|
||||
|
||||
//
|
||||
bool isBullish =
|
||||
isBullishOr &&
|
||||
!isBearishOr;
|
||||
|
||||
//
|
||||
bool isBearish =
|
||||
!isBullishOr &&
|
||||
isBearishOr;
|
||||
|
||||
//
|
||||
result = isBullish ||
|
||||
isBearish;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
dir =
|
||||
isBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
protected:
|
||||
//
|
||||
|
||||
@@ -0,0 +1,543 @@
|
||||
//
|
||||
bool HasSenario1Conditions(
|
||||
ENUM_X_CYCLES cycle,
|
||||
XBoxZone &box,
|
||||
XBoxZone &holderBox,
|
||||
ENUM_X_DIRECTION &dir,
|
||||
X121SMCStrategySignalProviderData &provider,
|
||||
ENUM_X_CYCLES holderCycle = X_CYCLE_NONE,
|
||||
int barIndex = 0 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Fil Selected Data ...
|
||||
XPOIState cState;
|
||||
X121Conditions cXConditions;
|
||||
XC121SMCCycleHelper *cHelper;
|
||||
X121SMCCycleConditions cConditions;
|
||||
result = provider.SelectCycle(
|
||||
cycle,
|
||||
cState,
|
||||
cXConditions,
|
||||
cHelper,
|
||||
cConditions //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
cState.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
Parse(cXConditions);
|
||||
|
||||
//
|
||||
// Fil Selected Data ...
|
||||
XPOIState chState;
|
||||
X121Conditions chXConditions;
|
||||
XC121SMCCycleHelper *chHelper;
|
||||
X121SMCCycleConditions chConditions;
|
||||
if (holderCycle != X_CYCLE_NONE)
|
||||
{
|
||||
//
|
||||
result = provider.SelectCycle(
|
||||
holderCycle,
|
||||
chState,
|
||||
chXConditions,
|
||||
chHelper,
|
||||
chConditions //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
chState.Clean();
|
||||
ZeroMemory(chHelper);
|
||||
chConditions.Clean();
|
||||
chXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Parse(chXConditions);
|
||||
}
|
||||
|
||||
//
|
||||
// Normalize Args ...
|
||||
|
||||
//
|
||||
box.Clean();
|
||||
holderBox.Clean();
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
int count = 0;
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
int zIDX = barIndex;
|
||||
int cIDX = zIDX + 1;
|
||||
int pIDX = cIDX + 1;
|
||||
|
||||
//
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
|
||||
//
|
||||
XOHCL zBar;
|
||||
XOHCL cBar;
|
||||
XOHCL pBar;
|
||||
|
||||
//
|
||||
// Initial Bars ...
|
||||
result = zBar.Init(
|
||||
cState.symbol,
|
||||
cState.period,
|
||||
barIndex //
|
||||
);
|
||||
result =
|
||||
result &&
|
||||
zBar.GetPreviousBar(cBar);
|
||||
result =
|
||||
result &&
|
||||
cBar.GetPreviousBar(pBar);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
cState.Clean();
|
||||
chState.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
ZeroMemory(chHelper);
|
||||
chConditions.Clean();
|
||||
chXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Detecting Signal Conditions ...
|
||||
|
||||
//
|
||||
bool isX3MAFastRejectUp =
|
||||
//
|
||||
cBar.low < cXConditions.x3maFastBuffer[cIDX] &&
|
||||
cBar.GetDown() > cXConditions.x3maFastBuffer[cIDX]
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isX3MAFastRejectDown =
|
||||
//
|
||||
cBar.high > cXConditions.x3maFastBuffer[cIDX] &&
|
||||
cBar.GetUp() < cXConditions.x3maFastBuffer[cIDX]
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Find Breaker Bar ...
|
||||
datetime nearCloseOverX3MAFast = cHelper.GetNearestCloseOverX3MAFast(cBar);
|
||||
datetime nearCloseUnderX3MAFast = cHelper.GetNearestCloseUnderX3MAFast(cBar);
|
||||
bool hasNearestCloseOverX3MAFast =
|
||||
IsValid(nearCloseOverX3MAFast) &&
|
||||
IsValid(nearCloseUnderX3MAFast)
|
||||
? nearCloseOverX3MAFast > nearCloseUnderX3MAFast
|
||||
: IsValid(nearCloseOverX3MAFast)
|
||||
? true
|
||||
: false;
|
||||
bool hasNearestCloseUnderX3MAFast =
|
||||
IsValid(nearCloseOverX3MAFast) &&
|
||||
IsValid(nearCloseUnderX3MAFast)
|
||||
? nearCloseUnderX3MAFast > nearCloseOverX3MAFast
|
||||
: IsValid(nearCloseUnderX3MAFast)
|
||||
? true
|
||||
: false;
|
||||
|
||||
//
|
||||
// Bullish Conditions ...
|
||||
isBullish =
|
||||
//
|
||||
// Base Condition ...
|
||||
(
|
||||
//
|
||||
cBar.IsBullish() &&
|
||||
isX3MAFastRejectUp &&
|
||||
cXConditions.isSMHKBullish &&
|
||||
hasNearestCloseOverX3MAFast &&
|
||||
cXConditions.xhkSMOpenBuffer[cIDX] < cXConditions.x3maMidBuffer[cIDX]
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Bearish Conditions ...
|
||||
isBearish =
|
||||
//
|
||||
// Base Condition ...
|
||||
(
|
||||
//
|
||||
cBar.IsBearish() &&
|
||||
isX3MAFastRejectDown &&
|
||||
cXConditions.isSMHKBearish &&
|
||||
hasNearestCloseUnderX3MAFast &&
|
||||
cXConditions.xhkSMOpenBuffer[cIDX] > cXConditions.x3maMidBuffer[cIDX]
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Filling Requirements ...
|
||||
result =
|
||||
isBullish ||
|
||||
isBearish;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
dir =
|
||||
isBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
box.dir = dir;
|
||||
box.to = TimeCurrent();
|
||||
box.symbol = cXConditions.symbol;
|
||||
box.period = cXConditions.period;
|
||||
|
||||
//
|
||||
int fromIDX = -1;
|
||||
if (isBullish)
|
||||
{
|
||||
//
|
||||
fromIDX = GetBarIndex(
|
||||
cBar.symbol,
|
||||
cBar.period,
|
||||
nearCloseOverX3MAFast //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
fromIDX = GetBarIndex(
|
||||
cBar.symbol,
|
||||
cBar.period,
|
||||
nearCloseUnderX3MAFast //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (IsValidIndex(fromIDX))
|
||||
{
|
||||
//
|
||||
box.from = iTime(
|
||||
zBar.symbol,
|
||||
zBar.period,
|
||||
fromIDX //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
box.from = pBar.time;
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Holder Box ...
|
||||
XBoxZone tmpBoxes[];
|
||||
if (chState.IsValid())
|
||||
{
|
||||
//
|
||||
if (isBullish)
|
||||
{
|
||||
//
|
||||
// Demand Zones ...
|
||||
XBoxZone tmp[];
|
||||
ToBox(
|
||||
chState.demandZones,
|
||||
tmp //
|
||||
);
|
||||
Copy(
|
||||
tmp,
|
||||
tmpBoxes,
|
||||
false //
|
||||
);
|
||||
Clean(tmp);
|
||||
|
||||
//
|
||||
// Bullish Order Blocks ...
|
||||
ToBox(
|
||||
chState.bullishOrderBlocks,
|
||||
tmp //
|
||||
);
|
||||
Copy(
|
||||
tmp,
|
||||
tmpBoxes,
|
||||
false //
|
||||
);
|
||||
Clean(tmp);
|
||||
|
||||
//
|
||||
// Bullish Fair Value Gaps ...
|
||||
ToBox(
|
||||
chState.bullishFairValueGaps,
|
||||
tmp //
|
||||
);
|
||||
Copy(
|
||||
tmp,
|
||||
tmpBoxes,
|
||||
false //
|
||||
);
|
||||
Clean(tmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Supply Zones ...
|
||||
XBoxZone tmp[];
|
||||
ToBox(
|
||||
chState.supplyZones,
|
||||
tmp //
|
||||
);
|
||||
Copy(
|
||||
tmp,
|
||||
tmpBoxes,
|
||||
false //
|
||||
);
|
||||
Clean(tmp);
|
||||
|
||||
//
|
||||
// Bearish Order Blocks ...
|
||||
ToBox(
|
||||
chState.bearishOrderBlocks,
|
||||
tmp //
|
||||
);
|
||||
Copy(
|
||||
tmp,
|
||||
tmpBoxes,
|
||||
false //
|
||||
);
|
||||
Clean(tmp);
|
||||
|
||||
//
|
||||
// Bearish Fair Value Gaps ...
|
||||
ToBox(
|
||||
chState.bearishFairValueGaps,
|
||||
tmp //
|
||||
);
|
||||
Copy(
|
||||
tmp,
|
||||
tmpBoxes,
|
||||
false //
|
||||
);
|
||||
Clean(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
has = HasChild(tmpBoxes);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
while (HasChild(tmpBoxes))
|
||||
{
|
||||
//
|
||||
idx = GetOldest(tmpBoxes);
|
||||
has = IsValidIndex(idx);
|
||||
if (!has)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone iBox = tmpBoxes[idx];
|
||||
ArrayRemove(
|
||||
tmpBoxes,
|
||||
idx,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
has = IsBoxInside(
|
||||
box,
|
||||
iBox //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
holderBox = iBox;
|
||||
holderBox.to = TimeCurrent();
|
||||
iBox.Clean();
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Clean(tmpBoxes);
|
||||
|
||||
//
|
||||
// Fix Box Upper and Lower based on Strategy ...
|
||||
|
||||
//
|
||||
double points = GetPoints(box.symbol);
|
||||
double minPointsDiff = points * 20;
|
||||
|
||||
//
|
||||
double prefferSL = 0;
|
||||
|
||||
//
|
||||
// Other SL Conditions ...
|
||||
if (prefferSL <= 0)
|
||||
{
|
||||
//
|
||||
prefferSL = cHelper
|
||||
.mX121Helper
|
||||
.xhkHelper
|
||||
.GetSMHKOpen(fromIDX);
|
||||
}
|
||||
|
||||
//
|
||||
if (prefferSL > 0)
|
||||
{
|
||||
//
|
||||
box.upper =
|
||||
isBullish
|
||||
? zBar.open
|
||||
: prefferSL;
|
||||
|
||||
//
|
||||
box.lower =
|
||||
isBullish
|
||||
? prefferSL
|
||||
: zBar.open;
|
||||
}
|
||||
|
||||
//
|
||||
if (box.IsValid())
|
||||
{
|
||||
//
|
||||
XCBoxObject *iObj;
|
||||
bool isCreated = cHelper.mPOIDrawer.DrawBox(
|
||||
box,
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
iObj.BoxWidth(2);
|
||||
iObj.BoxFill(true);
|
||||
iObj.BoxStyle(STYLE_DOT);
|
||||
|
||||
//
|
||||
Print("Signal ...");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Conditions to Force Has Holder Box ...
|
||||
|
||||
// //
|
||||
// result =
|
||||
// result &&
|
||||
// holderBox.IsValid() &&
|
||||
// dir == holderBox.dir;
|
||||
|
||||
// //
|
||||
// if (!result)
|
||||
// {
|
||||
// //
|
||||
// isBullish = false;
|
||||
// isBearish = false;
|
||||
// }
|
||||
}
|
||||
|
||||
//
|
||||
// Check All Conditions ...
|
||||
result =
|
||||
box.IsValid() &&
|
||||
HasDirection(dir) &&
|
||||
(isBullish ||
|
||||
isBearish);
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
zBar.Clean();
|
||||
cBar.Clean();
|
||||
pBar.Clean();
|
||||
cState.Clean();
|
||||
chState.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
ZeroMemory(chHelper);
|
||||
chConditions.Clean();
|
||||
chXConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// Detecting Signal Conditions ...
|
||||
|
||||
//
|
||||
// Bullish Conditions ...
|
||||
isBullish =
|
||||
//
|
||||
// Base Condition ...
|
||||
(
|
||||
//
|
||||
provider.visionXConditions.isSMHKBullish &&
|
||||
provider.decisionXConditions.isSarBullish &&
|
||||
provider.decisionXConditions.isVWapFastBullish &&
|
||||
provider.decisionXConditions.isX3MaFastBullish &&
|
||||
provider.consolidationXConditions.isSMHKBullish &&
|
||||
provider.decisionXConditions.isSMHKSwitchedToBullish
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Bearish Conditions ...
|
||||
isBearish =
|
||||
//
|
||||
// Base Condition ...
|
||||
(
|
||||
//
|
||||
provider.visionXConditions.isSMHKBearish &&
|
||||
provider.decisionXConditions.isSarBearish &&
|
||||
provider.decisionXConditions.isVWapFastBearish &&
|
||||
provider.decisionXConditions.isX3MaFastBearish &&
|
||||
provider.consolidationXConditions.isSMHKBearish &&
|
||||
provider.decisionXConditions.isSMHKSwitchedToBearish
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -224,7 +224,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
// Detectiong Signal Boxes ...
|
||||
hasWaitingBoxes = workingZone
|
||||
.DetectSignalBoxes(
|
||||
X_CYCLE_ANALYSE,
|
||||
X_CYCLE_DECISION,
|
||||
provider,
|
||||
zIndex //
|
||||
);
|
||||
@@ -464,58 +464,59 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
||||
//
|
||||
// Select and Provide SL Based on ...
|
||||
double iAtr = 0;
|
||||
if (signalProvider == X121SMC_XWZ_PROVIDER_ACTIVATED_MA)
|
||||
if (signalProvider == X121SMC_XWZ_PROVIDER_XHKMA)
|
||||
{
|
||||
//
|
||||
iAtr = provider.decisionXConditions.atrBuffer[1];
|
||||
iAtr *= 1.5;
|
||||
iAtr *= 0;
|
||||
}
|
||||
else if (signalProvider == X121SMC_XWZ_PROVIDER_ACTIVATED_BOX)
|
||||
{
|
||||
//
|
||||
iAtr = provider.decisionXConditions.atrBuffer[1];
|
||||
iAtr *= 1.5;
|
||||
// else
|
||||
// if (signalProvider == X121SMC_XWZ_PROVIDER_ACTIVATED_BOX)
|
||||
// {
|
||||
// //
|
||||
// iAtr = provider.decisionXConditions.atrBuffer[1];
|
||||
// iAtr *= 1.5;
|
||||
|
||||
// //
|
||||
// if (isBullish)
|
||||
// {
|
||||
// //
|
||||
// iSL = MathMin(
|
||||
// provider.decisionXConditions.le1Buffer[1],
|
||||
// provider.decisionXConditions.le2Buffer[1] //
|
||||
// );
|
||||
// if (iSL > 0)
|
||||
// {
|
||||
// //
|
||||
// Add(
|
||||
// iSL,
|
||||
// sls //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //
|
||||
// iSL = MathMax(
|
||||
// provider.decisionXConditions.se1Buffer[1],
|
||||
// provider.decisionXConditions.se2Buffer[1] //
|
||||
// );
|
||||
// if (iSL > 0)
|
||||
// {
|
||||
// //
|
||||
// Add(
|
||||
// iSL,
|
||||
// sls //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
}
|
||||
else if (signalProvider == X121SMC_XWZ_PROVIDER_ACTIVATED_AREA)
|
||||
{
|
||||
//
|
||||
iAtr = provider.decisionXConditions.atrBuffer[1];
|
||||
iAtr *= 1.5;
|
||||
}
|
||||
// // //
|
||||
// // if (isBullish)
|
||||
// // {
|
||||
// // //
|
||||
// // iSL = MathMin(
|
||||
// // provider.decisionXConditions.le1Buffer[1],
|
||||
// // provider.decisionXConditions.le2Buffer[1] //
|
||||
// // );
|
||||
// // if (iSL > 0)
|
||||
// // {
|
||||
// // //
|
||||
// // Add(
|
||||
// // iSL,
|
||||
// // sls //
|
||||
// // );
|
||||
// // }
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // //
|
||||
// // iSL = MathMax(
|
||||
// // provider.decisionXConditions.se1Buffer[1],
|
||||
// // provider.decisionXConditions.se2Buffer[1] //
|
||||
// // );
|
||||
// // if (iSL > 0)
|
||||
// // {
|
||||
// // //
|
||||
// // Add(
|
||||
// // iSL,
|
||||
// // sls //
|
||||
// // );
|
||||
// // }
|
||||
// // }
|
||||
// }
|
||||
// else if (signalProvider == X121SMC_XWZ_PROVIDER_ACTIVATED_AREA)
|
||||
// {
|
||||
// //
|
||||
// iAtr = provider.decisionXConditions.atrBuffer[1];
|
||||
// iAtr *= 1.5;
|
||||
// }
|
||||
|
||||
//
|
||||
// Select Condition SL ...
|
||||
|
||||
@@ -31,10 +31,7 @@
|
||||
enum ENUM_X121SMC_XWZ_PROVIDERS
|
||||
{
|
||||
X121SMC_XWZ_PROVIDER_NONE,
|
||||
X121SMC_XWZ_PROVIDER_PVHK,
|
||||
X121SMC_XWZ_PROVIDER_ACTIVATED_MA,
|
||||
X121SMC_XWZ_PROVIDER_ACTIVATED_BOX,
|
||||
X121SMC_XWZ_PROVIDER_ACTIVATED_AREA,
|
||||
X121SMC_XWZ_PROVIDER_XHKMA,
|
||||
};
|
||||
|
||||
//
|
||||
@@ -478,6 +475,11 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int idx = -1;
|
||||
int count = 0;
|
||||
bool has = false;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
@@ -487,12 +489,14 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
//
|
||||
// Select Cycle ...
|
||||
XPOIState cState;
|
||||
XPOIStateEvents cStateEvents;
|
||||
X121Conditions cXConditions;
|
||||
XC121SMCCycleHelper *cHelper;
|
||||
X121SMCCycleConditions cConditions;
|
||||
result = provider.SelectCycle(
|
||||
cycle,
|
||||
cState,
|
||||
cStateEvents,
|
||||
cXConditions,
|
||||
cHelper,
|
||||
cConditions //
|
||||
@@ -503,6 +507,7 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
cState.Clean();
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cStateEvents.Clean();
|
||||
cXConditions.Clean();
|
||||
|
||||
//
|
||||
@@ -510,30 +515,231 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
}
|
||||
|
||||
//
|
||||
// Select Validate Rejection Boxes ...
|
||||
XBoxZone rejections[];
|
||||
int count = cHelper
|
||||
.DetectRejections(
|
||||
rejections,
|
||||
barIndex //
|
||||
);
|
||||
// Select Rejection Boxes ...
|
||||
|
||||
// //
|
||||
// // Select Validate Rejection Boxes ...
|
||||
// XBoxZone rejections[];
|
||||
// int count = cHelper
|
||||
// .DetectRejections(
|
||||
// rejections,
|
||||
// barIndex //
|
||||
// );
|
||||
|
||||
// //
|
||||
// result = IsValidSize(count);
|
||||
// if (result)
|
||||
// {
|
||||
// //
|
||||
// for (int i = 0; i < count; i++)
|
||||
// {
|
||||
// //
|
||||
// has = IsExists(rejections[i]);
|
||||
// if (!has)
|
||||
// {
|
||||
// //
|
||||
// AddRef(
|
||||
// rejections[i],
|
||||
// waitingBoxes //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
result = IsValidSize(count);
|
||||
if (result)
|
||||
// Select Order Blocks ...
|
||||
// if (cStateEvents.hasNewOrderBlock)
|
||||
// {
|
||||
// //
|
||||
// idx = GetYoungest(cState.orderBlocks);
|
||||
// has = IsValidIndex(idx);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// XCOrderBlock *iOB = cState.orderBlocks[idx];
|
||||
|
||||
// //
|
||||
// XBoxZone iBox;
|
||||
// has = ToBox(
|
||||
// iBox,
|
||||
// iOB //
|
||||
// );
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// has = IsExists(iBox);
|
||||
// if (!has)
|
||||
// {
|
||||
// //
|
||||
// AddRef(
|
||||
// iBox,
|
||||
// waitingBoxes //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
// Select Fair Value Gaps ...
|
||||
// if (cStateEvents.hasNewFairValueGap)
|
||||
// {
|
||||
// //
|
||||
// idx = GetYoungest(cState.fairValueGaps);
|
||||
// has = IsValidIndex(idx);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// XCFVG *iOB = cState.fairValueGaps[idx];
|
||||
|
||||
// //
|
||||
// XBoxZone iBox;
|
||||
// has = ToBox(
|
||||
// iBox,
|
||||
// iOB //
|
||||
// );
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// has = IsExists(iBox);
|
||||
// if (!has)
|
||||
// {
|
||||
// //
|
||||
// AddRef(
|
||||
// iBox,
|
||||
// waitingBoxes //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
// Select Supply/Demand Zones ...
|
||||
// if (cStateEvents.hasNewSupplyZone)
|
||||
// {
|
||||
// //
|
||||
// idx = GetYoungest(cState.supplyZones);
|
||||
// has = IsValidIndex(idx);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// XCSupplyZone *iSupply = cState.supplyZones[idx];
|
||||
|
||||
// //
|
||||
// XBoxZone iBox;
|
||||
// has = ToBox(
|
||||
// iBox,
|
||||
// iSupply //
|
||||
// );
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// has = IsExists(iBox);
|
||||
// if (!has)
|
||||
// {
|
||||
// //
|
||||
// AddRef(
|
||||
// iBox,
|
||||
// waitingBoxes //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (cStateEvents.hasNewDemandZone)
|
||||
// {
|
||||
// //
|
||||
// idx = GetYoungest(cState.demandZones);
|
||||
// has = IsValidIndex(idx);
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// XCDemandZone *iDemand = cState.demandZones[idx];
|
||||
|
||||
// //
|
||||
// XBoxZone iBox;
|
||||
// has = ToBox(
|
||||
// iBox,
|
||||
// iDemand //
|
||||
// );
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// has = IsExists(iBox);
|
||||
// if (!has)
|
||||
// {
|
||||
// //
|
||||
// AddRef(
|
||||
// iBox,
|
||||
// waitingBoxes //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
// Select Support/Resistance Zones ...
|
||||
if (cStateEvents.hasNewSupportZone)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
idx = GetYoungest(cState.supportZones);
|
||||
has = IsValidIndex(idx);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
bool has = IsExists(rejections[i]);
|
||||
if (!has)
|
||||
XCSupportZone *iSupport = cState.supportZones[idx];
|
||||
|
||||
//
|
||||
XBoxZone iBox;
|
||||
has = ToBox(
|
||||
iBox,
|
||||
iSupport //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
rejections[i],
|
||||
waitingBoxes //
|
||||
);
|
||||
has = IsExists(iBox);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iBox,
|
||||
waitingBoxes //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cStateEvents.hasNewResistanceZone)
|
||||
{
|
||||
//
|
||||
idx = GetYoungest(cState.resistanceZones);
|
||||
has = IsValidIndex(idx);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
XCResistanceZone *iResistance = cState.resistanceZones[idx];
|
||||
|
||||
//
|
||||
XBoxZone iBox;
|
||||
has = ToBox(
|
||||
iBox,
|
||||
iResistance //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
has = IsExists(iBox);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iBox,
|
||||
waitingBoxes //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -550,6 +756,7 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
ZeroMemory(cHelper);
|
||||
cConditions.Clean();
|
||||
cXConditions.Clean();
|
||||
cStateEvents.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -765,6 +972,13 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Trend Based On Boxes ...
|
||||
*
|
||||
* @param dir: ENUM_X_DIRECTION ember ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool DetectTreand(
|
||||
ENUM_X_DIRECTION &dir //
|
||||
)
|
||||
@@ -1014,6 +1228,7 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
box,
|
||||
holderBox,
|
||||
dir,
|
||||
waitingBoxes,
|
||||
provider,
|
||||
X_CYCLE_ANALYSE,
|
||||
barIndex //
|
||||
@@ -1032,7 +1247,7 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
//
|
||||
if (isSenario1Happend)
|
||||
{
|
||||
signalProvider = X121SMC_XWZ_PROVIDER_PVHK;
|
||||
signalProvider = X121SMC_XWZ_PROVIDER_XHKMA;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1045,50 +1260,50 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
bool isSenario2Happend = false;
|
||||
bool isSenario2Bullish = false;
|
||||
bool isSenario2Bearish = false;
|
||||
if (useSenario2)
|
||||
{
|
||||
//
|
||||
// Senario 2 Working Based on
|
||||
// Breaked Boxes ...
|
||||
// Since we Works only
|
||||
// when Has UnAvailable Boxes ...
|
||||
has = HasBreakedBoxes();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
ENUM_X_DIRECTION overalTrend;
|
||||
bool hasTrend = DetectOveralDirection(overalTrend);
|
||||
// if (useSenario2)
|
||||
// {
|
||||
// //
|
||||
// // Senario 2 Working Based on
|
||||
// // Breaked Boxes ...
|
||||
// // Since we Works only
|
||||
// // when Has UnAvailable Boxes ...
|
||||
// has = HasBreakedBoxes();
|
||||
// if (has)
|
||||
// {
|
||||
// //
|
||||
// ENUM_X_DIRECTION overalTrend;
|
||||
// bool hasTrend = DetectOveralDirection(overalTrend);
|
||||
|
||||
if (hasTrend)
|
||||
{
|
||||
//
|
||||
isSenario2Happend = cParser.HasSenario2Conditions(
|
||||
X_CYCLE_DECISION,
|
||||
breakedBoxes,
|
||||
box,
|
||||
dir,
|
||||
provider,
|
||||
barIndex //
|
||||
);
|
||||
// if (hasTrend)
|
||||
// {
|
||||
// //
|
||||
// isSenario2Happend = cParser.HasSenario2Conditions(
|
||||
// X_CYCLE_DECISION,
|
||||
// breakedBoxes,
|
||||
// box,
|
||||
// dir,
|
||||
// provider,
|
||||
// barIndex //
|
||||
// );
|
||||
|
||||
//
|
||||
isSenario2Bullish =
|
||||
isSenario2Happend &&
|
||||
IsBullish(dir);
|
||||
// //
|
||||
// isSenario2Bullish =
|
||||
// isSenario2Happend &&
|
||||
// IsBullish(dir);
|
||||
|
||||
//
|
||||
isSenario2Bearish =
|
||||
isSenario2Happend &&
|
||||
IsBearish(dir);
|
||||
// //
|
||||
// isSenario2Bearish =
|
||||
// isSenario2Happend &&
|
||||
// IsBearish(dir);
|
||||
|
||||
//
|
||||
if (isSenario2Happend)
|
||||
{
|
||||
signalProvider = X121SMC_XWZ_PROVIDER_ACTIVATED_BOX;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// //
|
||||
// if (isSenario2Happend)
|
||||
// {
|
||||
// signalProvider = X121SMC_XWZ_PROVIDER_ACTIVATED_BOX;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
// Senario 3:
|
||||
@@ -1098,9 +1313,9 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
bool isSenario3Happend = false;
|
||||
bool isSenario3Bullish = false;
|
||||
bool isSenario3Bearish = false;
|
||||
if (useSenario3)
|
||||
{
|
||||
}
|
||||
// if (useSenario3)
|
||||
// {
|
||||
// }
|
||||
|
||||
//
|
||||
// Senario 4:
|
||||
@@ -1111,35 +1326,35 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
bool isSenario4Happend = false;
|
||||
bool isSenario4Bullish = false;
|
||||
bool isSenario4Bearish = false;
|
||||
if (useSenario4)
|
||||
{
|
||||
//
|
||||
isSenario4Happend = cParser.HasSenario4Conditions(
|
||||
X_CYCLE_ANALYSE,
|
||||
box,
|
||||
holderBox,
|
||||
dir,
|
||||
provider,
|
||||
X_CYCLE_CONSOLIDATION,
|
||||
barIndex //
|
||||
);
|
||||
// if (useSenario4)
|
||||
// {
|
||||
// //
|
||||
// isSenario4Happend = cParser.HasSenario4Conditions(
|
||||
// X_CYCLE_ANALYSE,
|
||||
// box,
|
||||
// holderBox,
|
||||
// dir,
|
||||
// provider,
|
||||
// X_CYCLE_CONSOLIDATION,
|
||||
// barIndex //
|
||||
// );
|
||||
|
||||
//
|
||||
isSenario4Bullish =
|
||||
isSenario4Happend &&
|
||||
IsBullish(dir);
|
||||
// //
|
||||
// isSenario4Bullish =
|
||||
// isSenario4Happend &&
|
||||
// IsBullish(dir);
|
||||
|
||||
//
|
||||
isSenario4Bearish =
|
||||
isSenario4Happend &&
|
||||
IsBearish(dir);
|
||||
// //
|
||||
// isSenario4Bearish =
|
||||
// isSenario4Happend &&
|
||||
// IsBearish(dir);
|
||||
|
||||
//
|
||||
if (isSenario4Happend)
|
||||
{
|
||||
signalProvider = X121SMC_XWZ_PROVIDER_ACTIVATED_BOX;
|
||||
}
|
||||
}
|
||||
// //
|
||||
// if (isSenario4Happend)
|
||||
// {
|
||||
// signalProvider = X121SMC_XWZ_PROVIDER_ACTIVATED_BOX;
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
// Senario 5:
|
||||
@@ -1149,9 +1364,9 @@ struct X121SMCStrategyXWZWorkingZone
|
||||
bool isSenario5Happend = false;
|
||||
bool isSenario5Bullish = false;
|
||||
bool isSenario5Bearish = false;
|
||||
if (useSenario5)
|
||||
{
|
||||
}
|
||||
// if (useSenario5)
|
||||
// {
|
||||
// }
|
||||
|
||||
//
|
||||
// Summarize All Senario(s) Conditions ...
|
||||
|
||||
@@ -786,27 +786,27 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
x121Inputs.xpvInputs.showSar = showAll || true;
|
||||
x121Inputs.xpvInputs.showPeaks = showAll || true;
|
||||
x121Inputs.xpvInputs.showVales = showAll || true;
|
||||
x121Inputs.xpvInputs.showSupports = showAll || true;
|
||||
x121Inputs.xpvInputs.showResistances = showAll || true;
|
||||
x121Inputs.xpvInputs.showGoldenZones = showAll || true;
|
||||
x121Inputs.xpvInputs.showSar = showAll || false;
|
||||
x121Inputs.xpvInputs.showPeaks = showAll || false;
|
||||
x121Inputs.xpvInputs.showVales = showAll || false;
|
||||
x121Inputs.xpvInputs.showSupports = showAll || false;
|
||||
x121Inputs.xpvInputs.showResistances = showAll || false;
|
||||
x121Inputs.xpvInputs.showGoldenZones = showAll || false;
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
|
||||
//
|
||||
x121Inputs.xhkInputs.drawRawXHKCandles = showAll || false;
|
||||
x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || true;
|
||||
x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || false;
|
||||
|
||||
//
|
||||
// XMAS ...
|
||||
|
||||
//
|
||||
x121Inputs.xmasInputs.showUpper = showAll || true;
|
||||
x121Inputs.xmasInputs.showMid = showAll || true;
|
||||
x121Inputs.xmasInputs.showLower = showAll || true;
|
||||
x121Inputs.xmasInputs.showUpper = showAll || false;
|
||||
x121Inputs.xmasInputs.showMid = showAll || false;
|
||||
x121Inputs.xmasInputs.showLower = showAll || false;
|
||||
|
||||
//
|
||||
// XATR ...
|
||||
@@ -841,9 +841,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
|
||||
//
|
||||
// X3MA ...
|
||||
x121Inputs.x3maInputs.showX3MaFast = showAll || false;
|
||||
x121Inputs.x3maInputs.showX3MaMid = showAll || false;
|
||||
x121Inputs.x3maInputs.showX3MaSlow = showAll || false;
|
||||
x121Inputs.x3maInputs.showX3MaFast = showAll || true;
|
||||
x121Inputs.x3maInputs.showX3MaMid = showAll || true;
|
||||
x121Inputs.x3maInputs.showX3MaSlow = showAll || true;
|
||||
|
||||
//
|
||||
// Initialize Cycle Helpers ...
|
||||
|
||||
Reference in New Issue
Block a user