This commit is contained in:
2025-03-04 16:18:51 +03:30
parent ec006cd6b7
commit 52856ff815
4 changed files with 753 additions and 881 deletions
+137 -812
View File
@@ -2897,815 +2897,140 @@ int FilterZones(
// //
// //
// /** /**
// * Check Trading Conditions based on Specified Box ... * Detect Nearest Price Out of Specified Box ...
// * *
// * @param box: XBoxZone instance Reference, specified Box for Checking Conditions ... * @param box: XBoxZone instance Reference ...
// * @param appliedBox: XBoxZone instance Reference, hold's Selected Box inside Parent which trading conditions happens on it ... * @param outSideBar: XOHCL instance Reference which Represents Out Side Bar if Exists ...
// * @param swingBar: XOHCL instance Reference, holds Swing Bar if Exists ... * @param forPeriod: ENUM_TIMEFRAMES member which provides time frame of Out Bar, if not Provides used box Period as Default ...
// * @param breakerBar: XOHCL instance Reference, holds Breaker Bar if Exists ... * @param forDir: ENUM_X_DIRECTION member which Specified outSide Direction, use Box Dir as Default ...
// * @param rejectionBar: XOHCL instance Reference, holds Rejection Bar if Exists ... * @param forceBodyIn: bool value which Specifyed Body Breakes or not, Default is false ...
// * @param momentumBar: XOHCL instance Reference, holds Momentum Bar if Exists ... * @param barIndex: integer value which Specified Start Bar Index, Default is 0 ...
// * @param state: XPOIState instance Reference, provides requirement zone's for check Conditions ... *
// * @param barIndex: int, Specified Bar Index ... * @return ( bool )
// * @param forPeriod: ENUM_TIMEFRAMES member, Specified Conditions Checking Period ... */
// * bool DetectBoxNearestPriceOut(
// * @return ( bool ) XBoxZone &box,
// */ XOHCL &outSideBar,
// bool CheckBoxForTradeConditions( ENUM_TIMEFRAMES forPeriod = NULL,
// XBoxZone &box, ENUM_X_DIRECTION forDir = X_DIRECTION_NONE,
// XBoxZone &appliedBox, bool forceBodyIn = false,
// XOHCL &swingBar, int barIndex = 0 //
// XOHCL &breakerBar, )
// XOHCL &rejectionBar, {
// XOHCL &momentumBar, //
// XPOIState &state, bool result = false;
// int barIndex = 0,
// ENUM_TIMEFRAMES forPeriod = NULL // //
// ) outSideBar.Clean();
// {
// // //
// bool result = false; if (barIndex < 0)
{
// // barIndex = 0;
// swingBar.Clean(); }
// appliedBox.Clean();
// breakerBar.Clean(); //
// momentumBar.Clean(); result = box.IsValid();
// rejectionBar.Clean(); if (!result)
{
// // return result;
// if (barIndex < 0) }
// {
// barIndex = 0; //
// } if (!IsValid(forPeriod))
{
// // forPeriod = box.period;
// result = box.IsValid() && }
// state.IsValid() &&
// state.HasChild(); //
// if (!result) if (!HasDirection(forDir))
// { {
// return result; forDir = box.dir;
// } }
// // //
// if (!IsValid(forPeriod)) bool isBullish = IsBullish(forDir);
// {
// forPeriod = box.period; //
// } int fromIndex = iBarShift(
box.symbol,
// // box.period,
// string symbol = box.symbol; box.from //
// datetime cTime = iTime( );
// symbol, result = IsValidIndex(fromIndex);
// forPeriod, if (!result)
// barIndex // {
// ); return result;
}
// //
// ENUM_X_DIRECTION forDir = box.dir; //
// result = HasDirection(forDir); XOHCL iBar;
// if (!result) XOHCL iPBar;
// { bool has = false;
// return result; for (int i = barIndex; i < fromIndex; i++)
// } {
//
// // has = iBar.Init(
// bool isBullish = IsBullish(forDir); box.symbol,
forPeriod,
// // i //
// int supportsCount = 0; );
// bool hasSupports = false; if (!has)
// XCSupportZone *supports[]; {
continue;
// // }
// int resistancesCount = 0;
// bool hasResistances = false; //
// XCResistanceZone *resistances[]; has = iBar.GetPreviousBar(iPBar);
if (!has)
// // {
// XBoxZone supResBoxes[]; continue;
// int supresBoxesCount = 0; }
// bool hasSupResBoxes = false;
//
// // bool isInsideFromLower =
// int count = 0; iBar.high < box.lower &&
// bool has = false; iPBar.high > box.lower;
// // //
// has = state.HasSupportZones(); bool isInsideFromUpper =
// if (has) iBar.low > box.upper &&
// { iPBar.low < box.upper;
// //
// count = state.CountSupportZones(); //
// for (int i = 0; i < count; i++) bool isInsideBodyFromLower =
// { iPBar.GetUp() > box.lower;
// //
// XCSupportZone *iZone = state.supportZones[i]; //
bool isInsideBodyFromUpper =
// // iPBar.GetDown() < box.upper;
// iZone.To(cTime);
//
// // result =
// XBoxZone iBox; isBullish
// bool hasBox = ToBox( ? (!forceBodyIn
// iBox, ? isInsideFromLower
// iZone // : isInsideFromLower &&
// ); isInsideBodyFromLower)
// if (!hasBox) : (!forceBodyIn
// { ? isInsideFromUpper
// // : isInsideFromUpper &&
// iBox.Clean(); isInsideBodyFromUpper);
// continue; if (result)
// } {
//
// // outSideBar = iBar;
// // Check From ... break;
// bool isInside = IsBoxInside( }
// iBox, }
// box //
// ); //
// if (!isInside) iBar.Clean();
// { iPBar.Clean();
// //
// iBox.Clean(); //
// continue; return result;
// } }
// // //
// 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);
// //
// return result;
// }
// //
// // Detect Bars ...
// //
// XOHCL zBar;
// result = zBar.Init(
// symbol,
// forPeriod,
// barIndex //
// );
// if (!result)
// {
// //
// zBar.Clean();
// Clean(supports);
// Clean(resistances);
// Clean(supResBoxes);
// //
// return result;
// }
// //
// XOHCL cBar;
// result = zBar.GetPreviousBar(cBar);
// if (!result)
// {
// //
// zBar.Clean();
// cBar.Clean();
// Clean(supports);
// Clean(resistances);
// Clean(supResBoxes);
// //
// return result;
// }
// //
// XOHCL pBar;
// result = cBar.GetPreviousBar(pBar);
// if (!result)
// {
// //
// zBar.Clean();
// cBar.Clean();
// pBar.Clean();
// Clean(supports);
// Clean(resistances);
// Clean(supResBoxes);
// //
// return result;
// }
// //
// XOHCL ppBar;
// result = pBar.GetPreviousBar(ppBar);
// if (!result)
// {
// //
// zBar.Clean();
// cBar.Clean();
// pBar.Clean();
// ppBar.Clean();
// Clean(supports);
// Clean(resistances);
// Clean(supResBoxes);
// //
// 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;
// }
+168 -47
View File
@@ -329,6 +329,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
// //
// Setup Conditions ... // Setup Conditions ...
double sls[]; double sls[];
double sl = 0;
double pivot = 0; double pivot = 0;
double point = 0; double point = 0;
double targets[]; double targets[];
@@ -339,10 +340,16 @@ class XCX121SMCXWZSignalDetector : public XCBase
bool hasSignalBox = false; bool hasSignalBox = false;
bool hasRewardAmount = false; bool hasRewardAmount = false;
bool isSignalBoxReversal = false; bool isSignalBoxReversal = false;
bool hasWorkingZoneOveralDirection = false;
ENUM_X_DIRECTION wzOveralDir = X_DIRECTION_NONE;
ENUM_X_DIRECTION signalBoxDir = X_DIRECTION_NONE; ENUM_X_DIRECTION signalBoxDir = X_DIRECTION_NONE;
ENUM_X121SMC_XWZ_PRIORITY priority = X121SMC_XWZ_PRIORITY_NONE; ENUM_X121SMC_XWZ_PRIORITY priority = X121SMC_XWZ_PRIORITY_NONE;
ENUM_X121SMC_XWZ_PROVIDERS provider = X121SMC_XWZ_PROVIDER_NONE; ENUM_X121SMC_XWZ_PROVIDERS provider = X121SMC_XWZ_PROVIDER_NONE;
//
//
//
// //
// First We Have to Has Working Zone ... // First We Have to Has Working Zone ...
bool hasWorkingZone = workingZone.IsValid(); bool hasWorkingZone = workingZone.IsValid();
@@ -361,21 +368,25 @@ class XCX121SMCXWZSignalDetector : public XCBase
} }
// //
// Update Working Zone ...
if (hasWorkingZone) if (hasWorkingZone)
{ {
// //
// Reset POI Detector Required POI(s) ...
visionCycleHelper.mPOIDetector.MaxRequiredPOIs(50); visionCycleHelper.mPOIDetector.MaxRequiredPOIs(50);
analyseCycleHelper.mPOIDetector.MaxRequiredPOIs(50); analyseCycleHelper.mPOIDetector.MaxRequiredPOIs(50);
decisionCycleHelper.mPOIDetector.MaxRequiredPOIs(50); decisionCycleHelper.mPOIDetector.MaxRequiredPOIs(50);
consolidationCycleHelper.mPOIDetector.MaxRequiredPOIs(50); consolidationCycleHelper.mPOIDetector.MaxRequiredPOIs(50);
// //
// Reset POI Detector Allowed Loopback ...
visionCycleHelper.mPOIDetector.MaxAllowedLoopbackForInit(578); visionCycleHelper.mPOIDetector.MaxAllowedLoopbackForInit(578);
analyseCycleHelper.mPOIDetector.MaxAllowedLoopbackForInit(578); analyseCycleHelper.mPOIDetector.MaxAllowedLoopbackForInit(578);
decisionCycleHelper.mPOIDetector.MaxAllowedLoopbackForInit(578); decisionCycleHelper.mPOIDetector.MaxAllowedLoopbackForInit(578);
consolidationCycleHelper.mPOIDetector.MaxAllowedLoopbackForInit(578); consolidationCycleHelper.mPOIDetector.MaxAllowedLoopbackForInit(578);
// //
// Update Working Zone ...
workingZone.Update( workingZone.Update(
zIndex, zIndex,
visionState, visionState,
@@ -385,16 +396,63 @@ class XCX121SMCXWZSignalDetector : public XCBase
); );
// //
bool isDestroyed = workingZone.IsDestroyed( // Check Working Zone Overal Direction ...
hasWorkingZoneOveralDirection = workingZone
.DetectOveralDirection(wzOveralDir);
//
// Checking Working Zone Destory or not ...
bool isWorkingZoneDestroyed = workingZone.IsDestroyed(
zIndex, zIndex,
period // period //
); );
if (isDestroyed)
//
// Cleanup WorkingZone and ignore all conditions ...
if (isWorkingZoneDestroyed)
{ {
// //
result = false; result = false;
workingZone.Clean(); workingZone.Clean();
hasWorkingZone = false; hasWorkingZone = false;
//
// Cleanup Resources ...
Clean(visionPoiEvents);
Clean(analysePoiEvents);
Clean(decisionPoiEvents);
Clean(consolidationPoiEvents);
//
Clean(visionCycleEvents);
Clean(analyseCycleEvents);
Clean(decisionCycleEvents);
Clean(consolidationCycleEvents);
//
visionState.Clean();
analyseState.Clean();
decisionState.Clean();
consolidationState.Clean();
//
visionConditions.Clean();
analyseConditions.Clean();
decisionConditions.Clean();
consolidationConditions.Clean();
//
visionXConditions.Clean();
analyseXConditions.Clean();
decisionXConditions.Clean();
consolidationXConditions.Clean();
//
mConditions.Clean();
consolidationZBar.Clean();
//
return result;
} }
} }
@@ -513,17 +571,24 @@ class XCX121SMCXWZSignalDetector : public XCBase
// //
// Remove Signal Box from Waiting Boxes of // Remove Signal Box from Waiting Boxes of
// Working Zone ... // Working Zone ...
if (hasSignalBox && if (hasSignalBox)
IsValidIndex(idx))
{ {
// //
ArrayRemove( if (IsValidIndex(idx))
workingZone.waitingBoxes, {
idx, //
1 // ArrayRemove(
); workingZone.waitingBoxes,
idx,
1 //
);
}
} }
//
// Ignore Zone's Signals ...
hasSignalBox = false;
// //
// Cleanup Resources ... // Cleanup Resources ...
@@ -555,8 +620,6 @@ class XCX121SMCXWZSignalDetector : public XCBase
{ {
// //
// Senari A ... // Senari A ...
//
hasSignalBox = hasWorkingZone && hasSignalBox = hasWorkingZone &&
workingZone.DetectSenarioASignalBox( workingZone.DetectSenarioASignalBox(
signalBox, signalBox,
@@ -574,6 +637,55 @@ class XCX121SMCXWZSignalDetector : public XCBase
isSignalBoxReversal = false; isSignalBoxReversal = false;
provider = X121SMC_XWZ_PROVIDER_PV_ZONE; provider = X121SMC_XWZ_PROVIDER_PV_ZONE;
} }
//
// Validating Signal Box if Exists ...
if (hasSignalBox)
{
//
// Validate Signal Boxes using Inside Box ...
if (hasInsideBoxes)
{
//
int idx = -1;
bool has = false;
//
idx =
IsBullish(signalBoxDir)
? GetLowest(workingZone.insideBoxes)
: GetHighest(workingZone.insideBoxes);
has = IsValidIndex(idx);
if (has)
{
//
hasSignalBox =
signalBoxDir == workingZone.insideBoxes[idx].dir;
}
}
//
// Validate Signal Box Using Overal Trend ...
if (hasWorkingZoneOveralDirection)
{
//
hasSignalBox =
signalBoxDir == wzOveralDir;
}
}
}
//
//
//
//
// Cleanup Signal if UnApproved ...
if (!hasSignalBox)
{
//
signalBox.Clean();
signalBoxDir = X_DIRECTION_NONE;
} }
// //
@@ -646,15 +758,54 @@ class XCX121SMCXWZSignalDetector : public XCBase
iSL = signalBox.lower + (signalBox.upper - signalBox.lower) / 2; iSL = signalBox.lower + (signalBox.upper - signalBox.lower) / 2;
} }
//
if (provider == X121SMC_XWZ_PROVIDER_PV_ZONE)
{
}
// //
Add( Add(
iSL, iSL,
sls // sls //
); );
//
// Select Condition SL ...
//
double entry = GetEntry(
signalBox.symbol,
signalBoxDir //
);
//
double slsMin = GetMin(sls);
double slsMax = GetMax(sls);
//
double longSL = slsMin;
double shortSL = slsMax;
//
sl = isBullish
? longSL
: shortSL;
// //
// Targets ... // Targets ...
//
// Force Add TP 2 as Target ...
double risk = MathAbs(entry - sl);
double reward2 = 2 * risk;
double iTP2 = isBullish
? entry + reward2
: entry - reward2;
Add(
iTP2,
targets //
);
// //
// Based On Priority ... // Based On Priority ...
has = priority != X121SMC_XWZ_PRIORITY_NONE; has = priority != X121SMC_XWZ_PRIORITY_NONE;
@@ -979,6 +1130,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
} }
// //
// Summarize Results ...
result = hasPriority && result = hasPriority &&
hasSignalBox && hasSignalBox &&
hasRewardAmount; hasRewardAmount;
@@ -997,6 +1149,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
); );
// //
mConditions.sl = sl;
mConditions.pivot = pivot; mConditions.pivot = pivot;
mConditions.point = point; mConditions.point = point;
mConditions.reward = reward; mConditions.reward = reward;
@@ -1032,6 +1185,10 @@ class XCX121SMCXWZSignalDetector : public XCBase
); );
} }
//
//
//
// //
// Cleanup Resources ... // Cleanup Resources ...
@@ -1222,42 +1379,6 @@ class XCX121SMCXWZSignalDetector : public XCBase
if (result) if (result)
{ {
// //
// Retrieve Entry Price ...
double entry = GetEntry(
conditions.symbol,
setupDir //
);
//
// Select and Apply SL ...
//
double slsMin = GetMin(conditions.sls);
double slsMax = GetMax(conditions.sls);
//
double longSL = slsMin;
double shortSL = slsMax;
//
double sl = isBullish
? longSL
: shortSL;
//
// Add TP 2 as Target ...
double risk = MathAbs(entry - sl);
double reward2 = 2 * risk;
double iTP2 = isBullish
? entry + reward2
: entry - reward2;
Add(
iTP2,
conditions.targets //
);
//
conditions.sl = sl;
conditions.triggerTime = cTime; conditions.triggerTime = cTime;
conditions.type = isBullish conditions.type = isBullish
? X_POSITION_TYPE_LONG ? X_POSITION_TYPE_LONG
+429 -3
View File
@@ -47,6 +47,9 @@ enum ENUM_X121SMC_XWZ_PRIORITY
X121SMC_XWZ_PRIORITY_STRONG_HIGH, X121SMC_XWZ_PRIORITY_STRONG_HIGH,
}; };
//
// Definitions ...
// //
struct X121SMCStrategyXWZWorkingZone struct X121SMCStrategyXWZWorkingZone
{ {
@@ -78,6 +81,7 @@ struct X121SMCStrategyXWZWorkingZone
XBoxZone insideBoxes[]; XBoxZone insideBoxes[];
XBoxZone breakedBoxes[]; XBoxZone breakedBoxes[];
XBoxZone waitingBoxes[]; XBoxZone waitingBoxes[];
XBoxZone breakedInsideBoxes[];
XConsolidationZone consolidationZones[]; XConsolidationZone consolidationZones[];
// //
@@ -85,8 +89,10 @@ struct X121SMCStrategyXWZWorkingZone
CArrayObj mBreakedZoneObjects; CArrayObj mBreakedZoneObjects;
CArrayObj mWaitingZoneObjects; CArrayObj mWaitingZoneObjects;
CArrayObj mWorkingZoneObjects; CArrayObj mWorkingZoneObjects;
CArrayObj mBreakedInsideZoneObjects;
// //
bool mUseSupDems;
bool mUseOrderBlocks; bool mUseOrderBlocks;
bool mUseFairValueGaps; bool mUseFairValueGaps;
@@ -134,10 +140,12 @@ struct X121SMCStrategyXWZWorkingZone
mBreakedZoneObjects.Clear(); mBreakedZoneObjects.Clear();
mWaitingZoneObjects.Clear(); mWaitingZoneObjects.Clear();
mWorkingZoneObjects.Clear(); mWorkingZoneObjects.Clear();
mBreakedInsideZoneObjects.Clear();
// //
mUseSupDems = false;
mUseOrderBlocks = true; mUseOrderBlocks = true;
mUseFairValueGaps = false; mUseFairValueGaps = true;
} }
// //
@@ -271,6 +279,10 @@ struct X121SMCStrategyXWZWorkingZone
} }
} }
//
//
//
// //
// Supply Zones ... // Supply Zones ...
has = HasSupplyZones(); has = HasSupplyZones();
@@ -581,6 +593,102 @@ struct X121SMCStrategyXWZWorkingZone
// //
// Update Exists Zones ... // Update Exists Zones ...
// //
// // Supply Zones ...
// has = mtfState.HasSupplyZones();
// if (has)
// {
// //
// XCSupplyZone *tmpZones[];
// count = mtfState.FilterSupplyZones(
// tmpZones,
// period,
// XZONE_STATE_PASSED,
// false,
// XZONE_STATE_FAILED,
// false,
// XZONE_STATE_FAILED,
// false,
// XZONE_STATE_IGNORED,
// false //
// );
// has = IsValidSize(count);
// if (has)
// {
// //
// for (int i = 0; i < count; i++)
// {
// //
// // Try to Validate Indexes ...
// //
// XCSupplyZone *iZone = tmpZones[i];
// has = IsSupplyExists(iZone);
// if (!has)
// {
// //
// Add(
// iZone,
// supplyZones //
// );
// }
// }
// }
// //
// Clean(tmpZones);
// }
// //
// // Demand Zones ...
// has = mtfState.HasDemandZones();
// if (has)
// {
// //
// XCDemandZone *tmpZones[];
// count = mtfState.FilterDemandZones(
// tmpZones,
// period,
// XZONE_STATE_PASSED,
// false,
// XZONE_STATE_FAILED,
// false,
// XZONE_STATE_FAILED,
// false,
// XZONE_STATE_IGNORED,
// false //
// );
// has = IsValidSize(count);
// if (has)
// {
// //
// for (int i = 0; i < count; i++)
// {
// //
// // Try to Validate Indexes ...
// //
// XCDemandZone *iZone = tmpZones[i];
// has = IsDemandExists(iZone);
// if (!has)
// {
// //
// Add(
// iZone,
// demandZones //
// );
// }
// }
// }
// //
// Clean(tmpZones);
// }
//
//
//
// //
// Supply Zones ... // Supply Zones ...
has = HasSupplyZones(); has = HasSupplyZones();
@@ -1647,7 +1755,7 @@ struct X121SMCStrategyXWZWorkingZone
{ {
// //
XCBoxObject *iObj; XCBoxObject *iObj;
bool isCreated= drawer.DrawBox( bool isCreated = drawer.DrawBox(
signalBox, signalBox,
iObj // iObj //
); );
@@ -1763,6 +1871,120 @@ struct X121SMCStrategyXWZWorkingZone
return result; return result;
} }
//
bool DetectOveralDirection(
ENUM_X_DIRECTION &dir //
)
{
//
bool result = false;
//
dir = X_DIRECTION_NONE;
//
result = IsValid() &&
HasSupplyZone() &&
HasDemandZone();
if (!result)
{
return result;
}
//
XBoxZone demBox;
XBoxZone supBox;
result = ToBox(
demBox,
demandZone //
);
if (!result)
{
//
supBox.Clean();
demBox.Clean();
//
return result;
}
result = ToBox(
supBox,
supplyZone //
);
if (!result)
{
//
supBox.Clean();
demBox.Clean();
//
return result;
}
//
XOHCL supPriceOutBar;
XOHCL demPriceOutBar;
result = DetectBoxNearestPriceOut(
supBox,
supPriceOutBar,
period //
);
if (!result)
{
//
demBox.Clean();
supBox.Clean();
supPriceOutBar.Clean();
demPriceOutBar.Clean();
//
return result;
}
result = DetectBoxNearestPriceOut(
demBox,
demPriceOutBar,
period //
);
if (!result)
{
//
demBox.Clean();
supBox.Clean();
supPriceOutBar.Clean();
demPriceOutBar.Clean();
//
return result;
}
//
// Specified Direction ...
dir =
(supPriceOutBar.IsValid() &&
demPriceOutBar.IsValid())
? supPriceOutBar.time > demPriceOutBar.time
? X_DIRECTION_BEARISH
: demPriceOutBar.time > supPriceOutBar.time
? X_DIRECTION_BULLISH
: X_DIRECTION_NONE
: X_DIRECTION_NONE;
//
result = HasDirection(dir);
//
// Clean Up Resources ...
//
demBox.Clean();
supBox.Clean();
supPriceOutBar.Clean();
demPriceOutBar.Clean();
//
return result;
}
// //
bool HasInsideBox( bool HasInsideBox(
XBoxZone &box // XBoxZone &box //
@@ -1868,6 +2090,199 @@ struct X121SMCStrategyXWZWorkingZone
return result; return result;
} }
//
bool IsExists(XBoxZone &box)
{
//
bool result = false;
//
result = box.IsValid();
if (!result)
{
return result;
}
//
int idx = -1;
bool has = false;
//
// Checking Index Waiting Box ...
has = HasWaitingBoxes();
if (has)
{
//
idx = FindIndex(
box,
waitingBoxes //
);
result = !IsValidIndex(idx);
if (!result)
{
return result;
}
}
//
// Checking Index Inside Boxes ...
has = HasInsideBoxes();
if (has)
{
//
idx = FindIndex(
box,
insideBoxes //
);
result = !IsValidIndex(idx);
if (!result)
{
return result;
}
}
//
// Checking Index Breaked Boxes ...
has = HasBreakedBoxes();
if (has)
{
//
idx = FindIndex(
box,
breakedBoxes //
);
result = !IsValidIndex(idx);
if (!result)
{
return result;
}
}
//
// Checking Index BreakedInside Boxes ...
has = HasBreakedInsideBoxes();
if (has)
{
//
idx = FindIndex(
box,
breakedInsideBoxes //
);
result = !IsValidIndex(idx);
if (!result)
{
return result;
}
}
//
return result;
}
//
bool IsSupplyExists(XCSupplyZone *zone)
{
//
bool result = false;
//
result = zone != NULL &&
zone.IsValid();
if (!result)
{
return result;
}
//
// Converts Zone to Box ...
XBoxZone box;
result = ToBox(
box,
zone //
);
if (!result)
{
//
box.Clean();
return result;
}
//
// Checking Index in SupplyZones ...
int idx = FindIndex(
zone,
supplyZones //
);
result = !IsValidIndex(idx);
if (!result)
{
//
box.Clean();
return result;
}
//
result = IsExists(box);
//
box.Clean();
//
return result;
}
//
bool IsDemandExists(XCDemandZone *zone)
{
//
bool result = false;
//
result = zone != NULL &&
zone.IsValid();
if (!result)
{
return result;
}
//
// Converts Zone to Box ...
XBoxZone box;
result = ToBox(
box,
zone //
);
if (!result)
{
//
box.Clean();
return result;
}
//
// Checking Index in SupplyZones ...
int idx = FindIndex(
zone,
demandZones //
);
result = !IsValidIndex(idx);
if (!result)
{
//
box.Clean();
return result;
}
//
result = IsExists(box);
//
box.Clean();
//
return result;
}
// //
void UpdateTo(datetime value = NULL) void UpdateTo(datetime value = NULL)
{ {
@@ -2486,11 +2901,22 @@ struct X121SMCStrategyXWZWorkingZone
return ArraySize(breakedBoxes); return ArraySize(breakedBoxes);
} }
//
bool HasBreakedInsideBoxes()
{
return HasChild(breakedInsideBoxes);
}
//
int CountBreakedInsideBoxes()
{
return ArraySize(breakedInsideBoxes);
}
// //
}; };
// //
// Definitions ...
struct X121SMCStrategyXWZSignalConditions struct X121SMCStrategyXWZSignalConditions
{ {
// //
+19 -19
View File
@@ -763,38 +763,38 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// XTREND ... // XTREND ...
x121Inputs.xtrendInputs.showUpTrend = showAll || false; x121Inputs.xtrendInputs.showUpTrend = showAll || false;
x121Inputs.xtrendInputs.showDownTrend = showAll || false; x121Inputs.xtrendInputs.showDownTrend = showAll || false;
x121Inputs.xtrendInputs.showOnlyTrendStart = showAll || true; x121Inputs.xtrendInputs.showOnlyTrendStart = showAll || false;
// //
// XPV ... // XPV ...
x121Inputs.xpvInputs.showSar = showAll || true; x121Inputs.xpvInputs.showSar = showAll || false;
x121Inputs.xpvInputs.showPeaks = showAll || true; x121Inputs.xpvInputs.showPeaks = showAll || false;
x121Inputs.xpvInputs.showVales = showAll || true; x121Inputs.xpvInputs.showVales = showAll || false;
// //
// XHK ... // XHK ...
// //
x121Inputs.xhkInputs.drawRawXHKCandles = showAll || true; x121Inputs.xhkInputs.drawRawXHKCandles = showAll || false;
x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || true; x121Inputs.xhkInputs.drawSmoothedXHKCandles = showAll || false;
// //
// XATR ... // XATR ...
x121Inputs.xatrInputs.showATRUpper = showAll || true; x121Inputs.xatrInputs.showATRUpper = showAll || false;
x121Inputs.xatrInputs.showATRLower = showAll || true; x121Inputs.xatrInputs.showATRLower = showAll || false;
// //
// XSTR ... // XSTR ...
x121Inputs.xstrInputs.showStr = showAll || true; x121Inputs.xstrInputs.showStr = showAll || false;
x121Inputs.xstrInputs.showStrUpper = showAll || false; x121Inputs.xstrInputs.showStrUpper = showAll || false;
x121Inputs.xstrInputs.showStrLower = showAll || false; x121Inputs.xstrInputs.showStrLower = showAll || false;
// //
// XCHE ... // XCHE ...
x121Inputs.xcheInputs.showLE1 = showAll || true; x121Inputs.xcheInputs.showLE1 = showAll || false;
x121Inputs.xcheInputs.showLE2 = showAll || true; x121Inputs.xcheInputs.showLE2 = showAll || false;
x121Inputs.xcheInputs.showSE1 = showAll || true; x121Inputs.xcheInputs.showSE1 = showAll || false;
x121Inputs.xcheInputs.showSE2 = showAll || true; x121Inputs.xcheInputs.showSE2 = showAll || false;
// //
// XDON ... // XDON ...
@@ -805,15 +805,15 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// //
// XVWAP ... // XVWAP ...
x121Inputs.xvwapInputs.showVWapFast = showAll || true; x121Inputs.xvwapInputs.showVWapFast = showAll || false;
x121Inputs.xvwapInputs.showVWapMedium = showAll || true; x121Inputs.xvwapInputs.showVWapMedium = showAll || false;
x121Inputs.xvwapInputs.showVWapSlow = showAll || true; x121Inputs.xvwapInputs.showVWapSlow = showAll || false;
// //
// X3MA ... // X3MA ...
x121Inputs.x3maInputs.showX3MaFast = showAll || true; x121Inputs.x3maInputs.showX3MaFast = showAll || false;
x121Inputs.x3maInputs.showX3MaMid = showAll || true; x121Inputs.x3maInputs.showX3MaMid = showAll || false;
x121Inputs.x3maInputs.showX3MaSlow = showAll || true; x121Inputs.x3maInputs.showX3MaSlow = showAll || false;
// //
// Initialize Cycle Helpers ... // Initialize Cycle Helpers ...