last ...
This commit is contained in:
@@ -790,3 +790,275 @@ bool Strategy2HasSignal(
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
// =======================================
|
||||
// Signaller 4:
|
||||
// CONSOLIDATION Zones ...
|
||||
// =======================================
|
||||
|
||||
/**
|
||||
* Check Bar Has Signal Based on Strategy 4 ...
|
||||
*
|
||||
* @param bar: XOHCL, reference to Bar ...
|
||||
* @param zone: XBoxZone, reference to holds affected zone ...
|
||||
* @param targets: XTarget, reference to detected Signal's Targets collections ...
|
||||
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Strategy4HasSignal(
|
||||
XOHCL &bar,
|
||||
XBoxZone &zone,
|
||||
XTarget &targets[],
|
||||
ENUM_X_DIRECTION &dir //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
zone.Clean();
|
||||
XClean(targets);
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Requirements ...
|
||||
|
||||
//
|
||||
XOHCL pBar;
|
||||
XOHCL p2Bar;
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
|
||||
//
|
||||
// Read PBar ...
|
||||
result = bar.GetPreviousBar(pBar);
|
||||
result = result &&
|
||||
pBar.GetPreviousBar(p2Bar);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Reading pBar Patterns ...
|
||||
XPatternAnalysis pBarAnalysis;
|
||||
poiDetector.AnalyseBarPatterns(
|
||||
pBar,
|
||||
pBarAnalysis,
|
||||
structureConfig.barsAnalysisConfig //
|
||||
);
|
||||
|
||||
//
|
||||
// Do ...
|
||||
|
||||
//
|
||||
bool isConsolidation = poiDetector.IsConsolidationPattern(
|
||||
pBar,
|
||||
zone,
|
||||
dir //
|
||||
);
|
||||
|
||||
//
|
||||
// Validating Consolidation Zone ...
|
||||
int lastPeakOverLast = -1;
|
||||
int lastValeUnderLast = -1;
|
||||
|
||||
//
|
||||
// Bullish Consolidation ...
|
||||
bool isConsolidationBullish =
|
||||
isConsolidation &&
|
||||
IsXBullish(dir) &&
|
||||
fimaHelper.FindLastPeakOverLast(
|
||||
lastPeakOverLast,
|
||||
zone.ToIndex(),
|
||||
zone.FromIndex() - zone.ToIndex() //
|
||||
) &&
|
||||
fimaHelper.IsSarBullish(pBar.Index());
|
||||
|
||||
//
|
||||
// Bearish Consolidation ...
|
||||
bool isConsolidationBearish =
|
||||
isConsolidation &&
|
||||
IsXBearish(dir) &&
|
||||
fimaHelper.FindLastValeUnderLast(
|
||||
lastValeUnderLast,
|
||||
zone.ToIndex(),
|
||||
zone.FromIndex() - zone.ToIndex() //
|
||||
) &&
|
||||
fimaHelper.IsSarBearish(pBar.Index());
|
||||
|
||||
//
|
||||
// Validate based on Bars Patterns ...
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
bool isPBarHasBullishPatterns =
|
||||
(bar.close > pBar.low ||
|
||||
bar.open > pBar.low) &&
|
||||
(
|
||||
//
|
||||
pBarAnalysis.IsPinned(X_DIRECTION_BULLISH) ||
|
||||
pBarAnalysis.IsEngulfed(X_DIRECTION_BULLISH) ||
|
||||
pBarAnalysis.IsMomentum(X_DIRECTION_BULLISH) ||
|
||||
pBarAnalysis.IsPiercing(X_DIRECTION_BULLISH) ||
|
||||
pBarAnalysis.IsSignalKey(X_DIRECTION_BULLISH)
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
bool isPBarHasBearishPatterns =
|
||||
(bar.close < pBar.high ||
|
||||
bar.open < pBar.high) &&
|
||||
(
|
||||
//
|
||||
pBarAnalysis.IsPinned(X_DIRECTION_BEARISH) ||
|
||||
pBarAnalysis.IsEngulfed(X_DIRECTION_BEARISH) ||
|
||||
pBarAnalysis.IsMomentum(X_DIRECTION_BEARISH) ||
|
||||
pBarAnalysis.IsPiercing(X_DIRECTION_BEARISH) ||
|
||||
pBarAnalysis.IsSignalKey(X_DIRECTION_BEARISH)
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
isConsolidationBullish =
|
||||
isConsolidationBullish &&
|
||||
isPBarHasBullishPatterns;
|
||||
|
||||
//
|
||||
isConsolidationBearish =
|
||||
isConsolidationBearish &&
|
||||
isPBarHasBearishPatterns;
|
||||
|
||||
//
|
||||
// Validate Based on Same Peaks and Vales ...
|
||||
|
||||
//
|
||||
int samePVValidationLength = 3;
|
||||
int samePeaks = fimaHelper.CountSamePeaks(pBar.Index(), (zone.FromIndex() - zone.ToIndex()));
|
||||
int sameVales = fimaHelper.CountSameVales(pBar.Index(), (zone.FromIndex() - zone.ToIndex()));
|
||||
|
||||
//
|
||||
bool isPeakValid = samePeaks >= samePVValidationLength;
|
||||
bool isValeValid = sameVales >= samePVValidationLength;
|
||||
bool isPVValid = isPeakValid ||
|
||||
isValeValid;
|
||||
|
||||
//
|
||||
isConsolidationBullish =
|
||||
isConsolidationBullish &&
|
||||
isPVValid;
|
||||
|
||||
//
|
||||
isConsolidationBearish =
|
||||
isConsolidationBearish &&
|
||||
isPVValid;
|
||||
|
||||
//
|
||||
// Validation Consolidation ...
|
||||
isConsolidation =
|
||||
isConsolidationBullish ||
|
||||
isConsolidationBearish;
|
||||
|
||||
//
|
||||
if (isConsolidation)
|
||||
{
|
||||
//
|
||||
zone.to = bar.time;
|
||||
XPOIDrawConfig iConfig = structureDrawConfig.drawConfig;
|
||||
iConfig.zonesWidth = 3;
|
||||
iConfig.bullishColor = clrYellow;
|
||||
iConfig.bearishColor = clrDarkOrange;
|
||||
poiDrawer.DrawZone(zone, iConfig);
|
||||
Print("Consolidation");
|
||||
}
|
||||
|
||||
//
|
||||
isBullish =
|
||||
//
|
||||
false
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
isBearish =
|
||||
//
|
||||
false
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = isBullish ||
|
||||
isBearish;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
dir =
|
||||
isBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
result = HasDirection(dir);
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare Zone ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
result = ToBox(
|
||||
p2Bar,
|
||||
zone,
|
||||
dir,
|
||||
X_BAR_PATTERN_PINNED //
|
||||
);
|
||||
|
||||
//
|
||||
// Manage Stops ...
|
||||
if (result)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
result = zone.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
// Prepare Targets ...
|
||||
if (result)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
zone.Clean();
|
||||
XClean(targets);
|
||||
dir = X_DIRECTION_NONE;
|
||||
}
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user