مشسف ...
This commit is contained in:
@@ -844,17 +844,20 @@ class XCBarZone : public XCZone
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Activated Zone or not ...
|
||||
* Is Zone Activated ...
|
||||
*
|
||||
* @param forDir: ENUM_X_DIRECTION member, Specified Action Direction ...
|
||||
* @param activatedBar: XOHCL instance Reference ...
|
||||
* @param activatedDir: ENUM_X_DIRECTION member ...
|
||||
* @param forPeriod: ENUM_TIMEFRAMES member, Specified Rejection Period ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsActivated(
|
||||
ENUM_X_DIRECTION forDir,
|
||||
XOHCL &activatedBar,
|
||||
ENUM_X_DIRECTION &activatedDir //
|
||||
ENUM_X_DIRECTION &activatedDir,
|
||||
ENUM_TIMEFRAMES forPeriod = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -865,7 +868,15 @@ class XCBarZone : public XCZone
|
||||
activatedDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
if (!IsSpecifiedValid(forPeriod))
|
||||
{
|
||||
forPeriod = GetPeriod();
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
HasDirection(forDir) &&
|
||||
IsSpecifiedValid(forPeriod);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
@@ -877,7 +888,8 @@ class XCBarZone : public XCZone
|
||||
bool isStarted = IsStarted(
|
||||
forDir,
|
||||
startedBar,
|
||||
startedDir //
|
||||
startedDir,
|
||||
forPeriod //
|
||||
);
|
||||
result = isStarted;
|
||||
if (!result)
|
||||
@@ -899,7 +911,7 @@ class XCBarZone : public XCZone
|
||||
XOHCL iBar;
|
||||
bool isInited = iBar.Init(
|
||||
GetSymbol(),
|
||||
GetPeriod(),
|
||||
forPeriod,
|
||||
i //
|
||||
);
|
||||
result = isInited;
|
||||
@@ -971,17 +983,20 @@ class XCBarZone : public XCZone
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Breaked Zone or not ...
|
||||
* Is Zone Breaked ...
|
||||
*
|
||||
* @param forDir: ENUM_X_DIRECTION member, Specified Action Direction ...
|
||||
* @param breakerBar: XOHCL instance Reference ...
|
||||
* @param breakerDir: ENUM_X_DIRECTION member ...
|
||||
* @param forPeriod: ENUM_TIMEFRAMES member, Specified Rejection Period ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsBreaked(
|
||||
ENUM_X_DIRECTION forDir,
|
||||
XOHCL &breakerBar,
|
||||
ENUM_X_DIRECTION &breakerDir //
|
||||
ENUM_X_DIRECTION &breakerDir,
|
||||
ENUM_TIMEFRAMES forPeriod = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -991,9 +1006,16 @@ class XCBarZone : public XCZone
|
||||
breakerBar.Clean();
|
||||
breakerDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
if (!IsSpecifiedValid(forPeriod))
|
||||
{
|
||||
forPeriod = GetPeriod();
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
HasDirection(forDir);
|
||||
HasDirection(forDir) &&
|
||||
IsSpecifiedValid(forPeriod);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
@@ -1005,7 +1027,8 @@ class XCBarZone : public XCZone
|
||||
bool isActivated = IsActivated(
|
||||
forDir,
|
||||
activatedBar,
|
||||
activatedDir //
|
||||
activatedDir,
|
||||
forPeriod //
|
||||
);
|
||||
result = isActivated;
|
||||
if (!result)
|
||||
@@ -1024,7 +1047,7 @@ class XCBarZone : public XCZone
|
||||
XOHCL iBar;
|
||||
bool isInited = iBar.Init(
|
||||
GetSymbol(),
|
||||
GetPeriod(),
|
||||
forPeriod,
|
||||
i //
|
||||
);
|
||||
result = isInited;
|
||||
@@ -1085,17 +1108,20 @@ class XCBarZone : public XCZone
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Order Zone First Breaker Bar ...
|
||||
* Is Zone Started ...
|
||||
*
|
||||
* @param forDir: ENUM_X_DIRECTION member, Specified Action Direction ...
|
||||
* @param breakerBar: XOHCL instance Reference ...
|
||||
* @param breakerDir: ENUM_X_DIRECTION member ...
|
||||
* @param forPeriod: ENUM_TIMEFRAMES member, Specified Rejection Period ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsStarted(
|
||||
ENUM_X_DIRECTION forDir,
|
||||
XOHCL &startedBar,
|
||||
ENUM_X_DIRECTION &startedDir //
|
||||
ENUM_X_DIRECTION &startedDir,
|
||||
ENUM_TIMEFRAMES forPeriod = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -1105,9 +1131,16 @@ class XCBarZone : public XCZone
|
||||
startedBar.Clean();
|
||||
startedDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
if (!IsSpecifiedValid(forPeriod))
|
||||
{
|
||||
forPeriod = GetPeriod();
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
HasDirection(forDir);
|
||||
HasDirection(forDir) &&
|
||||
IsSpecifiedValid(forPeriod);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
@@ -1121,7 +1154,7 @@ class XCBarZone : public XCZone
|
||||
// Detect From Bar Index ...
|
||||
int fromIndex = iBarShift(
|
||||
GetSymbol(),
|
||||
GetPeriod(),
|
||||
forPeriod,
|
||||
From() //
|
||||
);
|
||||
|
||||
@@ -1132,7 +1165,7 @@ class XCBarZone : public XCZone
|
||||
XOHCL iBar;
|
||||
bool isInited = iBar.Init(
|
||||
GetSymbol(),
|
||||
GetPeriod(),
|
||||
forPeriod,
|
||||
i //
|
||||
);
|
||||
result = isInited;
|
||||
@@ -1196,6 +1229,191 @@ class XCBarZone : public XCZone
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Zone Rejected/Sweeped ...
|
||||
*
|
||||
* @param forDir: ENUM_X_DIRECTION member, Specified Action Direction ...
|
||||
* @param rejectedBar: XOHCL instance Reference ...
|
||||
* @param rejectedDir: ENUM_X_DIRECTION member, Provides Rejection Direction ...
|
||||
* @param from: datetime start checking optional ...
|
||||
* @param forceSweep: bool, Specified Force Sweep Rejection ...
|
||||
* @param forPeriod: ENUM_TIMEFRAMES member, Specified Rejection Period ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsRejected(
|
||||
ENUM_X_DIRECTION forDir,
|
||||
XOHCL &rejectedBar,
|
||||
ENUM_X_DIRECTION &rejectedDir,
|
||||
datetime from = NULL,
|
||||
bool forceSweep = false,
|
||||
ENUM_TIMEFRAMES forPeriod = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
rejectedBar.Clean();
|
||||
rejectedDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
if (!IsSpecifiedValid(forPeriod))
|
||||
{
|
||||
forPeriod = GetPeriod();
|
||||
}
|
||||
|
||||
//
|
||||
if (!IsSpecifiedValid(from))
|
||||
{
|
||||
from = From();
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
HasDirection(forDir) &&
|
||||
IsSpecifiedValid(forPeriod);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBullish = IsBullish(forDir);
|
||||
bool isBearish = IsBearish(forDir);
|
||||
|
||||
//
|
||||
int fromIndex = iBarShift(
|
||||
GetSymbol(),
|
||||
forPeriod,
|
||||
from //
|
||||
);
|
||||
fromIndex--;
|
||||
|
||||
//
|
||||
for (int i = fromIndex; i >= 0; i--)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
bool isInited = iBar.Init(
|
||||
GetSymbol(),
|
||||
forPeriod,
|
||||
i //
|
||||
);
|
||||
result = isInited;
|
||||
if (!result)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool isRejectedFromUpper =
|
||||
//
|
||||
isBullish &&
|
||||
//
|
||||
(
|
||||
//
|
||||
(iBar.low <= Upper() &&
|
||||
iBar.high > Upper() &&
|
||||
iBar.GetUp() > Upper())
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isRejectedFromLower =
|
||||
//
|
||||
isBearish &&
|
||||
//
|
||||
(
|
||||
//
|
||||
(iBar.high >= Lower() &&
|
||||
iBar.low < Lower() &&
|
||||
iBar.GetDown() < Lower())
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isSweepedFromUpper =
|
||||
//
|
||||
isBullish &&
|
||||
//
|
||||
(
|
||||
//
|
||||
(iBar.low <= Lower() &&
|
||||
iBar.high > Upper() &&
|
||||
iBar.GetUp() > Upper())
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isSweepedFromLower =
|
||||
//
|
||||
isBearish &&
|
||||
//
|
||||
(
|
||||
//
|
||||
(iBar.high >= Upper() &&
|
||||
iBar.low < Lower() &&
|
||||
iBar.GetDown() < Lower())
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isRejected = isRejectedFromUpper ||
|
||||
isRejectedFromLower;
|
||||
|
||||
//
|
||||
bool isSweeped = isSweepedFromUpper ||
|
||||
isSweepedFromLower;
|
||||
|
||||
//
|
||||
bool fromUpper = isRejectedFromUpper ||
|
||||
isSweepedFromUpper;
|
||||
|
||||
//
|
||||
bool fromLower = isRejectedFromLower ||
|
||||
isSweepedFromLower;
|
||||
|
||||
//
|
||||
// Prepare Result ...
|
||||
bool isPassed =
|
||||
isSweeped ||
|
||||
isRejected;
|
||||
if (forceSweep)
|
||||
{
|
||||
isPassed = isSweeped;
|
||||
}
|
||||
|
||||
//
|
||||
if (isPassed)
|
||||
{
|
||||
//
|
||||
result = isPassed;
|
||||
rejectedBar = iBar;
|
||||
rejectedDir =
|
||||
fromUpper
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = rejectedBar.IsValid() &&
|
||||
HasDirection(rejectedDir);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Overrides ...
|
||||
|
||||
@@ -1523,16 +1741,20 @@ class XCTwoBarZone : public XCZone
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Activated Zone or not ...
|
||||
* Is Zone Activated ...
|
||||
*
|
||||
* @param forDir: ENUM_X_DIRECTION member, Specified Action Direction ...
|
||||
* @param activatedBar: XOHCL instance Reference ...
|
||||
* @param activatedDir: ENUM_X_DIRECTION member ...
|
||||
* @param forPeriod: ENUM_TIMEFRAMES member, Specified Rejection Period ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsActivated(
|
||||
ENUM_X_DIRECTION forDir,
|
||||
XOHCL &activatedBar,
|
||||
ENUM_X_DIRECTION &activatedDir //
|
||||
ENUM_X_DIRECTION &activatedDir,
|
||||
ENUM_TIMEFRAMES forPeriod = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -1543,35 +1765,50 @@ class XCTwoBarZone : public XCZone
|
||||
activatedDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
if (!IsSpecifiedValid(forPeriod))
|
||||
{
|
||||
forPeriod = GetPeriod();
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
HasDirection(forDir) &&
|
||||
IsSpecifiedValid(forPeriod);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Detect From Bar Index ...
|
||||
int fromIndex = iBarShift(
|
||||
GetSymbol(),
|
||||
GetPeriod(),
|
||||
From() //
|
||||
XOHCL startedBar;
|
||||
ENUM_X_DIRECTION startedDir;
|
||||
bool isStarted = IsStarted(
|
||||
forDir,
|
||||
startedBar,
|
||||
startedDir,
|
||||
forPeriod //
|
||||
);
|
||||
fromIndex--;
|
||||
result = isStarted;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = fromIndex; i >= 0; i--)
|
||||
{
|
||||
//
|
||||
if (i == fromIndex)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bool isBullish = IsBullish(forDir);
|
||||
bool isBearish = IsBearish(forDir);
|
||||
|
||||
//
|
||||
int startIndex = startedBar.Index() - 1;
|
||||
|
||||
//
|
||||
for (int i = startIndex; i >= 0; i--)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
bool isInited = iBar.Init(
|
||||
GetSymbol(),
|
||||
GetPeriod(),
|
||||
forPeriod,
|
||||
i //
|
||||
);
|
||||
result = isInited;
|
||||
@@ -1582,8 +1819,7 @@ class XCTwoBarZone : public XCZone
|
||||
|
||||
//
|
||||
XOHCL iPBar;
|
||||
isInited = iBar
|
||||
.GetPreviousBar(iPBar);
|
||||
isInited = iBar.GetPreviousBar(iPBar);
|
||||
result = isInited;
|
||||
if (!result)
|
||||
{
|
||||
@@ -1593,16 +1829,28 @@ class XCTwoBarZone : public XCZone
|
||||
//
|
||||
bool isActivedFromUpper =
|
||||
//
|
||||
(iPBar.low > Upper() &&
|
||||
iBar.low <= Upper())
|
||||
isBullish &&
|
||||
//
|
||||
(
|
||||
//
|
||||
(iPBar.low > Upper() &&
|
||||
iBar.low <= Upper())
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isActivedFromLower =
|
||||
//
|
||||
(iPBar.high < Lower() &&
|
||||
iBar.high >= Lower())
|
||||
isBearish &&
|
||||
//
|
||||
(
|
||||
//
|
||||
(iPBar.high < Lower() &&
|
||||
iBar.high >= Lower())
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
@@ -1623,21 +1871,29 @@ class XCTwoBarZone : public XCZone
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = activatedBar.IsValid() &&
|
||||
HasDirection(activatedDir);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Breaked Zone or not ...
|
||||
* Is Zone Breaked ...
|
||||
*
|
||||
* @param forDir: ENUM_X_DIRECTION member, Specified Action Direction ...
|
||||
* @param breakerBar: XOHCL instance Reference ...
|
||||
* @param breakerDir: ENUM_X_DIRECTION member ...
|
||||
* @param forPeriod: ENUM_TIMEFRAMES member, Specified Rejection Period ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsBreaked(
|
||||
ENUM_X_DIRECTION forDir,
|
||||
XOHCL &breakerBar,
|
||||
ENUM_X_DIRECTION &breakerDir //
|
||||
ENUM_X_DIRECTION &breakerDir,
|
||||
ENUM_TIMEFRAMES forPeriod = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -1648,7 +1904,15 @@ class XCTwoBarZone : public XCZone
|
||||
breakerDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
if (!IsSpecifiedValid(forPeriod))
|
||||
{
|
||||
forPeriod = GetPeriod();
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
HasDirection(forDir) &&
|
||||
IsSpecifiedValid(forPeriod);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
@@ -1658,8 +1922,10 @@ class XCTwoBarZone : public XCZone
|
||||
XOHCL activatedBar;
|
||||
ENUM_X_DIRECTION activatedDir;
|
||||
bool isActivated = IsActivated(
|
||||
forDir,
|
||||
activatedBar,
|
||||
activatedDir //
|
||||
activatedDir,
|
||||
forPeriod //
|
||||
);
|
||||
result = isActivated;
|
||||
if (!result)
|
||||
@@ -1678,7 +1944,7 @@ class XCTwoBarZone : public XCZone
|
||||
XOHCL iBar;
|
||||
bool isInited = iBar.Init(
|
||||
GetSymbol(),
|
||||
GetPeriod(),
|
||||
forPeriod,
|
||||
i //
|
||||
);
|
||||
result = isInited;
|
||||
@@ -1730,6 +1996,317 @@ class XCTwoBarZone : public XCZone
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = breakerBar.IsValid() &&
|
||||
HasDirection(breakerDir);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Zone Started ...
|
||||
*
|
||||
* @param forDir: ENUM_X_DIRECTION member, Specified Action Direction ...
|
||||
* @param breakerBar: XOHCL instance Reference ...
|
||||
* @param breakerDir: ENUM_X_DIRECTION member ...
|
||||
* @param forPeriod: ENUM_TIMEFRAMES member, Specified Rejection Period ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsStarted(
|
||||
ENUM_X_DIRECTION forDir,
|
||||
XOHCL &startedBar,
|
||||
ENUM_X_DIRECTION &startedDir,
|
||||
ENUM_TIMEFRAMES forPeriod = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
startedBar.Clean();
|
||||
startedDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
if (!IsSpecifiedValid(forPeriod))
|
||||
{
|
||||
forPeriod = GetPeriod();
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
HasDirection(forDir) &&
|
||||
IsSpecifiedValid(forPeriod);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBullish = IsBullish(forDir);
|
||||
bool isBearish = IsBearish(forDir);
|
||||
|
||||
//
|
||||
// Detect From Bar Index ...
|
||||
int fromIndex = iBarShift(
|
||||
GetSymbol(),
|
||||
forPeriod,
|
||||
From() //
|
||||
);
|
||||
|
||||
//
|
||||
for (int i = fromIndex; i >= 0; i--)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
bool isInited = iBar.Init(
|
||||
GetSymbol(),
|
||||
forPeriod,
|
||||
i //
|
||||
);
|
||||
result = isInited;
|
||||
if (!result)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBreakedFromUpper =
|
||||
//
|
||||
isBullish &&
|
||||
//
|
||||
(
|
||||
//
|
||||
iBar.low > Upper() ||
|
||||
(iBar.low <= Upper() &&
|
||||
iBar.high > Upper())
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isBreakedFromLower =
|
||||
//
|
||||
isBearish &&
|
||||
//
|
||||
(
|
||||
//
|
||||
iBar.low < Lower() ||
|
||||
(iBar.high >= Lower() &&
|
||||
iBar.low < Lower())
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isBreaked =
|
||||
isBreakedFromUpper ||
|
||||
isBreakedFromLower;
|
||||
if (isBreaked)
|
||||
{
|
||||
//
|
||||
result = isBreaked;
|
||||
startedBar = iBar;
|
||||
startedDir =
|
||||
isBreakedFromUpper
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = startedBar.IsValid() &&
|
||||
HasDirection(startedDir);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Zone Rejected/Sweeped ...
|
||||
*
|
||||
* @param forDir: ENUM_X_DIRECTION member, Specified Action Direction ...
|
||||
* @param rejectedBar: XOHCL instance Reference ...
|
||||
* @param rejectedDir: ENUM_X_DIRECTION member, Provides Rejection Direction ...
|
||||
* @param from: datetime start checking optional ...
|
||||
* @param forceSweep: bool, Specified Force Sweep Rejection ...
|
||||
* @param forPeriod: ENUM_TIMEFRAMES member, Specified Rejection Period ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsRejected(
|
||||
ENUM_X_DIRECTION forDir,
|
||||
XOHCL &rejectedBar,
|
||||
ENUM_X_DIRECTION &rejectedDir,
|
||||
datetime from = NULL,
|
||||
bool forceSweep = false,
|
||||
ENUM_TIMEFRAMES forPeriod = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
rejectedBar.Clean();
|
||||
rejectedDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
if (!IsSpecifiedValid(forPeriod))
|
||||
{
|
||||
forPeriod = GetPeriod();
|
||||
}
|
||||
|
||||
//
|
||||
if (!IsSpecifiedValid(from))
|
||||
{
|
||||
from = From();
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
HasDirection(forDir) &&
|
||||
IsSpecifiedValid(forPeriod);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBullish = IsBullish(forDir);
|
||||
bool isBearish = IsBearish(forDir);
|
||||
|
||||
//
|
||||
int fromIndex = iBarShift(
|
||||
GetSymbol(),
|
||||
forPeriod,
|
||||
from //
|
||||
);
|
||||
fromIndex--;
|
||||
|
||||
//
|
||||
for (int i = fromIndex; i >= 0; i--)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
bool isInited = iBar.Init(
|
||||
GetSymbol(),
|
||||
forPeriod,
|
||||
i //
|
||||
);
|
||||
result = isInited;
|
||||
if (!result)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool isRejectedFromUpper =
|
||||
//
|
||||
isBullish &&
|
||||
//
|
||||
(
|
||||
//
|
||||
(iBar.low <= Upper() &&
|
||||
iBar.high > Upper() &&
|
||||
iBar.GetUp() > Upper())
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isRejectedFromLower =
|
||||
//
|
||||
isBearish &&
|
||||
//
|
||||
(
|
||||
//
|
||||
(iBar.high >= Lower() &&
|
||||
iBar.low < Lower() &&
|
||||
iBar.GetDown() < Lower())
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isSweepedFromUpper =
|
||||
//
|
||||
isBullish &&
|
||||
//
|
||||
(
|
||||
//
|
||||
(iBar.low <= Lower() &&
|
||||
iBar.high > Upper() &&
|
||||
iBar.GetUp() > Upper())
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isSweepedFromLower =
|
||||
//
|
||||
isBearish &&
|
||||
//
|
||||
(
|
||||
//
|
||||
(iBar.high >= Upper() &&
|
||||
iBar.low < Lower() &&
|
||||
iBar.GetDown() < Lower())
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isRejected = isRejectedFromUpper ||
|
||||
isRejectedFromLower;
|
||||
|
||||
//
|
||||
bool isSweeped = isSweepedFromUpper ||
|
||||
isSweepedFromLower;
|
||||
|
||||
//
|
||||
bool fromUpper = isRejectedFromUpper ||
|
||||
isSweepedFromUpper;
|
||||
|
||||
//
|
||||
bool fromLower = isRejectedFromLower ||
|
||||
isSweepedFromLower;
|
||||
|
||||
//
|
||||
// Prepare Result ...
|
||||
bool isPassed =
|
||||
isSweeped ||
|
||||
isRejected;
|
||||
if (forceSweep)
|
||||
{
|
||||
isPassed = isSweeped;
|
||||
}
|
||||
|
||||
//
|
||||
if (isPassed)
|
||||
{
|
||||
//
|
||||
result = isPassed;
|
||||
rejectedBar = iBar;
|
||||
rejectedDir =
|
||||
fromUpper
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = rejectedBar.IsValid() &&
|
||||
HasDirection(rejectedDir);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ struct XOBTest
|
||||
XCFVG *fvgs[];
|
||||
|
||||
//
|
||||
datetime fvgBreakedAt;
|
||||
datetime fvgActedAt;
|
||||
datetime rewardedAt;
|
||||
|
||||
//
|
||||
@@ -65,7 +65,7 @@ struct XOBTest
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
rewardedAt = NULL;
|
||||
fvgBreakedAt = NULL;
|
||||
fvgActedAt = NULL;
|
||||
|
||||
//
|
||||
reward = 0;
|
||||
@@ -1655,7 +1655,8 @@ bool ReTestMarket(
|
||||
}
|
||||
|
||||
//
|
||||
// Now we Have to Validate Breaked Order Blocks Count in additions to Youngest OB directions ...
|
||||
// Now we Have to Validate Breaked Order Blocks Count in additions to
|
||||
// Youngest OB directions ...
|
||||
|
||||
//
|
||||
bool hasBullishOrderFlow =
|
||||
@@ -1728,6 +1729,7 @@ bool ReTestMarket(
|
||||
|
||||
//
|
||||
XCFVG *iOBFVGs[];
|
||||
datetime fvgActedAt = NULL;
|
||||
for (int j = 0; j < fvgsCount; j++)
|
||||
{
|
||||
//
|
||||
@@ -1751,8 +1753,89 @@ bool ReTestMarket(
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate FVG Based on Conditions ...
|
||||
// for Bullish Order Blocks FVGs must Rejected as Liquidity ...
|
||||
// in ttf ...
|
||||
|
||||
//
|
||||
XOHCL rejectedBar;
|
||||
ENUM_X_DIRECTION rejectedDir;
|
||||
bool isRejected = jFVG.IsRejected(
|
||||
X_DIRECTION_BULLISH,
|
||||
rejectedBar,
|
||||
rejectedDir,
|
||||
NULL, // From ...
|
||||
true, // Force Sweeped ...
|
||||
ttfState.period // For Period ...
|
||||
);
|
||||
|
||||
//
|
||||
XOHCL breakedBar;
|
||||
ENUM_X_DIRECTION breakedDir;
|
||||
bool isBreaked = jFVG.IsBreaked(
|
||||
X_DIRECTION_BULLISH,
|
||||
breakedBar,
|
||||
breakedDir //
|
||||
);
|
||||
|
||||
//
|
||||
bool isFVGActed =
|
||||
isRejected ||
|
||||
isBreaked;
|
||||
if (!isFVGActed)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
datetime iFvgActedAt =
|
||||
isBreaked &&
|
||||
!isRejected
|
||||
? breakedBar.time
|
||||
: !isBreaked &&
|
||||
isRejected
|
||||
? rejectedBar.time
|
||||
: isBreaked &&
|
||||
isRejected
|
||||
? (breakedBar.time < rejectedBar.time)
|
||||
? breakedBar.time
|
||||
: rejectedBar.time
|
||||
: NULL;
|
||||
if (!IsValid(iFvgActedAt))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
if (!IsValid(fvgActedAt)) {
|
||||
fvgActedAt = iFvgActedAt;
|
||||
}
|
||||
|
||||
//
|
||||
XCFVG *lastFVG = NULL;
|
||||
int fvgsCount = ArraySize(iOBFVGs);
|
||||
bool hasLastFVG = IsValidSize(fvgsCount);
|
||||
if (hasLastFVG)
|
||||
{
|
||||
lastFVG = iOBFVGs[fvgsCount - 1];
|
||||
}
|
||||
bool isLastPassed =
|
||||
!hasLastFVG
|
||||
? true
|
||||
: IsAbove(
|
||||
jFVG,
|
||||
lastFVG,
|
||||
true // Ignore Inside ...
|
||||
);
|
||||
if (!isLastPassed)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
jFVG.To(iOB.To());
|
||||
jFVG.To(iFvgActedAt);
|
||||
|
||||
//
|
||||
Add(
|
||||
@@ -1775,6 +1858,9 @@ bool ReTestMarket(
|
||||
iTest.symbol = iOB.GetSymbol();
|
||||
iTest.period = iOB.GetPeriod();
|
||||
|
||||
//
|
||||
iTest.fvgActedAt = fvgActedAt;
|
||||
|
||||
//
|
||||
Copy(
|
||||
iOBFVGs,
|
||||
@@ -1823,6 +1909,7 @@ bool ReTestMarket(
|
||||
|
||||
//
|
||||
XCFVG *iOBFVGs[];
|
||||
datetime fvgActedAt = NULL;
|
||||
for (int j = 0; j < fvgsCount; j++)
|
||||
{
|
||||
//
|
||||
@@ -1846,8 +1933,89 @@ bool ReTestMarket(
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate FVG Based on Conditions ...
|
||||
// for Bearish Order Blocks FVGs must Rejected as Liquidity ...
|
||||
// in ttf ...
|
||||
|
||||
//
|
||||
XOHCL rejectedBar;
|
||||
ENUM_X_DIRECTION rejectedDir;
|
||||
bool isRejected = jFVG.IsRejected(
|
||||
X_DIRECTION_BEARISH,
|
||||
rejectedBar,
|
||||
rejectedDir,
|
||||
NULL, // From ...
|
||||
true, // Force Sweeped ...
|
||||
ttfState.period // For Period ...
|
||||
);
|
||||
|
||||
//
|
||||
XOHCL breakedBar;
|
||||
ENUM_X_DIRECTION breakedDir;
|
||||
bool isBreaked = jFVG.IsBreaked(
|
||||
X_DIRECTION_BEARISH,
|
||||
breakedBar,
|
||||
breakedDir //
|
||||
);
|
||||
|
||||
//
|
||||
bool isFVGActed =
|
||||
isRejected ||
|
||||
isBreaked;
|
||||
if (!isFVGActed)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
datetime iFvgActedAt =
|
||||
isBreaked &&
|
||||
!isRejected
|
||||
? breakedBar.time
|
||||
: !isBreaked &&
|
||||
isRejected
|
||||
? rejectedBar.time
|
||||
: isBreaked &&
|
||||
isRejected
|
||||
? (breakedBar.time < rejectedBar.time)
|
||||
? breakedBar.time
|
||||
: rejectedBar.time
|
||||
: NULL;
|
||||
if (!IsValid(iFvgActedAt))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
if (!IsValid(fvgActedAt)) {
|
||||
fvgActedAt = iFvgActedAt;
|
||||
}
|
||||
|
||||
//
|
||||
XCFVG *lastFVG = NULL;
|
||||
int fvgsCount = ArraySize(iOBFVGs);
|
||||
bool hasLastFVG = IsValidSize(fvgsCount);
|
||||
if (hasLastFVG)
|
||||
{
|
||||
lastFVG = iOBFVGs[fvgsCount - 1];
|
||||
}
|
||||
bool isLastPassed =
|
||||
!hasLastFVG
|
||||
? true
|
||||
: IsBelow(
|
||||
jFVG,
|
||||
lastFVG,
|
||||
true // Ignore Inside ...
|
||||
);
|
||||
if (!isLastPassed)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
jFVG.To(iOB.To());
|
||||
jFVG.To(iFvgActedAt);
|
||||
|
||||
//
|
||||
Add(
|
||||
@@ -1870,6 +2038,9 @@ bool ReTestMarket(
|
||||
iTest.symbol = iOB.GetSymbol();
|
||||
iTest.period = iOB.GetPeriod();
|
||||
|
||||
//
|
||||
iTest.fvgActedAt = fvgActedAt;
|
||||
|
||||
//
|
||||
Copy(
|
||||
iOBFVGs,
|
||||
@@ -2054,7 +2225,7 @@ bool ReTestMarket(
|
||||
{
|
||||
//
|
||||
XCFVG *jFVG = iTest.fvgs[j];
|
||||
jFVG.To(iTest.ob.To());
|
||||
// jFVG.To(iTest.ob.To());
|
||||
|
||||
//
|
||||
XCBaseObject *fvgObj;
|
||||
|
||||
Reference in New Issue
Block a user