last works on x Signalling ...
This commit is contained in:
@@ -6195,12 +6195,6 @@ struct XStateZones
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(supportZones);
|
||||
|
||||
@@ -6214,12 +6208,6 @@ struct XStateZones
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(resistanceZones);
|
||||
|
||||
@@ -6233,12 +6221,6 @@ struct XStateZones
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(supplyZones);
|
||||
|
||||
@@ -6252,12 +6234,6 @@ struct XStateZones
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(demandZones);
|
||||
|
||||
@@ -6271,12 +6247,6 @@ struct XStateZones
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(bullishOrderBlocks);
|
||||
|
||||
@@ -6290,12 +6260,6 @@ struct XStateZones
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(bearishOrderBlocks);
|
||||
|
||||
@@ -6309,12 +6273,6 @@ struct XStateZones
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(bullishFairValueGaps);
|
||||
|
||||
@@ -6328,12 +6286,6 @@ struct XStateZones
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(bearishFairValueGaps);
|
||||
|
||||
@@ -9400,6 +9352,17 @@ bool CalculatePriceInsideZones(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate Zone by Providing Specified Data ...
|
||||
*
|
||||
* @param zones: XStateZone instance Reference ...
|
||||
* @param source: XPOIState instance Reference ...
|
||||
* @param upper: Double ...
|
||||
* @param lower: Double ...
|
||||
* @param from: DateTime ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool CalculateStateZones(
|
||||
XStateZones &zones,
|
||||
XPOIState &source,
|
||||
@@ -10647,6 +10610,136 @@ double CalculateTarget(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Valid Order Blocks ...
|
||||
*
|
||||
* @param forDir: ENUM_X_DIRECTION member ...
|
||||
* @param source: XPOIState instance Reference ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int DetectDirectionOrderBlocks(
|
||||
ENUM_X_DIRECTION forDir,
|
||||
XPOIState &source,
|
||||
XCOrderBlock *&orderBlocks[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
Clean(orderBlocks);
|
||||
|
||||
//
|
||||
bool isValid =
|
||||
//
|
||||
source.IsValid() &&
|
||||
source.HasChild() &&
|
||||
HasDirection(forDir)
|
||||
//
|
||||
;
|
||||
if (!isValid)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
datetime cTime = TimeCurrent();
|
||||
|
||||
//
|
||||
XOHCL cBar;
|
||||
bool isInited = cBar.Init(
|
||||
source.symbol,
|
||||
source.period,
|
||||
1 //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int count = 0;
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
count = source.CountBullishOrderBlocks();
|
||||
isValid = IsValidSize(count) &&
|
||||
IsBullish(forDir);
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCOrderBlock *iOB = source.bullishOrderBlocks[i];
|
||||
|
||||
//
|
||||
// Update Order Block Time ...
|
||||
iOB.To(cTime);
|
||||
|
||||
//
|
||||
// Check Order Block Validation ...
|
||||
isValid = IsValid(
|
||||
iOB,
|
||||
forDir,
|
||||
cBar.symbol,
|
||||
cBar.period //
|
||||
);
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
iOB,
|
||||
orderBlocks //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
count = source.CountBearishOrderBlocks();
|
||||
isValid = IsValidSize(count) &&
|
||||
IsBearish(forDir);
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCOrderBlock *iOB = source.bearishOrderBlocks[i];
|
||||
|
||||
//
|
||||
// Update Order Block Time ...
|
||||
iOB.To(cTime);
|
||||
|
||||
//
|
||||
// Check Order Block Validation ...
|
||||
isValid = IsValid(
|
||||
iOB,
|
||||
forDir,
|
||||
cBar.symbol,
|
||||
cBar.period //
|
||||
);
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
iOB,
|
||||
orderBlocks //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(orderBlocks);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Market for Detect Order Block FVG ...
|
||||
*
|
||||
@@ -11011,6 +11104,415 @@ bool DetectFVGOB(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect a Zone Breaker Bar ...
|
||||
*
|
||||
* @param toBar: XOHCL instance Reference ...
|
||||
* @param fromBar: XOHCL instance Reference ...
|
||||
* @param breakerBar: XOHCL instance Reference ...
|
||||
* @param forDir: ENUM_X_DIRECTION member ...
|
||||
* @param symbol: String ...
|
||||
* @param period: ENUM_TIMEFRAMES member ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasBreakerBar(
|
||||
XOHCL &toBar,
|
||||
XOHCL &fromBar,
|
||||
XOHCL &breakerBar,
|
||||
ENUM_X_DIRECTION forDir,
|
||||
string symbol,
|
||||
ENUM_TIMEFRAMES period,
|
||||
XCZone *zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
toBar.Clean();
|
||||
fromBar.Clean();
|
||||
breakerBar.Clean();
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
zone != NULL &&
|
||||
IsValid(zone.To()) &&
|
||||
IsValid(zone.From()) &&
|
||||
HasDirection(forDir);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = fromBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
zone.From() //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = toBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
zone.To() //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int toIndex = toBar.Index();
|
||||
int fromIndex = fromBar.Index();
|
||||
|
||||
//
|
||||
double upper = zone.Upper();
|
||||
double lower = zone.Lower();
|
||||
|
||||
//
|
||||
// Detect Zone BreakerBar ...
|
||||
for (int i = fromIndex; i >= toIndex; i--)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
result = iBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
i //
|
||||
);
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
IsBullish(forDir)
|
||||
?
|
||||
//
|
||||
iBar.low < upper &&
|
||||
iBar.high > upper &&
|
||||
iBar.GetUp() > upper
|
||||
//
|
||||
:
|
||||
//
|
||||
iBar.high > lower &&
|
||||
iBar.low < lower &&
|
||||
iBar.GetDown() < lower
|
||||
//
|
||||
;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
breakerBar = iBar;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = breakerBar.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a Zone is Valid for Specified Direction ...
|
||||
*
|
||||
* @param toBar: XOHCL instance Reference ...
|
||||
* @param fromBar: XOHCL instance Reference ...
|
||||
* @param breakerBar: XOHCL instance Reference ...
|
||||
* @param forDir: ENUM_X_DIRECTION member ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid(
|
||||
XOHCL &toBar,
|
||||
XOHCL &fromBar,
|
||||
XOHCL &breakerBar,
|
||||
ENUM_X_DIRECTION forDir,
|
||||
XCZone *zone //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
zone != NULL &&
|
||||
toBar.IsValid() &&
|
||||
fromBar.IsValid() &&
|
||||
breakerBar.IsValid() &&
|
||||
HasDirection(forDir)
|
||||
//
|
||||
;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int toIndex = toBar.Index();
|
||||
int fromIndex = fromBar.Index();
|
||||
int breakerIndex = breakerBar.Index();
|
||||
|
||||
//
|
||||
double upper = zone.Upper();
|
||||
double lower = zone.Lower();
|
||||
|
||||
//
|
||||
bool isBreaked = false;
|
||||
for (int i = breakerIndex - 1; i >= toIndex; i--)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
result = iBar.Init(
|
||||
fromBar.symbol,
|
||||
fromBar.period,
|
||||
i //
|
||||
);
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
isBreaked =
|
||||
//
|
||||
IsBullish(forDir)
|
||||
//
|
||||
?
|
||||
//
|
||||
iBar.low < upper
|
||||
//
|
||||
:
|
||||
//
|
||||
iBar.high > lower
|
||||
//
|
||||
;
|
||||
if (isBreaked)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = !isBreaked;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Specified Order Block ...
|
||||
*
|
||||
* @param forDir: ENUM_X_DIRECTION member ...
|
||||
* @param symbol: String ...
|
||||
* @param period: ENUM_TIMEFRAMES member ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid(
|
||||
XCOrderBlock *orderBlock,
|
||||
ENUM_X_DIRECTION forDir,
|
||||
string symbol,
|
||||
ENUM_TIMEFRAMES period //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
IsValid(symbol) &&
|
||||
IsValid(period) &&
|
||||
orderBlock != NULL &&
|
||||
HasDirection(forDir) &&
|
||||
orderBlock.IsValid()
|
||||
//
|
||||
;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL toBar;
|
||||
XOHCL fromBar;
|
||||
XOHCL breakerBar;
|
||||
result = HasBreakerBar(
|
||||
toBar,
|
||||
fromBar,
|
||||
breakerBar,
|
||||
forDir,
|
||||
symbol,
|
||||
period,
|
||||
(XCZone *)orderBlock //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Zone Touch ...
|
||||
result = IsValid(
|
||||
toBar,
|
||||
fromBar,
|
||||
breakerBar,
|
||||
forDir,
|
||||
(XCZone *)orderBlock //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Oldest Zone ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int GetOldest(
|
||||
XCZone *&source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XCZone *oldest = NULL;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCZone *iZone = source[i];
|
||||
|
||||
//
|
||||
bool canSet =
|
||||
oldest == NULL ||
|
||||
(oldest != NULL &&
|
||||
oldest.From() > iZone.From());
|
||||
if (canSet)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
oldest = iZone;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Youngest Zone ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int GetYoungest(
|
||||
XCZone *&source[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XCZone *youngest = NULL;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XCZone *iZone = source[i];
|
||||
|
||||
//
|
||||
bool canSet =
|
||||
youngest == NULL ||
|
||||
(youngest != NULL &&
|
||||
youngest.From() < iZone.From());
|
||||
if (canSet)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
youngest = iZone;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool ToZone(
|
||||
T *&source[],
|
||||
XCZone *&dest[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
Clean(dest);
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
result = IsValidSize(count);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
T *item = source[i];
|
||||
|
||||
//
|
||||
if (item != NULL)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
(XCZone *)item,
|
||||
dest //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
int destCount = ArraySize(dest);
|
||||
result = IsValidSize(destCount);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
typedef void (*TOnPOIEvent)(ENUM_XPOI_EVENTS event,
|
||||
XCBasePOI *param //
|
||||
|
||||
Reference in New Issue
Block a user