This commit is contained in:
2025-03-11 01:42:32 +03:30
parent d00dcf9ca0
commit f952cd1d93
6 changed files with 1311 additions and 124 deletions
@@ -54,6 +54,21 @@ string ToString(ENUM_X_CYCLES value)
return result;
}
bool IsValid(ENUM_X_CYCLES value)
{
//
bool result = false;
//
result =
value != X_CYCLE_NONE ||
value != X_CYCLE_TRIGGER ||
value != X_CYCLE_VERIFICATION;
//
return result;
}
enum ENUM_X_CYCLE_EVENTS
{
SAR_CHANGE_DETECTED,
@@ -584,6 +599,224 @@ class XC121SMCCycleHelper : public XCBase
return result;
}
//
int DetectRejections(
XBoxZone &rejections[],
int barIndex = 0,
bool forceBarType = true,
bool forceFiboPressure = true,
bool forceUnUsedRejections = true,
int maxAllowedLoopback = 587 //
)
{
//
int result = 0;
//
// Normalize Args ...
Clean(rejections);
//
if (barIndex < 0)
{
barIndex = 0;
}
//
int idx = -1;
bool has = false;
for (int i = barIndex + 1; i < barIndex + maxAllowedLoopback; i++)
{
//
// Init Indexed Bar ...
XOHCL iBar;
XOHCL iCBar;
XOHCL iPBar;
has = GetBar(iBar, i);
has =
has &&
iBar.GetPreviousBar(iCBar);
has =
has &&
iCBar.GetPreviousBar(iPBar);
if (!has)
{
//
iBar.Clean();
iCBar.Clean();
iPBar.Clean();
break;
}
//
// Check CBar Bullish Fibo Pressure ...
bool cBarHasBullishFiboPressure =
mBarAnalyser
.HasFiboPressure(
iCBar,
X_DIRECTION_BULLISH,
X_FIBO_LEVEL_382 //
);
//
// Check CBar Bearish Fibo Pressure ...
bool cBarHasBearishFiboPressure =
mBarAnalyser
.HasFiboPressure(
iCBar,
X_DIRECTION_BEARISH,
X_FIBO_LEVEL_382 //
);
//
// Check Bar is Bullish Rejection Swing ...
bool isBullishRejection =
//
iCBar.low < iBar.low &&
iCBar.low < iPBar.low &&
//
iCBar.low < iCBar.GetDown() &&
iCBar.GetLowShadow() > iCBar.GetBody() &&
iCBar.GetLowShadow() > iCBar.GetHighShadow()
//
;
//
// Check Bar is Bearish Rejection Swing ...
bool isBearishRejection =
//
iCBar.high > iBar.high &&
iCBar.high > iPBar.high &&
//
iCBar.high > iCBar.GetUp() &&
iCBar.GetHighShadow() > iCBar.GetBody() &&
iCBar.GetHighShadow() > iCBar.GetLowShadow()
//
;
//
// Apply Fibo Pressure ...
if (forceFiboPressure)
{
//
isBullishRejection =
isBullishRejection &&
cBarHasBullishFiboPressure;
//
isBearishRejection =
isBearishRejection &&
cBarHasBearishFiboPressure;
}
//
// Apply Force Bar Type ...
if (forceBarType)
{
//
isBullishRejection =
isBullishRejection &&
iCBar.IsBullish();
//
isBearishRejection =
isBearishRejection &&
iCBar.IsBearish();
}
//
// Summarize Result ...
has = isBullishRejection ||
isBearishRejection;
if (has)
{
//
XBoxZone iBox;
//
iBox.to = iBar.time;
iBox.from = iCBar.time;
iBox.period = iBar.period;
iBox.symbol = iBar.symbol;
//
iBox.dir =
isBullishRejection
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
iBox.upper =
isBullishRejection
? iCBar.GetDown()
: iCBar.high;
//
iBox.lower =
isBullishRejection
? iCBar.low
: iCBar.GetUp();
//
iBox.type =
isBullishRejection
? "XSwingLow"
: "XSwingHigh";
//
// Validate Box ...
has = iBox.IsValid();
if (has)
{
//
// Apply Force Unused Rejections ...
if (forceUnUsedRejections)
{
//
has = !IsBoxBreaked(
iBox,
iCBar.Index() + 1,
barIndex //
);
}
//
if (has)
{
//
idx = FindIndex(
iBox,
rejections //
);
has = !IsValidIndex(idx);
if (has)
{
//
AddRef(
iBox,
rejections //
);
}
}
}
//
iBox.Clean();
}
//
iBar.Clean();
iCBar.Clean();
iPBar.Clean();
}
//
result = ArraySize(rejections);
//
return result;
}
//
// Virtuals ...
@@ -638,7 +871,7 @@ class XC121SMCCycleHelper : public XCBase
bool mShowBidLine = true; // show bid line
bool mShowAskLine = true; // show ask line
bool mShowGrid = false; // show grids on chart
bool mShowVolumes = false; // show volumes
bool mShowVolumes = true; // show volumes
bool mShowTradeLevels = true; // Displaying trade levels in the chart (levels of open positions, Stop Loss, Take Profit and pending orders)
bool mAutoScroll = true; // chart autoscroll
bool mQuickNavigation = true; // chart quick navigation state
@@ -2676,5 +2909,262 @@ struct X121SMCStrategyConditionParser
return result;
}
//
bool HasSenario2Conditions(
ENUM_X_CYCLES ttfCycle,
ENUM_X_DIRECTION trend,
XBoxZone &unavailableBoxes[],
XBoxZone &box,
ENUM_X_DIRECTION &dir,
X121SMCStrategySignalProviderData &provider,
int barIndex = 0 //
)
{
//
bool result = false;
//
// Validate Args ...
result =
IsValid(ttfCycle) &&
HasDirection(trend) &&
HasChild(unavailableBoxes);
if (!result)
{
return result;
}
//
bool hasBullishTrend = IsBullish(trend);
bool hasBearishTrend = IsBearish(trend);
//
// TTF Cycle Extract ...
XPOIState ttfState;
X121Conditions ttfXConditions;
XC121SMCCycleHelper *ttfHelper;
X121SMCCycleConditions ttfConditions;
result = provider.SelectCycle(
ttfCycle,
ttfState,
ttfXConditions,
ttfHelper,
ttfConditions //
);
if (!result)
{
//
ttfState.Clean();
ZeroMemory(ttfHelper);
ttfConditions.Clean();
ttfXConditions.Clean();
//
return result;
}
Parse(ttfXConditions);
//
// Normalize Args ...
//
box.Clean();
dir = X_DIRECTION_NONE;
//
if (barIndex < 0)
{
barIndex = 0;
}
//
int idx = -1;
int count = 0;
bool has = false;
//
int zIDX = barIndex;
int cIDX = zIDX + 1;
int pIDX = cIDX + 1;
//
double ask = GetAsk(ttfState.symbol);
double bid = GetBid(ttfState.symbol);
//
bool isBullish = false;
bool isBearish = false;
//
XOHCL zBar;
XOHCL cBar;
XOHCL pBar;
//
// Initial Bars ...
result = zBar.Init(
ttfState.symbol,
ttfState.period,
barIndex //
);
result =
result &&
zBar.GetPreviousBar(cBar);
result =
result &&
cBar.GetPreviousBar(pBar);
if (!result)
{
//
zBar.Clean();
cBar.Clean();
pBar.Clean();
ttfState.Clean();
ZeroMemory(ttfHelper);
ttfConditions.Clean();
ttfXConditions.Clean();
//
return result;
}
//
// Conditions ...
//
// First we Have to Detect Inside Box ...
XBoxZone insideBox;
count = ArraySize(unavailableBoxes);
for (int i = 0; i < count; i++)
{
//
XBoxZone iBox = unavailableBoxes[i];
//
bool isInside =
IsInsideBox(
zBar,
iBox //
);
if (isInside)
{
//
// Since we have to Follow Trend based on Breaked Boxes ...
// we have to use:
// - Breaked Bullish Boxes on Bearish Trend ...
// - Breaked Bearish Boxes on Bullish Trend ...
isInside =
hasBullishTrend
? iBox.IsBearish()
: hasBearishTrend
? iBox.IsBullish()
: false;
//
if (isInside)
{
//
insideBox = iBox;
iBox.Clean();
//
break;
}
}
//
iBox.Clean();
}
//
result = insideBox.IsValid();
if (!result)
{
//
zBar.Clean();
cBar.Clean();
pBar.Clean();
ttfState.Clean();
insideBox.Clean();
ZeroMemory(ttfHelper);
ttfConditions.Clean();
ttfXConditions.Clean();
}
//
if (result)
{
//
insideBox.from = insideBox.to;
insideBox.to = zBar.time;
//
XCBoxObject *iObj;
has = ttfHelper.mPOIDrawer.DrawBox(
insideBox,
iObj //
);
if (has) {
//
iObj.Width(2);
iObj.BoxColor(clrGray);
}
//
Print("Has Inside Box ...");
}
//
// Bullish Conditions ...
isBullish = (
//
false
//
);
//
// Bearish Conditions ...
isBearish = (
//
false
//
);
//
// Filling Requirements ...
result =
isBullish ||
isBearish;
if (result)
{
}
//
// Check All Conditions ...
result =
box.IsValid() &&
HasDirection(dir) &&
(isBullish ||
isBearish //
);
//
// Cleanup Resource ...
//
zBar.Clean();
cBar.Clean();
pBar.Clean();
//
ttfState.Clean();
ZeroMemory(ttfHelper);
ttfConditions.Clean();
ttfXConditions.Clean();
//
return result;
}
//
};