2047 lines
44 KiB
Plaintext
2047 lines
44 KiB
Plaintext
|
|
/**
|
|
* Sort Order Blocks / Fair Value Gaps based on Place and Remove unused ...
|
|
*/
|
|
template <typename T>
|
|
void OrderedSortZones(
|
|
T *youngest,
|
|
T *&items[] //
|
|
)
|
|
{
|
|
//
|
|
int count = ArraySize(items);
|
|
if (youngest == NULL ||
|
|
!youngest.IsValid() ||
|
|
!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
ENUM_X_DIRECTION dir = youngest.GetDirection();
|
|
bool isBullish = IsBullish(dir);
|
|
|
|
//
|
|
T *tmp[];
|
|
T *lastOB = youngest;
|
|
while (IsValidSize(count))
|
|
{
|
|
//
|
|
// Detect Youngest of Collection ...
|
|
int idx = GetYoungest(items);
|
|
T *iChild = items[idx];
|
|
ArrayRemove(
|
|
items,
|
|
idx,
|
|
1 //
|
|
);
|
|
count = ArraySize(items);
|
|
|
|
//
|
|
// Check Direction Must be Same ...
|
|
ENUM_X_DIRECTION iDir = iChild.GetDirection();
|
|
bool isSameDir = dir == iDir;
|
|
if (!isSameDir)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Check Creation time Sequence ...
|
|
bool isFromPassed = lastOB.From() > iChild.From();
|
|
if (!isFromPassed)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Check Order Block Place ...
|
|
bool isPlacePassed =
|
|
isBullish
|
|
? IsBelow(
|
|
iChild,
|
|
lastOB,
|
|
true // Ignore Inside ...
|
|
)
|
|
: IsAbove(
|
|
iOB,
|
|
lastOB,
|
|
true // Ignore Inside ...
|
|
);
|
|
if (!isPlacePassed)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Update Last OB ...
|
|
lastOB = iChild;
|
|
Add(
|
|
iChild,
|
|
tmp //
|
|
);
|
|
|
|
//
|
|
}
|
|
|
|
//
|
|
// Update Ordered Sorted Order Blocks ...
|
|
count = ArraySize(tmp);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
Copy(
|
|
tmp,
|
|
orderBlocks //
|
|
);
|
|
}
|
|
}
|
|
template <typename T>
|
|
void OrderedSortZones(
|
|
T *&items[] //
|
|
)
|
|
{
|
|
//
|
|
int count = ArraySize(items);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Detect Youngest ...
|
|
int youngestIDX = GetYoungest(
|
|
items //
|
|
);
|
|
bool hasYoungest = IsValidSize(youngestIDX);
|
|
if (!hasYoungest)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
T *youngest = items[youngestIDX];
|
|
ArrayRemove(
|
|
items,
|
|
youngestIDX,
|
|
1 //
|
|
);
|
|
count = ArraySize(items);
|
|
if (!IsValidSize(count))
|
|
{
|
|
//
|
|
Add(
|
|
youngest,
|
|
items //
|
|
);
|
|
|
|
//
|
|
return;
|
|
}
|
|
|
|
//
|
|
if (youngest == NULL ||
|
|
!youngest.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
ENUM_X_DIRECTION dir = youngest.GetDirection();
|
|
bool isBullish = IsBullish(dir);
|
|
|
|
//
|
|
T *tmp[];
|
|
T *lastOB = youngest;
|
|
while (IsValidSize(count))
|
|
{
|
|
//
|
|
// Detect Youngest of Collection ...
|
|
int idx = GetYoungest(items);
|
|
T *iChild = items[idx];
|
|
ArrayRemove(
|
|
items,
|
|
idx,
|
|
1 //
|
|
);
|
|
count = ArraySize(items);
|
|
|
|
//
|
|
// Check Direction Must be Same ...
|
|
ENUM_X_DIRECTION iDir = iChild.GetDirection();
|
|
bool isSameDir = dir == iDir;
|
|
if (!isSameDir)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Check Creation time Sequence ...
|
|
bool isFromPassed = lastOB.From() > iChild.From();
|
|
if (!isFromPassed)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Check Order Block Place ...
|
|
bool isPlacePassed =
|
|
isBullish
|
|
? IsBelow(
|
|
iChild,
|
|
lastOB,
|
|
true // Ignore Inside ...
|
|
)
|
|
: IsAbove(
|
|
iChild,
|
|
lastOB,
|
|
true // Ignore Inside ...
|
|
);
|
|
if (!isPlacePassed)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Update Last OB ...
|
|
lastOB = iChild;
|
|
Add(
|
|
iChild,
|
|
tmp //
|
|
);
|
|
|
|
//
|
|
}
|
|
|
|
//
|
|
// Update Ordered Sorted Order Blocks ...
|
|
count = ArraySize(tmp);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
Copy(
|
|
tmp,
|
|
items //
|
|
);
|
|
}
|
|
}
|
|
|
|
void OrderedSortBoxes(
|
|
XBoxZone &items[] //
|
|
)
|
|
{
|
|
//
|
|
int count = ArraySize(items);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
// Detect Youngest ...
|
|
int youngestIDX = GetYoungest(
|
|
items //
|
|
);
|
|
bool hasYoungest = IsValidSize(youngestIDX);
|
|
if (!hasYoungest)
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
XBoxZone youngest = items[youngestIDX];
|
|
ArrayRemove(
|
|
items,
|
|
youngestIDX,
|
|
1 //
|
|
);
|
|
count = ArraySize(items);
|
|
if (!IsValidSize(count))
|
|
{
|
|
//
|
|
AddRef(
|
|
youngest,
|
|
items //
|
|
);
|
|
|
|
//
|
|
return;
|
|
}
|
|
|
|
//
|
|
if (!youngest.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
ENUM_X_DIRECTION dir = youngest.dir;
|
|
bool isBullish = IsBullish(dir);
|
|
|
|
//
|
|
XBoxZone tmp[];
|
|
XBoxZone last = youngest;
|
|
while (IsValidSize(count))
|
|
{
|
|
//
|
|
// Detect Youngest of Collection ...
|
|
int idx = GetYoungest(items);
|
|
XBoxZone iChild = items[idx];
|
|
ArrayRemove(
|
|
items,
|
|
idx,
|
|
1 //
|
|
);
|
|
count = ArraySize(items);
|
|
|
|
//
|
|
// Check Direction Must be Same ...
|
|
ENUM_X_DIRECTION iDir = iChild.dir;
|
|
bool isSameDir = dir == iDir;
|
|
if (!isSameDir)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Check Creation time Sequence ...
|
|
bool isFromPassed = last.from > iChild.from;
|
|
if (!isFromPassed)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Check Order Block Place ...
|
|
bool isPlacePassed =
|
|
isBullish
|
|
? IsBoxBelow(
|
|
iChild,
|
|
last,
|
|
true // Ignore Inside ...
|
|
)
|
|
: IsBoxAbove(
|
|
iChild,
|
|
last,
|
|
true // Ignore Inside ...
|
|
);
|
|
if (!isPlacePassed)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Update Last OB ...
|
|
last = iChild;
|
|
AddRef(
|
|
iChild,
|
|
tmp //
|
|
);
|
|
|
|
//
|
|
}
|
|
|
|
//
|
|
// Update Ordered Sorted Order Blocks ...
|
|
count = ArraySize(tmp);
|
|
if (IsValidSize(count))
|
|
{
|
|
//
|
|
Copy(
|
|
tmp,
|
|
items //
|
|
);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Extract Order Flows Swing Points ...
|
|
*
|
|
* @param type: ENUM_X_SWING_TYPE member ...
|
|
* @param swings: double Collection ...
|
|
*
|
|
* @return ( int )
|
|
*/
|
|
int ExtractSwingPoints(
|
|
ENUM_X_SWING_TYPE type,
|
|
XCOrderBlock *&orderBlocks[],
|
|
XSwingPoint &swings[] //
|
|
)
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
Clean(swings);
|
|
|
|
//
|
|
int count = ArraySize(orderBlocks);
|
|
|
|
//
|
|
if (type == X_NO_SWING ||
|
|
!IsValidSize(count))
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool lookingForSwingLows = type == X_SWING_LOW;
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCOrderBlock *iOB = orderBlocks[i];
|
|
|
|
//
|
|
string iSymbol = iOB.GetSymbol();
|
|
ENUM_TIMEFRAMES iPeriod = iOB.GetPeriod();
|
|
|
|
//
|
|
int fromIndex = iBarShift(
|
|
iSymbol,
|
|
iPeriod,
|
|
iOB.From() //
|
|
);
|
|
|
|
//
|
|
fromIndex++;
|
|
|
|
//
|
|
double iValue = 0;
|
|
datetime iVTime = NULL;
|
|
if (lookingForSwingLows)
|
|
{
|
|
//
|
|
int idx = iLowest(
|
|
iSymbol,
|
|
iPeriod,
|
|
MODE_LOW,
|
|
fromIndex //
|
|
);
|
|
|
|
//
|
|
if (IsValidIndex(idx))
|
|
{
|
|
//
|
|
iValue = iLow(
|
|
iSymbol,
|
|
iPeriod,
|
|
idx //
|
|
);
|
|
|
|
//
|
|
iVTime = iTime(
|
|
iSymbol,
|
|
iPeriod,
|
|
idx //
|
|
);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
int idx = iHighest(
|
|
iSymbol,
|
|
iPeriod,
|
|
MODE_HIGH,
|
|
fromIndex //
|
|
);
|
|
|
|
//
|
|
if (IsValidIndex(idx))
|
|
{
|
|
//
|
|
iValue = iHigh(
|
|
iSymbol,
|
|
iPeriod,
|
|
idx //
|
|
);
|
|
|
|
//
|
|
iVTime = iTime(
|
|
iSymbol,
|
|
iPeriod,
|
|
idx //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
if (iValue > 0)
|
|
{
|
|
//
|
|
XSwingPoint iSwingP;
|
|
|
|
//
|
|
iSwingP.type = type;
|
|
iSwingP.time = iVTime;
|
|
iSwingP.swing = iValue;
|
|
iSwingP.symbol = iSymbol;
|
|
iSwingP.period = iPeriod;
|
|
|
|
//
|
|
if (iSwingP.IsValid())
|
|
{
|
|
//
|
|
AddRef(
|
|
iSwingP,
|
|
swings //
|
|
);
|
|
}
|
|
|
|
//
|
|
iSwingP.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
result = ArraySize(swings);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
|
|
//
|
|
bool IsRejectBox(
|
|
ENUM_X_DIRECTION &forDir,
|
|
XOHCL &bar,
|
|
XBoxZone &box,
|
|
XPOIState &state,
|
|
XOHCL &swingBar,
|
|
XOHCL &rejectBar,
|
|
XOHCL &breakerBar,
|
|
XOHCL &momentumBar,
|
|
bool forceSwingRejection = true //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
swingBar.Clean();
|
|
rejectBar.Clean();
|
|
breakerBar.Clean();
|
|
momentumBar.Clean();
|
|
|
|
//
|
|
result = bar.IsValid() &&
|
|
box.IsValid() &&
|
|
state.IsValid() &&
|
|
state.HasChild() &&
|
|
HasDirection(forDir);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
bool isBullish = IsBullish(forDir);
|
|
|
|
//
|
|
double appliedPrice =
|
|
isBullish
|
|
? box.upper
|
|
: box.lower;
|
|
|
|
//
|
|
// Fetch Required Bars ...
|
|
|
|
//
|
|
XOHCL cBar;
|
|
result = bar.GetPreviousBar(cBar);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL pBar;
|
|
result = cBar.GetPreviousBar(pBar);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL ppBar;
|
|
result = pBar.GetPreviousBar(ppBar);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Directional Swing Type ...
|
|
ENUM_X_SWING_TYPE swingType =
|
|
isBullish
|
|
? X_SWING_LOW
|
|
: X_SWING_HIGH;
|
|
|
|
//
|
|
bool isSwingLow =
|
|
//
|
|
pBar.low < ppBar.low &&
|
|
pBar.low < cBar.low &&
|
|
bar.open > pBar.low &&
|
|
//
|
|
appliedPrice > pBar.low &&
|
|
appliedPrice < pBar.GetDown()
|
|
//
|
|
;
|
|
|
|
//
|
|
bool isSwingHigh =
|
|
//
|
|
pBar.high > ppBar.high &&
|
|
pBar.high > cBar.high &&
|
|
bar.open < pBar.high &&
|
|
//
|
|
appliedPrice < pBar.high &&
|
|
appliedPrice > pBar.GetUp()
|
|
//
|
|
;
|
|
|
|
//
|
|
// Force Rejected By Swing ...
|
|
if (forceSwingRejection)
|
|
{
|
|
//
|
|
result = swingType == X_SWING_HIGH
|
|
? isSwingHigh
|
|
: swingType == X_SWING_LOW
|
|
? isSwingLow
|
|
: false;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
}
|
|
|
|
//
|
|
bool hasValidSwing =
|
|
isBullish
|
|
? isSwingLow
|
|
: isSwingHigh;
|
|
if (hasValidSwing)
|
|
{
|
|
swingBar = pBar;
|
|
}
|
|
|
|
//
|
|
bool isCBarBreaked = IsBarBreak(
|
|
appliedPrice,
|
|
forDir,
|
|
cBar //
|
|
);
|
|
if (isCBarBreaked)
|
|
{
|
|
breakerBar = cBar;
|
|
}
|
|
bool isPBarBreaked = IsBarBreak(
|
|
appliedPrice,
|
|
forDir,
|
|
pBar //
|
|
);
|
|
if (isPBarBreaked)
|
|
{
|
|
breakerBar = pBar;
|
|
}
|
|
bool isPPBarBreaked = IsBarBreak(
|
|
appliedPrice,
|
|
forDir,
|
|
ppBar //
|
|
);
|
|
if (isPPBarBreaked)
|
|
{
|
|
breakerBar = ppBar;
|
|
}
|
|
bool isBoxBreaked = isCBarBreaked ||
|
|
isPBarBreaked ||
|
|
isPPBarBreaked;
|
|
|
|
//
|
|
bool isCBarRejected = IsBarReject(
|
|
appliedPrice,
|
|
forDir,
|
|
cBar //
|
|
);
|
|
if (isCBarRejected)
|
|
{
|
|
rejectBar = cBar;
|
|
}
|
|
bool isPBarRejected = IsBarReject(
|
|
appliedPrice,
|
|
forDir,
|
|
pBar //
|
|
);
|
|
if (isPBarRejected)
|
|
{
|
|
rejectBar = pBar;
|
|
}
|
|
bool isPPBarRejected = IsBarReject(
|
|
appliedPrice,
|
|
forDir,
|
|
ppBar //
|
|
);
|
|
if (isPPBarRejected)
|
|
{
|
|
rejectBar = ppBar;
|
|
}
|
|
bool isBoxRejected = isCBarRejected ||
|
|
isPBarRejected ||
|
|
isPPBarRejected;
|
|
|
|
//
|
|
int count = 0;
|
|
|
|
//
|
|
bool hasRejectionBar = false;
|
|
if (isBullish)
|
|
{
|
|
//
|
|
count = state.CountBullishRejectionBars();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCRejectionBar *iZone = state.bullishRejectionBars[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iZone.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
int iBarIndex = iBar.Index();
|
|
|
|
//
|
|
hasRejectionBar =
|
|
//
|
|
(iBarIndex == cBar.Index() ||
|
|
iBarIndex == pBar.Index())
|
|
//
|
|
;
|
|
if (hasRejectionBar)
|
|
{
|
|
//
|
|
if (!rejectBar.IsValid())
|
|
{
|
|
rejectBar = iBar;
|
|
}
|
|
|
|
//
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
count = state.CountBearishRejectionBars();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCRejectionBar *iZone = state.bearishRejectionBars[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iZone.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
int iBarIndex = iBar.Index();
|
|
|
|
//
|
|
hasRejectionBar =
|
|
//
|
|
(iBarIndex == cBar.Index() ||
|
|
iBarIndex == pBar.Index())
|
|
//
|
|
;
|
|
if (hasRejectionBar)
|
|
{
|
|
//
|
|
if (!rejectBar.IsValid())
|
|
{
|
|
rejectBar = iBar;
|
|
}
|
|
|
|
//
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
bool hasMomentumBar = false;
|
|
if (isBullish)
|
|
{
|
|
//
|
|
count = state.CountBullishMomentumBars();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCMomentumBar *iZone = state.bullishMomentumBars[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iZone.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
int iBarIndex = iBar.Index();
|
|
|
|
//
|
|
hasMomentumBar =
|
|
//
|
|
(iBarIndex == cBar.Index() ||
|
|
iBarIndex == pBar.Index())
|
|
//
|
|
;
|
|
if (hasMomentumBar)
|
|
{
|
|
//
|
|
if (!momentumBar.IsValid())
|
|
{
|
|
momentumBar = iBar;
|
|
}
|
|
|
|
//
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
count = state.CountBearishMomentumBars();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCMomentumBar *iZone = state.bearishMomentumBars[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iZone.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
int iBarIndex = iBar.Index();
|
|
|
|
//
|
|
hasMomentumBar =
|
|
//
|
|
(iBarIndex == cBar.Index() ||
|
|
iBarIndex == pBar.Index())
|
|
//
|
|
;
|
|
if (hasMomentumBar)
|
|
{
|
|
//
|
|
if (!momentumBar.IsValid())
|
|
{
|
|
momentumBar = iBar;
|
|
}
|
|
|
|
//
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
bool hasSwing = false;
|
|
if (isBullish)
|
|
{
|
|
//
|
|
count = state.CountSwingLows();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCSwing *iSwing = state.swingLows[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iSwing.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
int iBarIndex = iBar.Index();
|
|
|
|
//
|
|
hasSwing =
|
|
//
|
|
(iBarIndex == cBar.Index() ||
|
|
iBarIndex == pBar.Index())
|
|
//
|
|
;
|
|
if (hasSwing)
|
|
{
|
|
//
|
|
if (!swingBar.IsValid())
|
|
{
|
|
swingBar = iBar;
|
|
}
|
|
|
|
//
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
count = state.CountSwingHighs();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCSwing *iSwing = state.swingHighs[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iSwing.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
int iBarIndex = iBar.Index();
|
|
|
|
//
|
|
hasSwing =
|
|
//
|
|
(iBarIndex == cBar.Index() ||
|
|
iBarIndex == pBar.Index())
|
|
//
|
|
;
|
|
if (hasSwing)
|
|
{
|
|
//
|
|
if (!swingBar.IsValid())
|
|
{
|
|
swingBar = iBar;
|
|
}
|
|
|
|
//
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
bool hasRequiredValidations =
|
|
//
|
|
(hasRejectionBar ||
|
|
hasMomentumBar)
|
|
//
|
|
||
|
|
//
|
|
(hasRejectionBar ||
|
|
hasSwing)
|
|
//
|
|
||
|
|
//
|
|
(hasMomentumBar ||
|
|
hasSwing)
|
|
//
|
|
;
|
|
|
|
//
|
|
result =
|
|
//
|
|
(isBoxBreaked &&
|
|
(hasRequiredValidations ||
|
|
hasValidSwing))
|
|
//
|
|
||
|
|
//
|
|
(isBoxRejected &&
|
|
(hasRequiredValidations ||
|
|
hasValidSwing))
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
|
|
template <typename T>
|
|
void UpdateTo(
|
|
T *&source[],
|
|
datetime time = NULL //
|
|
)
|
|
{
|
|
//
|
|
if (!IsValid(time))
|
|
{
|
|
time = TimeCurrent();
|
|
}
|
|
|
|
//
|
|
int count = ArraySize(source);
|
|
if (!IsValidSize(count))
|
|
{
|
|
return;
|
|
}
|
|
|
|
//
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
source[i].To(time);
|
|
}
|
|
}
|
|
|
|
|
|
template <typename T>
|
|
bool IsReject(
|
|
ENUM_X_DIRECTION forDir,
|
|
XOHCL &bar,
|
|
T *source,
|
|
XPOIState &state,
|
|
XOHCL &swingBar,
|
|
XOHCL &rejectBar,
|
|
XOHCL &breakerBar,
|
|
XOHCL &momentumBar,
|
|
bool forceSwingRejection = true //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
XBoxZone sourceBox;
|
|
result = ToBox(
|
|
sourceBox,
|
|
source //
|
|
);
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = IsRejectBox(
|
|
forDir,
|
|
bar,
|
|
sourceBox,
|
|
state,
|
|
swingBar,
|
|
rejectBar,
|
|
breakerBar,
|
|
momentumBar,
|
|
forceSwingRejection //
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
|
|
//
|
|
bool HasConditions(
|
|
ENUM_X_DIRECTION &conditionsDir,
|
|
XPOIState &state,
|
|
int barIndex = 0,
|
|
ENUM_TIMEFRAMES forPeriod = NULL //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
conditionsDir = X_DIRECTION_NONE;
|
|
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
if (forPeriod == NULL)
|
|
{
|
|
forPeriod = period;
|
|
}
|
|
|
|
//
|
|
result =
|
|
//
|
|
IsValid(symbol) &&
|
|
IsValid(period) &&
|
|
state.IsValid() &&
|
|
HasWorkingZone() &&
|
|
state.HasChild()
|
|
//
|
|
;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = false;
|
|
|
|
//
|
|
// Detect Conditions Based On Start Zones ...
|
|
bool hasStartZones = HasStartZones();
|
|
if (hasStartZones)
|
|
{
|
|
//
|
|
int count = CountStartZones();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
X121SMCXWZZone iStartZone = startZones[i];
|
|
|
|
//
|
|
XBoxZone insideBox;
|
|
bool isPriceInside = iStartZone.IsPriceInside(
|
|
insideBox,
|
|
barIndex,
|
|
forPeriod //
|
|
);
|
|
if (!isPriceInside)
|
|
{
|
|
//
|
|
iStartZone.Clean();
|
|
continue;
|
|
}
|
|
|
|
//
|
|
Print("PriceInside ...");
|
|
|
|
//
|
|
bool hasConditions = iStartZone.HasCondition(
|
|
insideBox,
|
|
state,
|
|
barIndex,
|
|
forPeriod //
|
|
);
|
|
if (!hasConditions)
|
|
{
|
|
//
|
|
iStartZone.Clean();
|
|
continue;
|
|
}
|
|
|
|
//
|
|
iStartZone.Clean();
|
|
}
|
|
}
|
|
|
|
//
|
|
// Detect Conditions Based On Working Zones ...
|
|
if (!result)
|
|
{
|
|
//
|
|
// Detect Result Based On WorkingZone ...
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
|
|
//
|
|
bool HasCondition(
|
|
XBoxZone &box,
|
|
XPOIState &state,
|
|
int barIndex = 0,
|
|
ENUM_TIMEFRAMES forPeriod = NULL //
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
swingBar.Clean();
|
|
breakerBar.Clean();
|
|
appliedBox.Clean();
|
|
momentumBar.Clean();
|
|
rejectionBar.Clean();
|
|
|
|
//
|
|
result = IsValid() &&
|
|
box.IsValid() &&
|
|
HasDirection() &&
|
|
state.IsValid() &&
|
|
state.HasChild();
|
|
if (!result)
|
|
{
|
|
//
|
|
swingBar.Clean();
|
|
breakerBar.Clean();
|
|
appliedBox.Clean();
|
|
momentumBar.Clean();
|
|
rejectionBar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
string symbol = box.symbol;
|
|
if (!IsValid(forPeriod))
|
|
{
|
|
forPeriod = box.period;
|
|
}
|
|
datetime cTime = iTime(
|
|
symbol,
|
|
forPeriod,
|
|
barIndex //
|
|
);
|
|
|
|
//
|
|
ENUM_X_DIRECTION forDir = box.dir;
|
|
bool isBullish = IsBullish(forDir);
|
|
|
|
//
|
|
int supportsCount = 0;
|
|
bool hasSupports = false;
|
|
XCSupportZone *supports[];
|
|
|
|
//
|
|
int resistancesCount = 0;
|
|
bool hasResistances = false;
|
|
XCResistanceZone *resistances[];
|
|
|
|
//
|
|
XBoxZone supResBoxes[];
|
|
int supresBoxesCount = 0;
|
|
bool hasSupResBoxes = false;
|
|
|
|
//
|
|
int count = 0;
|
|
bool has = false;
|
|
|
|
//
|
|
has = state.HasSupportZones();
|
|
if (has)
|
|
{
|
|
//
|
|
count = state.CountSupportZones();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCSupportZone *iZone = state.supportZones[i];
|
|
|
|
//
|
|
iZone.To(cTime);
|
|
|
|
//
|
|
XBoxZone iBox;
|
|
bool hasBox = ToBox(
|
|
iBox,
|
|
iZone //
|
|
);
|
|
if (!hasBox)
|
|
{
|
|
//
|
|
iBox.Clean();
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Check From ...
|
|
bool isInside = IsBoxInside(
|
|
iBox,
|
|
box //
|
|
);
|
|
if (!isInside)
|
|
{
|
|
//
|
|
iBox.Clean();
|
|
continue;
|
|
}
|
|
|
|
//
|
|
Add(
|
|
iZone,
|
|
supports //
|
|
);
|
|
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
supResBoxes //
|
|
);
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
|
|
//
|
|
supportsCount = ArraySize(supports);
|
|
hasSupports = IsValidSize(supportsCount);
|
|
|
|
//
|
|
supresBoxesCount = ArraySize(supResBoxes);
|
|
hasSupResBoxes = IsValidSize(supresBoxesCount);
|
|
}
|
|
|
|
//
|
|
has = state.HasResistanceZones();
|
|
if (has)
|
|
{
|
|
//
|
|
count = state.CountResistanceZones();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCResistanceZone *iZone = state.resistanceZones[i];
|
|
|
|
//
|
|
iZone.To(cTime);
|
|
|
|
//
|
|
XBoxZone iBox;
|
|
bool hasBox = ToBox(
|
|
iBox,
|
|
iZone //
|
|
);
|
|
if (!hasBox)
|
|
{
|
|
//
|
|
iBox.Clean();
|
|
continue;
|
|
}
|
|
|
|
//
|
|
// Check From ...
|
|
bool isInside = IsBoxInside(
|
|
iBox,
|
|
box //
|
|
);
|
|
if (!isInside)
|
|
{
|
|
//
|
|
iBox.Clean();
|
|
continue;
|
|
}
|
|
|
|
//
|
|
Add(
|
|
iZone,
|
|
resistances //
|
|
);
|
|
|
|
//
|
|
AddRef(
|
|
iBox,
|
|
supResBoxes //
|
|
);
|
|
|
|
//
|
|
iBox.Clean();
|
|
}
|
|
|
|
//
|
|
resistancesCount = ArraySize(resistances);
|
|
hasResistances = IsValidSize(resistancesCount);
|
|
|
|
//
|
|
supresBoxesCount = ArraySize(supResBoxes);
|
|
hasSupResBoxes = IsValidSize(supresBoxesCount);
|
|
}
|
|
|
|
//
|
|
result = hasSupResBoxes;
|
|
if (!result)
|
|
{
|
|
//
|
|
Clean(supports);
|
|
Clean(resistances);
|
|
Clean(supResBoxes);
|
|
|
|
//
|
|
swingBar.Clean();
|
|
breakerBar.Clean();
|
|
appliedBox.Clean();
|
|
momentumBar.Clean();
|
|
rejectionBar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
// //
|
|
// AddRef(
|
|
// box,
|
|
// supResBoxes //
|
|
// );
|
|
|
|
//
|
|
// Detect Bars ...
|
|
|
|
//
|
|
XOHCL zBar;
|
|
result = zBar.Init(
|
|
symbol,
|
|
forPeriod,
|
|
barIndex //
|
|
);
|
|
if (!result)
|
|
{
|
|
//
|
|
zBar.Clean();
|
|
Clean(supports);
|
|
Clean(resistances);
|
|
Clean(supResBoxes);
|
|
|
|
//
|
|
swingBar.Clean();
|
|
breakerBar.Clean();
|
|
appliedBox.Clean();
|
|
momentumBar.Clean();
|
|
rejectionBar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL cBar;
|
|
result = zBar.GetPreviousBar(cBar);
|
|
if (!result)
|
|
{
|
|
//
|
|
zBar.Clean();
|
|
cBar.Clean();
|
|
Clean(supports);
|
|
Clean(resistances);
|
|
Clean(supResBoxes);
|
|
|
|
//
|
|
swingBar.Clean();
|
|
breakerBar.Clean();
|
|
appliedBox.Clean();
|
|
momentumBar.Clean();
|
|
rejectionBar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL pBar;
|
|
result = cBar.GetPreviousBar(pBar);
|
|
if (!result)
|
|
{
|
|
//
|
|
zBar.Clean();
|
|
cBar.Clean();
|
|
pBar.Clean();
|
|
Clean(supports);
|
|
Clean(resistances);
|
|
Clean(supResBoxes);
|
|
|
|
//
|
|
swingBar.Clean();
|
|
breakerBar.Clean();
|
|
appliedBox.Clean();
|
|
momentumBar.Clean();
|
|
rejectionBar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
XOHCL ppBar;
|
|
result = pBar.GetPreviousBar(ppBar);
|
|
if (!result)
|
|
{
|
|
//
|
|
zBar.Clean();
|
|
cBar.Clean();
|
|
pBar.Clean();
|
|
ppBar.Clean();
|
|
Clean(supports);
|
|
Clean(resistances);
|
|
Clean(supResBoxes);
|
|
|
|
//
|
|
swingBar.Clean();
|
|
breakerBar.Clean();
|
|
appliedBox.Clean();
|
|
momentumBar.Clean();
|
|
rejectionBar.Clean();
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Conditions ...
|
|
|
|
//
|
|
// Detect Start Senario ...
|
|
|
|
//
|
|
double fiboPressureLevel = GetFiboLevelValue(X_FIBO_LEVEL_382);
|
|
|
|
//
|
|
double fiboUpDown = GetFibonacciLevel(
|
|
pBar.high,
|
|
pBar.low,
|
|
X_FIBO_LEVEL_382,
|
|
X_DIRECTION_BEARISH //
|
|
);
|
|
double fiboDownUp = GetFibonacciLevel(
|
|
pBar.high,
|
|
pBar.low,
|
|
X_FIBO_LEVEL_382,
|
|
X_DIRECTION_BULLISH //
|
|
);
|
|
|
|
//
|
|
bool hasFiboToUpPressure =
|
|
fiboDownUp > 0 &&
|
|
fiboDownUp <= pBar.GetDown();
|
|
bool hasFiboToDownPressure =
|
|
fiboUpDown > 0 &&
|
|
fiboUpDown >= pBar.GetUp();
|
|
|
|
//
|
|
int selectedBoxIDX = -1;
|
|
for (int j = 0; j < supresBoxesCount; j++)
|
|
{
|
|
//
|
|
double appliedPrice =
|
|
isBullish
|
|
? supResBoxes[j].lower
|
|
: supResBoxes[j].upper;
|
|
|
|
//
|
|
// Check Swing Low ...
|
|
bool isSwingLow =
|
|
//
|
|
pBar.low < ppBar.low &&
|
|
pBar.low < cBar.low &&
|
|
zBar.open > pBar.low &&
|
|
//
|
|
appliedPrice > pBar.low &&
|
|
appliedPrice < pBar.GetDown()
|
|
//
|
|
;
|
|
bool isPressuredSwingLow =
|
|
isSwingLow &&
|
|
hasFiboToUpPressure;
|
|
bool isPressuredStrongSwingLow =
|
|
pBar.IsBullish() &&
|
|
isPressuredSwingLow;
|
|
|
|
//
|
|
bool isSwingHigh =
|
|
//
|
|
pBar.high > ppBar.high &&
|
|
pBar.high > cBar.high &&
|
|
zBar.open < pBar.high &&
|
|
//
|
|
appliedPrice < pBar.high &&
|
|
appliedPrice > pBar.GetUp()
|
|
//
|
|
;
|
|
bool isPressuredSwingHigh =
|
|
isSwingHigh &&
|
|
hasFiboToDownPressure;
|
|
bool isPressuredStrongSwingHigh =
|
|
pBar.IsBearish() &&
|
|
isPressuredSwingHigh;
|
|
|
|
//
|
|
bool hasValidSwing =
|
|
isBullish
|
|
? isSwingLow
|
|
: isSwingHigh;
|
|
bool hasValidPressuredSwing =
|
|
isBullish
|
|
? isPressuredSwingLow
|
|
: isPressuredSwingHigh;
|
|
bool hasValidPressuredStrongSwing =
|
|
isBullish
|
|
? isPressuredStrongSwingLow
|
|
: isPressuredStrongSwingHigh;
|
|
if (hasValidSwing)
|
|
{
|
|
swingBar = pBar;
|
|
}
|
|
if (hasValidPressuredSwing)
|
|
{
|
|
swingBar = pBar;
|
|
}
|
|
if (hasValidPressuredStrongSwing)
|
|
{
|
|
swingBar = pBar;
|
|
}
|
|
|
|
//
|
|
bool isCBarBreaked = IsBarBreak(
|
|
appliedPrice,
|
|
forDir,
|
|
cBar //
|
|
);
|
|
if (isCBarBreaked)
|
|
{
|
|
breakerBar = cBar;
|
|
}
|
|
bool isPBarBreaked = IsBarBreak(
|
|
appliedPrice,
|
|
forDir,
|
|
pBar //
|
|
);
|
|
if (!isCBarBreaked && isPBarBreaked)
|
|
{
|
|
breakerBar = pBar;
|
|
}
|
|
else
|
|
{
|
|
isPBarBreaked = false;
|
|
}
|
|
bool isPPBarBreaked = IsBarBreak(
|
|
appliedPrice,
|
|
forDir,
|
|
ppBar //
|
|
);
|
|
if (!isCBarBreaked &&
|
|
!isPBarBreaked &&
|
|
isPPBarBreaked)
|
|
{
|
|
breakerBar = ppBar;
|
|
}
|
|
else
|
|
{
|
|
isPPBarBreaked = false;
|
|
}
|
|
bool isBoxBreaked = isCBarBreaked ||
|
|
isPBarBreaked ||
|
|
isPPBarBreaked;
|
|
|
|
//
|
|
bool isCBarRejected = IsBarReject(
|
|
appliedPrice,
|
|
forDir,
|
|
cBar //
|
|
);
|
|
if (isCBarRejected)
|
|
{
|
|
rejectionBar = cBar;
|
|
}
|
|
bool isPBarRejected = IsBarReject(
|
|
appliedPrice,
|
|
forDir,
|
|
pBar //
|
|
);
|
|
if (!isCBarRejected && isPBarRejected)
|
|
{
|
|
rejectionBar = pBar;
|
|
}
|
|
else
|
|
{
|
|
isPBarRejected = false;
|
|
}
|
|
bool isPPBarRejected = IsBarReject(
|
|
appliedPrice,
|
|
forDir,
|
|
ppBar //
|
|
);
|
|
if (!isCBarRejected &&
|
|
!isPBarRejected &&
|
|
isPPBarRejected)
|
|
{
|
|
rejectionBar = ppBar;
|
|
}
|
|
else
|
|
{
|
|
isPPBarRejected = false;
|
|
}
|
|
bool isBoxRejected = isCBarRejected ||
|
|
isPBarRejected ||
|
|
isPPBarRejected;
|
|
|
|
//
|
|
bool hasRejectionBar = false;
|
|
if (isBullish)
|
|
{
|
|
//
|
|
count = state.CountBullishRejectionBars();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCRejectionBar *iZone = state.bullishRejectionBars[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iZone.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
int iBarIndex = iBar.Index();
|
|
|
|
//
|
|
hasRejectionBar =
|
|
//
|
|
(iBarIndex == cBar.Index() ||
|
|
iBarIndex == pBar.Index())
|
|
//
|
|
;
|
|
if (hasRejectionBar)
|
|
{
|
|
//
|
|
if (!rejectionBar.IsValid())
|
|
{
|
|
rejectionBar = iBar;
|
|
}
|
|
|
|
//
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
count = state.CountBearishRejectionBars();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCRejectionBar *iZone = state.bearishRejectionBars[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iZone.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
int iBarIndex = iBar.Index();
|
|
|
|
//
|
|
hasRejectionBar =
|
|
//
|
|
(iBarIndex == cBar.Index() ||
|
|
iBarIndex == pBar.Index())
|
|
//
|
|
;
|
|
if (hasRejectionBar)
|
|
{
|
|
//
|
|
if (!rejectionBar.IsValid())
|
|
{
|
|
rejectionBar = iBar;
|
|
}
|
|
|
|
//
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
bool hasMomentumBar = false;
|
|
if (isBullish)
|
|
{
|
|
//
|
|
count = state.CountBullishMomentumBars();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCMomentumBar *iZone = state.bullishMomentumBars[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iZone.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
int iBarIndex = iBar.Index();
|
|
|
|
//
|
|
hasMomentumBar =
|
|
//
|
|
(iBarIndex == cBar.Index() ||
|
|
iBarIndex == pBar.Index())
|
|
//
|
|
;
|
|
if (hasMomentumBar)
|
|
{
|
|
//
|
|
if (!momentumBar.IsValid())
|
|
{
|
|
momentumBar = iBar;
|
|
}
|
|
|
|
//
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
count = state.CountBearishMomentumBars();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCMomentumBar *iZone = state.bearishMomentumBars[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iZone.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
int iBarIndex = iBar.Index();
|
|
|
|
//
|
|
hasMomentumBar =
|
|
//
|
|
(iBarIndex == cBar.Index() ||
|
|
iBarIndex == pBar.Index())
|
|
//
|
|
;
|
|
if (hasMomentumBar)
|
|
{
|
|
//
|
|
if (!momentumBar.IsValid())
|
|
{
|
|
momentumBar = iBar;
|
|
}
|
|
|
|
//
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
bool hasSwing = false;
|
|
if (isBullish)
|
|
{
|
|
//
|
|
count = state.CountSwingLows();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCSwing *iSwing = state.swingLows[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iSwing.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
int iBarIndex = iBar.Index();
|
|
|
|
//
|
|
hasSwing =
|
|
//
|
|
(iBarIndex == cBar.Index() ||
|
|
iBarIndex == pBar.Index())
|
|
//
|
|
;
|
|
if (hasSwing)
|
|
{
|
|
//
|
|
if (!swingBar.IsValid())
|
|
{
|
|
swingBar = iBar;
|
|
}
|
|
|
|
//
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//
|
|
count = state.CountSwingHighs();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
//
|
|
XCSwing *iSwing = state.swingHighs[i];
|
|
|
|
//
|
|
XOHCL iBar;
|
|
bool isFilled = iSwing.FillBar(iBar);
|
|
if (!isFilled)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
int iBarIndex = iBar.Index();
|
|
|
|
//
|
|
hasSwing =
|
|
//
|
|
(iBarIndex == cBar.Index() ||
|
|
iBarIndex == pBar.Index())
|
|
//
|
|
;
|
|
if (hasSwing)
|
|
{
|
|
//
|
|
if (!swingBar.IsValid())
|
|
{
|
|
swingBar = iBar;
|
|
}
|
|
|
|
//
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
bool hasRequiredValidations =
|
|
//
|
|
(hasRejectionBar ||
|
|
hasMomentumBar)
|
|
//
|
|
||
|
|
//
|
|
(hasRejectionBar ||
|
|
hasSwing)
|
|
//
|
|
||
|
|
//
|
|
(hasMomentumBar ||
|
|
hasSwing)
|
|
//
|
|
;
|
|
|
|
//
|
|
result =
|
|
//
|
|
(isBoxBreaked &&
|
|
(hasRequiredValidations ||
|
|
hasValidPressuredSwing))
|
|
//
|
|
||
|
|
//
|
|
(isBoxRejected &&
|
|
(hasRequiredValidations ||
|
|
hasValidPressuredSwing))
|
|
//
|
|
;
|
|
if (result)
|
|
{
|
|
//
|
|
selectedBoxIDX = j;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//
|
|
result =
|
|
result &&
|
|
(isBullish
|
|
? zBar.open >= box.upper
|
|
: zBar.open <= box.lower) &&
|
|
IsValidIndex(selectedBoxIDX);
|
|
if (result)
|
|
{
|
|
appliedBox = supResBoxes[selectedBoxIDX];
|
|
}
|
|
|
|
//
|
|
zBar.Clean();
|
|
cBar.Clean();
|
|
pBar.Clean();
|
|
ppBar.Clean();
|
|
Clean(supports);
|
|
Clean(resistances);
|
|
Clean(supResBoxes);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
//
|
|
ulong chartID = visionCycleHelper.mPOIDrawer.ChartIdentification();
|
|
int subWindow = visionCycleHelper.mPOIDrawer.SubWindowIdentification();
|
|
|
|
//
|
|
if (pivot > 0)
|
|
{
|
|
//
|
|
string name = "Pivot_" + symbol + ToString(period) + ToString(pivot) + "_";
|
|
CChartObjectHLine *iObj;
|
|
iObj = new CChartObjectHLine();
|
|
bool isCreated = iObj.Create(
|
|
chartID,
|
|
name,
|
|
subWindow,
|
|
pivot //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
//
|
|
iObj.Color(clrLime);
|
|
mObjects.Add(iObj);
|
|
}
|
|
}
|
|
|
|
//
|
|
if (point > 0)
|
|
{
|
|
//
|
|
string name = "Point_" + symbol + ToString(period) + ToString(pivot) + "_";
|
|
CChartObjectHLine *iObj;
|
|
iObj = new CChartObjectHLine();
|
|
bool isCreated = iObj.Create(
|
|
chartID,
|
|
name,
|
|
subWindow,
|
|
point //
|
|
);
|
|
if (isCreated)
|
|
{
|
|
//
|
|
iObj.Color(clrLime);
|
|
mObjects.Add(iObj);
|
|
}
|
|
}
|