last ...
This commit is contained in:
@@ -0,0 +1,830 @@
|
|||||||
|
//
|
||||||
|
bool HasSenario1Conditions(
|
||||||
|
ENUM_X_CYCLES cycle,
|
||||||
|
XBoxZone &box,
|
||||||
|
XBoxZone &holderBox,
|
||||||
|
ENUM_X_DIRECTION &dir,
|
||||||
|
XBoxZone &waitingBoxes[],
|
||||||
|
X121SMCStrategySignalProviderData &provider,
|
||||||
|
ENUM_X_CYCLES holderCycle = X_CYCLE_NONE,
|
||||||
|
int barIndex = 0 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Fil Selected Data ...
|
||||||
|
XPOIState cState;
|
||||||
|
X121Conditions cXConditions;
|
||||||
|
XPOIStateEvents cStateEvents;
|
||||||
|
XC121SMCCycleHelper *cHelper;
|
||||||
|
X121SMCCycleConditions cConditions;
|
||||||
|
result = provider.SelectCycle(
|
||||||
|
cycle,
|
||||||
|
cState,
|
||||||
|
cStateEvents,
|
||||||
|
cXConditions,
|
||||||
|
cHelper,
|
||||||
|
cConditions //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
cState.Clean();
|
||||||
|
ZeroMemory(cHelper);
|
||||||
|
cConditions.Clean();
|
||||||
|
cXConditions.Clean();
|
||||||
|
cStateEvents.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
Parse(cXConditions);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Fil Selected Data ...
|
||||||
|
XPOIState chState;
|
||||||
|
X121Conditions chXConditions;
|
||||||
|
XPOIStateEvents chStateEvents;
|
||||||
|
XC121SMCCycleHelper *chHelper;
|
||||||
|
X121SMCCycleConditions chConditions;
|
||||||
|
if (holderCycle != X_CYCLE_NONE)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = provider.SelectCycle(
|
||||||
|
holderCycle,
|
||||||
|
chState,
|
||||||
|
chStateEvents,
|
||||||
|
chXConditions,
|
||||||
|
chHelper,
|
||||||
|
chConditions //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
chState.Clean();
|
||||||
|
ZeroMemory(chHelper);
|
||||||
|
chConditions.Clean();
|
||||||
|
chXConditions.Clean();
|
||||||
|
chStateEvents.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Parse(chXConditions);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Checking Waiting Baoxes Exists ...
|
||||||
|
result = HasChild(waitingBoxes);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XCPOIDrawer *drawer = provider
|
||||||
|
.visionCycleHelper
|
||||||
|
.mPOIDrawer;
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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;
|
||||||
|
int ppIDX = pIDX + 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Inside Box ...
|
||||||
|
XBoxZone insideBox;
|
||||||
|
count = ArraySize(waitingBoxes);
|
||||||
|
has = IsValidSize(count);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XBoxZone iBox = waitingBoxes[i];
|
||||||
|
bool isBullish = iBox.IsBullish();
|
||||||
|
double iMid = iBox.lower + ((iBox.upper - iBox.lower) / 2);
|
||||||
|
|
||||||
|
//
|
||||||
|
has =
|
||||||
|
//
|
||||||
|
isBullish
|
||||||
|
? cBar.low < iMid &&
|
||||||
|
cBar.low > iBox.lower
|
||||||
|
: cBar.high > iMid &&
|
||||||
|
cBar.high < iBox.upper
|
||||||
|
//
|
||||||
|
;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
insideBox = iBox;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
has = insideBox.IsValid();
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_X_DIRECTION iBarPosDir;
|
||||||
|
bool isBarValidForDir = cHelper
|
||||||
|
.mBarAnalyser
|
||||||
|
.IsValidForPosition(
|
||||||
|
cBar,
|
||||||
|
iBarPosDir //
|
||||||
|
);
|
||||||
|
bool isBarValidForBullish =
|
||||||
|
isBarValidForDir &&
|
||||||
|
IsBullish(iBarPosDir);
|
||||||
|
bool isBarValidForBearish =
|
||||||
|
isBarValidForDir &&
|
||||||
|
IsBearish(iBarPosDir);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCBoxObject *iObj;
|
||||||
|
has = drawer.DrawBox(
|
||||||
|
insideBox,
|
||||||
|
iObj //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Print("Dec Scores:");
|
||||||
|
Print("-------------");
|
||||||
|
Print("Bull: ", provider.decisionBullishScore);
|
||||||
|
Print("Bear: ", provider.decisionBearishScore);
|
||||||
|
Print("-------------");
|
||||||
|
Print("Anal Scores:");
|
||||||
|
Print("-------------");
|
||||||
|
Print("Bull: ", provider.analyseBullishScore);
|
||||||
|
Print("Bear: ", provider.analyseBearishScore);
|
||||||
|
Print("-------------");
|
||||||
|
Print("Bar Valid For: " + ToString(iBarPosDir));
|
||||||
|
Print("-------------");
|
||||||
|
Print(ToString(insideBox.dir), " Inside ...");
|
||||||
|
Print("-------------");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = has;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
zBar.Clean();
|
||||||
|
cBar.Clean();
|
||||||
|
pBar.Clean();
|
||||||
|
cState.Clean();
|
||||||
|
chState.Clean();
|
||||||
|
insideBox.Clean();
|
||||||
|
ZeroMemory(cHelper);
|
||||||
|
cConditions.Clean();
|
||||||
|
cXConditions.Clean();
|
||||||
|
ZeroMemory(chHelper);
|
||||||
|
chConditions.Clean();
|
||||||
|
chXConditions.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detecting Signal Conditions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bullish Conditions ...
|
||||||
|
isBullish =
|
||||||
|
//
|
||||||
|
// Base Condition ...
|
||||||
|
(
|
||||||
|
//
|
||||||
|
insideBox.IsBullish() &&
|
||||||
|
isBarValidForBullish
|
||||||
|
//
|
||||||
|
)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bearish Conditions ...
|
||||||
|
isBearish =
|
||||||
|
//
|
||||||
|
// Base Condition ...
|
||||||
|
(
|
||||||
|
//
|
||||||
|
insideBox.IsBearish() &&
|
||||||
|
isBarValidForBearish
|
||||||
|
//
|
||||||
|
)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Filling Requirements ...
|
||||||
|
result =
|
||||||
|
isBullish ||
|
||||||
|
isBearish;
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
dir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
|
||||||
|
//
|
||||||
|
box.dir = dir;
|
||||||
|
box.to = TimeCurrent();
|
||||||
|
box.from = insideBox.from;
|
||||||
|
box.upper = insideBox.upper;
|
||||||
|
box.lower = insideBox.lower;
|
||||||
|
box.symbol = cXConditions.symbol;
|
||||||
|
box.period = cXConditions.period;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check All Conditions ...
|
||||||
|
result =
|
||||||
|
box.IsValid() &&
|
||||||
|
HasDirection(dir) &&
|
||||||
|
(isBullish ||
|
||||||
|
isBearish);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup Resources ...
|
||||||
|
zBar.Clean();
|
||||||
|
cBar.Clean();
|
||||||
|
pBar.Clean();
|
||||||
|
cState.Clean();
|
||||||
|
chState.Clean();
|
||||||
|
insideBox.Clean();
|
||||||
|
ZeroMemory(cHelper);
|
||||||
|
cConditions.Clean();
|
||||||
|
cStateEvents.Clean();
|
||||||
|
cXConditions.Clean();
|
||||||
|
ZeroMemory(chHelper);
|
||||||
|
chConditions.Clean();
|
||||||
|
chStateEvents.Clean();
|
||||||
|
chXConditions.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checking a Box Exists in Collections or not ...
|
||||||
|
*
|
||||||
|
* @param box: XBoxZone instance reference ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsExists(XBoxZone &box)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Validation ...
|
||||||
|
result = box.IsValid() &&
|
||||||
|
(HasWaitingBoxes() ||
|
||||||
|
HasBreakedBoxes() ||
|
||||||
|
HasUnavailableBoxes());
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int idx = -1;
|
||||||
|
bool has = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Index in Waiting Boxes ...
|
||||||
|
has = HasWaitingBoxes();
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
idx = FindIndex(
|
||||||
|
box,
|
||||||
|
waitingBoxes //
|
||||||
|
);
|
||||||
|
result = IsValidIndex(idx);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Index in Breaked Boxes ...
|
||||||
|
has = HasBreakedBoxes();
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
idx = FindIndex(
|
||||||
|
box,
|
||||||
|
breakedBoxes //
|
||||||
|
);
|
||||||
|
result = IsValidIndex(idx);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Index in Unavailable Boxes ...
|
||||||
|
has = HasUnavailableBoxes();
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
idx = FindIndex(
|
||||||
|
box,
|
||||||
|
unavailableBoxes //
|
||||||
|
);
|
||||||
|
result = IsValidIndex(idx);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect Signal Boxes ...
|
||||||
|
*
|
||||||
|
* @param cycle: ENUM_X_CYCLES member ...
|
||||||
|
* @param provider: X121SMCStrategySignalProviderData instance reference ...
|
||||||
|
* @param barIndex: int ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool DetectSignalBoxes(
|
||||||
|
ENUM_X_CYCLES cycle,
|
||||||
|
X121SMCStrategySignalProviderData &provider,
|
||||||
|
int barIndex = 0 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
int idx = -1;
|
||||||
|
int count = 0;
|
||||||
|
bool has = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Select Cycle ...
|
||||||
|
XPOIState cState;
|
||||||
|
XPOIStateEvents cStateEvents;
|
||||||
|
X121Conditions cXConditions;
|
||||||
|
XC121SMCCycleHelper *cHelper;
|
||||||
|
X121SMCCycleConditions cConditions;
|
||||||
|
result = provider.SelectCycle(
|
||||||
|
cycle,
|
||||||
|
cState,
|
||||||
|
cStateEvents,
|
||||||
|
cXConditions,
|
||||||
|
cHelper,
|
||||||
|
cConditions //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
cState.Clean();
|
||||||
|
ZeroMemory(cHelper);
|
||||||
|
cConditions.Clean();
|
||||||
|
cStateEvents.Clean();
|
||||||
|
cXConditions.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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 //
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // 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)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// idx = GetYoungest(cState.supportZones);
|
||||||
|
// has = IsValidIndex(idx);
|
||||||
|
// if (has)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// XCSupportZone *iSupport = cState.supportZones[idx];
|
||||||
|
|
||||||
|
// //
|
||||||
|
// XBoxZone iBox;
|
||||||
|
// has = ToBox(
|
||||||
|
// iBox,
|
||||||
|
// iSupport //
|
||||||
|
// );
|
||||||
|
// if (has)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// 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 //
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
count = CountWaitingBoxes();
|
||||||
|
result = IsValidSize(count);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup Resources ...
|
||||||
|
|
||||||
|
//
|
||||||
|
cState.Clean();
|
||||||
|
ZeroMemory(cHelper);
|
||||||
|
cConditions.Clean();
|
||||||
|
cXConditions.Clean();
|
||||||
|
cStateEvents.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validating Waiting Boxes and Detect Breaked Boxes ...
|
||||||
|
*
|
||||||
|
* @param barIndex: int ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int ValidateWaitingBoxes(
|
||||||
|
int barIndex = 0 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool has = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (barIndex < 0)
|
||||||
|
{
|
||||||
|
barIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (barIndex == 0)
|
||||||
|
{
|
||||||
|
barIndex = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
has = HasWaitingBoxes();
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int removeIDX[];
|
||||||
|
result = CountWaitingBoxes();
|
||||||
|
for (int i = 0; i < result; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XOHCL iBar;
|
||||||
|
XBoxZone iBox = waitingBoxes[i];
|
||||||
|
bool isInite = iBar
|
||||||
|
.Init(
|
||||||
|
iBox.symbol,
|
||||||
|
iBox.period,
|
||||||
|
iBox.from //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
has = isInite &&
|
||||||
|
IsBoxBreaked(
|
||||||
|
iBox,
|
||||||
|
iBar.Index() - 1,
|
||||||
|
barIndex,
|
||||||
|
period //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
i,
|
||||||
|
removeIDX //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
AddRef(
|
||||||
|
iBox,
|
||||||
|
breakedBoxes //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
iBox.Clean();
|
||||||
|
iBar.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
has = HasChild(removeIDX);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
CleanupArray(
|
||||||
|
removeIDX,
|
||||||
|
waitingBoxes //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Clean(removeIDX);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = CountWaitingBoxes();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -339,7 +339,7 @@ bool IsSame(
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
result = sourceBox.IsSame(destBox);
|
result = sourceBox.IsSameAs(destBox);
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -894,7 +894,7 @@ bool FindBoxIndex(
|
|||||||
XBoxZone iBox = boxes[i];
|
XBoxZone iBox = boxes[i];
|
||||||
|
|
||||||
//
|
//
|
||||||
bool isSame = box.IsSame(iBox);
|
bool isSame = box.IsSameAs(iBox);
|
||||||
if (isSame)
|
if (isSame)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -931,7 +931,7 @@ bool IsBoxBelow(
|
|||||||
//
|
//
|
||||||
result = source.IsValid() &&
|
result = source.IsValid() &&
|
||||||
dest.IsValid() &&
|
dest.IsValid() &&
|
||||||
!source.IsSame(dest);
|
!source.IsSameAs(dest);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
@@ -974,7 +974,7 @@ bool IsBoxAbove(
|
|||||||
//
|
//
|
||||||
result = source.IsValid() &&
|
result = source.IsValid() &&
|
||||||
dest.IsValid() &&
|
dest.IsValid() &&
|
||||||
!source.IsSame(dest);
|
!source.IsSameAs(dest);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
@@ -1019,7 +1019,7 @@ bool IsBoxInside(
|
|||||||
//
|
//
|
||||||
result = source.IsValid() &&
|
result = source.IsValid() &&
|
||||||
dest.IsValid() &&
|
dest.IsValid() &&
|
||||||
!source.IsSame(dest);
|
!source.IsSameAs(dest);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
@@ -1083,7 +1083,7 @@ bool IsBoxInsideOr(
|
|||||||
//
|
//
|
||||||
result = source.IsValid() &&
|
result = source.IsValid() &&
|
||||||
dest.IsValid() &&
|
dest.IsValid() &&
|
||||||
!source.IsSame(dest);
|
!source.IsSameAs(dest);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -5317,6 +5317,7 @@ struct XBoxZone
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
return IsValid() &&
|
return IsValid() &&
|
||||||
|
item.IsValid() &&
|
||||||
dir == item.dir &&
|
dir == item.dir &&
|
||||||
from == item.from &&
|
from == item.from &&
|
||||||
type == item.type &&
|
type == item.type &&
|
||||||
@@ -5326,42 +5327,42 @@ struct XBoxZone
|
|||||||
period == item.period;
|
period == item.period;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Check Box is Same as another ...
|
// * Check Box is Same as another ...
|
||||||
*
|
// *
|
||||||
* @param box: XBoxZone instance Reference ...
|
// * @param box: XBoxZone instance Reference ...
|
||||||
*
|
// *
|
||||||
* @return ( bool )
|
// * @return ( bool )
|
||||||
*/
|
// */
|
||||||
bool IsSame(XBoxZone &box)
|
// bool IsSame(XBoxZone &box)
|
||||||
{
|
// {
|
||||||
//
|
// //
|
||||||
bool result = false;
|
// bool result = false;
|
||||||
|
|
||||||
//
|
// //
|
||||||
result = IsValid() &&
|
// result = IsValid() &&
|
||||||
box.IsValid();
|
// box.IsValid();
|
||||||
if (!result)
|
// if (!result)
|
||||||
{
|
// {
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
|
||||||
//
|
// //
|
||||||
result =
|
// result =
|
||||||
//
|
// //
|
||||||
dir == box.dir &&
|
// dir == box.dir &&
|
||||||
from == box.from &&
|
// from == box.from &&
|
||||||
type == box.type &&
|
// type == box.type &&
|
||||||
upper == box.upper &&
|
// upper == box.upper &&
|
||||||
lower == box.lower &&
|
// lower == box.lower &&
|
||||||
symbol == box.symbol &&
|
// symbol == box.symbol &&
|
||||||
period == box.period
|
// period == box.period
|
||||||
//
|
// //
|
||||||
;
|
// ;
|
||||||
|
|
||||||
//
|
// //
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve Box Age ...
|
* Retrieve Box Age ...
|
||||||
|
|||||||
@@ -642,6 +642,54 @@ struct XOBFVG
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
struct XSignalBox
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XBoxZone ob;
|
||||||
|
XBoxZone fvg;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor ...
|
||||||
|
XSignalBox()
|
||||||
|
{
|
||||||
|
Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleanup Model ...
|
||||||
|
*/
|
||||||
|
void Clean()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ob.Clean();
|
||||||
|
fvg.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate Model ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsValid()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
ob.IsValid();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Model State Parsing ...
|
// Model State Parsing ...
|
||||||
struct XPOIStateEvents
|
struct XPOIStateEvents
|
||||||
@@ -4869,6 +4917,165 @@ int AddIfNotExists(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find Index of a Signal Box on another ...
|
||||||
|
*
|
||||||
|
* @param index: int, index of exists ...
|
||||||
|
* @param item: XSignal Box ...
|
||||||
|
* @param items: XSignal Box Collection ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool FindIndex(
|
||||||
|
int &index,
|
||||||
|
XSignalBox &item,
|
||||||
|
XSignalBox &items[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
index = -1;
|
||||||
|
int count = ArraySize(items);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = item.IsValid() &&
|
||||||
|
HasChild(items);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool isSame = item.ob
|
||||||
|
.IsSameAs(items[i].ob);
|
||||||
|
if (isSame)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = IsValidIndex(index);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find Index of a Signal Box on another ...
|
||||||
|
*
|
||||||
|
* @param index: int, index of exists ...
|
||||||
|
* @param item: XSignal Box ...
|
||||||
|
* @param items: XSignal Box Collection ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool FindIndex(
|
||||||
|
int &index,
|
||||||
|
XBoxZone &item,
|
||||||
|
XSignalBox &items[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
index = -1;
|
||||||
|
int count = ArraySize(items);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = item.IsValid() &&
|
||||||
|
HasChild(items);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool isSame = item.IsSameAs(items[i].ob);
|
||||||
|
if (isSame)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
isSame = item.IsSameAs(items[i].fvg);
|
||||||
|
if (isSame)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = IsValidIndex(index);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a Signal Box in a Collection if not Exists ...
|
||||||
|
*
|
||||||
|
* @param item: XSignal Box ...
|
||||||
|
* @param items: XSignal Box Collection ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool AddIfNotExists(
|
||||||
|
XSignalBox &item,
|
||||||
|
XSignalBox &items[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = item.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int idx = -1;
|
||||||
|
result = !FindIndex(
|
||||||
|
idx,
|
||||||
|
item,
|
||||||
|
items //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
AddRef(
|
||||||
|
item,
|
||||||
|
items //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// XPOI State Event Parsers ...
|
// XPOI State Event Parsers ...
|
||||||
|
|
||||||
|
|||||||
@@ -2631,7 +2631,7 @@ struct X121SMCStrategyConditionParser
|
|||||||
XBoxZone &box,
|
XBoxZone &box,
|
||||||
XBoxZone &holderBox,
|
XBoxZone &holderBox,
|
||||||
ENUM_X_DIRECTION &dir,
|
ENUM_X_DIRECTION &dir,
|
||||||
XBoxZone &waitingBoxes[],
|
XSignalBox &waitingBoxes[],
|
||||||
X121SMCStrategySignalProviderData &provider,
|
X121SMCStrategySignalProviderData &provider,
|
||||||
ENUM_X_CYCLES holderCycle = X_CYCLE_NONE,
|
ENUM_X_CYCLES holderCycle = X_CYCLE_NONE,
|
||||||
int barIndex = 0 //
|
int barIndex = 0 //
|
||||||
@@ -2783,41 +2783,6 @@ struct X121SMCStrategyConditionParser
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Detect Inside Box ...
|
|
||||||
XBoxZone insideBox;
|
|
||||||
count = ArraySize(waitingBoxes);
|
|
||||||
has = IsValidSize(count);
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XBoxZone iBox = waitingBoxes[i];
|
|
||||||
bool isBullish = iBox.IsBullish();
|
|
||||||
double iMid = iBox.lower + ((iBox.upper - iBox.lower) / 2);
|
|
||||||
|
|
||||||
//
|
|
||||||
has =
|
|
||||||
//
|
|
||||||
isBullish
|
|
||||||
? cBar.low < iMid &&
|
|
||||||
cBar.low > iBox.lower
|
|
||||||
: cBar.high > iMid &&
|
|
||||||
cBar.high < iBox.upper
|
|
||||||
//
|
|
||||||
;
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
insideBox = iBox;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
has = insideBox.IsValid();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
ENUM_X_DIRECTION iBarPosDir;
|
ENUM_X_DIRECTION iBarPosDir;
|
||||||
bool isBarValidForDir = cHelper
|
bool isBarValidForDir = cHelper
|
||||||
@@ -2834,55 +2799,27 @@ struct X121SMCStrategyConditionParser
|
|||||||
IsBearish(iBarPosDir);
|
IsBearish(iBarPosDir);
|
||||||
|
|
||||||
//
|
//
|
||||||
if (has)
|
// result = isBarValidForBullish ||
|
||||||
{
|
// isBarValidForBearish;
|
||||||
//
|
// if (!result)
|
||||||
XCBoxObject *iObj;
|
// {
|
||||||
has = drawer.DrawBox(
|
// //
|
||||||
insideBox,
|
// zBar.Clean();
|
||||||
iObj //
|
// cBar.Clean();
|
||||||
);
|
// pBar.Clean();
|
||||||
if (has)
|
// cState.Clean();
|
||||||
{
|
// chState.Clean();
|
||||||
//
|
// insideBox.Clean();
|
||||||
Print("Dec Scores:");
|
// ZeroMemory(cHelper);
|
||||||
Print("-------------");
|
// cConditions.Clean();
|
||||||
Print("Bull: ", provider.decisionBullishScore);
|
// cXConditions.Clean();
|
||||||
Print("Bear: ", provider.decisionBearishScore);
|
// ZeroMemory(chHelper);
|
||||||
Print("-------------");
|
// chConditions.Clean();
|
||||||
Print("Anal Scores:");
|
// chXConditions.Clean();
|
||||||
Print("-------------");
|
|
||||||
Print("Bull: ", provider.analyseBullishScore);
|
|
||||||
Print("Bear: ", provider.analyseBearishScore);
|
|
||||||
Print("-------------");
|
|
||||||
Print("Bar Valid For: " + ToString(iBarPosDir));
|
|
||||||
Print("-------------");
|
|
||||||
Print(ToString(insideBox.dir), " Inside ...");
|
|
||||||
Print("-------------");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
// //
|
||||||
result = has;
|
// return result;
|
||||||
if (!result)
|
// }
|
||||||
{
|
|
||||||
//
|
|
||||||
zBar.Clean();
|
|
||||||
cBar.Clean();
|
|
||||||
pBar.Clean();
|
|
||||||
cState.Clean();
|
|
||||||
chState.Clean();
|
|
||||||
insideBox.Clean();
|
|
||||||
ZeroMemory(cHelper);
|
|
||||||
cConditions.Clean();
|
|
||||||
cXConditions.Clean();
|
|
||||||
ZeroMemory(chHelper);
|
|
||||||
chConditions.Clean();
|
|
||||||
chXConditions.Clean();
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Detecting Signal Conditions ...
|
// Detecting Signal Conditions ...
|
||||||
@@ -2894,8 +2831,11 @@ struct X121SMCStrategyConditionParser
|
|||||||
// Base Condition ...
|
// Base Condition ...
|
||||||
(
|
(
|
||||||
//
|
//
|
||||||
insideBox.IsBullish() &&
|
false
|
||||||
isBarValidForBullish
|
// cBar.IsBullish() &&
|
||||||
|
// isBarValidForBullish &&
|
||||||
|
// cBar.close > cXConditions.x3maFastBuffer[cIDX] &&
|
||||||
|
// cXConditions.x3maFastBuffer[cIDX] < cXConditions.x3maSlowBuffer[cIDX]
|
||||||
//
|
//
|
||||||
)
|
)
|
||||||
//
|
//
|
||||||
@@ -2908,8 +2848,11 @@ struct X121SMCStrategyConditionParser
|
|||||||
// Base Condition ...
|
// Base Condition ...
|
||||||
(
|
(
|
||||||
//
|
//
|
||||||
insideBox.IsBearish() &&
|
false
|
||||||
isBarValidForBearish
|
// cBar.IsBearish() &&
|
||||||
|
// isBarValidForBearish &&
|
||||||
|
// cBar.close < cXConditions.x3maFastBuffer[cIDX] &&
|
||||||
|
// cXConditions.x3maFastBuffer[cIDX] > cXConditions.x3maSlowBuffer[cIDX]
|
||||||
//
|
//
|
||||||
)
|
)
|
||||||
//
|
//
|
||||||
@@ -2931,9 +2874,9 @@ struct X121SMCStrategyConditionParser
|
|||||||
//
|
//
|
||||||
box.dir = dir;
|
box.dir = dir;
|
||||||
box.to = TimeCurrent();
|
box.to = TimeCurrent();
|
||||||
box.from = insideBox.from;
|
// box.from = insideBox.from;
|
||||||
box.upper = insideBox.upper;
|
// box.upper = insideBox.upper;
|
||||||
box.lower = insideBox.lower;
|
// box.lower = insideBox.lower;
|
||||||
box.symbol = cXConditions.symbol;
|
box.symbol = cXConditions.symbol;
|
||||||
box.period = cXConditions.period;
|
box.period = cXConditions.period;
|
||||||
}
|
}
|
||||||
@@ -2953,7 +2896,7 @@ struct X121SMCStrategyConditionParser
|
|||||||
pBar.Clean();
|
pBar.Clean();
|
||||||
cState.Clean();
|
cState.Clean();
|
||||||
chState.Clean();
|
chState.Clean();
|
||||||
insideBox.Clean();
|
// insideBox.Clean();
|
||||||
ZeroMemory(cHelper);
|
ZeroMemory(cHelper);
|
||||||
cConditions.Clean();
|
cConditions.Clean();
|
||||||
cStateEvents.Clean();
|
cStateEvents.Clean();
|
||||||
|
|||||||
@@ -119,11 +119,11 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
zIndex,
|
zIndex,
|
||||||
loopback,
|
loopback,
|
||||||
false, // Trigger ...
|
false, // Trigger ...
|
||||||
true, // Decision ...
|
true, // Decision ...
|
||||||
true, // Analyse ...
|
true, // Analyse ...
|
||||||
true, // Verification ...
|
true, // Verification ...
|
||||||
true, // Consolidation ...
|
true, // Consolidation ...
|
||||||
true // Vision ...
|
true // Vision ...
|
||||||
);
|
);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
@@ -224,7 +224,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
// Detectiong Signal Boxes ...
|
// Detectiong Signal Boxes ...
|
||||||
hasWaitingBoxes = workingZone
|
hasWaitingBoxes = workingZone
|
||||||
.DetectSignalBoxes(
|
.DetectSignalBoxes(
|
||||||
X_CYCLE_DECISION,
|
X_CYCLE_ANALYSE,
|
||||||
provider,
|
provider,
|
||||||
zIndex //
|
zIndex //
|
||||||
);
|
);
|
||||||
@@ -311,11 +311,12 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
if (hasBreakedBoxes)
|
if (hasBreakedBoxes)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
int idx = FindIndex(
|
int idx = -1;
|
||||||
|
bool has = FindIndex(
|
||||||
|
idx,
|
||||||
signalBox,
|
signalBox,
|
||||||
workingZone.breakedBoxes //
|
workingZone.breakedBoxes //
|
||||||
);
|
);
|
||||||
bool has = IsValidIndex(idx);
|
|
||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -333,11 +334,12 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
if (hasWaitingBoxes)
|
if (hasWaitingBoxes)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
int idx = FindIndex(
|
int idx = -1;
|
||||||
|
bool has = FindIndex(
|
||||||
|
idx,
|
||||||
signalBox,
|
signalBox,
|
||||||
workingZone.waitingBoxes //
|
workingZone.waitingBoxes //
|
||||||
);
|
);
|
||||||
bool has = IsValidIndex(idx);
|
|
||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -838,8 +840,8 @@ class XCX121SMCXWZSignalDetector : public XCBase
|
|||||||
//
|
//
|
||||||
// Summarize Results ...
|
// Summarize Results ...
|
||||||
result = hasPriority &&
|
result = hasPriority &&
|
||||||
hasSignalBox &&
|
hasSignalBox &&
|
||||||
hasRewardAmount;
|
hasRewardAmount;
|
||||||
|
|
||||||
//
|
//
|
||||||
if (result)
|
if (result)
|
||||||
|
|||||||
@@ -71,9 +71,9 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
XCDemandZone *demandZone;
|
XCDemandZone *demandZone;
|
||||||
|
|
||||||
//
|
//
|
||||||
XBoxZone waitingBoxes[];
|
XSignalBox waitingBoxes[];
|
||||||
XBoxZone breakedBoxes[];
|
XSignalBox breakedBoxes[];
|
||||||
XBoxZone unavailableBoxes[];
|
XSignalBox unavailableBoxes[];
|
||||||
|
|
||||||
//
|
//
|
||||||
CArrayObj mDrawnObjects;
|
CArrayObj mDrawnObjects;
|
||||||
@@ -236,7 +236,7 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
*
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
*/
|
*/
|
||||||
bool IsExists(XBoxZone &box)
|
bool IsExists(XSignalBox &box)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
bool result = false;
|
bool result = false;
|
||||||
@@ -262,11 +262,11 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
idx = FindIndex(
|
result = FindIndex(
|
||||||
|
idx,
|
||||||
box,
|
box,
|
||||||
waitingBoxes //
|
waitingBoxes //
|
||||||
);
|
);
|
||||||
result = IsValidIndex(idx);
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
@@ -279,11 +279,11 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
idx = FindIndex(
|
result = FindIndex(
|
||||||
|
idx,
|
||||||
box,
|
box,
|
||||||
breakedBoxes //
|
breakedBoxes //
|
||||||
);
|
);
|
||||||
result = IsValidIndex(idx);
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
@@ -296,11 +296,11 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
idx = FindIndex(
|
result = FindIndex(
|
||||||
|
idx,
|
||||||
box,
|
box,
|
||||||
unavailableBoxes //
|
unavailableBoxes //
|
||||||
);
|
);
|
||||||
result = IsValidIndex(idx);
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
@@ -514,233 +514,78 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// 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 //
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Select Order Blocks ...
|
// Select Order Blocks ...
|
||||||
// if (cStateEvents.hasNewOrderBlock)
|
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)
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
idx = GetYoungest(cState.supportZones);
|
idx = GetYoungest(cState.orderBlocks);
|
||||||
has = IsValidIndex(idx);
|
has = IsValidIndex(idx);
|
||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
XCSupportZone *iSupport = cState.supportZones[idx];
|
XCOrderBlock *iOB = cState.orderBlocks[idx];
|
||||||
|
bool isBullish = iOB.IsBullish();
|
||||||
|
|
||||||
//
|
//
|
||||||
XBoxZone iBox;
|
XBoxZone iOBBox;
|
||||||
|
XBoxZone iFVGBox;
|
||||||
has = ToBox(
|
has = ToBox(
|
||||||
iBox,
|
iOBBox,
|
||||||
iSupport //
|
iOB //
|
||||||
);
|
);
|
||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
has = IsExists(iBox);
|
// Detect FVGs ...
|
||||||
if (!has)
|
if (cStateEvents.hasNewFairValueGap)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
AddRef(
|
int idx =
|
||||||
iBox,
|
isBullish
|
||||||
waitingBoxes //
|
? GetLowest(cState.bullishFairValueGaps)
|
||||||
);
|
: GetHighest(cState.bearishFairValueGaps);
|
||||||
|
XCFVG *iFVG =
|
||||||
|
isBullish
|
||||||
|
? cState.bullishFairValueGaps[idx]
|
||||||
|
: cState.bearishFairValueGaps[idx];
|
||||||
|
has = IsValidIndex(idx);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
ToBox(
|
||||||
|
iFVGBox,
|
||||||
|
iFVG //
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
if (cStateEvents.hasNewResistanceZone)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
idx = GetYoungest(cState.resistanceZones);
|
|
||||||
has = IsValidIndex(idx);
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCResistanceZone *iResistance = cState.resistanceZones[idx];
|
|
||||||
|
|
||||||
//
|
//
|
||||||
XBoxZone iBox;
|
has = iOBBox.IsValid() &&
|
||||||
has = ToBox(
|
iFVGBox.IsValid();
|
||||||
iBox,
|
|
||||||
iResistance //
|
|
||||||
);
|
|
||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
has = IsExists(iBox);
|
XSignalBox iSignalBox;
|
||||||
if (!has)
|
|
||||||
{
|
//
|
||||||
//
|
iSignalBox.ob = iOBBox;
|
||||||
AddRef(
|
iSignalBox.fvg = iFVGBox;
|
||||||
iBox,
|
|
||||||
waitingBoxes //
|
//
|
||||||
);
|
AddRef(
|
||||||
}
|
iSignalBox,
|
||||||
|
waitingBoxes //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
iSignalBox.Clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
iOBBox.Clean();
|
||||||
|
iFVGBox.Clean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -805,21 +650,33 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
XOHCL iBar;
|
XOHCL iBar;
|
||||||
XBoxZone iBox = waitingBoxes[i];
|
XSignalBox iBox = waitingBoxes[i];
|
||||||
bool isInite = iBar
|
bool isInite = iBar.Init(
|
||||||
.Init(
|
iBox.ob.symbol,
|
||||||
iBox.symbol,
|
iBox.ob.period,
|
||||||
iBox.period,
|
iBox.ob.from //
|
||||||
iBox.from //
|
);
|
||||||
);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
has = isInite &&
|
has = isInite &&
|
||||||
IsBoxBreaked(
|
(
|
||||||
iBox,
|
//
|
||||||
iBar.Index() - 1,
|
IsBoxBreaked(
|
||||||
barIndex,
|
iBox.fvg,
|
||||||
period //
|
iBar.Index() - 1,
|
||||||
|
barIndex,
|
||||||
|
period //
|
||||||
|
)
|
||||||
|
//
|
||||||
|
||
|
||||||
|
//
|
||||||
|
IsBoxBreaked(
|
||||||
|
iBox.ob,
|
||||||
|
iBar.Index() - 1,
|
||||||
|
barIndex,
|
||||||
|
period //
|
||||||
|
)
|
||||||
|
//
|
||||||
);
|
);
|
||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
@@ -837,7 +694,7 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
iBox.Clean();
|
// iBox.Clean();
|
||||||
iBar.Clean();
|
iBar.Clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -996,18 +853,6 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Waiting Boxes ...
|
// Waiting Boxes ...
|
||||||
ENUM_X_DIRECTION boxDir = X_DIRECTION_NONE;
|
|
||||||
XBoxZone tmpBoxes[];
|
|
||||||
Copy(
|
|
||||||
waitingBoxes,
|
|
||||||
tmpBoxes //
|
|
||||||
);
|
|
||||||
int count = ArraySize(tmpBoxes);
|
|
||||||
bool has = IsValidSize(count);
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
@@ -1051,7 +896,14 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
count = CountWaitingBoxes();
|
count = CountWaitingBoxes();
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
waitingBoxes[i].to = value;
|
//
|
||||||
|
waitingBoxes[i].ob.to = value;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (waitingBoxes[i].fvg.IsValid())
|
||||||
|
{
|
||||||
|
waitingBoxes[i].fvg.to = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1786,18 +1638,38 @@ struct X121SMCStrategyXWZWorkingZone
|
|||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
XCBoxObject *iBoxObj;
|
// OB ...
|
||||||
|
XCBoxObject *iOBBoxObj;
|
||||||
has = drawer.DrawBox(
|
has = drawer.DrawBox(
|
||||||
waitingBoxes[i],
|
waitingBoxes[i].ob,
|
||||||
iBoxObj //
|
iOBBoxObj //
|
||||||
);
|
);
|
||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
mDrawnObjects.Add(iBoxObj);
|
mDrawnObjects.Add(iOBBoxObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
ZeroMemory(iBoxObj);
|
// FVG ...
|
||||||
|
if (waitingBoxes[i].fvg.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCBoxObject *iFVGBoxObj;
|
||||||
|
has = drawer.DrawBox(
|
||||||
|
waitingBoxes[i].fvg,
|
||||||
|
iFVGBoxObj //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
mDrawnObjects.Add(iFVGBoxObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ZeroMemory(iFVGBoxObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ZeroMemory(iOBBoxObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user