1291 lines
37 KiB
Plaintext
1291 lines
37 KiB
Plaintext
|
|
//
|
|
// Fix Signal TP Based On Working Zone ...
|
|
// double maxAllowedTP =
|
|
// hasLong
|
|
// ? mXWZConditions.workingZone.upper
|
|
// : mXWZConditions.workingZone.lower;
|
|
// bool canApplyMaxAlowedTP = (hasLong &&
|
|
// signal.tp > maxAllowedTP) ||
|
|
// (!hasLong && signal.tp < maxAllowedTP);
|
|
// if (canApplyMaxAlowedTP)
|
|
// {
|
|
// signal.tp = maxAllowedTP;
|
|
// }
|
|
|
|
//
|
|
// Configuring Global Protector ...
|
|
// signal.trailSL = true;
|
|
// signal.trailSLStartOnReachTPLevel = 3;
|
|
// signal.fullTPLevel = signal.GetRiskRewardRatio();
|
|
|
|
// //
|
|
// mXSupDemOBSSignalDetector.RemoveDraws();
|
|
// mXSupDemOBSSignalDetector.DrawConditions(
|
|
// mXSupDemOBSConditions,
|
|
// mVisionCycleHelper.mPOIDrawer //
|
|
// );
|
|
|
|
// //
|
|
// mXSupDemOBSSignalDetector.RemoveWorkingZoneDraws();
|
|
// mXSupDemOBSSignalDetector.DrawWorkingZone(
|
|
// mXSupDemOBSConditions,
|
|
// mVisionCycleHelper.mPOIDrawer //
|
|
// );
|
|
|
|
//
|
|
// bool canReplaceTarget =
|
|
// signal.target > 0 &&
|
|
// (hasLong
|
|
// ? signal.target > signal.tp
|
|
// : signal.target < signal.tp);
|
|
// if (canReplaceTarget)
|
|
// {
|
|
// //
|
|
// signal.tp = conditions.target;
|
|
// signal.target = tp;
|
|
// }
|
|
|
|
//
|
|
// consolidationState.UpdateTo(cTime);
|
|
// XPOIState filtered;
|
|
// consolidationState.Filter(
|
|
// filtered,
|
|
// NULL,
|
|
// XZONE_STATE_PASSED,
|
|
// false,
|
|
// XZONE_STATE_FAILED,
|
|
// false,
|
|
// XZONE_STATE_FAILED,
|
|
// false,
|
|
// XZONE_STATE_IGNORED,
|
|
// false //
|
|
// );
|
|
// XCBaseObject *objects[];
|
|
// int objectsCount = drawer.DrawState(
|
|
// filtered,
|
|
// objects //
|
|
// );
|
|
// if (IsValidSize(objectsCount))
|
|
// {
|
|
// //
|
|
// Print("");
|
|
// }
|
|
|
|
// //
|
|
// XOBFVG activeObfvgs[];
|
|
// int activeObfvgsCount = ExtractOBFVGs(
|
|
// activeObfvgs,
|
|
// consolidationState,
|
|
// analyseState //
|
|
// );
|
|
// bool hasActiveOBFVGs = IsValidSize(activeObfvgsCount);
|
|
// if (hasActiveOBFVGs)
|
|
// {
|
|
// //
|
|
// SpecifiedUpdateTo(activeObfvgs);
|
|
// for (int i = 0; i < activeObfvgsCount; i++)
|
|
// {
|
|
// //
|
|
// XCBaseObject *objects[];
|
|
// int objectsCount = drawer.DrawOBFVG(
|
|
// activeObfvgs[i],
|
|
// objects //
|
|
// );
|
|
// }
|
|
// }
|
|
|
|
// //
|
|
// // Swings ...
|
|
// bool lookupSwings = ArraySize(mSwingLows) < mMaxRequiredPOIs ||
|
|
// ArraySize(mSwingHighs) < mMaxRequiredPOIs;
|
|
// lookupSwings =
|
|
// ignoreMaxAllowed
|
|
// ? true
|
|
// : lookupSwings;
|
|
// if (has &&
|
|
// lookupSwings)
|
|
// {
|
|
// }
|
|
|
|
// //
|
|
// // Momentum Bar ...
|
|
// bool lookupMomentums = ArraySize(mBullishMomentumBars) < mMaxRequiredPOIs ||
|
|
// ArraySize(mBearishMomentumBars) < mMaxRequiredPOIs;
|
|
// lookupMomentums =
|
|
// ignoreMaxAllowed
|
|
// ? true
|
|
// : lookupMomentums;
|
|
// if (has &&
|
|
// lookupMomentums)
|
|
// {
|
|
// }
|
|
|
|
// //
|
|
// // Rejection Bar ...
|
|
// bool lookupRejections = ArraySize(mBullishRejectionBars) < mMaxRequiredPOIs ||
|
|
// ArraySize(mBearishRejectionBars) < mMaxRequiredPOIs;
|
|
// lookupRejections =
|
|
// ignoreMaxAllowed
|
|
// ? true
|
|
// : lookupRejections;
|
|
// if (has &&
|
|
// lookupRejections)
|
|
// {
|
|
// }
|
|
|
|
// //
|
|
// // Support ...
|
|
// bool lookupSupports = ArraySize(mSupportZones) < mMaxRequiredPOIs;
|
|
// lookupSupports =
|
|
// ignoreMaxAllowed
|
|
// ? true
|
|
// : lookupSupports;
|
|
// if (has &&
|
|
// lookupSupports)
|
|
// {
|
|
// }
|
|
|
|
// //
|
|
// // Demand ...
|
|
// bool lookupDemands = ArraySize(mDemandZones) < mMaxRequiredPOIs;
|
|
// lookupDemands =
|
|
// ignoreMaxAllowed
|
|
// ? true
|
|
// : lookupDemands;
|
|
// if (has &&
|
|
// lookupDemands)
|
|
// {
|
|
// }
|
|
|
|
// //
|
|
// // Resistance ...
|
|
// bool lookupResistance = ArraySize(mResistanceZones) < mMaxRequiredPOIs;
|
|
// lookupResistance =
|
|
// ignoreMaxAllowed
|
|
// ? true
|
|
// : lookupResistance;
|
|
// if (has &&
|
|
// lookupResistance)
|
|
// {
|
|
// }
|
|
|
|
// //
|
|
// // Supply ...
|
|
// bool lookupSupplies = ArraySize(mSupplyZones) < mMaxRequiredPOIs;
|
|
// lookupSupplies =
|
|
// ignoreMaxAllowed
|
|
// ? true
|
|
// : lookupSupplies;
|
|
// if (has &&
|
|
// lookupSupplies)
|
|
// {
|
|
// }
|
|
|
|
// //
|
|
// // OrderBlock ...
|
|
// bool lookupOrderBlocks = ArraySize(mBullishOrderBlocks) < mMaxRequiredPOIs ||
|
|
// ArraySize(mBearishOrderBlocks) < mMaxRequiredPOIs;
|
|
// lookupOrderBlocks =
|
|
// ignoreMaxAllowed
|
|
// ? true
|
|
// : lookupOrderBlocks;
|
|
// if (has &&
|
|
// lookupOrderBlocks)
|
|
// {
|
|
// }
|
|
|
|
// //
|
|
// // FairValueGap ...
|
|
// bool lookupFairValeGaps = ArraySize(mBullishFairValueGaps) < mMaxRequiredPOIs ||
|
|
// ArraySize(mBearishFairValueGaps) < mMaxRequiredPOIs;
|
|
// lookupFairValeGaps =
|
|
// ignoreMaxAllowed
|
|
// ? true
|
|
// : lookupFairValeGaps;
|
|
// if (has &&
|
|
// (lookupFairValeGaps))
|
|
// {
|
|
// }
|
|
|
|
//
|
|
XCBaseObject *stateObjects[];
|
|
int stateObjectsCount = drawer.DrawState(
|
|
decisionState,
|
|
stateObjects,
|
|
false, //
|
|
true, // ignoreSwingHighs
|
|
true, // ignoreSwingLows
|
|
true, // ignoreSupportZones
|
|
true, // ignoreResistanceZones
|
|
true, // ignoreSupplyZones
|
|
true, // ignoreDemandZones
|
|
true, // ignoreBullishOrderBlocks
|
|
true, // ignoreBearishOrderBlocks
|
|
true, // ignoreBullishFairValueGaps
|
|
true, // ignoreBearishFairValueGaps
|
|
true, // ignoreBullishRejectionBars
|
|
true, // ignoreBearishRejectionBars
|
|
true, // ignoreBullishMomentumBars
|
|
true, // ignoreBearishMomentumBars
|
|
false, // ignoreBullishConsolidationZones
|
|
false // ignoreBearishConsolidationZones
|
|
);
|
|
|
|
//
|
|
// Draw ...
|
|
if (hasSelectedConsolidationZone)
|
|
{
|
|
//
|
|
XCConsolidationZoneObject *iObj;
|
|
selectedConsolidationZone.to = cTime;
|
|
bool isCreated = drawer.CreateConsolidationZone(
|
|
selectedConsolidationZone,
|
|
iObj //
|
|
);
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
// //
|
|
// // Based On Waiting Zones ...
|
|
// has = isBarInited &&
|
|
// hasWorkingZone;
|
|
// if (has)
|
|
// {
|
|
// //
|
|
// XOBFVG tmpZones[];
|
|
// Copy(
|
|
// workingZone.waitingZones,
|
|
// tmpZones //
|
|
// );
|
|
|
|
// //
|
|
// while (HasChild(tmpZones))
|
|
// {
|
|
// //
|
|
// XOBFVG iOBFVG;
|
|
|
|
// //
|
|
// idx = GetYoungest(tmpZones);
|
|
// if (!IsValidIndex(idx))
|
|
// {
|
|
// //
|
|
// iOBFVG.Clean();
|
|
// break;
|
|
// }
|
|
|
|
// //
|
|
// iOBFVG = tmpZones[idx];
|
|
// ArrayRemove(
|
|
// tmpZones,
|
|
// idx,
|
|
// 1 //
|
|
// );
|
|
|
|
// //
|
|
// double iTarget =
|
|
// isSelectedZonDirBullish
|
|
// ? iOBFVG.ob.Lower()
|
|
// : iOBFVG.ob.Upper();
|
|
|
|
// //
|
|
// has =
|
|
// isSelectedZonDirBullish
|
|
// ? cBar.high < iTarget
|
|
// : cBar.low > iTarget;
|
|
|
|
// //
|
|
// if (has)
|
|
// {
|
|
// //
|
|
// Add(
|
|
// iTarget,
|
|
// targets //
|
|
// );
|
|
// }
|
|
|
|
// //
|
|
// iOBFVG.Clean();
|
|
// }
|
|
|
|
// //
|
|
// Clean(tmpZones);
|
|
// }
|
|
|
|
// //
|
|
// // Based On Breaked Zones ...
|
|
// has = isBarInited &&
|
|
// hasBreakedZones;
|
|
// if (has)
|
|
// {
|
|
// //
|
|
// XOBFVG tmpZones[];
|
|
// Copy(
|
|
// workingZone.breakedZones,
|
|
// tmpZones //
|
|
// );
|
|
|
|
// //
|
|
// while (HasChild(tmpZones))
|
|
// {
|
|
// //
|
|
// XOBFVG iOBFVG;
|
|
|
|
// //
|
|
// idx = GetYoungest(tmpZones);
|
|
// if (!IsValidIndex(idx))
|
|
// {
|
|
// //
|
|
// iOBFVG.Clean();
|
|
// break;
|
|
// }
|
|
|
|
// //
|
|
// iOBFVG = tmpZones[idx];
|
|
// ArrayRemove(
|
|
// tmpZones,
|
|
// idx,
|
|
// 1 //
|
|
// );
|
|
|
|
// //
|
|
// double iTarget =
|
|
// isSelectedZonDirBullish
|
|
// ? iOBFVG.ob.Lower()
|
|
// : iOBFVG.ob.Upper();
|
|
|
|
// //
|
|
// has =
|
|
// isSelectedZonDirBullish
|
|
// ? cBar.high < iTarget
|
|
// : cBar.low > iTarget;
|
|
|
|
// //
|
|
// if (has)
|
|
// {
|
|
// //
|
|
// Add(
|
|
// iTarget,
|
|
// targets //
|
|
// );
|
|
// }
|
|
|
|
// //
|
|
// iOBFVG.Clean();
|
|
// }
|
|
|
|
// //
|
|
// Clean(tmpZones);
|
|
// }
|
|
|
|
// //
|
|
// // Based On Priority ...
|
|
// if (hasPriority)
|
|
// {
|
|
// //
|
|
// switch (priority)
|
|
// {
|
|
// //
|
|
// case X121SMC_XWZ_PRIORITY_WEAK:
|
|
// //
|
|
// if (isSelectedZonDirBullish)
|
|
// {
|
|
// //
|
|
// // Weak ...
|
|
// Add(
|
|
// workingZone.supplyZone.Lower(),
|
|
// targets //
|
|
// );
|
|
// }
|
|
// else
|
|
// {
|
|
// //
|
|
// // Weak ...
|
|
// Add(
|
|
// workingZone.demandZone.Upper(),
|
|
// targets //
|
|
// );
|
|
// }
|
|
// break;
|
|
|
|
// //
|
|
// case X121SMC_XWZ_PRIORITY_LOW:
|
|
// //
|
|
// if (isSelectedZonDirBullish)
|
|
// {
|
|
// //
|
|
// // Weak ...
|
|
// Add(
|
|
// workingZone.supplyZone.Lower(),
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // Low ...
|
|
// Add(
|
|
// workingZone.quarter1,
|
|
// targets //
|
|
// );
|
|
// }
|
|
// else
|
|
// {
|
|
// //
|
|
// // Weak ...
|
|
// Add(
|
|
// workingZone.demandZone.Upper(),
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // Low ...
|
|
// Add(
|
|
// workingZone.quarter3,
|
|
// targets //
|
|
// );
|
|
// }
|
|
// break;
|
|
|
|
// //
|
|
// case X121SMC_XWZ_PRIORITY_REGULAR:
|
|
// //
|
|
// if (isSelectedZonDirBullish)
|
|
// {
|
|
// //
|
|
// // Weak ...
|
|
// Add(
|
|
// workingZone.supplyZone.Lower(),
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // Low ...
|
|
// Add(
|
|
// workingZone.quarter1,
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // Regular ...
|
|
// Add(
|
|
// workingZone.quarter2,
|
|
// targets //
|
|
// );
|
|
// }
|
|
// else
|
|
// {
|
|
// //
|
|
// // Weak ...
|
|
// Add(
|
|
// workingZone.demandZone.Upper(),
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // Low ...
|
|
// Add(
|
|
// workingZone.quarter3,
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // Regular ...
|
|
// Add(
|
|
// workingZone.quarter2,
|
|
// targets //
|
|
// );
|
|
// }
|
|
// break;
|
|
|
|
// //
|
|
// case X121SMC_XWZ_PRIORITY_HIGH:
|
|
// //
|
|
// if (isSelectedZonDirBullish)
|
|
// {
|
|
// //
|
|
// // Weak ...
|
|
// Add(
|
|
// workingZone.supplyZone.Lower(),
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // Low ...
|
|
// Add(
|
|
// workingZone.quarter1,
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // Regular ...
|
|
// Add(
|
|
// workingZone.quarter2,
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // High ...
|
|
// Add(
|
|
// workingZone.quarter3,
|
|
// targets //
|
|
// );
|
|
// }
|
|
// else
|
|
// {
|
|
// //
|
|
// // Weak ...
|
|
// Add(
|
|
// workingZone.demandZone.Upper(),
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // Low ...
|
|
// Add(
|
|
// workingZone.quarter3,
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // Regular ...
|
|
// Add(
|
|
// workingZone.quarter2,
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // High ...
|
|
// Add(
|
|
// workingZone.quarter1,
|
|
// targets //
|
|
// );
|
|
// }
|
|
// break;
|
|
|
|
// //
|
|
// case X121SMC_XWZ_PRIORITY_STRONG_HIGH:
|
|
// //
|
|
// if (isSelectedZonDirBullish)
|
|
// {
|
|
// //
|
|
// // Weak ...
|
|
// Add(
|
|
// workingZone.supplyZone.Lower(),
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // Low ...
|
|
// Add(
|
|
// workingZone.quarter1,
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // Regular ...
|
|
// Add(
|
|
// workingZone.quarter2,
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // High ...
|
|
// Add(
|
|
// workingZone.quarter3,
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // Strong High ...
|
|
// Add(
|
|
// workingZone.demandZone.Upper(),
|
|
// targets //
|
|
// );
|
|
// }
|
|
// else
|
|
// {
|
|
// //
|
|
// // Weak ...
|
|
// Add(
|
|
// workingZone.demandZone.Upper(),
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // Low ...
|
|
// Add(
|
|
// workingZone.quarter3,
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // Regular ...
|
|
// Add(
|
|
// workingZone.quarter2,
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // High ...
|
|
// Add(
|
|
// workingZone.quarter1,
|
|
// targets //
|
|
// );
|
|
|
|
// //
|
|
// // Strong High ...
|
|
// Add(
|
|
// workingZone.supplyZone.Lower(),
|
|
// targets //
|
|
// );
|
|
// }
|
|
// break;
|
|
// }
|
|
// }
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
// Based On Consolidation Zones ...
|
|
has = isBarInited &&
|
|
decisionState.HasConsolidationZones();
|
|
if (has)
|
|
{
|
|
//
|
|
XConsolidationZone tmpZones[];
|
|
if (isSelectedZonDirBullish)
|
|
{
|
|
//
|
|
Copy(
|
|
decisionState.bullishConsolidationZones,
|
|
tmpZones //
|
|
);
|
|
}
|
|
else
|
|
{
|
|
//
|
|
Copy(
|
|
decisionState.bearishConsolidationZones,
|
|
tmpZones //
|
|
);
|
|
}
|
|
|
|
//
|
|
while (HasChild(tmpZones))
|
|
{
|
|
//
|
|
idx = GetYoungest(tmpZones);
|
|
if (!IsValidIndex(idx))
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
XConsolidationZone iZone = tmpZones[idx];
|
|
|
|
//
|
|
ArrayRemove(
|
|
tmpZones,
|
|
idx,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
hasSelectedConsolidationZone =
|
|
isSelectedZonDirBullish
|
|
? cBar.low < iZone.upper
|
|
: cBar.high < iZone.lower;
|
|
if (hasSelectedConsolidationZone)
|
|
{
|
|
//
|
|
selectedConsolidationZone = iZone;
|
|
iZone.Clean();
|
|
break;
|
|
}
|
|
|
|
//
|
|
iZone.Clean();
|
|
}
|
|
|
|
//
|
|
Clean(tmpZones);
|
|
|
|
//
|
|
if (hasSelectedConsolidationZone)
|
|
{
|
|
//
|
|
XCConsolidationZoneObject *iObj;
|
|
selectedConsolidationZone.to = cTime;
|
|
bool isCreated = drawer.CreateConsolidationZone(
|
|
selectedConsolidationZone,
|
|
iObj //
|
|
);
|
|
|
|
//
|
|
double iSL =
|
|
isSelectedZonDirBullish
|
|
? selectedConsolidationZone.lower
|
|
: selectedConsolidationZone.upper;
|
|
double iSLDiff = MathAbs(iSL - pivot);
|
|
has =
|
|
iSLDiff > 0 &&
|
|
iSLDiff <= maxAllowedSLDistanceInPoint * points;
|
|
if (has)
|
|
{
|
|
//
|
|
Add(
|
|
iSL,
|
|
sls //
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Based On Supply and Demand Zones ...
|
|
|
|
//
|
|
// Demand Zones ...
|
|
has = hasWorkingZone &&
|
|
workingZone.HasDemandZones();
|
|
if (has)
|
|
{
|
|
//
|
|
XCDemandZone *tmpZones[];
|
|
Copy(
|
|
workingZone.demandZones,
|
|
tmpZones //
|
|
);
|
|
XCDemandZone *selectedDemand = NULL;
|
|
|
|
//
|
|
while (HasChild(tmpZones))
|
|
{
|
|
//
|
|
idx = GetLowest(tmpZones);
|
|
has = IsValidIndex(idx);
|
|
if (!has)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
XCDemandZone *iZone = tmpZones[idx];
|
|
ArrayRemove(
|
|
tmpZones,
|
|
idx,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
// Validate Zone ...
|
|
has =
|
|
isSelectedZonDirBullish
|
|
? IsBelowDiff(
|
|
iZone,
|
|
selectedZone.ob,
|
|
true // Ignore Inside ...
|
|
)
|
|
: IsAboveDiff(
|
|
iZone,
|
|
selectedZone.ob,
|
|
true // Ignore Inside ...
|
|
);
|
|
if (!has)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
has =
|
|
selectedDemand == NULL
|
|
? true
|
|
: isSelectedZonDirBullish
|
|
? selectedDemand.Lower() < iZone.Lower()
|
|
: selectedDemand.Upper() > iZone.Upper();
|
|
if (!has)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
selectedDemand = iZone;
|
|
|
|
//
|
|
}
|
|
|
|
//
|
|
has = selectedDemand != NULL;
|
|
if (has)
|
|
{
|
|
//
|
|
XCDemandZoneObject *iObj;
|
|
bool isCreated = drawer.CreateDemandZone(
|
|
selectedDemand,
|
|
iObj //
|
|
);
|
|
|
|
//
|
|
double iSL =
|
|
isSelectedZonDirBullish
|
|
? selectedDemand.Lower()
|
|
: selectedDemand.Upper();
|
|
double iSLDiff = MathAbs(iSL - pivot);
|
|
has =
|
|
iSLDiff > 0 &&
|
|
iSLDiff <= maxAllowedSLDistanceInPoint * points;
|
|
if (has)
|
|
{
|
|
//
|
|
Add(
|
|
iSL,
|
|
sls //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
Clean(tmpZones);
|
|
ZeroMemory(selectedDemand);
|
|
}
|
|
|
|
//
|
|
// Support Zones ...
|
|
has = hasWorkingZone &&
|
|
workingZone.HasSupportZones();
|
|
if (has)
|
|
{
|
|
//
|
|
XCSupportZone *tmpZones[];
|
|
Copy(
|
|
workingZone.supportZones,
|
|
tmpZones //
|
|
);
|
|
XCSupportZone *selectedSupport = NULL;
|
|
|
|
//
|
|
while (HasChild(tmpZones))
|
|
{
|
|
//
|
|
idx = GetLowest(tmpZones);
|
|
has = IsValidIndex(idx);
|
|
if (!has)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
XCSupportZone *iZone = tmpZones[idx];
|
|
ArrayRemove(
|
|
tmpZones,
|
|
idx,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
// Validate Zone ...
|
|
has =
|
|
isSelectedZonDirBullish
|
|
? IsBelowDiff(
|
|
iZone,
|
|
selectedZone.ob,
|
|
true // Ignore Inside ...
|
|
)
|
|
: IsAboveDiff(
|
|
iZone,
|
|
selectedZone.ob,
|
|
true // Ignore Inside ...
|
|
);
|
|
if (!has)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
has =
|
|
selectedSupport == NULL
|
|
? true
|
|
: isSelectedZonDirBullish
|
|
? selectedSupport.Lower() < iZone.Lower()
|
|
: selectedSupport.Upper() > iZone.Upper();
|
|
if (!has)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
selectedSupport = iZone;
|
|
|
|
//
|
|
}
|
|
|
|
//
|
|
has = selectedSupport != NULL;
|
|
if (has)
|
|
{
|
|
//
|
|
XCSupportZoneObject *iObj;
|
|
bool isCreated = drawer.CreateSupportZone(
|
|
selectedSupport,
|
|
iObj //
|
|
);
|
|
|
|
//
|
|
double iSL = isSelectedZonDirBullish
|
|
? selectedSupport.Lower()
|
|
: selectedSupport.Upper();
|
|
double iSLDiff = MathAbs(iSL - pivot);
|
|
has =
|
|
iSLDiff > 0 &&
|
|
iSLDiff <= maxAllowedSLDistanceInPoint * points;
|
|
if (has)
|
|
{
|
|
//
|
|
Add(
|
|
iSL,
|
|
sls //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
Clean(tmpZones);
|
|
ZeroMemory(selectedSupport);
|
|
}
|
|
|
|
//
|
|
// Supply Zones ...
|
|
has = hasWorkingZone &&
|
|
workingZone.HasSupplyZones();
|
|
if (has)
|
|
{
|
|
//
|
|
XCSupplyZone *tmpZones[];
|
|
Copy(
|
|
workingZone.supplyZones,
|
|
tmpZones //
|
|
);
|
|
XCSupplyZone *selectedSupply = NULL;
|
|
|
|
//
|
|
while (HasChild(tmpZones))
|
|
{
|
|
//
|
|
idx = GetHighest(tmpZones);
|
|
has = IsValidIndex(idx);
|
|
if (!has)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
XCSupplyZone *iZone = tmpZones[idx];
|
|
ArrayRemove(
|
|
tmpZones,
|
|
idx,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
// Validate Zone ...
|
|
has =
|
|
!isSelectedZonDirBullish
|
|
? IsAboveDiff(
|
|
iZone,
|
|
selectedZone.ob,
|
|
true // Ignore Inside ...
|
|
)
|
|
: IsBelowDiff(
|
|
iZone,
|
|
selectedZone.ob,
|
|
true // Ignore Inside ...
|
|
);
|
|
if (!has)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
has =
|
|
selectedSupply == NULL
|
|
? true
|
|
: !isSelectedZonDirBullish
|
|
? selectedSupply.Upper() > iZone.Upper()
|
|
: selectedSupply.Lower() < iZone.Lower();
|
|
if (!has)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
selectedSupply = iZone;
|
|
|
|
//
|
|
}
|
|
|
|
//
|
|
has = selectedSupply != NULL;
|
|
if (has)
|
|
{
|
|
//
|
|
XCSupplyZoneObject *iObj;
|
|
bool isCreated = drawer.CreateSupplyZone(
|
|
selectedSupply,
|
|
iObj //
|
|
);
|
|
|
|
//
|
|
double iSL =
|
|
!isSelectedZonDirBullish
|
|
? selectedSupply.Upper()
|
|
: selectedSupply.Lower();
|
|
double iSLDiff = MathAbs(iSL - pivot);
|
|
has =
|
|
iSLDiff > 0 &&
|
|
iSLDiff <= maxAllowedSLDistanceInPoint * points;
|
|
if (has)
|
|
{
|
|
//
|
|
Add(
|
|
iSL,
|
|
sls //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
Clean(tmpZones);
|
|
ZeroMemory(selectedSupply);
|
|
}
|
|
|
|
//
|
|
// Resistance Zones ...
|
|
has = hasWorkingZone &&
|
|
workingZone.HasDemandZones();
|
|
if (has)
|
|
{
|
|
//
|
|
XCResistanceZone *tmpZones[];
|
|
Copy(
|
|
workingZone.resistanceZones,
|
|
tmpZones //
|
|
);
|
|
XCResistanceZone *selectedResistance = NULL;
|
|
|
|
//
|
|
while (HasChild(tmpZones))
|
|
{
|
|
//
|
|
idx = GetHighest(tmpZones);
|
|
has = IsValidIndex(idx);
|
|
if (!has)
|
|
{
|
|
break;
|
|
}
|
|
|
|
//
|
|
XCResistanceZone *iZone = tmpZones[idx];
|
|
ArrayRemove(
|
|
tmpZones,
|
|
idx,
|
|
1 //
|
|
);
|
|
|
|
//
|
|
// Validate Zone ...
|
|
has =
|
|
!isSelectedZonDirBullish
|
|
? IsAboveDiff(
|
|
iZone,
|
|
selectedZone.ob,
|
|
true // Ignore Inside ...
|
|
)
|
|
: IsBelowDiff(
|
|
iZone,
|
|
selectedZone.ob,
|
|
true // Ignore Inside ...
|
|
);
|
|
if (!has)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
has =
|
|
selectedResistance == NULL
|
|
? true
|
|
: !isSelectedZonDirBullish
|
|
? selectedResistance.Upper() < iZone.Upper()
|
|
: selectedResistance.Lower() > iZone.Lower();
|
|
if (!has)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//
|
|
selectedResistance = iZone;
|
|
|
|
//
|
|
}
|
|
|
|
//
|
|
has = selectedResistance != NULL;
|
|
if (has)
|
|
{
|
|
//
|
|
XCResistanceZoneObject *iObj;
|
|
bool isCreated = drawer.CreateResistanceZone(
|
|
selectedResistance,
|
|
iObj //
|
|
);
|
|
|
|
//
|
|
double iSL =
|
|
!isSelectedZonDirBullish
|
|
? selectedResistance.Upper()
|
|
: selectedResistance.Lower();
|
|
double iSLDiff = MathAbs(iSL - pivot);
|
|
has =
|
|
iSLDiff > 0 &&
|
|
iSLDiff <= maxAllowedSLDistanceInPoint * points;
|
|
if (has)
|
|
{
|
|
//
|
|
Add(
|
|
iSL,
|
|
sls //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
Clean(tmpZones);
|
|
ZeroMemory(selectedResistance);
|
|
}
|
|
|
|
//
|
|
// Based On Passed Bars ...
|
|
XOHCL passedBar;
|
|
bool isPassed = false;
|
|
bool isBodyState = false;
|
|
ENUM_X_DIRECTION passedDir = selectedZone.GetDirection();
|
|
|
|
//
|
|
// Started Bar ...
|
|
isPassed = selectedZone.ob.IsStarted(
|
|
passedDir,
|
|
passedBar,
|
|
isBodyState //
|
|
);
|
|
if (isPassed)
|
|
{
|
|
//
|
|
double iSL =
|
|
isSelectedZonDirBullish
|
|
? passedBar.low
|
|
: passedBar.high;
|
|
double iSLDiff = MathAbs(iSL - pivot);
|
|
has =
|
|
iSLDiff > 0 &&
|
|
iSLDiff <= maxAllowedSLDistanceInPoint * points;
|
|
if (has)
|
|
{
|
|
//
|
|
Add(
|
|
iSL,
|
|
sls //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Activation Bar ...
|
|
passedBar.Clean();
|
|
isPassed = selectedZone.ob.IsActivated(
|
|
passedDir,
|
|
passedBar,
|
|
isBodyState //
|
|
);
|
|
if (isPassed)
|
|
{
|
|
//
|
|
double iSL =
|
|
isSelectedZonDirBullish
|
|
? passedBar.low
|
|
: passedBar.high;
|
|
double iSLDiff = MathAbs(iSL - pivot);
|
|
has =
|
|
iSLDiff > 0 &&
|
|
iSLDiff <= maxAllowedSLDistanceInPoint * points;
|
|
if (has)
|
|
{
|
|
//
|
|
Add(
|
|
iSL,
|
|
sls //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Worked Bar ...
|
|
passedBar.Clean();
|
|
isPassed = selectedZone.ob.IsActivated(
|
|
passedDir,
|
|
passedBar,
|
|
isBodyState //
|
|
);
|
|
if (isPassed)
|
|
{
|
|
//
|
|
double iSL =
|
|
isSelectedZonDirBullish
|
|
? passedBar.low
|
|
: passedBar.high;
|
|
double iSLDiff = MathAbs(iSL - pivot);
|
|
has =
|
|
iSLDiff > 0 &&
|
|
iSLDiff <= maxAllowedSLDistanceInPoint * points;
|
|
if (has)
|
|
{
|
|
//
|
|
Add(
|
|
iSL,
|
|
sls //
|
|
);
|
|
}
|
|
}
|
|
|
|
//
|
|
// Breaked Bar ...
|
|
passedBar.Clean();
|
|
isPassed = selectedZone.ob.IsActivated(
|
|
passedDir,
|
|
passedBar,
|
|
isBodyState //
|
|
);
|
|
if (isPassed)
|
|
{
|
|
//
|
|
double iSL =
|
|
isSelectedZonDirBullish
|
|
? passedBar.low
|
|
: passedBar.high;
|
|
double iSLDiff = MathAbs(iSL - pivot);
|
|
has =
|
|
iSLDiff > 0 &&
|
|
iSLDiff <= maxAllowedSLDistanceInPoint * points;
|
|
if (has)
|
|
{
|
|
//
|
|
Add(
|
|
iSL,
|
|
sls //
|
|
);
|
|
}
|
|
}
|
|
|
|
|