last ...
This commit is contained in:
@@ -1762,6 +1762,178 @@ class XCBarAnalyser : public XCBase
|
||||
//
|
||||
// Custom Logics ...
|
||||
|
||||
/**
|
||||
* Check a Bar is End of an OrderBlock Bar or Not ...
|
||||
*
|
||||
* @param bar: XOHCL ...
|
||||
* @param box: XBoxZone ...
|
||||
* @param forceFVGBarType: bool, Force all Bars must be Same as Direction ...
|
||||
* @param forceOBTwoBar: bool, Force Two Bars of OB Start must be InDirection ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsOB(
|
||||
XOHCL &bar,
|
||||
XBoxZone &box,
|
||||
bool forceFVGBarType = false,
|
||||
bool forceOBTwoBar = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
box.Clean();
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Bar Must be FVG ...
|
||||
result = IsFVG(
|
||||
bar,
|
||||
box,
|
||||
forceFVGBarType //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
box.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
box.type = "XOB";
|
||||
|
||||
//
|
||||
bool isBullish = box.IsBullish();
|
||||
bool isBearish = box.IsBearish();
|
||||
|
||||
//
|
||||
// Order Block Includes an FVG which Starts by atleast One
|
||||
// or More Indirectional Bars ...
|
||||
XOHCL fvgLastBar;
|
||||
XOHCL fvgLastBarPrev;
|
||||
XOHCL fvgLastBarPrev2;
|
||||
|
||||
//
|
||||
int barIndex = bar.Index();
|
||||
int fvgLastBarIndex = barIndex + 3;
|
||||
result = fvgLastBar.Init(
|
||||
bar.symbol,
|
||||
bar.period,
|
||||
fvgLastBarIndex //
|
||||
);
|
||||
result =
|
||||
result &&
|
||||
fvgLastBar.GetPreviousBar(fvgLastBarPrev);
|
||||
result =
|
||||
result &&
|
||||
fvgLastBarPrev.GetPreviousBar(fvgLastBarPrev2);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
box.Clean();
|
||||
fvgLastBar.Clean();
|
||||
fvgLastBarPrev.Clean();
|
||||
fvgLastBarPrev2.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check FVG Last Bar ...
|
||||
|
||||
//
|
||||
bool isBullishBlock =
|
||||
isBullish &&
|
||||
(fvgLastBar.IsBearish() ||
|
||||
(fvgLastBar.IsBullish() &&
|
||||
fvgLastBarPrev.IsBearish()));
|
||||
|
||||
//
|
||||
bool isBearishBlock =
|
||||
isBearish &&
|
||||
(fvgLastBar.IsBullish() ||
|
||||
(fvgLastBar.IsBearish() &&
|
||||
fvgLastBarPrev.IsBullish()));
|
||||
|
||||
//
|
||||
// Update Box ...
|
||||
|
||||
//
|
||||
if (isBullishBlock ||
|
||||
isBearishBlock)
|
||||
{
|
||||
//
|
||||
box.from = fvgLastBar.time;
|
||||
|
||||
//
|
||||
box.lower = MathMin(box.lower, fvgLastBar.low);
|
||||
box.upper = MathMax(box.upper, fvgLastBar.high);
|
||||
}
|
||||
|
||||
//
|
||||
// Apply Force Two Bar ...
|
||||
if (forceOBTwoBar)
|
||||
{
|
||||
//
|
||||
isBullishBlock =
|
||||
isBullishBlock &&
|
||||
fvgLastBarPrev.IsBearish();
|
||||
|
||||
//
|
||||
isBearishBlock =
|
||||
isBearishBlock &&
|
||||
fvgLastBarPrev.IsBullish();
|
||||
|
||||
//
|
||||
// Update Box ...
|
||||
if (isBullishBlock ||
|
||||
isBearishBlock)
|
||||
{
|
||||
//
|
||||
box.from = fvgLastBarPrev.time;
|
||||
box.lower = MathMin(box.lower, fvgLastBarPrev.low);
|
||||
box.upper = MathMax(box.upper, fvgLastBarPrev.high);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = isBullishBlock ||
|
||||
isBearishBlock;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
box.Clean();
|
||||
fvgLastBar.Clean();
|
||||
fvgLastBarPrev.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = box.IsValid();
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
|
||||
//
|
||||
fvgLastBar.Clean();
|
||||
fvgLastBarPrev.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a Bar is End of an FVG Bar or Not ...
|
||||
*
|
||||
@@ -1868,169 +2040,6 @@ class XCBarAnalyser : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a Bar is End of an OrderBlock Bar or Not ...
|
||||
*
|
||||
* @param bar: XOHCL ...
|
||||
* @param box: XBoxZone ...
|
||||
* @param forceFVGBarType: bool, Force all Bars must be Same as Direction ...
|
||||
* @param forceOBTwoBar: bool, Force Two Bars of OB Start must be InDirection ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsOrderBlock(
|
||||
XOHCL &bar,
|
||||
XBoxZone &box,
|
||||
bool forceFVGBarType = false,
|
||||
bool forceOBTwoBar = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
box.Clean();
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Bar Must be FVG ...
|
||||
result = IsFVG(
|
||||
bar,
|
||||
box,
|
||||
forceFVGBarType //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
box.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
box.type = "XOB";
|
||||
|
||||
//
|
||||
bool isBullish = box.IsBullish();
|
||||
bool isBearish = box.IsBearish();
|
||||
|
||||
//
|
||||
// Order Block Includes an FVG which Starts by atleast One
|
||||
// or More Indirectional Bars ...
|
||||
XOHCL fvgLastBar;
|
||||
XOHCL fvgLastBarPrev;
|
||||
|
||||
//
|
||||
int barIndex = bar.Index();
|
||||
int fvgLastBarIndex = barIndex + 3;
|
||||
result = fvgLastBar.Init(
|
||||
bar.symbol,
|
||||
bar.period,
|
||||
fvgLastBarIndex //
|
||||
);
|
||||
result =
|
||||
result &&
|
||||
fvgLastBar.GetPreviousBar(fvgLastBarPrev);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
box.Clean();
|
||||
fvgLastBar.Clean();
|
||||
fvgLastBarPrev.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check FVG Last Bar ...
|
||||
|
||||
//
|
||||
bool isBullishBlock =
|
||||
isBullish &&
|
||||
fvgLastBar.IsBearish();
|
||||
|
||||
//
|
||||
bool isBearishBlock =
|
||||
isBearish &&
|
||||
fvgLastBar.IsBullish();
|
||||
|
||||
//
|
||||
// Update Box ...
|
||||
|
||||
//
|
||||
if (isBullishBlock ||
|
||||
isBearishBlock)
|
||||
{
|
||||
//
|
||||
box.from = fvgLastBar.time;
|
||||
|
||||
//
|
||||
box.lower = MathMin(box.lower, fvgLastBar.low);
|
||||
box.upper = MathMax(box.upper, fvgLastBar.high);
|
||||
}
|
||||
|
||||
//
|
||||
// Apply Force Two Bar ...
|
||||
if (forceOBTwoBar)
|
||||
{
|
||||
//
|
||||
isBullishBlock =
|
||||
isBullishBlock &&
|
||||
fvgLastBarPrev.IsBearish();
|
||||
|
||||
//
|
||||
isBearishBlock =
|
||||
isBearishBlock &&
|
||||
fvgLastBarPrev.IsBullish();
|
||||
|
||||
//
|
||||
// Update Box ...
|
||||
if (isBullishBlock ||
|
||||
isBearishBlock)
|
||||
{
|
||||
//
|
||||
box.from = fvgLastBarPrev.time;
|
||||
box.lower = MathMin(box.lower, fvgLastBarPrev.low);
|
||||
box.upper = MathMax(box.upper, fvgLastBarPrev.high);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = isBullishBlock ||
|
||||
isBearishBlock;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
box.Clean();
|
||||
fvgLastBar.Clean();
|
||||
fvgLastBarPrev.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = box.IsValid();
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
|
||||
//
|
||||
fvgLastBar.Clean();
|
||||
fvgLastBarPrev.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Candlestick ...
|
||||
|
||||
@@ -2091,7 +2100,7 @@ class XCBarAnalyser : public XCBase
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Bar is Pullback or not ...
|
||||
* Check Specified Bar is Swing or not ...
|
||||
*
|
||||
* @param bar: XOHCL instance reference, Specified Bar to Check ...
|
||||
* @param dir: ENUM_X_DIRECTION member, Specified Doji Direction ...
|
||||
|
||||
@@ -94,3 +94,125 @@
|
||||
swing.Clean();
|
||||
breaker.Clean();
|
||||
outSide.Clean();
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/**
|
||||
* Check Specified Bar is Swing or not ...
|
||||
*
|
||||
* @param bar: XOHCL instance reference, Specified Swing Bar ...
|
||||
* @param forDir: ENUM_X_DIRECTION member, Specified Direction of Swing ...
|
||||
* @param barIndex: int, Specified Bar Index to Check ...
|
||||
* @param loopback: int, Specified Loopback for BothSide Checking ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsSwingSide(
|
||||
XOHCL &bar,
|
||||
ENUM_X_DIRECTION forDir,
|
||||
int loopback = 7 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid() &&
|
||||
HasDirection(forDir);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isSwingLow = IsBullish(forDir);
|
||||
bool isSwingHigh = IsBearish(forDir);
|
||||
|
||||
//
|
||||
string symbol = bar.symbol;
|
||||
ENUM_TIMEFRAMES period = bar.period;
|
||||
|
||||
//
|
||||
int totalBars = iBars(
|
||||
symbol,
|
||||
period //
|
||||
);
|
||||
int barIndex = bar.Index();
|
||||
loopback = NormalizeInt(loopback, 3);
|
||||
result =
|
||||
barIndex - loopback > 0 &&
|
||||
barIndex + 1 + loopback <= totalBars;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < loopback; i++)
|
||||
{
|
||||
//
|
||||
XOHCL iPBar;
|
||||
XOHCL iNBar;
|
||||
result = iPBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
barIndex + i //
|
||||
);
|
||||
result =
|
||||
result &&
|
||||
iNBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
barIndex - i //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
iPBar.Clean();
|
||||
iNBar.Clean();
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
isSwingLow =
|
||||
isSwingLow &&
|
||||
bar.low < iPBar.low &&
|
||||
bar.low < iNBar.low;
|
||||
|
||||
//
|
||||
isSwingHigh =
|
||||
isSwingHigh &&
|
||||
bar.high > iPBar.high &&
|
||||
bar.high > iNBar.high;
|
||||
|
||||
//
|
||||
result = isSwingLow ||
|
||||
isSwingHigh;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
iPBar.Clean();
|
||||
iNBar.Clean();
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
iPBar.Clean();
|
||||
iNBar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
if (!result)
|
||||
{
|
||||
bar.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -315,6 +315,7 @@ void OnTick()
|
||||
if (!has)
|
||||
{
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4211,7 +4211,7 @@ class XCXCAEAHelper : XCBase
|
||||
|
||||
//
|
||||
// Check to Find OB ...
|
||||
has = barAnalyser.IsOrderBlock(
|
||||
has = barAnalyser.IsOB(
|
||||
iBar,
|
||||
ob,
|
||||
false,
|
||||
@@ -4289,6 +4289,9 @@ class XCXCAEAHelper : XCBase
|
||||
iBar,
|
||||
swingDir //
|
||||
);
|
||||
has =
|
||||
has &&
|
||||
iBar.GetPreviousBar(swingBar);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
@@ -4302,7 +4305,6 @@ class XCXCAEAHelper : XCBase
|
||||
|
||||
//
|
||||
// Validate Founded Swing ...
|
||||
swingBar = iBar;
|
||||
|
||||
//
|
||||
bool isValidSwingLow =
|
||||
@@ -4427,7 +4429,7 @@ class XCXCAEAHelper : XCBase
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Swing Break must be happens
|
||||
// Validate Swing Break must be happens
|
||||
// after Block Formation ...
|
||||
has = iBar.time > ob.to;
|
||||
if (has)
|
||||
|
||||
@@ -433,6 +433,104 @@ int AddGuard(
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
enum ENUM_XCAEA_LQ_TYPES
|
||||
{
|
||||
XCAEA_LQ_TYPE_NONE = 0,
|
||||
XCAEA_LQ_TYPE_PEAK = 1,
|
||||
XCAEA_LQ_TYPE_VALE = 2,
|
||||
};
|
||||
|
||||
struct XCAEALQSweep
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
int length;
|
||||
datetime to;
|
||||
string symbol;
|
||||
datetime from;
|
||||
double sweeped;
|
||||
double reverse;
|
||||
ENUM_TIMEFRAMES period;
|
||||
ENUM_XCAEA_LQ_TYPES type;
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XCAEALQSweep()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
to = NULL;
|
||||
length = 0;
|
||||
from = NULL;
|
||||
sweeped = 0;
|
||||
reverse = 0;
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
type = XCAEA_LQ_TYPE_NONE;
|
||||
}
|
||||
|
||||
//
|
||||
// Validation ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
length > 0 &&
|
||||
IsValid(to) &&
|
||||
sweeped > 0 &&
|
||||
reverse > 0 &&
|
||||
IsValid(from) &&
|
||||
IsValid(symbol) &&
|
||||
IsValid(period) &&
|
||||
type != XCAEA_LQ_TYPE_NONE
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string GetTag()
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = symbol +
|
||||
ToString(period) +
|
||||
"XLQ" +
|
||||
(type == XCAEA_LQ_TYPE_PEAK ? "Peak" : "Vale") +
|
||||
ToString(sweeped);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Detect Decision Zone ...
|
||||
bool DetectDecisionZone(
|
||||
@@ -583,7 +681,7 @@ bool DetectDecisionZone(
|
||||
XBoxZone ob;
|
||||
bool isOB = helper
|
||||
.barAnalyser
|
||||
.IsOrderBlock(
|
||||
.IsOB(
|
||||
cBar,
|
||||
ob,
|
||||
false, // Force FVG Bar Type
|
||||
@@ -962,7 +1060,7 @@ bool DetectDecisionZone(
|
||||
|
||||
//
|
||||
// Custom Senarios ...
|
||||
|
||||
|
||||
//
|
||||
bool isCond1Bullish =
|
||||
//
|
||||
@@ -1071,9 +1169,6 @@ bool DetectDecisionZone(
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Style Object ...
|
||||
Print("Salam");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1636,6 +1731,7 @@ bool CanTriggerCond3(
|
||||
ENUM_X_DIRECTION &dir,
|
||||
double &sl,
|
||||
double &tp,
|
||||
CArrayObj *drawns,
|
||||
int barIndex = 0,
|
||||
int loopback = 10 //
|
||||
)
|
||||
@@ -1661,54 +1757,532 @@ bool CanTriggerCond3(
|
||||
}
|
||||
|
||||
//
|
||||
// Detect At Least one Outside Bar ...
|
||||
// TODO: Complete this ...
|
||||
bool isBullish = box.IsBullish();
|
||||
bool isBearish = box.IsBearish();
|
||||
|
||||
//
|
||||
// Add Support for a Breaked Swing as Liquidity ...
|
||||
// for Improve Validations ...
|
||||
// TODO: Complete this ...
|
||||
|
||||
//
|
||||
// Detect Block Based Trigger ...
|
||||
XBoxZone ob;
|
||||
XOHCL swing;
|
||||
XOHCL breaker;
|
||||
XOHCL outSide;
|
||||
ENUM_X_DIRECTION passedDir;
|
||||
bool isPassed = helper.IsBlockBasedTriggerBar(
|
||||
ob,
|
||||
swing,
|
||||
breaker,
|
||||
outSide,
|
||||
passedDir,
|
||||
barIndex + 1, // Bar Index ...
|
||||
30, // Loopback ...
|
||||
3 // Swing Length ...
|
||||
bool has = false;
|
||||
int swingLoopback = 7;
|
||||
ENUM_TIMEFRAMES period = helper.GetPeriod();
|
||||
string symbol = helper.GetSymbol();
|
||||
int toIDX = box.ToIndex(period);
|
||||
int fromIDX = box.FromIndex(period);
|
||||
datetime cTime = GetBarTime(
|
||||
symbol,
|
||||
period,
|
||||
barIndex //
|
||||
);
|
||||
bool isBullishPassed =
|
||||
isPassed &&
|
||||
ob.IsBullish() &&
|
||||
box.IsBullish() &&
|
||||
ob.upper < box.upper &&
|
||||
ob.lower > box.lower;
|
||||
bool isBearishPassed =
|
||||
isPassed &&
|
||||
ob.IsBearish() &&
|
||||
box.IsBearish() &&
|
||||
ob.upper < box.upper &&
|
||||
ob.lower > box.lower;
|
||||
|
||||
//
|
||||
// Detect Box FVG ...
|
||||
|
||||
//
|
||||
// we Have to Detect a Broken Liquidity for Box ...
|
||||
|
||||
//
|
||||
XBoxZone fvg;
|
||||
XBoxZone fvgs[];
|
||||
for (int i = fromIDX + loopback; i > barIndex; i--)
|
||||
{
|
||||
//
|
||||
// Initialize iBar ...
|
||||
XOHCL iBar;
|
||||
has = iBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
i //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
iBar.Clean();
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Check iBar Has FVG ...
|
||||
XBoxZone iFVG;
|
||||
has = helper
|
||||
.barAnalyser
|
||||
.IsFVG(
|
||||
iBar,
|
||||
iFVG,
|
||||
true //
|
||||
);
|
||||
has =
|
||||
//
|
||||
// Check FVG Exists ...
|
||||
has &&
|
||||
//
|
||||
// Check FVG Direction ...
|
||||
iFVG.dir == box.dir &&
|
||||
//
|
||||
// Check FVG not Breaked ...
|
||||
!IsBoxBreaked(
|
||||
helper,
|
||||
iFVG,
|
||||
barIndex //
|
||||
) &&
|
||||
//
|
||||
// Check FVG Placement ...
|
||||
(iFVG.IsBullish()
|
||||
? iFVG.lower < box.upper
|
||||
: iFVG.upper > box.lower);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
iFVG.to = cTime;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iFVG,
|
||||
fvgs //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
iFVG.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Detecting Target FVG ...
|
||||
int idx = isBullish
|
||||
? GetHighest(fvgs)
|
||||
: GetLowest(fvgs);
|
||||
has = IsValidIndex(idx);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
fvg = fvgs[idx];
|
||||
|
||||
//
|
||||
fvg.to = cTime;
|
||||
}
|
||||
|
||||
//
|
||||
// Ensure FVG must Exists ...
|
||||
result = fvg.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
fvg.Clean();
|
||||
Clean(fvgs);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check FVg Break ...
|
||||
bool isBreaked = IsBoxBreaked(
|
||||
helper,
|
||||
fvg,
|
||||
barIndex //
|
||||
);
|
||||
result = !isBreaked;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
// Here We Can Cleanup Decision Zone ...
|
||||
// since the Conditions Destructed ...
|
||||
// box.Clean();
|
||||
|
||||
//
|
||||
fvg.Clean();
|
||||
Clean(fvgs);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Draw FVG ...
|
||||
XCBoxObject *iObj;
|
||||
has = helper.poiDrawer.DrawBox(
|
||||
fvg,
|
||||
iObj //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
color fvgColor =
|
||||
isBullish
|
||||
? clrLime
|
||||
: clrRed;
|
||||
|
||||
//
|
||||
iObj.BoxWidth(2);
|
||||
iObj.BoxColor(fvgColor);
|
||||
iObj.Style(STYLE_SOLID);
|
||||
|
||||
//
|
||||
drawns.Add(iObj);
|
||||
}
|
||||
ZeroMemory(iObj);
|
||||
|
||||
//
|
||||
// Detecting Liquiidties ...
|
||||
XOHCL iBar;
|
||||
XCAEALQSweep iLQ;
|
||||
XCAEALQSweep lqs[];
|
||||
toIDX = fvg.ToIndex();
|
||||
fromIDX = fvg.FromIndex();
|
||||
XCAEAConditions iConditions;
|
||||
double fvgPrice = isBullish
|
||||
? fvg.upper
|
||||
: fvg.lower;
|
||||
double fvgReversePrice = isBullish
|
||||
? fvg.lower
|
||||
: fvg.upper;
|
||||
for (int i = fromIDX; i > toIDX; i--)
|
||||
{
|
||||
//
|
||||
// Initialize iBar ...
|
||||
has = iBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
i //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
iBar.Clean();
|
||||
iConditions.Clean();
|
||||
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Reading Conditions ...
|
||||
has = helper.GetConditions(
|
||||
iConditions,
|
||||
i,
|
||||
5 //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
iBar.Clean();
|
||||
iConditions.Clean();
|
||||
|
||||
//
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
double iSweep =
|
||||
isBullish
|
||||
? iConditions.valeBuffer[1]
|
||||
: iConditions.peakBuffer[1];
|
||||
double iSweepP =
|
||||
isBullish
|
||||
? iConditions.valeBuffer[2]
|
||||
: iConditions.peakBuffer[2];
|
||||
double iSweepP2 =
|
||||
isBullish
|
||||
? iConditions.valeBuffer[3]
|
||||
: iConditions.peakBuffer[3];
|
||||
double iReverse =
|
||||
isBullish
|
||||
? iConditions.peakBuffer[1]
|
||||
: iConditions.valeBuffer[1];
|
||||
|
||||
//
|
||||
bool isSweepContinue =
|
||||
iSweepP == iSweep &&
|
||||
(isBullish
|
||||
? iSweep > fvgPrice
|
||||
: iSweep < fvgPrice);
|
||||
|
||||
//
|
||||
bool isSweepContinueP =
|
||||
iSweepP2 == iSweepP &&
|
||||
(isBullish
|
||||
? iSweepP > fvgPrice
|
||||
: iSweepP < fvgPrice);
|
||||
|
||||
//
|
||||
bool isSweepStart =
|
||||
isSweepContinue &&
|
||||
!isSweepContinueP;
|
||||
|
||||
//
|
||||
bool isSweepFinished =
|
||||
!isSweepContinue &&
|
||||
isSweepContinueP;
|
||||
|
||||
//
|
||||
if (isSweepStart)
|
||||
{
|
||||
//
|
||||
iLQ.Clean();
|
||||
|
||||
//
|
||||
iLQ.symbol = iBar.symbol;
|
||||
iLQ.period = iBar.period;
|
||||
iLQ.type = isBullish
|
||||
? XCAEA_LQ_TYPE_VALE
|
||||
: XCAEA_LQ_TYPE_PEAK;
|
||||
iLQ.to = iBar.time;
|
||||
iLQ.from = iBar.time;
|
||||
|
||||
//
|
||||
iLQ.length = 1;
|
||||
iLQ.sweeped = iSweep;
|
||||
iLQ.reverse = iReverse;
|
||||
}
|
||||
|
||||
//
|
||||
if (isSweepContinue)
|
||||
{
|
||||
//
|
||||
iLQ.length++;
|
||||
iLQ.to = iBar.time;
|
||||
iLQ.sweeped = iSweep;
|
||||
iLQ.reverse = MathMin(iLQ.reverse, iReverse);
|
||||
}
|
||||
|
||||
//
|
||||
if (isSweepFinished)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iLQ,
|
||||
lqs //
|
||||
);
|
||||
|
||||
//
|
||||
iLQ.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
iConditions.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Bar and Conditions ...
|
||||
has = iBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
barIndex //
|
||||
);
|
||||
has = has &&
|
||||
helper.GetConditions(
|
||||
iConditions,
|
||||
barIndex,
|
||||
loopback //
|
||||
);
|
||||
result = has;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
Clean(lqs);
|
||||
fvg.Clean();
|
||||
iLQ.Clean();
|
||||
Clean(fvgs);
|
||||
iBar.Clean();
|
||||
iConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Select Peak/Vale Value Based on Box ...
|
||||
double iPV = isBullish
|
||||
? iConditions.valeBuffer[1]
|
||||
: iConditions.peakBuffer[1];
|
||||
double iPVReverse = isBullish
|
||||
? iConditions.peakBuffer[1]
|
||||
: iConditions.valeBuffer[1];
|
||||
|
||||
//
|
||||
// Validate Liquidities Exists ...
|
||||
result = HasChild(lqs);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
Clean(lqs);
|
||||
fvg.Clean();
|
||||
iLQ.Clean();
|
||||
Clean(fvgs);
|
||||
iBar.Clean();
|
||||
iConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Liquidities ...
|
||||
for (int i = 0; i < ArraySize(lqs); i++)
|
||||
{
|
||||
//
|
||||
iLQ = lqs[i];
|
||||
|
||||
//
|
||||
CChartObjectTrend *iTrend;
|
||||
iTrend = new CChartObjectTrend();
|
||||
string itName = iLQ.GetTag();
|
||||
has = iTrend.Create(
|
||||
0,
|
||||
itName,
|
||||
0,
|
||||
iLQ.from,
|
||||
iLQ.sweeped,
|
||||
iLQ.to,
|
||||
iLQ.sweeped //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
color itColor =
|
||||
isBullish
|
||||
? clrLime
|
||||
: clrRed;
|
||||
|
||||
//
|
||||
iTrend.Width(2);
|
||||
iTrend.Color(itColor);
|
||||
iTrend.Style(STYLE_SOLID);
|
||||
|
||||
//
|
||||
drawns.Add(iTrend);
|
||||
}
|
||||
|
||||
//
|
||||
ZeroMemory(iTrend);
|
||||
}
|
||||
|
||||
//
|
||||
// PV Must go Inside FVG ...
|
||||
has =
|
||||
isBullish
|
||||
? iPV < fvgPrice
|
||||
: iPV > fvgPrice;
|
||||
result = has;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
Clean(lqs);
|
||||
fvg.Clean();
|
||||
iLQ.Clean();
|
||||
Clean(fvgs);
|
||||
iBar.Clean();
|
||||
iConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Detect a Traget for SL based on Activated FVG ...
|
||||
XBoxZone slTarget;
|
||||
double fvgValidatorPrice =
|
||||
isBullish
|
||||
? fvg.lower
|
||||
: fvg.upper;
|
||||
for (int i = 0; i < ArraySize(fvgs); i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iFVG = fvgs[i];
|
||||
|
||||
//
|
||||
double iFVGPrice =
|
||||
isBullish
|
||||
? iFVG.upper
|
||||
: iFVG.lower;
|
||||
|
||||
//
|
||||
// Validate Placement ...
|
||||
has = iFVGPrice > fvgValidatorPrice;
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
iFVG.Clean();
|
||||
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Set slTarget ...
|
||||
double slTargetPrice = (isBullish
|
||||
? slTarget.upper
|
||||
: slTarget.lower);
|
||||
has =
|
||||
!slTarget.IsValid()
|
||||
? true
|
||||
: (isBullish
|
||||
? slTargetPrice < iFVGPrice
|
||||
: slTargetPrice > iFVGPrice);
|
||||
if (has)
|
||||
{
|
||||
slTarget = iFVG;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Ensure SL Target Exists ...
|
||||
result = slTarget.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
Clean(lqs);
|
||||
fvg.Clean();
|
||||
iLQ.Clean();
|
||||
Clean(fvgs);
|
||||
iBar.Clean();
|
||||
iConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Darw SL Target Zone ...
|
||||
slTarget.to = cTime;
|
||||
XCBoxObject *iSLObj;
|
||||
has = helper.poiDrawer.DrawBox(
|
||||
slTarget,
|
||||
iSLObj //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
color slTargetColor =
|
||||
isBullish
|
||||
? clrAqua
|
||||
: clrMagenta;
|
||||
|
||||
//
|
||||
iSLObj.BoxWidth(1);
|
||||
iSLObj.BoxColor(slTargetColor);
|
||||
|
||||
//
|
||||
drawns.Add(iSLObj);
|
||||
}
|
||||
ZeroMemory(iSLObj);
|
||||
|
||||
//
|
||||
// Summarizing ...
|
||||
|
||||
//
|
||||
bool canTriggerLong =
|
||||
isBullishPassed;
|
||||
isBullish &&
|
||||
fvg.IsBullish() &&
|
||||
slTarget.IsBullish();
|
||||
|
||||
//
|
||||
bool canTriggerShort =
|
||||
isBearishPassed;
|
||||
isBearish &&
|
||||
fvg.IsBearish() &&
|
||||
slTarget.IsBearish();
|
||||
|
||||
//
|
||||
result = canTriggerLong ||
|
||||
@@ -1724,9 +2298,9 @@ bool CanTriggerCond3(
|
||||
// Preparing TP and SL ...
|
||||
|
||||
//
|
||||
sl = canTriggerLong
|
||||
? ob.lower
|
||||
: ob.upper;
|
||||
sl = isBullish
|
||||
? slTarget.lower
|
||||
: slTarget.upper;
|
||||
|
||||
//
|
||||
// Since Here TP Must Calculated
|
||||
@@ -1738,10 +2312,12 @@ bool CanTriggerCond3(
|
||||
// Cleanup Resources ...
|
||||
|
||||
//
|
||||
ob.Clean();
|
||||
swing.Clean();
|
||||
breaker.Clean();
|
||||
outSide.Clean();
|
||||
Clean(lqs);
|
||||
fvg.Clean();
|
||||
iLQ.Clean();
|
||||
Clean(fvgs);
|
||||
iBar.Clean();
|
||||
iConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
|
||||
@@ -475,25 +475,29 @@ class XCXCAEASignaller : XCBase
|
||||
//
|
||||
// Checking Signal's Decision Zone ...
|
||||
// On Analyse Time Frame ...
|
||||
hasDecisionZone = DetectDecisionZone(
|
||||
analyseHelper,
|
||||
drawer,
|
||||
decisionZone,
|
||||
decisionZoneDir,
|
||||
conditions,
|
||||
zIndex,
|
||||
loopback //
|
||||
);
|
||||
|
||||
//
|
||||
// Make Signal Box UnAvailable ...
|
||||
if (hasDecisionZone)
|
||||
if (!HasChild(mConditionsCollection))
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
hasDecisionZone = DetectDecisionZone(
|
||||
analyseHelper,
|
||||
drawer,
|
||||
decisionZone,
|
||||
unAvailableBoxes //
|
||||
decisionZoneDir,
|
||||
conditions,
|
||||
zIndex,
|
||||
loopback //
|
||||
);
|
||||
|
||||
//
|
||||
// Make Signal Box UnAvailable ...
|
||||
if (hasDecisionZone)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
decisionZone,
|
||||
unAvailableBoxes //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -554,7 +558,7 @@ class XCXCAEASignaller : XCBase
|
||||
bool DetectSignalTrigger(
|
||||
XCAEAStrategyConditions &conditions,
|
||||
int barIndex = 0,
|
||||
int maxAllowedSetupAge = 200 //
|
||||
int maxAllowedSetupAge = 1000 //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -618,76 +622,12 @@ class XCXCAEASignaller : XCBase
|
||||
double sl = 0;
|
||||
double tp = 0;
|
||||
ENUM_X_DIRECTION triggerDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
// Detect All Inside Directional FVGs ...
|
||||
XBoxZone fvgs[];
|
||||
int toIDX = conditions.decisionZone.ToIndex();
|
||||
int fromIDX = conditions.decisionZone.FromIndex();
|
||||
for (int i = fromIDX; i > toIDX; i--)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
XBoxZone iFVG;
|
||||
|
||||
//
|
||||
// Initialize iBar ...
|
||||
has = iBar.Init(
|
||||
conditions.symbol,
|
||||
conditions.period,
|
||||
i //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
iFVG.Clean();
|
||||
iBar.Clean();
|
||||
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Check iBar has FVG ...
|
||||
has = helper
|
||||
.barAnalyser
|
||||
.IsFVG(
|
||||
iBar,
|
||||
iFVG,
|
||||
true //
|
||||
);
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
iBar.Clean();
|
||||
iFVG.Clean();
|
||||
|
||||
//
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Check FVG Direction and Placement ...
|
||||
has =
|
||||
iFVG.dir == conditions.decisionZone.dir &&
|
||||
iFVG.upper < conditions.decisionZone.upper &&
|
||||
iFVG.lower > conditions.decisionZone.lower;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
iFVG.to = cTime;
|
||||
AddRef(
|
||||
iFVG,
|
||||
fvgs //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
iBar.Clean();
|
||||
iFVG.Clean();
|
||||
}
|
||||
bool hasFVGs = HasChild(fvgs);
|
||||
int fvgsCount = ArraySize(fvgs);
|
||||
//
|
||||
CArrayObj *iObjects;
|
||||
iObjects = new CArrayObj();
|
||||
|
||||
//
|
||||
// Checking Trigger Cond 0 ...
|
||||
@@ -733,6 +673,7 @@ class XCXCAEASignaller : XCBase
|
||||
triggerDir,
|
||||
sl,
|
||||
tp,
|
||||
iObjects,
|
||||
barIndex //
|
||||
);
|
||||
|
||||
@@ -754,28 +695,12 @@ class XCXCAEASignaller : XCBase
|
||||
ZeroMemory(iObj);
|
||||
|
||||
//
|
||||
// Draw FVGs ...
|
||||
if (hasFVGs)
|
||||
for (int i = 0; i < iObjects.Total(); i++)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < fvgsCount; i++)
|
||||
{
|
||||
//
|
||||
fvgs[i].to = cTime;
|
||||
|
||||
//
|
||||
XCBoxObject *iObj;
|
||||
has = helper.poiDrawer.DrawBox(
|
||||
fvgs[i],
|
||||
iObj //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
mObjects.Add(iObj);
|
||||
}
|
||||
ZeroMemory(iObj);
|
||||
}
|
||||
mObjects.Add(iObjects.At(i));
|
||||
}
|
||||
// iObjects.Clear();
|
||||
// ZeroMemory(iObjects);
|
||||
|
||||
//
|
||||
// Summarizing Result ...
|
||||
@@ -879,6 +804,14 @@ class XCXCAEASignaller : XCBase
|
||||
conditions.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Checking Decision Zone Validation ...
|
||||
bool isValid = conditions.decisionZone.IsValid();
|
||||
if (!isValid)
|
||||
{
|
||||
conditions.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Check Box Price ...
|
||||
has = IsBoxBreaked(
|
||||
|
||||
Reference in New Issue
Block a user