This commit is contained in:
2025-10-31 06:58:43 +03:30
parent 2c4a4dc5e5
commit 7d5e4d17f9
3 changed files with 1447 additions and 970 deletions
File diff suppressed because it is too large Load Diff
+193 -141
View File
@@ -4064,6 +4064,7 @@ bool ToPivot(
* @param prefix: string, Specified Pattern Type ...
* @param peakPriceType: ENUM_X_PRICE, Specified Peak Pivot's Applied Price ...
* @param valePriceType: ENUM_X_PRICE, Specified Vale Pivot's Applied Price ...
* @param setFromByBreakerBar: bool, Set Box From Time to Breaker Bar ...
*
* @return ( bool )
*/
@@ -4073,7 +4074,8 @@ bool ToBox(
ENUM_X_DIRECTION forDir,
string prefix = NULL,
ENUM_X_PRICE peakPriceType = X_PRICE_HIGH,
ENUM_X_PRICE valePriceType = X_PRICE_LOW //
ENUM_X_PRICE valePriceType = X_PRICE_LOW,
bool setFromByBreakerBar = false //
)
{
//
@@ -4119,7 +4121,8 @@ bool ToBox(
forDir,
iPattern,
peakPriceType,
valePriceType //
valePriceType,
setFromByBreakerBar //
);
}
//
@@ -4177,6 +4180,7 @@ bool ToBox(
* @param prefix: string, Specified Pattern Type ...
* @param peakPriceType: ENUM_X_PRICE, Specified Peak Pivot's Applied Price ...
* @param valePriceType: ENUM_X_PRICE, Specified Vale Pivot's Applied Price ...
* @param setFromByBreakerBar: bool, Set Box From Time to Breaker Bar ...
*
* @return ( bool )
*/
@@ -4186,7 +4190,8 @@ bool ToBox(
ENUM_X_DIRECTION patternDir,
ENUM_X_BAR_PATTERN pattern,
ENUM_X_PRICE peakPriceType = X_PRICE_HIGH,
ENUM_X_PRICE valePriceType = X_PRICE_LOW //
ENUM_X_PRICE valePriceType = X_PRICE_LOW,
bool setFromByBreakerBar = false //
)
{
//
@@ -4245,17 +4250,21 @@ bool ToBox(
//
case X_BAR_PATTERN_HIGH: {
//
tmpBar.Clean();
has = GetBreakerBar(
bar,
tmpBar,
peakPriceType,
peakPriceType,
X_DIRECTION_BULLISH //
);
if (has)
if (setFromByBreakerBar)
{
iFrom = tmpBar.time;
//
tmpBar.Clean();
has = GetBreakerBar(
bar,
tmpBar,
peakPriceType,
peakPriceType,
X_DIRECTION_BULLISH //
);
if (has)
{
iFrom = tmpBar.time;
}
}
//
@@ -4267,17 +4276,21 @@ bool ToBox(
//
case X_BAR_PATTERN_LOW: {
//
tmpBar.Clean();
has = GetBreakerBar(
bar,
tmpBar,
valePriceType,
valePriceType,
X_DIRECTION_BEARISH //
);
if (has)
if (setFromByBreakerBar)
{
iFrom = tmpBar.time;
//
tmpBar.Clean();
has = GetBreakerBar(
bar,
tmpBar,
valePriceType,
valePriceType,
X_DIRECTION_BEARISH //
);
if (has)
{
iFrom = tmpBar.time;
}
}
//
@@ -4289,20 +4302,24 @@ bool ToBox(
//
case X_BAR_PATTERN_MOMENTUM: {
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
if (setFromByBreakerBar)
{
iFrom = tmpBar.time;
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
{
iFrom = tmpBar.time;
}
}
//
@@ -4314,20 +4331,24 @@ bool ToBox(
//
case X_BAR_PATTERN_ENGULFED: {
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
if (setFromByBreakerBar)
{
iFrom = tmpBar.time;
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
{
iFrom = tmpBar.time;
}
}
//
@@ -4362,20 +4383,24 @@ bool ToBox(
//
case X_BAR_PATTERN_PINNED: {
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
if (setFromByBreakerBar)
{
iFrom = tmpBar.time;
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
{
iFrom = tmpBar.time;
}
}
//
@@ -4407,7 +4432,10 @@ bool ToBox(
if (has)
{
//
iFrom = tmpBar.time;
if (setFromByBreakerBar)
{
iFrom = tmpBar.time;
}
//
int idx = -1;
@@ -4421,20 +4449,24 @@ bool ToBox(
//
case X_BAR_PATTERN_PIERCING: {
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
if (setFromByBreakerBar)
{
iFrom = tmpBar.time;
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
{
iFrom = tmpBar.time;
}
}
//
@@ -4446,20 +4478,24 @@ bool ToBox(
//
case X_BAR_PATTERN_RISING: {
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
if (setFromByBreakerBar)
{
iFrom = tmpBar.time;
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
{
iFrom = tmpBar.time;
}
}
//
@@ -4471,20 +4507,24 @@ bool ToBox(
//
case X_BAR_PATTERN_FLAG: {
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
if (setFromByBreakerBar)
{
iFrom = tmpBar.time;
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
{
iFrom = tmpBar.time;
}
}
//
@@ -4498,20 +4538,24 @@ bool ToBox(
//
case X_BAR_PATTERN_SIGNALKEY: {
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
if (setFromByBreakerBar)
{
iFrom = tmpBar.time;
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
{
iFrom = tmpBar.time;
}
}
//
@@ -4566,20 +4610,24 @@ bool ToBox(
//
case X_BAR_PATTERN_SUPPORT: {
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
if (setFromByBreakerBar)
{
iFrom = tmpBar.time;
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
{
iFrom = tmpBar.time;
}
}
//
@@ -4597,20 +4645,24 @@ bool ToBox(
//
case X_BAR_PATTERN_RESISTANCE: {
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
if (setFromByBreakerBar)
{
iFrom = tmpBar.time;
//
tmpBar.Clean();
ENUM_X_PRICE iPType = isBullish
? valePriceType
: peakPriceType;
has = GetBreakerBar(
bar,
tmpBar,
iPType,
iPType,
patternDir //
);
if (has)
{
iFrom = tmpBar.time;
}
}
//
@@ -1917,17 +1917,8 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
//
// Validator Flags ...
bool validateByATRZone = false;
bool validateByBarPatterns = false;
bool validateRejectedXFIMA = true;
bool validateByAffectedZone = false;
bool validateStartedPullback = true;
bool validateStartedPinnedBar = true;
bool validateByPinBarZoneTrend = false;
bool validateByDirectionalZones = false;
bool validateByDoubleBarPatterns = false;
bool validateByCycleMAsDirection = true;
bool validateByInDirectionalZones = false;
bool validateByCyclesTrend = true;
bool validateByMaFastSlowGrows = true;
//
// Define Requirements ...
@@ -1936,25 +1927,11 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
XOHCL pBar;
XOHCL p2Bar;
XOHCL p3Bar;
XBoxZone atrBox;
XBoxZone mcPVZone;
XBoxZone lcPVZone;
XBoxZone hcPVZone;
double rejecteds[];
XBoxZone supports[];
XBoxZone pinBarZone;
XBoxZone pullbackZone;
XBoxZone affectedZone;
XBoxZone resistances[];
XTrend pinBarZoneTrend;
bool isBullish = false;
bool isBearish = false;
XPatternAnalysis iPatterns;
XPatternAnalysis iPPatterns;
XPatternAnalysis pBarPatterns;
XPatternAnalysis p2BarPatterns;
XPatternAnalysis p3BarPatterns;
ENUM_X_BAR_PATTERN doublePatterns[];
XPatternAnalysisConfig iPatternsConfig;
//
@@ -2016,788 +1993,106 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
}
//
// Looking For a Pin Bar in P2Bar ...
bool isP2BarIsPinBar = poiDetector.IsPinnedBar(
p2Bar,
dir,
4, // Shadow Multiplier ...
4, // Minimum Range Multiplier ...
true // Force Pin Bar Direction ...
);
if (isP2BarIsPinBar)
{
//
isP2BarIsPinBar = ToBox(
p2Bar,
pinBarZone,
dir,
X_BAR_PATTERN_PINNED //
);
if (isP2BarIsPinBar)
{
//
pinBarZone.to = bar.time;
//
// Validate By PinBar Zone Trend ...
if (validateByPinBarZoneTrend)
{
//
isP2BarIsPinBar = poiDetector.HasBoundaryTrend(
pinBarZone,
pinBarZoneTrend,
false //
);
//
isP2BarIsPinBar =
isP2BarIsPinBar &&
dir == pinBarZoneTrend.dir;
}
//
// Validate PinBar Zone By XFIMA ...
if (validateRejectedXFIMA)
{
//
int rejectedsCount = poiDetector.IsRejectXFIMA(p2Bar, rejecteds, pinBarZone.dir);
isP2BarIsPinBar = IsValidSize(rejectedsCount);
}
}
}
bool isP2BarPinnedBullish = isP2BarIsPinBar && IsXBullish(dir);
bool isP2BarPinnedBearish = isP2BarIsPinBar && IsXBearish(dir);
// Detect a Cross of MAs ...
bool isFastCrossedOverSlow = fimaParser.IsMAFastCrossedOverSlow(p2Bar.Index());
bool isFastCrossedUnderSlow = fimaParser.IsMAFastCrossedUnderSlow(p2Bar.Index());
//
// Check P2Bar is Pullback Bar ...
bool isPBarIsPullBack = poiDetector.IsPullbackPattern(
pBar,
pullbackZone,
dir,
2, // Pull back Length ...
false // Force Break Pullback ...
);
bool isPBarPullbackBullish = isPBarIsPullBack && pullbackZone.IsBullish();
bool isPBarPullbackBaerish = isPBarIsPullBack && pullbackZone.IsBearish();
if (isPBarIsPullBack && validateRejectedXFIMA)
{
//
double iRejecteds[];
int rejectedCounts = poiDetector.IsRejectXFIMA(
p2Bar,
iRejecteds,
dir,
X_PRICE_CLOSE,
X_PRICE_OPEN,
X_PRICE_OPEN,
X_PRICE_CLOSE,
false //
);
isPBarIsPullBack = IsValidSize(rejectedCounts);
if (isPBarIsPullBack)
{
//
Copy(
iRejecteds,
rejecteds,
false //
);
}
}
//
isBullish =
isP2BarPinnedBullish ||
isPBarPullbackBullish;
//
isBearish =
isP2BarPinnedBearish ||
isPBarPullbackBullish;
isBullish = isFastCrossedOverSlow;
isBearish = isFastCrossedUnderSlow;
//
result = isBullish || isBearish;
//
// Validate Starter Pinned ...
if (result && validateStartedPinnedBar && !validateStartedPullback)
// Validate Cross By Over/Under Last ...
if (result && validateByMaFastSlowGrows)
{
//
// Bullish ...
bool isFastOverLast = fimaParser.IsMAFastOverLast(pBar.Index());
bool isSlowOverLast = fimaParser.IsMASlowOverLast(pBar.Index());
bool isOverLast = isFastOverLast && isSlowOverLast;
//
// Bearish ...
bool isFastUnderLast = fimaParser.IsMAFastUnderLast(pBar.Index());
bool isSlowUnderLast = fimaParser.IsMASlowUnderLast(pBar.Index());
bool isUnderLast = isFastUnderLast && isSlowUnderLast;
//
isBullish =
isBullish &&
isP2BarPinnedBullish;
isOverLast;
//
isBearish =
isBearish &&
isP2BarPinnedBearish;
isUnderLast;
//
result = isBullish || isBearish;
}
//
// Validate Starter Pullback ...
if (result && !validateStartedPinnedBar && validateStartedPullback)
// Validate By Cycles Trend ...
if (result && validateByCyclesTrend)
{
//
// Reading Cycles Trend ...
//
// Bullish ...
//
bool isLCMABullish = fimaParser.IsLCMABullish(pBar.Index());
bool isHCMABullish = fimaParser.IsHCMABullish(pBar.Index());
//
bool isLCMAOverLast = fimaParser.IsLCMAOverLast(pBar.Index());
bool isHCMAOverLast = fimaParser.IsHCMAOverLast(pBar.Index());
//
bool isCyclesMABullish = isLCMABullish && isHCMABullish && isLCMAOverLast && isHCMAOverLast;
//
// Bearish ...
//
bool isLCMABearish = fimaParser.IsLCMABearish(pBar.Index());
bool isHCMABearish = fimaParser.IsHCMABearish(pBar.Index());
//
bool isLCMAUnderLast = fimaParser.IsLCMAUnderLast(pBar.Index());
bool isHCMAUnderLast = fimaParser.IsHCMAUnderLast(pBar.Index());
//
bool isCyclesMABearish = isLCMABearish && isHCMABearish && isLCMAUnderLast && isHCMAUnderLast;
//
isBullish =
isBullish &&
isPBarPullbackBullish;
isCyclesMABullish;
//
isBearish =
isBearish &&
isPBarPullbackBaerish;
isCyclesMABearish;
//
result = isBullish || isBearish;
}
//
// Prepare Zone ...
if (result)
{
//
string type = NULL;
datetime to = NULL;
datetime from = NULL;
double upper = EMPTY_VALUE;
double lower = EMPTY_VALUE;
ENUM_X_DIRECTION zDir = X_DIRECTION_NONE;
DebugBreak();
//
zone.at = bar.time;
zone.symbol = bar.symbol;
zone.period = bar.period;
//
if (pinBarZone.IsValid())
{
//
upper =
!NotEmptyZero(upper)
? pinBarZone.upper
: MathMax(upper, pinBarZone.upper);
//
lower =
!NotEmptyZero(lower)
? pinBarZone.lower
: MathMin(lower, pinBarZone.lower);
//
to = bar.time;
from = !IsXValid(from)
? pinBarZone.from
: MathMin(from, pinBarZone.from);
//
zDir = pinBarZone.dir;
type = pinBarZone.type;
}
//
if (pullbackZone.IsValid())
{
//
upper =
!NotEmptyZero(upper)
? pullbackZone.upper
: MathMax(upper, pullbackZone.upper);
//
lower =
!NotEmptyZero(lower)
? pullbackZone.lower
: MathMin(lower, pullbackZone.lower);
//
from = !IsXValid(from)
? pullbackZone.from
: MathMin(from, pullbackZone.from);
//
if (!HasDirection(zDir))
{
zDir = pullbackZone.dir;
}
//
type =
!IsXValid(type)
? pullbackZone.type
: type + "_" + pullbackZone.type;
}
//
zone.to = to;
zone.dir = zDir;
zone.from = from;
zone.type = type;
zone.upper = upper;
zone.lower = lower;
//
result = zone.IsValid();
if (result)
{
//
int zoneLength = zone.FromIndex() - zone.ToIndex();
double zoneLL = pBar.FindLowest(zoneLength, MODE_LOW);
double zoneHH = pBar.FindHighest(zoneLength, MODE_HIGH);
//
if (zone.IsBullish())
{
zone.lower = MathMin(zone.lower, zoneLL);
}
if (zone.IsBearish())
{
zone.upper = MathMax(zone.upper, zoneHH);
}
}
//
if (!result)
{
//
result = false;
isBullish = false;
isBearish = false;
dir = X_DIRECTION_NONE;
}
//
if (result)
{
//
poiDrawer.DrawZone(zone, structureDrawConfig.drawConfig);
DebugBreak();
}
//
zone.Clean();
result = false;
isBullish = false;
isBearish = false;
dir = X_DIRECTION_NONE;
}
//
// Validate By Affected Zone ...
if (result && validateByAffectedZone)
{
//
// Prepare Zone ...
//
XOHCL tmpBar;
XBoxZone tmpZone;
//
isBullish =
isBullish &&
poiDetector.IsSupportTouched(
p2Bar,
tmpBar,
tmpZone,
5,
21 //
);
if (isBullish)
{
affectedZone = tmpZone;
}
//
isBearish =
isBearish &&
poiDetector.IsResistanceTouched(
p2Bar,
tmpBar,
tmpZone,
5,
21 //
);
if (isBearish)
{
affectedZone = tmpZone;
}
//
tmpBar.Clean();
tmpZone.Clean();
//
result = isBullish || isBearish;
}
//
// Validate By ATR Zone ...
if (result && validateByATRZone)
{
//
// Checking ATR Box ...
bool hasATRBox = fimaParser.GetATRBox(
atrBox,
bar.Index() //
);
bool hasATRBoxBullish = hasATRBox && atrBox.IsBullish();
bool hasATRBoxBearish = hasATRBox && atrBox.IsBearish();
//
isBullish =
isBullish &&
hasATRBoxBullish;
//
isBearish =
isBearish &&
hasATRBoxBearish;
//
// Summarize Result ...
result = isBullish || isBearish;
}
//
// Detect Directional Candlestic Patterns ...
if (result && validateByBarPatterns)
{
//
// Bullish ...
bool isPBarHasBullishPatterns =
(bar.close > pBar.low ||
bar.open > pBar.low) &&
(
//
pBarPatterns.IsPinned(X_DIRECTION_BULLISH) ||
pBarPatterns.IsEngulfed(X_DIRECTION_BULLISH) ||
pBarPatterns.IsMomentum(X_DIRECTION_BULLISH) ||
pBarPatterns.IsPiercing(X_DIRECTION_BULLISH) ||
pBarPatterns.IsSignalKey(X_DIRECTION_BULLISH)
//
);
bool isP2BarHasBullishPatterns =
(bar.close > p2Bar.low ||
bar.open > p2Bar.low) &&
(
//
p2BarPatterns.IsPinned(X_DIRECTION_BULLISH) ||
p2BarPatterns.IsEngulfed(X_DIRECTION_BULLISH) ||
p2BarPatterns.IsMomentum(X_DIRECTION_BULLISH) ||
p2BarPatterns.IsPiercing(X_DIRECTION_BULLISH) ||
p2BarPatterns.IsSignalKey(X_DIRECTION_BULLISH)
//
);
bool isP3BarHasBullishPatterns =
(bar.close > p3Bar.low ||
bar.open > p3Bar.low) &&
(
//
p3BarPatterns.IsPinned(X_DIRECTION_BULLISH) ||
p3BarPatterns.IsEngulfed(X_DIRECTION_BULLISH) ||
p3BarPatterns.IsMomentum(X_DIRECTION_BULLISH) ||
p3BarPatterns.IsPiercing(X_DIRECTION_BULLISH) ||
p3BarPatterns.IsSignalKey(X_DIRECTION_BULLISH)
//
);
//
// Bearish ...
bool isPBarHasBearishPatterns =
(bar.close < pBar.high ||
bar.open < pBar.high) &&
(
//
pBarPatterns.IsPinned(X_DIRECTION_BEARISH) ||
pBarPatterns.IsEngulfed(X_DIRECTION_BEARISH) ||
pBarPatterns.IsMomentum(X_DIRECTION_BEARISH) ||
pBarPatterns.IsPiercing(X_DIRECTION_BEARISH) ||
pBarPatterns.IsSignalKey(X_DIRECTION_BEARISH)
//
);
bool isP2BarHasBearishPatterns =
(bar.close < p2Bar.high ||
bar.open < p2Bar.high) &&
(
//
p2BarPatterns.IsPinned(X_DIRECTION_BEARISH) ||
p2BarPatterns.IsEngulfed(X_DIRECTION_BEARISH) ||
p2BarPatterns.IsMomentum(X_DIRECTION_BEARISH) ||
p2BarPatterns.IsPiercing(X_DIRECTION_BEARISH) ||
p2BarPatterns.IsSignalKey(X_DIRECTION_BEARISH)
//
);
bool isP3BarHasBearishPatterns =
(bar.close < p3Bar.high ||
bar.open < p3Bar.high) &&
(
//
p3BarPatterns.IsPinned(X_DIRECTION_BEARISH) ||
p3BarPatterns.IsEngulfed(X_DIRECTION_BEARISH) ||
p3BarPatterns.IsMomentum(X_DIRECTION_BEARISH) ||
p3BarPatterns.IsPiercing(X_DIRECTION_BEARISH) ||
p3BarPatterns.IsSignalKey(X_DIRECTION_BEARISH)
//
);
//
bool hasBullishPatterns =
isPBarHasBullishPatterns &&
(isP2BarHasBullishPatterns ||
isP3BarHasBullishPatterns);
//
bool hasBearishPatterns =
isPBarHasBearishPatterns &&
(isP2BarHasBearishPatterns ||
isP3BarHasBearishPatterns);
//
isBullish =
isBullish &&
hasBullishPatterns;
//
isBearish =
isBearish &&
hasBearishPatterns;
//
// Summarize Result ...
result = isBullish || isBearish;
}
//
// Validating Market Direction ...
if (result && validateByCycleMAsDirection)
{
//
// Bullish ...
bool isLCBullish = fimaParser.IsLCMABullish(pBar.Index());
bool isHCBullish = fimaParser.IsHCMABullish(pBar.Index());
bool isLCHigherLow =
(fimaParser.IsLCHigherLow(pBar.Index()) ||
fimaParser.IsLCHigherLow(p2Bar.Index()) ||
fimaParser.IsLCHigherLow(p3Bar.Index()));
bool isCyclesBullish =
isLCBullish &&
isHCBullish &&
isLCHigherLow;
//
// Bearish ...
bool isLCBearish = fimaParser.IsLCMABearish(pBar.Index());
bool isHCBearish = fimaParser.IsHCMABearish(pBar.Index());
bool isLCLowerHigh =
(fimaParser.IsLCLowerHigh(pBar.Index()) ||
fimaParser.IsLCLowerHigh(p2Bar.Index()) ||
fimaParser.IsLCLowerHigh(p3Bar.Index()));
bool isCyclesBearish =
isLCBearish &&
isHCBearish &&
isLCLowerHigh;
//
isBullish =
isBullish &&
isCyclesBullish;
//
isBearish =
isBearish &&
isCyclesBearish;
//
// Summarize Result ...
result = isBullish || isBearish;
}
//
// Validate By Double Bar Patterns ...
if (result && validateByDoubleBarPatterns)
{
//
GetCandlestickPatterns(doublePatterns);
bool hasDoublePatterns = poiDetector.HasDoublePatterns(
pBar,
dir,
iPatterns,
iPPatterns,
doublePatterns,
iPatternsConfig,
5 //
);
bool hasBullishDoublePatterns = hasDoublePatterns && IsXBullish(dir);
bool hasBearishDoublePatterns = hasDoublePatterns && IsXBearish(dir);
//
isBullish =
isBullish &&
hasBullishDoublePatterns;
//
isBearish =
isBearish &&
hasBearishDoublePatterns;
//
// Summarize Result ...
result = isBullish || isBearish;
}
//
// Validate by Directional Zones ...
if (result && validateByDirectionalZones)
{
//
// Collecting Zones ...
XOHCL tmpBar;
XPivot tmpPivot;
XBoxZone tmpZone;
//
// Support ...
bool hasSupport = pBarPatterns.IsSupport();
if (hasSupport)
{
//
hasSupport = pBarPatterns.GetSupport(tmpBar, tmpPivot, tmpZone);
if (hasSupport)
{
AddIfNotExists(tmpZone, supports);
}
}
hasSupport = p2BarPatterns.IsSupport();
if (hasSupport)
{
//
hasSupport = p2BarPatterns.GetSupport(tmpBar, tmpPivot, tmpZone);
if (hasSupport)
{
AddIfNotExists(tmpZone, supports);
}
}
hasSupport = p3BarPatterns.IsSupport();
if (hasSupport)
{
//
hasSupport = p3BarPatterns.GetSupport(tmpBar, tmpPivot, tmpZone);
if (hasSupport)
{
AddIfNotExists(tmpZone, supports);
}
}
hasSupport = HasChild(supports);
//
// Resistance ...
bool hasResistance = pBarPatterns.IsResistance();
if (hasResistance)
{
//
hasResistance = pBarPatterns.GetResistance(tmpBar, tmpPivot, tmpZone);
if (hasResistance)
{
AddIfNotExists(tmpZone, resistances);
}
}
hasResistance = p2BarPatterns.IsResistance();
if (hasResistance)
{
//
hasResistance = p2BarPatterns.GetResistance(tmpBar, tmpPivot, tmpZone);
if (hasResistance)
{
AddIfNotExists(tmpZone, resistances);
}
}
hasResistance = p3BarPatterns.IsResistance();
if (hasResistance)
{
//
hasResistance = p3BarPatterns.GetResistance(tmpBar, tmpPivot, tmpZone);
if (hasResistance)
{
AddIfNotExists(tmpZone, resistances);
}
}
hasResistance = HasChild(resistances);
//
// Cleanup ...
tmpBar.Clean();
tmpZone.Clean();
tmpPivot.Clean();
//
// Validating ...
//
isBullish =
isBullish &&
hasSupport;
//
isBearish =
isBearish &&
hasResistance;
//
// Summarize Result ...
result = isBullish || isBearish;
}
//
// Validate by InDirectional Zones ...
if (result && validateByInDirectionalZones)
{
//
// Collecting Zones ...
XOHCL tmpBar;
XPivot tmpPivot;
XBoxZone tmpZone;
//
// Supports ...
bool hasSupport = false;
if (!HasChild(supports))
{
//
hasSupport = pBarPatterns.IsSupport();
if (hasSupport)
{
//
hasSupport = pBarPatterns.GetSupport(tmpBar, tmpPivot, tmpZone);
if (hasSupport)
{
AddIfNotExists(tmpZone, supports);
}
}
hasSupport = p2BarPatterns.IsSupport();
if (hasSupport)
{
//
hasSupport = p2BarPatterns.GetSupport(tmpBar, tmpPivot, tmpZone);
if (hasSupport)
{
AddIfNotExists(tmpZone, supports);
}
}
hasSupport = p3BarPatterns.IsSupport();
if (hasSupport)
{
//
hasSupport = p3BarPatterns.GetSupport(tmpBar, tmpPivot, tmpZone);
if (hasSupport)
{
AddIfNotExists(tmpZone, supports);
}
}
hasSupport = HasChild(supports);
}
hasSupport = HasChild(supports);
//
// Resistances ...
bool hasResistance = false;
if (!HasChild(resistances))
{
//
hasResistance = pBarPatterns.IsResistance();
if (hasResistance)
{
//
hasResistance = pBarPatterns.GetResistance(tmpBar, tmpPivot, tmpZone);
if (hasResistance)
{
AddIfNotExists(tmpZone, resistances);
}
}
hasResistance = p2BarPatterns.IsResistance();
if (hasResistance)
{
//
hasResistance = p2BarPatterns.GetResistance(tmpBar, tmpPivot, tmpZone);
if (hasResistance)
{
AddIfNotExists(tmpZone, resistances);
}
}
hasResistance = p3BarPatterns.IsResistance();
if (hasResistance)
{
//
hasResistance = p3BarPatterns.GetResistance(tmpBar, tmpPivot, tmpZone);
if (hasResistance)
{
AddIfNotExists(tmpZone, resistances);
}
}
hasResistance = HasChild(resistances);
}
hasResistance = HasChild(resistances);
//
// Cleanup ...
tmpBar.Clean();
tmpZone.Clean();
tmpPivot.Clean();
//
// Validate by Not InDirectional Exixsts ...
result =
(isBullish && !hasResistance) ||
(isBearish && !hasSupport);
//
// Validate InDirectional Distance by TP ...
if (!result)
{
//
// Calculate Requirements ...
double points = GetPoints(bar.symbol);
double entry = GetEntry(bar.symbol, (isBullish ? X_DIRECTION_BULLISH : X_DIRECTION_BEARISH));
double slAddition = slAdditionDistance <= 0 ? 0 : slAdditionDistance * points;
double sl = isBullish
? pinBarZone.lower - slAddition
: pinBarZone.upper + slAddition;
double risk = MathAbs(entry - sl);
double tpReward = defaultSignalR2R * risk;
double tp = isBullish
? entry + tpReward
: entry - tpReward;
//
int idx = -1;
if (isBullish)
{
idx = GetYoungest(resistances);
}
else if (isBearish)
{
idx = GetYoungest(supports);
}
result = IsValidIndex(idx);
result =
result &&
(isBullish
? tp < resistances[idx].lower
: tp > supports[idx].upper);
}
//
// Reset Flags ...
if (!result)
{
//
result = false;
isBullish = false;
isBearish = false;
dir = X_DIRECTION_NONE;
}
}
//
@@ -2834,58 +2129,6 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
iConfig.trendRayLeft = false;
iConfig.trendRayRight = false;
//
// PinBar Zone ...
if (pinBarZone.IsValid())
{
poiDrawer.DrawZone(pinBarZone, iConfig);
}
//
// Pullback Zone ...
if (pullbackZone.IsValid())
{
poiDrawer.DrawZone(pullbackZone, iConfig);
}
//
// PinBar Zone Trend ...
if (pinBarZoneTrend.IsValid())
{
poiDrawer.DrawTrendLine(pinBarZoneTrend, iConfig);
}
//
// Rejected Values ...
if (HasChild(rejecteds))
{
//
XTrend iTrend;
bool has = false;
int count = ArraySize(rejecteds);
datetime toTime = zone.to + PeriodSeconds(zone.period);
datetime fromTime = zone.to - PeriodSeconds(zone.period);
for (int i = 0; i < count; i++)
{
//
// Initialize Trend ...
iTrend.Clean();
has = iTrend.Init(
bar.symbol,
bar.period,
bar.time,
rejecteds[i],
fromTime,
rejecteds[i],
toTime //
);
if (has)
{
poiDrawer.DrawTrendLine(iTrend, iConfig);
}
}
}
//
// Draw Zone ...
if (zone.IsValid())
@@ -2960,22 +2203,9 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
pBar.Clean();
p2Bar.Clean();
p3Bar.Clean();
XClean(supports);
mcPVZone.Clean();
lcPVZone.Clean();
hcPVZone.Clean();
XClean(rejecteds);
iPatterns.Clean();
pinBarZone.Clean();
iPPatterns.Clean();
XClean(resistances);
affectedZone.Clean();
pullbackZone.Clean();
pBarPatterns.Clean();
p2BarPatterns.Clean();
p3BarPatterns.Clean();
XClean(doublePatterns);
pinBarZoneTrend.Clean();
iPatternsConfig.Clean();
//