last works ...
This commit is contained in:
@@ -1431,6 +1431,225 @@ class XCMarketPatternDetector : public XCBase
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsContinuationPullbackPattern(
|
||||||
|
XOHCL &bar,
|
||||||
|
XBoxZone &zone,
|
||||||
|
XBoxZone &continuationalZones[],
|
||||||
|
ENUM_X_DIRECTION &dir,
|
||||||
|
XOHCL &continuationalBar,
|
||||||
|
int continuationLength = 3,
|
||||||
|
bool forceContinuationHasZone = true,
|
||||||
|
bool forceContinuationHasPattern = true,
|
||||||
|
int pullbackLength = 2,
|
||||||
|
bool forcePullbackBreak = false,
|
||||||
|
int zonesLoopback = 5,
|
||||||
|
int zonesValidationLength = 5 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
zone.Clean();
|
||||||
|
CleanDirection(dir);
|
||||||
|
continuationalBar.Clean();
|
||||||
|
XClean(continuationalZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
zonesLoopback = NormalizeInt(zonesLoopback, 3);
|
||||||
|
pullbackLength = NormalizeInt(pullbackLength, 2);
|
||||||
|
continuationLength = NormalizeInt(continuationLength, 2);
|
||||||
|
zonesValidationLength = NormalizeInt(zonesValidationLength, 3);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = bar.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// First we Have to Detect a Pullback ...
|
||||||
|
result = IsPullbackPattern(bar, zone, dir, pullbackLength, forcePullbackBreak);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Select PullBack Start Bar ...
|
||||||
|
XOHCL startBar;
|
||||||
|
result = result &&
|
||||||
|
zone.FromBar(startBar);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Continuation Direction ...
|
||||||
|
XOHCL iBar;
|
||||||
|
int start = startBar.Index() + 1;
|
||||||
|
int end = start + continuationLength;
|
||||||
|
for (int i = start; i < end && result; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Initialize Indexed Bar ...
|
||||||
|
iBar.Clean();
|
||||||
|
result =
|
||||||
|
result &&
|
||||||
|
bar.BarAt(i, iBar);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Direction Same ...
|
||||||
|
result =
|
||||||
|
result &&
|
||||||
|
dir == iBar.GetDirection();
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Setting Continuational Bar ...
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
continuationalBar = iBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Apply Zone Force ...
|
||||||
|
if (result && forceContinuationHasZone)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XBoxZone tmps[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Collectiong Support and Resistances ...
|
||||||
|
CollectZones(startBar, tmps, zonesLoopback, zonesValidationLength, 0, zonesLoopback * 2);
|
||||||
|
Copy(tmps, continuationalZones, false);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Collecting Order Blocks ...
|
||||||
|
// CollectOBs(startBar, tmps, zonesLoopback, 0, zonesLoopback * 2);
|
||||||
|
// Copy(tmps, continuationalZones, false);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Collectiong Fair Value Gaps ...
|
||||||
|
CollectFVGs(startBar, tmps, zonesLoopback, 0, zonesLoopback * 2);
|
||||||
|
Copy(tmps, continuationalZones, false);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Extract Directional Zones ...
|
||||||
|
XClean(tmps);
|
||||||
|
ExtractByDirection(tmps, continuationalZones, zone.dir);
|
||||||
|
Copy(tmps, continuationalZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Result ...
|
||||||
|
result = result &&
|
||||||
|
HasChild(continuationalZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
XClean(tmps);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Apply Pattern Force ...
|
||||||
|
if (result && forceContinuationHasPattern)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool has = false;
|
||||||
|
int pattersCount = 0;
|
||||||
|
ENUM_X_DIRECTION iPatternDir;
|
||||||
|
for (int i = start; i < end; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
iBar.Clean();
|
||||||
|
CleanDirection(iPatternDir);
|
||||||
|
|
||||||
|
//
|
||||||
|
has = bar.BarAt(i, iBar);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Checking Required Patterns ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Pin Bar ...
|
||||||
|
has = IsPinnedBar(iBar, iPatternDir);
|
||||||
|
has = has &&
|
||||||
|
iPatternDir == zone.dir;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
pattersCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Engulfed Bar ...
|
||||||
|
has = IsEngulfedBar(iBar, iPatternDir);
|
||||||
|
has = has &&
|
||||||
|
iPatternDir == zone.dir;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
pattersCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Momentum Bar ...
|
||||||
|
has = IsMomentumBar(iBar, iPatternDir);
|
||||||
|
has = has &&
|
||||||
|
iPatternDir == zone.dir;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
pattersCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Piercing ...
|
||||||
|
has = IsPiercingPattern(iBar, iPatternDir);
|
||||||
|
has = has &&
|
||||||
|
iPatternDir == zone.dir;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
pattersCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// SignalKey ...
|
||||||
|
has = IsSignalKeyBarPattern(iBar, iPatternDir);
|
||||||
|
has = has &&
|
||||||
|
iPatternDir == zone.dir;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
pattersCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
result &&
|
||||||
|
IsValidSize(pattersCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
zone.Clean();
|
||||||
|
CleanDirection(dir);
|
||||||
|
continuationalBar.Clean();
|
||||||
|
XClean(continuationalZones);
|
||||||
|
}
|
||||||
|
iBar.Clean();
|
||||||
|
startBar.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// FVG ...
|
// FVG ...
|
||||||
|
|
||||||
@@ -3911,6 +4130,17 @@ class XCMarketPatternDetector : public XCBase
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter Zones ...
|
||||||
|
*
|
||||||
|
* @param bar: XOHCL, reference to Specified Filtering Bar ...
|
||||||
|
* @param source: XBoxZone, reference collection to hold's filtered zones ...
|
||||||
|
* @param filterDir: ENUM_X_DIRECTION, specified Filter Direction ...
|
||||||
|
* @param priceType: ENUM_X_PRICE, Specified Bar's Price type to Use for Filtering Zones ...
|
||||||
|
* @param forDir: ENUM_X_DIRECTION, Specified Zone's Direction to Handle Filtering ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
int FilterZones(
|
int FilterZones(
|
||||||
XOHCL &bar,
|
XOHCL &bar,
|
||||||
XBoxZone &source[],
|
XBoxZone &source[],
|
||||||
|
|||||||
@@ -0,0 +1,792 @@
|
|||||||
|
|
||||||
|
// =======================================
|
||||||
|
// Temp Signaller:
|
||||||
|
// =======================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Bar Has Signal Based on Strategy X ...
|
||||||
|
*
|
||||||
|
* @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 StrategyXHasSignal(
|
||||||
|
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 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bar Patterns ...
|
||||||
|
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)
|
||||||
|
//
|
||||||
|
);
|
||||||
|
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)
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do ...
|
||||||
|
|
||||||
|
//
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================
|
||||||
|
// Signaller 1:
|
||||||
|
// =======================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Bar Has Signal Based on Strategy 1 ...
|
||||||
|
*
|
||||||
|
* @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 Strategy1HasSignal(
|
||||||
|
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 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bar Patterns ...
|
||||||
|
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)
|
||||||
|
//
|
||||||
|
);
|
||||||
|
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)
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
double peak = fimaHelper.GetPeak(bar.Index());
|
||||||
|
double vale = fimaHelper.GetVale(bar.Index());
|
||||||
|
double pPeak = fimaHelper.GetPeak(pBar.Index());
|
||||||
|
double pVale = fimaHelper.GetVale(pBar.Index());
|
||||||
|
double p2Peak = fimaHelper.GetPeak(p2Bar.Index());
|
||||||
|
double p2Vale = fimaHelper.GetVale(p2Bar.Index());
|
||||||
|
bool isPPeakOverLast = fimaHelper.IsPeakOverLast(pBar.Index());
|
||||||
|
bool isPValeUnderLast = fimaHelper.IsValeUnderLast(pBar.Index());
|
||||||
|
bool isP2PeakOverLast = fimaHelper.IsPeakOverLast(p2Bar.Index());
|
||||||
|
bool isP2ValeUnderLast = fimaHelper.IsValeUnderLast(p2Bar.Index());
|
||||||
|
bool isPeakOverLast = isPPeakOverLast ||
|
||||||
|
isP2PeakOverLast;
|
||||||
|
bool isValeUnderLast = isPValeUnderLast ||
|
||||||
|
isP2ValeUnderLast;
|
||||||
|
bool isP2ValeOverLast = pVale > p2Vale;
|
||||||
|
bool isP2PeakUnderLast = pPeak < p2Peak;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check PBar Close Over Under Fast Ma ...
|
||||||
|
bool isPBarCloseOverFast = pBar.close > fimaHelper.GetMAFast(pBar.Index());
|
||||||
|
bool isPBarCloseUnderFast = pBar.close < fimaHelper.GetMAFast(pBar.Index());
|
||||||
|
bool isFastOverLast = fimaHelper.GetMAFast(pBar.Index()) > fimaHelper.GetMAFast(p2Bar.Index());
|
||||||
|
bool isFastUnderLast = fimaHelper.GetMAFast(pBar.Index()) < fimaHelper.GetMAFast(p2Bar.Index());
|
||||||
|
|
||||||
|
//
|
||||||
|
// Force P2Bar is Pin Bar ...
|
||||||
|
ENUM_X_DIRECTION p2Dir;
|
||||||
|
bool isP2BarPinned = poiDetector.IsPinnedBar(
|
||||||
|
p2Bar,
|
||||||
|
p2Dir //
|
||||||
|
);
|
||||||
|
bool isP2BarBullishPinned =
|
||||||
|
isP2BarPinned &&
|
||||||
|
IsXBullish(p2Dir);
|
||||||
|
bool isP2BarBearishPinned =
|
||||||
|
isP2BarPinned &&
|
||||||
|
IsXBearish(p2Dir);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do ...
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
//
|
||||||
|
isFastOverLast &&
|
||||||
|
isValeUnderLast &&
|
||||||
|
!isP2PeakUnderLast &&
|
||||||
|
isPBarCloseOverFast &&
|
||||||
|
isP2BarBullishPinned &&
|
||||||
|
isPBarHasBullishPatterns
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
//
|
||||||
|
isPeakOverLast &&
|
||||||
|
isFastUnderLast &&
|
||||||
|
!isP2ValeOverLast &&
|
||||||
|
isPBarCloseUnderFast &&
|
||||||
|
isP2BarBearishPinned &&
|
||||||
|
isPBarHasBearishPatterns
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double entry = GetEntry(zone.symbol, zone.dir);
|
||||||
|
double riskSide = zone.IsBullish() ? zone.lower : zone.upper;
|
||||||
|
double risk = MathAbs(entry - riskSide);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Collecting Affected Zones ...
|
||||||
|
XBoxZone tmps[];
|
||||||
|
XBoxZone zones[];
|
||||||
|
XBoxZone actedZones[];
|
||||||
|
XBoxZone insideZones[];
|
||||||
|
XBoxZone breakedZones[];
|
||||||
|
XBoxZone affectedZones[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Support and Resistances ...
|
||||||
|
poiDetector.CollectZones(bar, tmps);
|
||||||
|
Copy(tmps, zones, false);
|
||||||
|
|
||||||
|
//
|
||||||
|
// OBS ...
|
||||||
|
poiDetector.CollectOBs(bar, tmps);
|
||||||
|
Copy(tmps, zones, false);
|
||||||
|
|
||||||
|
//
|
||||||
|
// FVGs ...
|
||||||
|
poiDetector.CollectFVGs(bar, tmps);
|
||||||
|
Copy(tmps, zones, false);
|
||||||
|
|
||||||
|
//
|
||||||
|
ExtractAffectedZones(bar, zones, affectedZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Acteds Zones ...
|
||||||
|
ExtractActeds(bar, actedZones, affectedZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Inside Zones ...
|
||||||
|
ExtractInsides(bar, insideZones, affectedZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Breaked Zones ...
|
||||||
|
ExtractBreakeds(bar, breakedZones, affectedZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw Affected Zones ...
|
||||||
|
if (HasChild(affectedZones))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
UpdateToTime(affectedZones, bar.time);
|
||||||
|
poiDrawer.DrawZones(affectedZones, structureDrawConfig.drawConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw Acted Zones ...
|
||||||
|
// if (HasChild(actedZones))
|
||||||
|
// {
|
||||||
|
// poiDrawer.DrawZones(actedZones, structureDrawConfig.drawConfig);
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw Inside Zones ...
|
||||||
|
// if (HasChild(insideZones))
|
||||||
|
// {
|
||||||
|
// poiDrawer.DrawZones(insideZones, structureDrawConfig.drawConfig);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Draw Breaked Zones ...
|
||||||
|
// if (HasChild(breakedZones))
|
||||||
|
// {
|
||||||
|
// poiDrawer.DrawZones(breakedZones, structureDrawConfig.drawConfig);
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
XClean(tmps);
|
||||||
|
XClean(zones);
|
||||||
|
XClean(actedZones);
|
||||||
|
XClean(insideZones);
|
||||||
|
XClean(breakedZones);
|
||||||
|
XClean(affectedZones);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
zone.to = bar.time;
|
||||||
|
|
||||||
|
//
|
||||||
|
poiDrawer.DrawZone(
|
||||||
|
zone,
|
||||||
|
structureDrawConfig.drawConfig //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = zone.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Targets ...
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
zone.Clean();
|
||||||
|
XClean(targets);
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
}
|
||||||
|
pBar.Clean();
|
||||||
|
p2Bar.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================
|
||||||
|
// Signaller 2:
|
||||||
|
// =======================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Bar Has Signal Based on Strategy 1 ...
|
||||||
|
*
|
||||||
|
* @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 Strategy2HasSignal(
|
||||||
|
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;
|
||||||
|
bool isBullish = false;
|
||||||
|
bool isBearish = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Read PBar ...
|
||||||
|
result = bar.GetPreviousBar(pBar);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pBar.Clean();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reading Conditions ...
|
||||||
|
int pullBackStartBar = -1;
|
||||||
|
bool isPullBack = result &&
|
||||||
|
poiDetector.IsPullbackPattern(
|
||||||
|
pBar,
|
||||||
|
zone,
|
||||||
|
dir,
|
||||||
|
2,
|
||||||
|
false // Force Break ...
|
||||||
|
);
|
||||||
|
bool isPullbackBullish = isPullBack &&
|
||||||
|
IsXBullish(dir);
|
||||||
|
bool isPullbackBearish = isPullBack &&
|
||||||
|
IsXBearish(dir);
|
||||||
|
if (isPullBack)
|
||||||
|
{
|
||||||
|
pullBackStartBar = zone.FromIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reading HK Bond ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double pHKBondUpper = fimaHelper.GetHKBondUpper(pBar.Index());
|
||||||
|
double pHKBondLower = fimaHelper.GetHKBondLower(pBar.Index());
|
||||||
|
int overHKBondUpperCount = fimaHelper.CountOverHKBondUpper(pullBackStartBar, X_PRICE_LOW);
|
||||||
|
int underHKBondLowerCount = fimaHelper.CountUnderHKBondLower(pullBackStartBar, X_PRICE_HIGH);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reading PV Requirements ...
|
||||||
|
|
||||||
|
//
|
||||||
|
int lastPeakOverLastIDX = -1;
|
||||||
|
int lastValeUnderLastIDX = -1;
|
||||||
|
double pPeak = fimaHelper.GetPeak(pBar.Index());
|
||||||
|
double pVale = fimaHelper.GetVale(pBar.Index());
|
||||||
|
int samePeaks = fimaHelper.CountSamePeaks(pBar.Index());
|
||||||
|
int sameVales = fimaHelper.CountSameVales(pBar.Index());
|
||||||
|
fimaHelper.FindLastPeakOverLast(lastPeakOverLastIDX, pBar.Index());
|
||||||
|
fimaHelper.FindLastValeUnderLast(lastValeUnderLastIDX, pBar.Index());
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reading pBar Patterns ...
|
||||||
|
XPatternAnalysis pBarAnalysis;
|
||||||
|
poiDetector.AnalyseBarPatterns(
|
||||||
|
pBar,
|
||||||
|
pBarAnalysis,
|
||||||
|
structureConfig.barsAnalysisConfig //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bar Patterns ...
|
||||||
|
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)
|
||||||
|
//
|
||||||
|
);
|
||||||
|
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)
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check PBar Close Over Under Fast Ma ...
|
||||||
|
bool isPBarCloseOverFast = pBar.close > fimaHelper.GetMAFast(pBar.Index());
|
||||||
|
bool isPBarCloseUnderFast = pBar.close < fimaHelper.GetMAFast(pBar.Index());
|
||||||
|
|
||||||
|
//
|
||||||
|
// Try To Find Affected Zone ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Collecting Zones ...
|
||||||
|
XBoxZone zones[];
|
||||||
|
XBoxZone affectedZones[];
|
||||||
|
XBoxZone affectedZonesBullish[];
|
||||||
|
XBoxZone affectedZonesBearish[];
|
||||||
|
int zonesCount = poiDetector.CollectZones(
|
||||||
|
pBar,
|
||||||
|
zones, //
|
||||||
|
5, // Zones Loopback ...
|
||||||
|
3 // Zones Validation Length ...
|
||||||
|
// Required Zones ...
|
||||||
|
// Loopback ...
|
||||||
|
);
|
||||||
|
int affectedZonesCount = ExtractAffectedZones(
|
||||||
|
pBar,
|
||||||
|
zones,
|
||||||
|
affectedZones //
|
||||||
|
);
|
||||||
|
int affectedZonesBullishCount = ExtractByDirection(
|
||||||
|
affectedZonesBullish,
|
||||||
|
affectedZones,
|
||||||
|
X_DIRECTION_BULLISH //
|
||||||
|
);
|
||||||
|
int affectedZonesBearishCount = ExtractByDirection(
|
||||||
|
affectedZonesBearish,
|
||||||
|
affectedZones,
|
||||||
|
X_DIRECTION_BEARISH //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
int insideBullishIDX = -1;
|
||||||
|
int insideBearishIDX = -1;
|
||||||
|
bool hasBullishInside =
|
||||||
|
pBar.IsBullish() &&
|
||||||
|
HasInside(
|
||||||
|
insideBullishIDX,
|
||||||
|
pBar,
|
||||||
|
affectedZonesBullish //
|
||||||
|
);
|
||||||
|
bool hasBearishInside =
|
||||||
|
pBar.IsBearish() &&
|
||||||
|
HasInside(
|
||||||
|
insideBearishIDX,
|
||||||
|
pBar,
|
||||||
|
affectedZonesBearish //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do ...
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
//
|
||||||
|
hasBullishInside &&
|
||||||
|
isPullbackBullish &&
|
||||||
|
isPBarHasBullishPatterns &&
|
||||||
|
fimaHelper.IsSarBullish(pBar.Index()) &&
|
||||||
|
(pVale >= affectedZonesBullish[insideBullishIDX].lower &&
|
||||||
|
pVale <= affectedZonesBullish[insideBullishIDX].upper)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
//
|
||||||
|
hasBearishInside &&
|
||||||
|
isPullbackBearish &&
|
||||||
|
isPBarHasBearishPatterns &&
|
||||||
|
fimaHelper.IsSarBearish(pBar.Index()) &&
|
||||||
|
(pPeak >= affectedZonesBearish[insideBearishIDX].lower &&
|
||||||
|
pPeak <= affectedZonesBearish[insideBearishIDX].upper)
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = isBullish ||
|
||||||
|
isBearish;
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isBullish)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
poiDrawer.DrawZone(
|
||||||
|
affectedZonesBullish[insideBullishIDX],
|
||||||
|
structureDrawConfig.drawConfig //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
poiDrawer.DrawZone(
|
||||||
|
affectedZonesBearish[insideBearishIDX],
|
||||||
|
structureDrawConfig.drawConfig //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
dir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = HasDirection(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Zone ...
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
zone.Clean();
|
||||||
|
if (isBullish)
|
||||||
|
{
|
||||||
|
zone = affectedZonesBullish[insideBullishIDX];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
zone = affectedZonesBearish[insideBearishIDX];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = zone.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Targets ...
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
zone.Clean();
|
||||||
|
XClean(targets);
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
}
|
||||||
|
pBar.Clean();
|
||||||
|
XClean(zones);
|
||||||
|
pBarAnalysis.Clean();
|
||||||
|
XClean(affectedZones);
|
||||||
|
XClean(affectedZonesBullish);
|
||||||
|
XClean(affectedZonesBearish);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
@@ -1,97 +1,295 @@
|
|||||||
|
|
||||||
// //
|
// //
|
||||||
// isBullish =
|
// isBullish =
|
||||||
// //
|
// //
|
||||||
// // Vales Same ...
|
// // Vales Same ...
|
||||||
// sameVales >= 7 &&
|
// sameVales >= 7 &&
|
||||||
// //
|
// //
|
||||||
// // PBar Patterns ...
|
// // PBar Patterns ...
|
||||||
// isBarPatternsPassed &&
|
// isBarPatternsPassed &&
|
||||||
// isPBarCloseOverFast &&
|
// isPBarCloseOverFast &&
|
||||||
// //
|
// //
|
||||||
// // Validate PullBack based on HK Bond ...
|
// // Validate PullBack based on HK Bond ...
|
||||||
// isPullbackBullish &&
|
// isPullbackBullish &&
|
||||||
// pBar.close > pHKBondLower;
|
// pBar.close > pHKBondLower;
|
||||||
|
|
||||||
|
//
|
||||||
|
// poiDrawer.DrawPatternAnalysis(
|
||||||
|
// pBarAnalysis,
|
||||||
|
// structureDrawConfig.barAnalysisDrawConfig //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// if (IsValidSize(zonesCount))
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// poiDrawer.DrawZones(
|
||||||
|
// zones,
|
||||||
|
// structureDrawConfig.drawConfig //
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// if (IsValidSize(affectedZonesCount))
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// poiDrawer.DrawZones(
|
||||||
|
// affectedZones,
|
||||||
|
// structureDrawConfig.drawConfig //
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// poiDrawer.DrawZones(
|
||||||
|
// affectedZonesBullish,
|
||||||
|
// structureDrawConfig.drawConfig //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// poiDrawer.DrawZones(
|
||||||
|
// affectedZonesBearish,
|
||||||
|
// structureDrawConfig.drawConfig //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Update POI Zones ...
|
||||||
|
// ENUM_X_DETECTOR_ZONE_ACTION zoneActions[];
|
||||||
|
// poiDetector.UpdateZones(
|
||||||
|
// iBar,
|
||||||
|
// zoneActions //
|
||||||
|
// // Validation Length ...
|
||||||
|
// // Required Zones ...
|
||||||
|
// // Loopback ...
|
||||||
|
// );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve Conditions ...
|
||||||
|
// conditions.Clean();
|
||||||
|
// has = fimaHelper.GetConditions(
|
||||||
|
// conditions,
|
||||||
|
// barIndex,
|
||||||
|
// 10 // Loopback ...
|
||||||
|
// );
|
||||||
|
// if (!has)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// iBar.Clean();
|
||||||
|
// conditions.Clean();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// structure.Clean();
|
||||||
|
// poiDetector.AnalyseMarket(
|
||||||
|
// structure,
|
||||||
|
// structureConfig,
|
||||||
|
// barIndex //
|
||||||
|
// );
|
||||||
|
// poiDrawer.drawnObjects.Clear();
|
||||||
|
// poiDrawer.DrawMarketStructure(
|
||||||
|
// structure,
|
||||||
|
// structureDrawConfig //
|
||||||
|
// );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Bar Has Signal Based on Strategy X ...
|
||||||
|
*
|
||||||
|
* @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 StrategyXHasSignal(
|
||||||
|
XOHCL &bar,
|
||||||
|
XBoxZone &zone,
|
||||||
|
XTarget &targets[],
|
||||||
|
ENUM_X_DIRECTION &dir //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
// poiDrawer.DrawPatternAnalysis(
|
// Prepare ...
|
||||||
// pBarAnalysis,
|
zone.Clean();
|
||||||
// structureDrawConfig.barAnalysisDrawConfig //
|
XClean(targets);
|
||||||
// );
|
dir = X_DIRECTION_NONE;
|
||||||
|
|
||||||
// //
|
|
||||||
// if (IsValidSize(zonesCount))
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// poiDrawer.DrawZones(
|
|
||||||
// zones,
|
|
||||||
// structureDrawConfig.drawConfig //
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //
|
|
||||||
// if (IsValidSize(affectedZonesCount))
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// poiDrawer.DrawZones(
|
|
||||||
// affectedZones,
|
|
||||||
// structureDrawConfig.drawConfig //
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// poiDrawer.DrawZones(
|
// Validate ...
|
||||||
// affectedZonesBullish,
|
result = bar.IsValid();
|
||||||
// structureDrawConfig.drawConfig //
|
if (!result)
|
||||||
// );
|
{
|
||||||
|
return result;
|
||||||
// //
|
}
|
||||||
// poiDrawer.DrawZones(
|
|
||||||
// affectedZonesBearish,
|
|
||||||
// structureDrawConfig.drawConfig //
|
|
||||||
// );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// //
|
|
||||||
// // Update POI Zones ...
|
|
||||||
// ENUM_X_DETECTOR_ZONE_ACTION zoneActions[];
|
|
||||||
// poiDetector.UpdateZones(
|
|
||||||
// iBar,
|
|
||||||
// zoneActions //
|
|
||||||
// // Validation Length ...
|
|
||||||
// // Required Zones ...
|
|
||||||
// // Loopback ...
|
|
||||||
// );
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Retrieve Conditions ...
|
// Define Requirements ...
|
||||||
// conditions.Clean();
|
|
||||||
// has = fimaHelper.GetConditions(
|
|
||||||
// conditions,
|
|
||||||
// barIndex,
|
|
||||||
// 10 // Loopback ...
|
|
||||||
// );
|
|
||||||
// if (!has)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// iBar.Clean();
|
|
||||||
// conditions.Clean();
|
|
||||||
|
|
||||||
// //
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// structure.Clean();
|
XOHCL pBar;
|
||||||
// poiDetector.AnalyseMarket(
|
XOHCL p2Bar;
|
||||||
// structure,
|
bool isBullish = false;
|
||||||
// structureConfig,
|
bool isBearish = false;
|
||||||
// barIndex //
|
XOHCL continuationalBar;
|
||||||
// );
|
XBoxZone continuationalZones[];
|
||||||
// poiDrawer.drawnObjects.Clear();
|
|
||||||
// poiDrawer.DrawMarketStructure(
|
//
|
||||||
// structure,
|
// Read PBar ...
|
||||||
// structureDrawConfig //
|
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 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Continuational Pullback ...
|
||||||
|
bool isContinuationPullBack = poiDetector.IsContinuationPullbackPattern(
|
||||||
|
pBar,
|
||||||
|
zone,
|
||||||
|
continuationalZones,
|
||||||
|
dir,
|
||||||
|
continuationalBar,
|
||||||
|
3, // Continuational Length ...
|
||||||
|
true, // Force Continuational Loopback Has Zones ...
|
||||||
|
true, // Force Continuational Loopback Has Patterns ...
|
||||||
|
2, // Pullback Length ...
|
||||||
|
false // Force Pullback Break ...
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do ...
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
//
|
||||||
|
IsXBullish(dir) &&
|
||||||
|
isContinuationPullBack &&
|
||||||
|
continuationalBar.GetUp() < pBar.GetDown() &&
|
||||||
|
true
|
||||||
|
// isPBarHasBullishPatterns
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
//
|
||||||
|
IsXBearish(dir) &&
|
||||||
|
isContinuationPullBack &&
|
||||||
|
continuationalBar.GetDown() > pBar.GetUp() &&
|
||||||
|
true
|
||||||
|
// isPBarHasBearishPatterns
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = isBullish ||
|
||||||
|
isBearish;
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
dir =
|
||||||
|
isBullish
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: X_DIRECTION_BEARISH;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = HasDirection(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Zone ...
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// zone.to = bar.time;
|
||||||
|
// poiDrawer.DrawZone(zone, structureDrawConfig.drawConfig);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw Continuational Zones ...
|
||||||
|
UpdateToTime(continuationalZones, bar.time);
|
||||||
|
poiDrawer.DrawZones(continuationalZones, structureDrawConfig.drawConfig);
|
||||||
|
|
||||||
|
//
|
||||||
|
zone.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
int idx = -1;
|
||||||
|
if (isBullish)
|
||||||
|
{
|
||||||
|
idx = GetHighestBelow(bar.GetDown(), continuationalZones);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
idx = GetLowestAbove(bar.GetUp(), continuationalZones);
|
||||||
|
}
|
||||||
|
result = IsValidIndex(idx);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
zone = continuationalZones[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (zone.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XPOIDrawConfig iConfig = structureDrawConfig.drawConfig;
|
||||||
|
iConfig.bullishColor = clrYellow;
|
||||||
|
iConfig.bearishColor = clrYellow;
|
||||||
|
poiDrawer.DrawZones(continuationalZones, iConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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();
|
||||||
|
continuationalBar.Clean();
|
||||||
|
XClean(continuationalZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|||||||
@@ -5351,6 +5351,121 @@ int ExtractInsides(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract all Items which Specified Bar is Acted them ...
|
||||||
|
*
|
||||||
|
* @param bar: reference to Specified Bar ...
|
||||||
|
* @param dest: reference to result ...
|
||||||
|
* @param source: reference collection to provide source ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int ExtractActeds(
|
||||||
|
XOHCL &bar,
|
||||||
|
XBoxZone &dest[],
|
||||||
|
XBoxZone &source[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
XClean(dest);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool has = bar.IsValid() &&
|
||||||
|
HasChild(source);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(source);
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
has = IsActed(
|
||||||
|
bar,
|
||||||
|
source[i] //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
AddIfNotExists(
|
||||||
|
source[i],
|
||||||
|
dest //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = ArraySize(dest);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract all Items which Specified Bar is Breaked them ...
|
||||||
|
*
|
||||||
|
* @param bar: reference to Specified Bar ...
|
||||||
|
* @param dest: reference to result ...
|
||||||
|
* @param source: reference collection to provide source ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int ExtractBreakeds(
|
||||||
|
XOHCL &bar,
|
||||||
|
XBoxZone &dest[],
|
||||||
|
XBoxZone &source[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
SpecifiedClean(dest);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool has = bar.IsValid() &&
|
||||||
|
HasChild(source);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(source);
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
has = IsBreaked(
|
||||||
|
bar,
|
||||||
|
source[i] //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
AddIfNotExists(
|
||||||
|
source[i],
|
||||||
|
dest //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = ArraySize(dest);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collect all Bars which Breakes Specified Zone ...
|
* Collect all Bars which Breakes Specified Zone ...
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -349,8 +349,8 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Strategy 1 ...
|
// Strategy X ...
|
||||||
has = Strategy1HasSignal(
|
has = StrategyXHasSignal(
|
||||||
iBar,
|
iBar,
|
||||||
iZone,
|
iZone,
|
||||||
iTargets,
|
iTargets,
|
||||||
@@ -465,18 +465,16 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
// Implementing Strategies ...
|
// Implementing Strategies ...
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check Bar Has Signal Based on Strategy 1 ...
|
* Check Bar Has Signal Based on Strategy X ...
|
||||||
*
|
*
|
||||||
* @param bar: XOHCL, reference to Bar ...
|
* @param bar: XOHCL, reference to Bar ...
|
||||||
* @param zone: XBoxZone, reference to holds affected zone ...
|
* @param zone: XBoxZone, reference to holds affected zone ...
|
||||||
* @param targets: XTarget, reference to detected Signal's Targets collections ...
|
* @param targets: XTarget, reference to detected Signal's Targets collections ...
|
||||||
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
|
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
|
||||||
* @param conditions: XFIMAConditions, reference to Bar Specified XFIMA Conditions ...
|
|
||||||
* @param structure: XFIMAMarketStructure, refrence to Provides Market Structure ...
|
|
||||||
*
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
*/
|
*/
|
||||||
bool Strategy1HasSignal(
|
bool StrategyXHasSignal(
|
||||||
XOHCL &bar,
|
XOHCL &bar,
|
||||||
XBoxZone &zone,
|
XBoxZone &zone,
|
||||||
XTarget &targets[],
|
XTarget &targets[],
|
||||||
@@ -487,214 +485,41 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Prepare ...
|
result = Strategy2HasSignal(
|
||||||
zone.Clean();
|
bar,
|
||||||
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 //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check Bar Patterns ...
|
|
||||||
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)
|
|
||||||
//
|
|
||||||
);
|
|
||||||
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)
|
|
||||||
//
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
double pPeak = fimaHelper.GetPeak(pBar.Index());
|
|
||||||
double pVale = fimaHelper.GetVale(pBar.Index());
|
|
||||||
bool isPPeakOverLast = fimaHelper.IsPeakOverLast(pBar.Index());
|
|
||||||
bool isPValeUnderLast = fimaHelper.IsValeUnderLast(pBar.Index());
|
|
||||||
bool isP2PeakOverLast = fimaHelper.IsPeakOverLast(p2Bar.Index());
|
|
||||||
bool isP2ValeUnderLast = fimaHelper.IsValeUnderLast(p2Bar.Index());
|
|
||||||
bool isPeakOverLast = isPPeakOverLast ||
|
|
||||||
isP2PeakOverLast;
|
|
||||||
bool isValeUnderLast = isPValeUnderLast ||
|
|
||||||
isP2ValeUnderLast;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check PBar Close Over Under Fast Ma ...
|
|
||||||
bool isPBarCloseOverFast = pBar.close > fimaHelper.GetMAFast(pBar.Index());
|
|
||||||
bool isPBarCloseUnderFast = pBar.close < fimaHelper.GetMAFast(pBar.Index());
|
|
||||||
bool isFastOverLast = fimaHelper.GetMAFast(pBar.Index()) > fimaHelper.GetMAFast(p2Bar.Index());
|
|
||||||
bool isFastUnderLast = fimaHelper.GetMAFast(pBar.Index()) < fimaHelper.GetMAFast(p2Bar.Index());
|
|
||||||
|
|
||||||
//
|
|
||||||
// Force P2Bar is Pin Bar ...
|
|
||||||
ENUM_X_DIRECTION p2Dir;
|
|
||||||
bool isP2BarPinned = poiDetector.IsPinnedBar(
|
|
||||||
p2Bar,
|
|
||||||
p2Dir //
|
|
||||||
);
|
|
||||||
bool isP2BarBullishPinned =
|
|
||||||
isP2BarPinned &&
|
|
||||||
IsXBullish(p2Dir);
|
|
||||||
bool isP2BarBearishPinned =
|
|
||||||
isP2BarPinned &&
|
|
||||||
IsXBearish(p2Dir);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
|
|
||||||
//
|
|
||||||
isBullish =
|
|
||||||
//
|
|
||||||
isFastOverLast &&
|
|
||||||
isValeUnderLast &&
|
|
||||||
isPBarCloseOverFast &&
|
|
||||||
isP2BarBullishPinned &&
|
|
||||||
isPBarHasBullishPatterns
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
isBearish =
|
|
||||||
//
|
|
||||||
isPeakOverLast &&
|
|
||||||
isFastUnderLast &&
|
|
||||||
isPBarCloseUnderFast &&
|
|
||||||
isP2BarBearishPinned &&
|
|
||||||
isPBarHasBearishPatterns
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
// 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,
|
zone,
|
||||||
dir,
|
targets,
|
||||||
X_BAR_PATTERN_PINNED //
|
dir //
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
zone.to = bar.time;
|
|
||||||
|
|
||||||
//
|
|
||||||
poiDrawer.DrawZone(
|
|
||||||
zone,
|
|
||||||
structureDrawConfig.drawConfig //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
result = zone.IsValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Prepare Targets ...
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Cleanup ...
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
|
result = Strategy3HasSignal(
|
||||||
|
bar,
|
||||||
|
zone,
|
||||||
|
targets,
|
||||||
|
dir //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
zone.Clean();
|
if (result)
|
||||||
XClean(targets);
|
{
|
||||||
dir = X_DIRECTION_NONE;
|
Print("Salam");
|
||||||
}
|
}
|
||||||
pBar.Clean();
|
|
||||||
p2Bar.Clean();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check Bar Has Signal Based on Strategy 1 ...
|
* Check Bar Has Signal Based on Strategy 3 ...
|
||||||
*
|
*
|
||||||
* @param bar: XOHCL, reference to Bar ...
|
* @param bar: XOHCL, reference to Bar ...
|
||||||
* @param zone: XBoxZone, reference to holds affected zone ...
|
* @param zone: XBoxZone, reference to holds affected zone ...
|
||||||
* @param targets: XTarget, reference to detected Signal's Targets collections ...
|
* @param targets: XTarget, reference to detected Signal's Targets collections ...
|
||||||
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
|
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
|
||||||
* @param conditions: XFIMAConditions, reference to Bar Specified XFIMA Conditions ...
|
|
||||||
* @param structure: XFIMAMarketStructure, refrence to Provides Market Structure ...
|
|
||||||
*
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
*/
|
*/
|
||||||
@@ -980,6 +805,322 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Bar Has Signal Based on Strategy 3 ...
|
||||||
|
*
|
||||||
|
* @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 Strategy3HasSignal(
|
||||||
|
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 //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Bar Patterns ...
|
||||||
|
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)
|
||||||
|
//
|
||||||
|
);
|
||||||
|
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)
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
double peak = fimaHelper.GetPeak(bar.Index());
|
||||||
|
double vale = fimaHelper.GetVale(bar.Index());
|
||||||
|
double pPeak = fimaHelper.GetPeak(pBar.Index());
|
||||||
|
double pVale = fimaHelper.GetVale(pBar.Index());
|
||||||
|
double p2Peak = fimaHelper.GetPeak(p2Bar.Index());
|
||||||
|
double p2Vale = fimaHelper.GetVale(p2Bar.Index());
|
||||||
|
bool isPPeakOverLast = fimaHelper.IsPeakOverLast(pBar.Index());
|
||||||
|
bool isPValeUnderLast = fimaHelper.IsValeUnderLast(pBar.Index());
|
||||||
|
bool isP2PeakOverLast = fimaHelper.IsPeakOverLast(p2Bar.Index());
|
||||||
|
bool isP2ValeUnderLast = fimaHelper.IsValeUnderLast(p2Bar.Index());
|
||||||
|
bool isPeakOverLast = isPPeakOverLast ||
|
||||||
|
isP2PeakOverLast;
|
||||||
|
bool isValeUnderLast = isPValeUnderLast ||
|
||||||
|
isP2ValeUnderLast;
|
||||||
|
bool isP2ValeOverLast = pVale > p2Vale;
|
||||||
|
bool isP2PeakUnderLast = pPeak < p2Peak;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check PBar Close Over Under Fast Ma ...
|
||||||
|
bool isPBarCloseOverFast = pBar.close > fimaHelper.GetMAFast(pBar.Index());
|
||||||
|
bool isPBarCloseUnderFast = pBar.close < fimaHelper.GetMAFast(pBar.Index());
|
||||||
|
bool isFastOverLast = fimaHelper.GetMAFast(pBar.Index()) > fimaHelper.GetMAFast(p2Bar.Index());
|
||||||
|
bool isFastUnderLast = fimaHelper.GetMAFast(pBar.Index()) < fimaHelper.GetMAFast(p2Bar.Index());
|
||||||
|
|
||||||
|
//
|
||||||
|
// Force P2Bar is Pin Bar ...
|
||||||
|
ENUM_X_DIRECTION p2Dir;
|
||||||
|
bool isP2BarPinned = poiDetector.IsPinnedBar(
|
||||||
|
p2Bar,
|
||||||
|
p2Dir //
|
||||||
|
);
|
||||||
|
bool isP2BarBullishPinned =
|
||||||
|
isP2BarPinned &&
|
||||||
|
IsXBullish(p2Dir);
|
||||||
|
bool isP2BarBearishPinned =
|
||||||
|
isP2BarPinned &&
|
||||||
|
IsXBearish(p2Dir);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do ...
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
//
|
||||||
|
isFastOverLast &&
|
||||||
|
isValeUnderLast &&
|
||||||
|
!isP2PeakUnderLast &&
|
||||||
|
isPBarCloseOverFast &&
|
||||||
|
isP2BarBullishPinned &&
|
||||||
|
isPBarHasBullishPatterns
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
//
|
||||||
|
isPeakOverLast &&
|
||||||
|
isFastUnderLast &&
|
||||||
|
!isP2ValeOverLast &&
|
||||||
|
isPBarCloseUnderFast &&
|
||||||
|
isP2BarBearishPinned &&
|
||||||
|
isPBarHasBearishPatterns
|
||||||
|
//
|
||||||
|
;
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double entry = GetEntry(zone.symbol, zone.dir);
|
||||||
|
double riskSide = zone.IsBullish() ? zone.lower : zone.upper;
|
||||||
|
double risk = MathAbs(entry - riskSide);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Collecting Affected Zones ...
|
||||||
|
XBoxZone tmps[];
|
||||||
|
XBoxZone zones[];
|
||||||
|
XBoxZone actedZones[];
|
||||||
|
XBoxZone insideZones[];
|
||||||
|
XBoxZone breakedZones[];
|
||||||
|
XBoxZone affectedZones[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Support and Resistances ...
|
||||||
|
poiDetector.CollectZones(bar, tmps);
|
||||||
|
Copy(tmps, zones, false);
|
||||||
|
|
||||||
|
//
|
||||||
|
// OBS ...
|
||||||
|
poiDetector.CollectOBs(bar, tmps);
|
||||||
|
Copy(tmps, zones, false);
|
||||||
|
|
||||||
|
//
|
||||||
|
// FVGs ...
|
||||||
|
poiDetector.CollectFVGs(bar, tmps);
|
||||||
|
Copy(tmps, zones, false);
|
||||||
|
|
||||||
|
//
|
||||||
|
ExtractAffectedZones(bar, zones, affectedZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Acteds Zones ...
|
||||||
|
ExtractActeds(bar, actedZones, affectedZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Inside Zones ...
|
||||||
|
ExtractInsides(bar, insideZones, affectedZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Breaked Zones ...
|
||||||
|
ExtractBreakeds(bar, breakedZones, affectedZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw Affected Zones ...
|
||||||
|
if (HasChild(affectedZones))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
UpdateToTime(affectedZones, bar.time);
|
||||||
|
poiDrawer.DrawZones(affectedZones, structureDrawConfig.drawConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw Acted Zones ...
|
||||||
|
// if (HasChild(actedZones))
|
||||||
|
// {
|
||||||
|
// poiDrawer.DrawZones(actedZones, structureDrawConfig.drawConfig);
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw Inside Zones ...
|
||||||
|
// if (HasChild(insideZones))
|
||||||
|
// {
|
||||||
|
// poiDrawer.DrawZones(insideZones, structureDrawConfig.drawConfig);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Draw Breaked Zones ...
|
||||||
|
// if (HasChild(breakedZones))
|
||||||
|
// {
|
||||||
|
// poiDrawer.DrawZones(breakedZones, structureDrawConfig.drawConfig);
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
XClean(tmps);
|
||||||
|
XClean(zones);
|
||||||
|
XClean(actedZones);
|
||||||
|
XClean(insideZones);
|
||||||
|
XClean(breakedZones);
|
||||||
|
XClean(affectedZones);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
zone.to = bar.time;
|
||||||
|
|
||||||
|
//
|
||||||
|
poiDrawer.DrawZone(
|
||||||
|
zone,
|
||||||
|
structureDrawConfig.drawConfig //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = zone.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Targets ...
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
zone.Clean();
|
||||||
|
XClean(targets);
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
}
|
||||||
|
pBar.Clean();
|
||||||
|
p2Bar.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,986 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// SaherElm IT Center MQL5 Class
|
|
||||||
// -------------------------------------------------
|
|
||||||
// Name: XCXFIMASignaller ...
|
|
||||||
// Description: XFIMA Signaller Class ...
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Maintainer:
|
|
||||||
// ------------
|
|
||||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Global Properties ...
|
|
||||||
#property library
|
|
||||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
|
||||||
#property link "https://saherelm.ir"
|
|
||||||
#property version "1.00"
|
|
||||||
#property description "SaherElm XFIMA Signaller Class"
|
|
||||||
#property strict
|
|
||||||
|
|
||||||
//
|
|
||||||
// Imports ...
|
|
||||||
#include "../../Classes/x-saherelm.x-signaller.class.mq5"
|
|
||||||
#include "../../Helpers/x-saherelm.xfima.helper.mq5"
|
|
||||||
#include "../Classes/x-saherelm.xfima.x-poi.detector.class.mq5"
|
|
||||||
#include "../Classes/x-saherelm.xfima.x-poi.drawer.class.mq5"
|
|
||||||
|
|
||||||
//
|
|
||||||
// Implementation ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// Base XFIMA base Signaller ...
|
|
||||||
class XCXFIMABaseSignaller : public XCBaseSignaller
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Public ...
|
|
||||||
public:
|
|
||||||
//
|
|
||||||
// Props ...
|
|
||||||
|
|
||||||
//
|
|
||||||
bool ignoreTargets; // Ignore Signal Targets ...
|
|
||||||
CArrayObj drawnObjects; // Drawing Objects Holder ...
|
|
||||||
XFIMAInputs fimaInputs; // XFIMA Inputs ...
|
|
||||||
XCXFIMAHelper *fimaHelper; // XFIMA Indicator Helper ...
|
|
||||||
XCXFIMAPOIDrawer *poiDrawer; // XFIMA POI Drawer ...
|
|
||||||
XCXFIMAPOIDetector *poiDetector; // XFIMA POI Detector ...
|
|
||||||
XFIMAMarketStructureConfig structureConfig; // XFIMA Market Structure Detector Config ...
|
|
||||||
XFIMAMarketStructureDrawerConfig structureDrawConfig; // XFIMA Market Structure Draw Config ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// Constructor ...
|
|
||||||
XCXFIMABaseSignaller(
|
|
||||||
string _name, // Name ...
|
|
||||||
string _symbol, // Symbol ...
|
|
||||||
ENUM_TIMEFRAMES _period, // Period ...
|
|
||||||
XFIMAInputs &_fimaInputs, // XFIMAInputs ...
|
|
||||||
bool _processAllTicks = false, // Process All Ticks ...
|
|
||||||
double _defaultSignalR2R = 1.5, // Default Signal Risk To Reward Ratio ...
|
|
||||||
double _defaultSignalRiskInPoint = 50, // Default Signal Risk In Point ...
|
|
||||||
double _defaultSignalVolume = 0.01 // Default Signal Volume ...
|
|
||||||
) : XCBaseSignaller(_name,
|
|
||||||
_symbol,
|
|
||||||
_period,
|
|
||||||
_processAllTicks,
|
|
||||||
_defaultSignalR2R,
|
|
||||||
_defaultSignalRiskInPoint,
|
|
||||||
_defaultSignalVolume //
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Instantiating XFIMA Indicator Helper Class ...
|
|
||||||
if (_fimaInputs.IsValid())
|
|
||||||
{
|
|
||||||
//
|
|
||||||
fimaHelper = new XCXFIMAHelper();
|
|
||||||
bool isInited = fimaHelper.Init(
|
|
||||||
_symbol,
|
|
||||||
_period,
|
|
||||||
_fimaInputs //
|
|
||||||
);
|
|
||||||
if (isInited)
|
|
||||||
{
|
|
||||||
fimaInputs = _fimaInputs;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//
|
|
||||||
delete fimaHelper;
|
|
||||||
ZeroMemory(fimaHelper);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
poiDrawer = new XCXFIMAPOIDrawer();
|
|
||||||
poiDetector = new XCXFIMAPOIDetector(fimaHelper);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Configure ...
|
|
||||||
structureConfig.Default();
|
|
||||||
structureDrawConfig.Default();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Deconstructor ...
|
|
||||||
~XCXFIMABaseSignaller()
|
|
||||||
{
|
|
||||||
Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Overrides ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// Actions ...
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy ...
|
|
||||||
*/
|
|
||||||
void Destroy()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
BeforeDestroy();
|
|
||||||
|
|
||||||
//
|
|
||||||
fimaInputs.Clean();
|
|
||||||
|
|
||||||
//
|
|
||||||
delete fimaHelper;
|
|
||||||
ZeroMemory(fimaHelper);
|
|
||||||
|
|
||||||
//
|
|
||||||
delete poiDrawer;
|
|
||||||
ZeroMemory(poiDrawer);
|
|
||||||
|
|
||||||
//
|
|
||||||
delete poiDetector;
|
|
||||||
ZeroMemory(poiDetector);
|
|
||||||
|
|
||||||
//
|
|
||||||
structureConfig.Clean();
|
|
||||||
structureDrawConfig.Clean();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Virtuals ...
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Before Destroy ...
|
|
||||||
*/
|
|
||||||
void virtual BeforeDestroy()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Processing Tick ...
|
|
||||||
*
|
|
||||||
* @param barIndex: int, Specified Bar Index ...
|
|
||||||
*/
|
|
||||||
virtual void ProcessTick(int barIndex = 0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Processing New Bar ...
|
|
||||||
*
|
|
||||||
* @param barIndex: int, Specified Bar Index ...
|
|
||||||
*/
|
|
||||||
virtual void ProcessNewBar(int barIndex = 0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check Guards Based on MarketConditions ...
|
|
||||||
*
|
|
||||||
* @param guards: XGuard, reference collection to holds result ...
|
|
||||||
* @param positions: XPosition, reference collection to provides positions ...
|
|
||||||
* @param barIndex: int
|
|
||||||
*
|
|
||||||
* @return ( int )
|
|
||||||
*/
|
|
||||||
int virtual CheckForGuard(
|
|
||||||
XGuard &guards[],
|
|
||||||
XPosition &positions[],
|
|
||||||
int barIndex = 0 //
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
SpecifiedClean(guards);
|
|
||||||
|
|
||||||
//
|
|
||||||
result = ArraySize(guards);
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check Additional Validations on Childs Instances ...
|
|
||||||
*
|
|
||||||
* @return ( bool virtual )
|
|
||||||
*/
|
|
||||||
bool virtual CheckAdditionslSignallerValidations()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Validate Fima Helper Requirements ...
|
|
||||||
result = fimaInputs.IsValid() &&
|
|
||||||
fimaHelper != NULL &&
|
|
||||||
poiDetector != NULL;
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalizing Signal by Signaller Custom Props ...
|
|
||||||
*
|
|
||||||
* @param signal: XSignal ...
|
|
||||||
*/
|
|
||||||
void virtual NormalizeSignal(XSignal &signal)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Protected ...
|
|
||||||
protected:
|
|
||||||
//
|
|
||||||
|
|
||||||
//
|
|
||||||
// Protected Actions ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// Private ...
|
|
||||||
private:
|
|
||||||
//
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// XFIMA Strategy 2 Signaller Class ...
|
|
||||||
class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Public ...
|
|
||||||
public:
|
|
||||||
//
|
|
||||||
// Props ...
|
|
||||||
XFIMAConditions conditions; // XFIMA Conditions ...
|
|
||||||
XFIMAMarketStructure structure; // XFIMA Market Structure ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// Constructor ...
|
|
||||||
XCXFIMAStrategy1Signaller(
|
|
||||||
string _symbol, // Symbol ...
|
|
||||||
ENUM_TIMEFRAMES _period, // Period ...
|
|
||||||
XFIMAInputs &_fimaInputs, // XFIMAInputs ...
|
|
||||||
bool _processAllTicks = false, // Process All Ticks ...
|
|
||||||
double _defaultSignalR2R = 1.5, // Default Signal Risk To Reward Ratio ...
|
|
||||||
double _defaultSignalRiskInPoint = 50, // Default Signal Risk In Point ...
|
|
||||||
double _defaultSignalVolume = 0.01 // Default Signal Volume ...
|
|
||||||
) : XCXFIMABaseSignaller("XFIMA1",
|
|
||||||
_symbol,
|
|
||||||
_period,
|
|
||||||
_fimaInputs,
|
|
||||||
_processAllTicks,
|
|
||||||
_defaultSignalR2R,
|
|
||||||
_defaultSignalRiskInPoint,
|
|
||||||
_defaultSignalVolume //
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Configure ...
|
|
||||||
structureConfig.Default();
|
|
||||||
structureDrawConfig.Default();
|
|
||||||
|
|
||||||
//
|
|
||||||
structure.Clean();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Ignore Signal Targets ...
|
|
||||||
ignoreTargets = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Deconstructor ...
|
|
||||||
~XCXFIMAStrategy1Signaller()
|
|
||||||
{
|
|
||||||
//
|
|
||||||
Destroy();
|
|
||||||
|
|
||||||
//
|
|
||||||
structure.Clean();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Overrides ...
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Processing Tick ...
|
|
||||||
*
|
|
||||||
* @param barIndex: int, Specified Bar Index ...
|
|
||||||
*/
|
|
||||||
virtual void ProcessTick(int barIndex = 0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Processing New Bar ...
|
|
||||||
*
|
|
||||||
* @param barIndex: int, Specified Bar Index ...
|
|
||||||
*/
|
|
||||||
virtual void ProcessNewBar(int barIndex = 0)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Normalize ...
|
|
||||||
barIndex = NormalizeInt(barIndex, 0);
|
|
||||||
|
|
||||||
//
|
|
||||||
XOHCL iBar;
|
|
||||||
int count = 0;
|
|
||||||
XBoxZone iZone;
|
|
||||||
XSignal iSignal;
|
|
||||||
bool has = false;
|
|
||||||
XTarget iTargets[];
|
|
||||||
string iName = NULL;
|
|
||||||
bool isBullish = false;
|
|
||||||
bool isBearish = false;
|
|
||||||
ENUM_X_DIRECTION iDir = X_DIRECTION_NONE;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Initialize Bar as CBar ...
|
|
||||||
has = iBar.Init(
|
|
||||||
symbol,
|
|
||||||
period,
|
|
||||||
barIndex //
|
|
||||||
);
|
|
||||||
if (!has)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
iBar.Clean();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Strategy 1 ...
|
|
||||||
has = Strategy1HasSignal(
|
|
||||||
iBar,
|
|
||||||
iZone,
|
|
||||||
iTargets,
|
|
||||||
iDir //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
has = HasDirection(iDir) &&
|
|
||||||
iZone.IsValid();
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Draw Zone ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// has = false;
|
|
||||||
// iZone.Clean();
|
|
||||||
// iDir = X_DIRECTION_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
isBullish = IsXBullish(iDir);
|
|
||||||
isBearish = IsXBearish(iDir);
|
|
||||||
|
|
||||||
//
|
|
||||||
// TODO: Provided SL ...
|
|
||||||
double _point = GetPoints(iBar.symbol);
|
|
||||||
double slAddition = 10 * _point;
|
|
||||||
double atrAddition = GetAverageTrueRange(
|
|
||||||
iZone.symbol,
|
|
||||||
iZone.period,
|
|
||||||
0 //
|
|
||||||
);
|
|
||||||
double slPrice =
|
|
||||||
isBullish
|
|
||||||
? iZone.lower - slAddition
|
|
||||||
: iZone.upper + slAddition;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Prepare Founded Signal ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// Handle Signal Targets ...
|
|
||||||
if (ignoreTargets)
|
|
||||||
{
|
|
||||||
XClean(iTargets);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
has = PrepareSignal(
|
|
||||||
iSignal,
|
|
||||||
iDir,
|
|
||||||
iTargets,
|
|
||||||
0, // Use Default R2R ...
|
|
||||||
slPrice, // Provided Price for SL ...
|
|
||||||
0 // Specified Risk in Point ....
|
|
||||||
);
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Notify On Signal Event ...
|
|
||||||
NotifySignalEventListeners(iSignal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Cleanup Resources ...
|
|
||||||
iBar.Clean();
|
|
||||||
iZone.Clean();
|
|
||||||
iSignal.Clean();
|
|
||||||
SpecifiedClean(iTargets);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check Guards Based on MarketConditions ...
|
|
||||||
*
|
|
||||||
* @param guards: XGuard, reference collection to holds result ...
|
|
||||||
* @param positions: XPosition, reference collection to provides positions ...
|
|
||||||
* @param barIndex: int
|
|
||||||
*
|
|
||||||
* @return ( int )
|
|
||||||
*/
|
|
||||||
int virtual CheckForGuard(
|
|
||||||
XGuard &guards[],
|
|
||||||
XPosition &positions[],
|
|
||||||
int barIndex = 0 //
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
SpecifiedClean(guards);
|
|
||||||
|
|
||||||
//
|
|
||||||
result = ArraySize(guards);
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Private ...
|
|
||||||
private:
|
|
||||||
//
|
|
||||||
// Props ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// Implementing Strategies ...
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check Bar Has Signal Based on Strategy 1 ...
|
|
||||||
*
|
|
||||||
* @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 ...
|
|
||||||
* @param conditions: XFIMAConditions, reference to Bar Specified XFIMA Conditions ...
|
|
||||||
* @param structure: XFIMAMarketStructure, refrence to Provides Market Structure ...
|
|
||||||
*
|
|
||||||
* @return ( bool )
|
|
||||||
*/
|
|
||||||
bool Strategy1HasSignal(
|
|
||||||
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 //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check Bar Patterns ...
|
|
||||||
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)
|
|
||||||
//
|
|
||||||
);
|
|
||||||
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)
|
|
||||||
//
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
double pPeak = fimaHelper.GetPeak(pBar.Index());
|
|
||||||
double pVale = fimaHelper.GetVale(pBar.Index());
|
|
||||||
bool isPPeakOverLast = fimaHelper.IsPeakOverLast(pBar.Index());
|
|
||||||
bool isPValeUnderLast = fimaHelper.IsValeUnderLast(pBar.Index());
|
|
||||||
bool isP2PeakOverLast = fimaHelper.IsPeakOverLast(p2Bar.Index());
|
|
||||||
bool isP2ValeUnderLast = fimaHelper.IsValeUnderLast(p2Bar.Index());
|
|
||||||
bool isPeakOverLast = isPPeakOverLast ||
|
|
||||||
isP2PeakOverLast;
|
|
||||||
bool isValeUnderLast = isPValeUnderLast ||
|
|
||||||
isP2ValeUnderLast;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check PBar Close Over Under Fast Ma ...
|
|
||||||
bool isPBarCloseOverFast = pBar.close > fimaHelper.GetMAFast(pBar.Index());
|
|
||||||
bool isPBarCloseUnderFast = pBar.close < fimaHelper.GetMAFast(pBar.Index());
|
|
||||||
bool isFastOverLast = fimaHelper.GetMAFast(pBar.Index()) > fimaHelper.GetMAFast(p2Bar.Index());
|
|
||||||
bool isFastUnderLast = fimaHelper.GetMAFast(pBar.Index()) < fimaHelper.GetMAFast(p2Bar.Index());
|
|
||||||
|
|
||||||
//
|
|
||||||
// Force P2Bar is Pin Bar ...
|
|
||||||
ENUM_X_DIRECTION p2Dir;
|
|
||||||
bool isP2BarPinned = poiDetector.IsPinnedBar(
|
|
||||||
p2Bar,
|
|
||||||
p2Dir //
|
|
||||||
);
|
|
||||||
bool isP2BarBullishPinned =
|
|
||||||
isP2BarPinned &&
|
|
||||||
IsXBullish(p2Dir);
|
|
||||||
bool isP2BarBearishPinned =
|
|
||||||
isP2BarPinned &&
|
|
||||||
IsXBearish(p2Dir);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
|
|
||||||
//
|
|
||||||
isBullish =
|
|
||||||
//
|
|
||||||
isFastOverLast &&
|
|
||||||
isValeUnderLast &&
|
|
||||||
isPBarCloseOverFast &&
|
|
||||||
isP2BarBullishPinned &&
|
|
||||||
isPBarHasBullishPatterns
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
isBearish =
|
|
||||||
//
|
|
||||||
isPeakOverLast &&
|
|
||||||
isFastUnderLast &&
|
|
||||||
isPBarCloseUnderFast &&
|
|
||||||
isP2BarBearishPinned &&
|
|
||||||
isPBarHasBearishPatterns
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
// 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 //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
zone.to = bar.time;
|
|
||||||
|
|
||||||
//
|
|
||||||
poiDrawer.DrawZone(
|
|
||||||
zone,
|
|
||||||
structureDrawConfig.drawConfig //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
result = zone.IsValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Prepare Targets ...
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Cleanup ...
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
zone.Clean();
|
|
||||||
XClean(targets);
|
|
||||||
dir = X_DIRECTION_NONE;
|
|
||||||
}
|
|
||||||
pBar.Clean();
|
|
||||||
p2Bar.Clean();
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check Bar Has Signal Based on Strategy 1 ...
|
|
||||||
*
|
|
||||||
* @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 ...
|
|
||||||
* @param conditions: XFIMAConditions, reference to Bar Specified XFIMA Conditions ...
|
|
||||||
* @param structure: XFIMAMarketStructure, refrence to Provides Market Structure ...
|
|
||||||
*
|
|
||||||
* @return ( bool )
|
|
||||||
*/
|
|
||||||
bool Strategy2HasSignal(
|
|
||||||
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;
|
|
||||||
bool isBullish = false;
|
|
||||||
bool isBearish = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Read PBar ...
|
|
||||||
result = bar.GetPreviousBar(pBar);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
pBar.Clean();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Reading Conditions ...
|
|
||||||
int pullBackStartBar = -1;
|
|
||||||
bool isPullBack = result &&
|
|
||||||
poiDetector.IsPullbackPattern(
|
|
||||||
pBar,
|
|
||||||
zone,
|
|
||||||
dir,
|
|
||||||
2,
|
|
||||||
false // Force Break ...
|
|
||||||
);
|
|
||||||
bool isPullbackBullish = isPullBack &&
|
|
||||||
IsXBullish(dir);
|
|
||||||
bool isPullbackBearish = isPullBack &&
|
|
||||||
IsXBearish(dir);
|
|
||||||
if (isPullBack)
|
|
||||||
{
|
|
||||||
pullBackStartBar = zone.FromIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Reading HK Bond ...
|
|
||||||
|
|
||||||
//
|
|
||||||
double pHKBondUpper = fimaHelper.GetHKBondUpper(pBar.Index());
|
|
||||||
double pHKBondLower = fimaHelper.GetHKBondLower(pBar.Index());
|
|
||||||
int overHKBondUpperCount = fimaHelper.CountOverHKBondUpper(pullBackStartBar, X_PRICE_LOW);
|
|
||||||
int underHKBondLowerCount = fimaHelper.CountUnderHKBondLower(pullBackStartBar, X_PRICE_HIGH);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Reading PV Requirements ...
|
|
||||||
|
|
||||||
//
|
|
||||||
int lastPeakOverLastIDX = -1;
|
|
||||||
int lastValeUnderLastIDX = -1;
|
|
||||||
double pPeak = fimaHelper.GetPeak(pBar.Index());
|
|
||||||
double pVale = fimaHelper.GetVale(pBar.Index());
|
|
||||||
int samePeaks = fimaHelper.CountSamePeaks(pBar.Index());
|
|
||||||
int sameVales = fimaHelper.CountSameVales(pBar.Index());
|
|
||||||
fimaHelper.FindLastPeakOverLast(lastPeakOverLastIDX, pBar.Index());
|
|
||||||
fimaHelper.FindLastValeUnderLast(lastValeUnderLastIDX, pBar.Index());
|
|
||||||
|
|
||||||
//
|
|
||||||
// Reading pBar Patterns ...
|
|
||||||
XPatternAnalysis pBarAnalysis;
|
|
||||||
poiDetector.AnalyseBarPatterns(
|
|
||||||
pBar,
|
|
||||||
pBarAnalysis,
|
|
||||||
structureConfig.barsAnalysisConfig //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check Bar Patterns ...
|
|
||||||
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)
|
|
||||||
//
|
|
||||||
);
|
|
||||||
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)
|
|
||||||
//
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check PBar Close Over Under Fast Ma ...
|
|
||||||
bool isPBarCloseOverFast = pBar.close > fimaHelper.GetMAFast(pBar.Index());
|
|
||||||
bool isPBarCloseUnderFast = pBar.close < fimaHelper.GetMAFast(pBar.Index());
|
|
||||||
|
|
||||||
//
|
|
||||||
// Try To Find Affected Zone ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// Collecting Zones ...
|
|
||||||
XBoxZone zones[];
|
|
||||||
XBoxZone affectedZones[];
|
|
||||||
XBoxZone affectedZonesBullish[];
|
|
||||||
XBoxZone affectedZonesBearish[];
|
|
||||||
int zonesCount = poiDetector.CollectZones(
|
|
||||||
pBar,
|
|
||||||
zones, //
|
|
||||||
5, // Zones Loopback ...
|
|
||||||
3 // Zones Validation Length ...
|
|
||||||
// Required Zones ...
|
|
||||||
// Loopback ...
|
|
||||||
);
|
|
||||||
int affectedZonesCount = ExtractAffectedZones(
|
|
||||||
pBar,
|
|
||||||
zones,
|
|
||||||
affectedZones //
|
|
||||||
);
|
|
||||||
int affectedZonesBullishCount = ExtractByDirection(
|
|
||||||
affectedZonesBullish,
|
|
||||||
affectedZones,
|
|
||||||
X_DIRECTION_BULLISH //
|
|
||||||
);
|
|
||||||
int affectedZonesBearishCount = ExtractByDirection(
|
|
||||||
affectedZonesBearish,
|
|
||||||
affectedZones,
|
|
||||||
X_DIRECTION_BEARISH //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
int insideBullishIDX = -1;
|
|
||||||
int insideBearishIDX = -1;
|
|
||||||
bool hasBullishInside =
|
|
||||||
pBar.IsBullish() &&
|
|
||||||
HasInside(
|
|
||||||
insideBullishIDX,
|
|
||||||
pBar,
|
|
||||||
affectedZonesBullish //
|
|
||||||
);
|
|
||||||
bool hasBearishInside =
|
|
||||||
pBar.IsBearish() &&
|
|
||||||
HasInside(
|
|
||||||
insideBearishIDX,
|
|
||||||
pBar,
|
|
||||||
affectedZonesBearish //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Do ...
|
|
||||||
|
|
||||||
//
|
|
||||||
isBullish =
|
|
||||||
//
|
|
||||||
hasBullishInside &&
|
|
||||||
isPullbackBullish &&
|
|
||||||
isPBarHasBullishPatterns &&
|
|
||||||
fimaHelper.IsSarBullish(pBar.Index()) &&
|
|
||||||
(pVale >= affectedZonesBullish[insideBullishIDX].lower &&
|
|
||||||
pVale <= affectedZonesBullish[insideBullishIDX].upper)
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
isBearish =
|
|
||||||
//
|
|
||||||
hasBearishInside &&
|
|
||||||
isPullbackBearish &&
|
|
||||||
isPBarHasBearishPatterns &&
|
|
||||||
fimaHelper.IsSarBearish(pBar.Index()) &&
|
|
||||||
(pPeak >= affectedZonesBearish[insideBearishIDX].lower &&
|
|
||||||
pPeak <= affectedZonesBearish[insideBearishIDX].upper)
|
|
||||||
//
|
|
||||||
;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Validate ...
|
|
||||||
result = isBullish ||
|
|
||||||
isBearish;
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
if (isBullish)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
poiDrawer.DrawZone(
|
|
||||||
affectedZonesBullish[insideBullishIDX],
|
|
||||||
structureDrawConfig.drawConfig //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//
|
|
||||||
poiDrawer.DrawZone(
|
|
||||||
affectedZonesBearish[insideBearishIDX],
|
|
||||||
structureDrawConfig.drawConfig //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
dir =
|
|
||||||
isBullish
|
|
||||||
? X_DIRECTION_BULLISH
|
|
||||||
: X_DIRECTION_BEARISH;
|
|
||||||
|
|
||||||
//
|
|
||||||
result = HasDirection(dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Prepare Zone ...
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
zone.Clean();
|
|
||||||
if (isBullish)
|
|
||||||
{
|
|
||||||
zone = affectedZonesBullish[insideBullishIDX];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
zone = affectedZonesBearish[insideBearishIDX];
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
result = zone.IsValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Prepare Targets ...
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Cleanup ...
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
zone.Clean();
|
|
||||||
XClean(targets);
|
|
||||||
dir = X_DIRECTION_NONE;
|
|
||||||
}
|
|
||||||
pBar.Clean();
|
|
||||||
XClean(zones);
|
|
||||||
pBarAnalysis.Clean();
|
|
||||||
XClean(affectedZones);
|
|
||||||
XClean(affectedZonesBullish);
|
|
||||||
XClean(affectedZonesBearish);
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
Reference in New Issue
Block a user