last works ...
This commit is contained in:
@@ -1556,14 +1556,24 @@ class XCGuard : public XCBase
|
|||||||
//
|
//
|
||||||
// Validate Action and Requirements ...
|
// Validate Action and Requirements ...
|
||||||
has =
|
has =
|
||||||
guard.sl > 0 &&
|
guard.sl >= 0 &&
|
||||||
NotEmpty(guard.ticket) &&
|
NotEmpty(guard.ticket) &&
|
||||||
|
(guard.sl <= 0
|
||||||
|
? guard.force
|
||||||
|
: true) &&
|
||||||
guard.action == X_GUARD_ACTION_TRAIL_STOP;
|
guard.action == X_GUARD_ACTION_TRAIL_STOP;
|
||||||
if (!has)
|
if (!has)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize SL ...
|
||||||
|
if (guard.sl < 0)
|
||||||
|
{
|
||||||
|
guard.sl = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Retrieve Position ...
|
// Retrieve Position ...
|
||||||
XPosition position;
|
XPosition position;
|
||||||
@@ -1582,6 +1592,16 @@ class XCGuard : public XCBase
|
|||||||
|
|
||||||
//
|
//
|
||||||
bool isLong = IsLong(position.type);
|
bool isLong = IsLong(position.type);
|
||||||
|
bool isGuardPassed =
|
||||||
|
guard.sl > 0
|
||||||
|
? (isLong
|
||||||
|
? position.price > guard.sl &&
|
||||||
|
(position.sl == 0 ||
|
||||||
|
position.sl < guard.sl)
|
||||||
|
: position.price < guard.sl &&
|
||||||
|
(position.sl == 0 ||
|
||||||
|
position.sl > guard.sl))
|
||||||
|
: (guard.sl == 0 && guard.force);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check Can Trail Stop or not ...
|
// Check Can Trail Stop or not ...
|
||||||
@@ -1594,13 +1614,7 @@ class XCGuard : public XCBase
|
|||||||
position.profit > 0 &&
|
position.profit > 0 &&
|
||||||
//
|
//
|
||||||
// Validate SL based on Position Type ...
|
// Validate SL based on Position Type ...
|
||||||
(isLong
|
isGuardPassed;
|
||||||
? position.price > guard.sl &&
|
|
||||||
(position.sl == 0 ||
|
|
||||||
position.sl < guard.sl)
|
|
||||||
: position.price < guard.sl &&
|
|
||||||
(position.sl == 0 ||
|
|
||||||
position.sl > guard.sl));
|
|
||||||
if (!has)
|
if (!has)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1668,14 +1682,24 @@ class XCGuard : public XCBase
|
|||||||
//
|
//
|
||||||
// Validate Action and Requirements ...
|
// Validate Action and Requirements ...
|
||||||
has =
|
has =
|
||||||
guard.tp > 0 &&
|
guard.tp >= 0 &&
|
||||||
NotEmpty(guard.ticket) &&
|
NotEmpty(guard.ticket) &&
|
||||||
|
(guard.tp <= 0
|
||||||
|
? guard.force
|
||||||
|
: true) &&
|
||||||
guard.action == X_GUARD_ACTION_TRAIL_TARGET;
|
guard.action == X_GUARD_ACTION_TRAIL_TARGET;
|
||||||
if (!has)
|
if (!has)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
if (guard.tp < 0)
|
||||||
|
{
|
||||||
|
guard.tp = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Retrieve Position ...
|
// Retrieve Position ...
|
||||||
XPosition position;
|
XPosition position;
|
||||||
@@ -1694,6 +1718,12 @@ class XCGuard : public XCBase
|
|||||||
|
|
||||||
//
|
//
|
||||||
bool isLong = IsLong(position.type);
|
bool isLong = IsLong(position.type);
|
||||||
|
bool isGuardPassed =
|
||||||
|
guard.tp > 0
|
||||||
|
? (isLong
|
||||||
|
? guard.tp > position.price
|
||||||
|
: guard.tp < position.price)
|
||||||
|
: (guard.tp == 0 && guard.force);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check Can Trail Stop or not ...
|
// Check Can Trail Stop or not ...
|
||||||
@@ -1706,9 +1736,7 @@ class XCGuard : public XCBase
|
|||||||
guard.tp != position.tp &&
|
guard.tp != position.tp &&
|
||||||
//
|
//
|
||||||
// Validate TP based on Current Price ...
|
// Validate TP based on Current Price ...
|
||||||
(isLong
|
isGuardPassed;
|
||||||
? guard.tp > position.price
|
|
||||||
: guard.tp < position.price);
|
|
||||||
if (!has)
|
if (!has)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -4264,6 +4264,100 @@ class XCMarketPatternDetector : public XCBase
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Trigger Bar ...
|
||||||
|
bool IsTriggerBar(
|
||||||
|
XOHCL &bar,
|
||||||
|
ENUM_X_DIRECTION forDir,
|
||||||
|
ENUM_TIMEFRAMES forPeriod = PERIOD_M1 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Trigger Bars Detected in Specified Perido ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = bar.IsValid() &&
|
||||||
|
IsXValid(forPeriod) &&
|
||||||
|
HasDirection(forDir);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialized Specified Bar in Specified Time Frame ...
|
||||||
|
XOHCL periodBar;
|
||||||
|
int index = GetBarIndex(
|
||||||
|
bar.symbol,
|
||||||
|
forPeriod,
|
||||||
|
TimeCurrent() //
|
||||||
|
);
|
||||||
|
result = periodBar.Init(bar.symbol, forPeriod, index);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Pattern ...
|
||||||
|
XPatternAnalysisConfig iConfig;
|
||||||
|
iConfig.Default();
|
||||||
|
iConfig.CleanPatterns();
|
||||||
|
iConfig.AddPattern(X_BAR_PATTERN_LOW);
|
||||||
|
iConfig.AddPattern(X_BAR_PATTERN_HIGH);
|
||||||
|
iConfig.AddPattern(X_BAR_PATTERN_PINNED);
|
||||||
|
iConfig.AddPattern(X_BAR_PATTERN_ENGULFED);
|
||||||
|
iConfig.AddPattern(X_BAR_PATTERN_SIGNALKEY);
|
||||||
|
|
||||||
|
//
|
||||||
|
XPatternAnalysis periodBarAnalysis;
|
||||||
|
result = AnalyseBarPatterns(periodBar, periodBarAnalysis, iConfig);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBullish =
|
||||||
|
result &&
|
||||||
|
IsXBullish(forDir) &&
|
||||||
|
(
|
||||||
|
//
|
||||||
|
periodBarAnalysis.HasPattern(X_BAR_PATTERN_PINNED, X_DIRECTION_BULLISH) ||
|
||||||
|
periodBarAnalysis.HasPattern(X_BAR_PATTERN_ENGULFED, X_DIRECTION_BULLISH) ||
|
||||||
|
periodBarAnalysis.HasPattern(X_BAR_PATTERN_SIGNALKEY, X_DIRECTION_BULLISH)
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isBearish =
|
||||||
|
result &&
|
||||||
|
IsXBearish(forDir) &&
|
||||||
|
(
|
||||||
|
//
|
||||||
|
periodBarAnalysis.HasPattern(X_BAR_PATTERN_PINNED, X_DIRECTION_BEARISH) ||
|
||||||
|
periodBarAnalysis.HasPattern(X_BAR_PATTERN_ENGULFED, X_DIRECTION_BEARISH) ||
|
||||||
|
periodBarAnalysis.HasPattern(X_BAR_PATTERN_SIGNALKEY, X_DIRECTION_BEARISH)
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summarize Result ...
|
||||||
|
result = isBullish || isBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
iConfig.Clean();
|
||||||
|
periodBar.Clean();
|
||||||
|
periodBarAnalysis.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Protected ...
|
// Protected ...
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -1557,7 +1557,61 @@ class XCPOIDrawer : public XCBase
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Apply Style ...
|
// Apply Style ...
|
||||||
object.Color(clr);
|
object.Color(clrTrend);
|
||||||
|
object.Width(config.trendWidth);
|
||||||
|
object.Style(config.trendStyle);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Save Object ...
|
||||||
|
drawnObjects.Add(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ZeroMemory(object);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawTrendLine(
|
||||||
|
XTrend &trend,
|
||||||
|
XPOIDrawConfig &config,
|
||||||
|
color clr = CLR_NONE //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool has = trend.IsValid();
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
color trendColor =
|
||||||
|
(clr != CLR_NONE)
|
||||||
|
? clr
|
||||||
|
: trend.IsBullish()
|
||||||
|
? config.bullishColor
|
||||||
|
: trend.IsBearish()
|
||||||
|
? config.bearishColor
|
||||||
|
: config.neuturalColor;
|
||||||
|
string name = trend.GetObjectID();
|
||||||
|
|
||||||
|
//
|
||||||
|
CChartObjectTrend *object;
|
||||||
|
has = DrawTrendLine(
|
||||||
|
trend.fromValue,
|
||||||
|
trend.fromTime,
|
||||||
|
trend.toValue,
|
||||||
|
trend.toTime,
|
||||||
|
object,
|
||||||
|
name,
|
||||||
|
config.trendRayRight,
|
||||||
|
config.trendRayLeft //
|
||||||
|
);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Apply Style ...
|
||||||
|
object.Color(trendColor);
|
||||||
object.Width(config.trendWidth);
|
object.Width(config.trendWidth);
|
||||||
object.Style(config.trendStyle);
|
object.Style(config.trendStyle);
|
||||||
|
|
||||||
@@ -2528,23 +2582,26 @@ class XCPOIDrawer : public XCBase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a Collection of Pattern Analysis ...
|
* Draw a Collection of Pattern Analysis ...
|
||||||
*
|
*
|
||||||
* @param analysises: XPatternAnalysis, collection reference to Data Source ...
|
* @param analysises: XPatternAnalysis, collection reference to Data Source ...
|
||||||
* @param config: XPatternAnalysisDrawConfig, reference to Specified Drawing Config ...
|
* @param config: XPatternAnalysisDrawConfig, reference to Specified Drawing Config ...
|
||||||
*/
|
*/
|
||||||
void DrawPatternAnalysises(
|
void DrawPatternAnalysises(
|
||||||
XPatternAnalysis &analysises[],
|
XPatternAnalysis &analysises[],
|
||||||
XPatternAnalysisDrawConfig &config //
|
XPatternAnalysisDrawConfig &config //
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
bool has = HasChild(analysises);
|
bool has = HasChild(analysises);
|
||||||
if (!has) {
|
if (!has)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
int count = ArraySize(analysises);
|
int count = ArraySize(analysises);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
DrawPatternAnalysis(analysises[i], config);
|
DrawPatternAnalysis(analysises[i], config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,949 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* 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 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validation Flags ...
|
||||||
|
bool validateByBarPatterns = true;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Define Requirements ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL pBar;
|
||||||
|
XOHCL p2Bar;
|
||||||
|
XOHCL p3Bar;
|
||||||
|
bool isBullish = false;
|
||||||
|
bool isBearish = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Read PBar ...
|
||||||
|
result = bar.GetPreviousBar(pBar);
|
||||||
|
result = result &&
|
||||||
|
pBar.GetPreviousBar(p2Bar);
|
||||||
|
result = result &&
|
||||||
|
p2Bar.GetPreviousBar(p3Bar);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pBar.Clean();
|
||||||
|
p2Bar.Clean();
|
||||||
|
p3Bar.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve pBar Patterns ...
|
||||||
|
XPatternAnalysis pBarPatterns;
|
||||||
|
XPatternAnalysisConfig patternConfig = structureConfig.barsAnalysisConfig;
|
||||||
|
|
||||||
|
//
|
||||||
|
poiDetector.AnalyseBarPatterns(
|
||||||
|
pBar,
|
||||||
|
pBarPatterns,
|
||||||
|
patternConfig //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isConsolidation = poiDetector.DetectXPVZone(zone, p2Bar.Index());
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
isConsolidation &&
|
||||||
|
zone.IsBullish();
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
isConsolidation &&
|
||||||
|
zone.IsBearish();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summarize Result ...
|
||||||
|
result = isBullish || isBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Force PBar Has Pattern ...
|
||||||
|
if (result && validateByBarPatterns)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Analyse Bar Patterns ...
|
||||||
|
result = pBarPatterns.IsValid();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bullish ...
|
||||||
|
bool isPBarHasBullishPatterns =
|
||||||
|
result &&
|
||||||
|
(
|
||||||
|
//
|
||||||
|
pBarPatterns.IsPinned(X_DIRECTION_BULLISH) ||
|
||||||
|
pBarPatterns.IsEngulfed(X_DIRECTION_BULLISH) ||
|
||||||
|
pBarPatterns.IsMomentum(X_DIRECTION_BULLISH) ||
|
||||||
|
pBarPatterns.IsPiercing(X_DIRECTION_BULLISH) ||
|
||||||
|
pBarPatterns.IsSignalKey(X_DIRECTION_BULLISH)
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bearish ...
|
||||||
|
bool isPBarHasBearishPatterns =
|
||||||
|
result &&
|
||||||
|
(
|
||||||
|
//
|
||||||
|
pBarPatterns.IsPinned(X_DIRECTION_BEARISH) ||
|
||||||
|
pBarPatterns.IsEngulfed(X_DIRECTION_BEARISH) ||
|
||||||
|
pBarPatterns.IsMomentum(X_DIRECTION_BEARISH) ||
|
||||||
|
pBarPatterns.IsPiercing(X_DIRECTION_BEARISH) ||
|
||||||
|
pBarPatterns.IsSignalKey(X_DIRECTION_BEARISH)
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
isBullish &&
|
||||||
|
isPBarHasBullishPatterns &&
|
||||||
|
!isPBarHasBearishPatterns;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
isBearish &&
|
||||||
|
isPBarHasBearishPatterns &&
|
||||||
|
!isPBarHasBullishPatterns;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summarize Result ...
|
||||||
|
result = isBullish || isBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reset Flags ...
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
isBullish = false;
|
||||||
|
isBearish = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
poiDrawer.DrawZone(zone, structureDrawConfig.drawConfig);
|
||||||
|
poiDrawer.DrawPatternAnalysis(pBarPatterns, structureDrawConfig.barAnalysisDrawConfig);
|
||||||
|
DebugBreak();
|
||||||
|
|
||||||
|
//
|
||||||
|
result = false;
|
||||||
|
isBullish = false;
|
||||||
|
isBearish = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Validate based on Bars Patterns ...
|
||||||
|
// bool validateByBarPatterns = true;
|
||||||
|
// if (validateByBarPatterns)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// // Reading pBar Patterns ...
|
||||||
|
// XPatternAnalysis pBarAnalysis;
|
||||||
|
// poiDetector.AnalyseBarPatterns(
|
||||||
|
// pBar,
|
||||||
|
// pBarAnalysis,
|
||||||
|
// structureConfig.barsAnalysisConfig //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // 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)
|
||||||
|
// //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBullish =
|
||||||
|
// isBullish &&
|
||||||
|
// isPBarHasBullishPatterns &&
|
||||||
|
// !isPBarHasBearishPatterns;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBearish =
|
||||||
|
// isBearish &&
|
||||||
|
// isPBarHasBearishPatterns &&
|
||||||
|
// !isPBarHasBullishPatterns;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Summarize Result ...
|
||||||
|
// result = isBullish ||
|
||||||
|
// isBearish;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Checking PullBack ...
|
||||||
|
// bool validateByPullback = false;
|
||||||
|
// if (validateByPullback)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// XBoxZone pullback;
|
||||||
|
// ENUM_X_DIRECTION pullbackDir;
|
||||||
|
// bool isPullBack = result &&
|
||||||
|
// poiDetector.IsPullbackPattern(
|
||||||
|
// pBar,
|
||||||
|
// pullback,
|
||||||
|
// pullbackDir,
|
||||||
|
// 2,
|
||||||
|
// false // Force Break ...
|
||||||
|
// );
|
||||||
|
// bool isPullbackBullish = isPullBack &&
|
||||||
|
// IsXBullish(pullbackDir);
|
||||||
|
// bool isPullbackBearish = isPullBack &&
|
||||||
|
// IsXBearish(pullbackDir);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBullish =
|
||||||
|
// isBullish &&
|
||||||
|
// isPullbackBullish;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBearish =
|
||||||
|
// isBearish &&
|
||||||
|
// isPullbackBearish;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Summarize Result ...
|
||||||
|
// result = isBullish ||
|
||||||
|
// isBearish;
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = isBullish ||
|
||||||
|
isBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Zone ...
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Targets ...
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
zone.Clean();
|
||||||
|
XClean(targets);
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
}
|
||||||
|
pBar.Clean();
|
||||||
|
p2Bar.Clean();
|
||||||
|
p3Bar.Clean();
|
||||||
|
pBarPatterns.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// //
|
||||||
|
// bool isConsolidation = poiDetector.DetectXPVZone(zone, p2Bar.Index());
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBullish =
|
||||||
|
// isConsolidation &&
|
||||||
|
// zone.IsBullish();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBearish =
|
||||||
|
// isConsolidation &&
|
||||||
|
// zone.IsBearish();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Summarize Result ...
|
||||||
|
// result = isBullish || isBearish;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Force PBar Has Pattern ...
|
||||||
|
// if (result && validateByBarPatterns)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// // Analyse Bar Patterns ...
|
||||||
|
// result = pBarPatterns.IsValid();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Bullish ...
|
||||||
|
// bool isPBarHasBullishPatterns =
|
||||||
|
// result &&
|
||||||
|
// (
|
||||||
|
// //
|
||||||
|
// pBarPatterns.IsPinned(X_DIRECTION_BULLISH) ||
|
||||||
|
// pBarPatterns.IsEngulfed(X_DIRECTION_BULLISH) ||
|
||||||
|
// pBarPatterns.IsMomentum(X_DIRECTION_BULLISH) ||
|
||||||
|
// pBarPatterns.IsPiercing(X_DIRECTION_BULLISH) ||
|
||||||
|
// pBarPatterns.IsSignalKey(X_DIRECTION_BULLISH)
|
||||||
|
// //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Bearish ...
|
||||||
|
// bool isPBarHasBearishPatterns =
|
||||||
|
// result &&
|
||||||
|
// (
|
||||||
|
// //
|
||||||
|
// pBarPatterns.IsPinned(X_DIRECTION_BEARISH) ||
|
||||||
|
// pBarPatterns.IsEngulfed(X_DIRECTION_BEARISH) ||
|
||||||
|
// pBarPatterns.IsMomentum(X_DIRECTION_BEARISH) ||
|
||||||
|
// pBarPatterns.IsPiercing(X_DIRECTION_BEARISH) ||
|
||||||
|
// pBarPatterns.IsSignalKey(X_DIRECTION_BEARISH)
|
||||||
|
// //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBullish =
|
||||||
|
// isBullish &&
|
||||||
|
// isPBarHasBullishPatterns &&
|
||||||
|
// !isPBarHasBearishPatterns;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBearish =
|
||||||
|
// isBearish &&
|
||||||
|
// isPBarHasBearishPatterns &&
|
||||||
|
// !isPBarHasBullishPatterns;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Summarize Result ...
|
||||||
|
// result = isBullish || isBearish;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Reset Flags ...
|
||||||
|
// if (!result)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// isBullish = false;
|
||||||
|
// isBearish = false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// if (result)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// poiDrawer.DrawZone(zone, structureDrawConfig.drawConfig);
|
||||||
|
// poiDrawer.DrawPatternAnalysis(pBarPatterns, structureDrawConfig.barAnalysisDrawConfig);
|
||||||
|
// DebugBreak();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// result = false;
|
||||||
|
// isBullish = false;
|
||||||
|
// isBearish = false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Validate based on Bars Patterns ...
|
||||||
|
// bool validateByBarPatterns = true;
|
||||||
|
// if (validateByBarPatterns)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// // Reading pBar Patterns ...
|
||||||
|
// XPatternAnalysis pBarAnalysis;
|
||||||
|
// poiDetector.AnalyseBarPatterns(
|
||||||
|
// pBar,
|
||||||
|
// pBarAnalysis,
|
||||||
|
// structureConfig.barsAnalysisConfig //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // 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)
|
||||||
|
// //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBullish =
|
||||||
|
// isBullish &&
|
||||||
|
// isPBarHasBullishPatterns &&
|
||||||
|
// !isPBarHasBearishPatterns;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBearish =
|
||||||
|
// isBearish &&
|
||||||
|
// isPBarHasBearishPatterns &&
|
||||||
|
// !isPBarHasBullishPatterns;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Summarize Result ...
|
||||||
|
// result = isBullish ||
|
||||||
|
// isBearish;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Checking PullBack ...
|
||||||
|
// bool validateByPullback = false;
|
||||||
|
// if (validateByPullback)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// XBoxZone pullback;
|
||||||
|
// ENUM_X_DIRECTION pullbackDir;
|
||||||
|
// bool isPullBack = result &&
|
||||||
|
// poiDetector.IsPullbackPattern(
|
||||||
|
// pBar,
|
||||||
|
// pullback,
|
||||||
|
// pullbackDir,
|
||||||
|
// 2,
|
||||||
|
// false // Force Break ...
|
||||||
|
// );
|
||||||
|
// bool isPullbackBullish = isPullBack &&
|
||||||
|
// IsXBullish(pullbackDir);
|
||||||
|
// bool isPullbackBearish = isPullBack &&
|
||||||
|
// IsXBearish(pullbackDir);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBullish =
|
||||||
|
// isBullish &&
|
||||||
|
// isPullbackBullish;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBearish =
|
||||||
|
// isBearish &&
|
||||||
|
// isPullbackBearish;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Summarize Result ...
|
||||||
|
// result = isBullish ||
|
||||||
|
// isBearish;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validation Flags ...
|
||||||
|
bool validateByBarPatterns = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Define Requirements ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL pBar;
|
||||||
|
XOHCL p2Bar;
|
||||||
|
XOHCL p3Bar;
|
||||||
|
bool isBullish = false;
|
||||||
|
bool isBearish = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Read PBar ...
|
||||||
|
result = bar.GetPreviousBar(pBar);
|
||||||
|
result = result &&
|
||||||
|
pBar.GetPreviousBar(p2Bar);
|
||||||
|
result = result &&
|
||||||
|
p2Bar.GetPreviousBar(p3Bar);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
pBar.Clean();
|
||||||
|
p2Bar.Clean();
|
||||||
|
p3Bar.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Retrieve pBar Patterns ...
|
||||||
|
XPatternAnalysis pBarPatterns;
|
||||||
|
XPatternAnalysis p2BarPatterns;
|
||||||
|
XPatternAnalysisConfig patternConfig = structureConfig.barsAnalysisConfig;
|
||||||
|
|
||||||
|
//
|
||||||
|
poiDetector.AnalyseBarPatterns(
|
||||||
|
pBar,
|
||||||
|
pBarPatterns,
|
||||||
|
patternConfig //
|
||||||
|
);
|
||||||
|
poiDetector.AnalyseBarPatterns(
|
||||||
|
p2Bar,
|
||||||
|
p2BarPatterns,
|
||||||
|
patternConfig //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool hasSupport = p2BarPatterns.IsValid() &&
|
||||||
|
p2BarPatterns.IsSupport();
|
||||||
|
bool hasResistance = p2BarPatterns.IsValid() &&
|
||||||
|
p2BarPatterns.IsResistance();
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
hasSupport &&
|
||||||
|
p2BarPatterns.Count(X_DIRECTION_BULLISH) >= 4;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
hasResistance &&
|
||||||
|
p2BarPatterns.Count(X_DIRECTION_BEARISH) >= 4;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summarize Result ...
|
||||||
|
result = isBullish || isBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Extract Affected Zone ...
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XOHCL tmpBar;
|
||||||
|
XPivot tmpPivot;
|
||||||
|
XBoxZone tmpZone;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (hasSupport)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
hasSupport = p2BarPatterns.GetSupport(tmpBar, tmpPivot, tmpZone);
|
||||||
|
isBullish =
|
||||||
|
isBullish &&
|
||||||
|
hasSupport &&
|
||||||
|
(IsActed(pBar, tmpZone) ||
|
||||||
|
IsTested(pBar, tmpZone));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (hasResistance)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
hasResistance = p2BarPatterns.GetResistance(tmpBar, tmpPivot, tmpZone);
|
||||||
|
isBearish =
|
||||||
|
isBearish &&
|
||||||
|
hasResistance &&
|
||||||
|
(IsActed(pBar, tmpZone) ||
|
||||||
|
IsTested(pBar, tmpZone));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
tmpBar.Clean();
|
||||||
|
tmpZone.Clean();
|
||||||
|
tmpPivot.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summarize Result ...
|
||||||
|
result = isBullish || isBearish;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate based on Bars Patterns ...
|
||||||
|
if (result && validateByBarPatterns)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Bullish...
|
||||||
|
bool isPBarHasBullishPatterns =
|
||||||
|
pBarPatterns.IsValid() &&
|
||||||
|
(
|
||||||
|
//
|
||||||
|
pBarPatterns.IsPinned(X_DIRECTION_BULLISH) ||
|
||||||
|
pBarPatterns.IsEngulfed(X_DIRECTION_BULLISH) ||
|
||||||
|
pBarPatterns.IsMomentum(X_DIRECTION_BULLISH) ||
|
||||||
|
pBarPatterns.IsPiercing(X_DIRECTION_BULLISH) ||
|
||||||
|
pBarPatterns.IsSignalKey(X_DIRECTION_BULLISH)
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bearish ...
|
||||||
|
bool isPBarHasBearishPatterns =
|
||||||
|
pBarPatterns.IsValid() &&
|
||||||
|
(
|
||||||
|
//
|
||||||
|
pBarPatterns.IsPinned(X_DIRECTION_BEARISH) ||
|
||||||
|
pBarPatterns.IsEngulfed(X_DIRECTION_BEARISH) ||
|
||||||
|
pBarPatterns.IsMomentum(X_DIRECTION_BEARISH) ||
|
||||||
|
pBarPatterns.IsPiercing(X_DIRECTION_BEARISH) ||
|
||||||
|
pBarPatterns.IsSignalKey(X_DIRECTION_BEARISH)
|
||||||
|
//
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
isBullish &&
|
||||||
|
isPBarHasBullishPatterns &&
|
||||||
|
!isPBarHasBearishPatterns;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
isBearish &&
|
||||||
|
isPBarHasBearishPatterns &&
|
||||||
|
!isPBarHasBullishPatterns;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summarize Result ...
|
||||||
|
result = isBullish || isBearish;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
poiDrawer.DrawPatternAnalysis(pBarPatterns, structureDrawConfig.barAnalysisDrawConfig);
|
||||||
|
poiDrawer.DrawPatternAnalysis(p2BarPatterns, structureDrawConfig.barAnalysisDrawConfig);
|
||||||
|
DebugBreak();
|
||||||
|
|
||||||
|
//
|
||||||
|
result = false;
|
||||||
|
isBullish = false;
|
||||||
|
isBearish = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// //
|
||||||
|
// bool isConsolidation = poiDetector.DetectXPVZone(zone, p2Bar.Index());
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBullish =
|
||||||
|
// isConsolidation &&
|
||||||
|
// zone.IsBullish();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBearish =
|
||||||
|
// isConsolidation &&
|
||||||
|
// zone.IsBearish();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Summarize Result ...
|
||||||
|
// result = isBullish || isBearish;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Force PBar Has Pattern ...
|
||||||
|
// if (result && validateByBarPatterns)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// // Analyse Bar Patterns ...
|
||||||
|
// result = pBarPatterns.IsValid();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Bullish ...
|
||||||
|
// bool isPBarHasBullishPatterns =
|
||||||
|
// result &&
|
||||||
|
// (
|
||||||
|
// //
|
||||||
|
// pBarPatterns.IsPinned(X_DIRECTION_BULLISH) ||
|
||||||
|
// pBarPatterns.IsEngulfed(X_DIRECTION_BULLISH) ||
|
||||||
|
// pBarPatterns.IsMomentum(X_DIRECTION_BULLISH) ||
|
||||||
|
// pBarPatterns.IsPiercing(X_DIRECTION_BULLISH) ||
|
||||||
|
// pBarPatterns.IsSignalKey(X_DIRECTION_BULLISH)
|
||||||
|
// //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Bearish ...
|
||||||
|
// bool isPBarHasBearishPatterns =
|
||||||
|
// result &&
|
||||||
|
// (
|
||||||
|
// //
|
||||||
|
// pBarPatterns.IsPinned(X_DIRECTION_BEARISH) ||
|
||||||
|
// pBarPatterns.IsEngulfed(X_DIRECTION_BEARISH) ||
|
||||||
|
// pBarPatterns.IsMomentum(X_DIRECTION_BEARISH) ||
|
||||||
|
// pBarPatterns.IsPiercing(X_DIRECTION_BEARISH) ||
|
||||||
|
// pBarPatterns.IsSignalKey(X_DIRECTION_BEARISH)
|
||||||
|
// //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBullish =
|
||||||
|
// isBullish &&
|
||||||
|
// isPBarHasBullishPatterns &&
|
||||||
|
// !isPBarHasBearishPatterns;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBearish =
|
||||||
|
// isBearish &&
|
||||||
|
// isPBarHasBearishPatterns &&
|
||||||
|
// !isPBarHasBullishPatterns;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Summarize Result ...
|
||||||
|
// result = isBullish || isBearish;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Reset Flags ...
|
||||||
|
// if (!result)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// isBullish = false;
|
||||||
|
// isBearish = false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// if (result)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// poiDrawer.DrawZone(zone, structureDrawConfig.drawConfig);
|
||||||
|
// poiDrawer.DrawPatternAnalysis(pBarPatterns, structureDrawConfig.barAnalysisDrawConfig);
|
||||||
|
// DebugBreak();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// result = false;
|
||||||
|
// isBullish = false;
|
||||||
|
// isBearish = false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Checking PullBack ...
|
||||||
|
// bool validateByPullback = false;
|
||||||
|
// if (validateByPullback)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// XBoxZone pullback;
|
||||||
|
// ENUM_X_DIRECTION pullbackDir;
|
||||||
|
// bool isPullBack = result &&
|
||||||
|
// poiDetector.IsPullbackPattern(
|
||||||
|
// pBar,
|
||||||
|
// pullback,
|
||||||
|
// pullbackDir,
|
||||||
|
// 2,
|
||||||
|
// false // Force Break ...
|
||||||
|
// );
|
||||||
|
// bool isPullbackBullish = isPullBack &&
|
||||||
|
// IsXBullish(pullbackDir);
|
||||||
|
// bool isPullbackBearish = isPullBack &&
|
||||||
|
// IsXBearish(pullbackDir);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBullish =
|
||||||
|
// isBullish &&
|
||||||
|
// isPullbackBullish;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// isBearish =
|
||||||
|
// isBearish &&
|
||||||
|
// isPullbackBearish;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Summarize Result ...
|
||||||
|
// result = isBullish ||
|
||||||
|
// isBearish;
|
||||||
|
// }
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = isBullish ||
|
||||||
|
isBearish;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Zone ...
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare Targets ...
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
zone.Clean();
|
||||||
|
XClean(targets);
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
}
|
||||||
|
pBar.Clean();
|
||||||
|
p2Bar.Clean();
|
||||||
|
p3Bar.Clean();
|
||||||
|
pBarPatterns.Clean();
|
||||||
|
patternConfig.Clean();
|
||||||
|
p2BarPatterns.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool validateByPVChange = false;
|
||||||
|
bool validateByPVInside = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate By PV Inside ...
|
||||||
|
if (result && validateByPVInside)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double pVale = fimaHelper.GetVale(pBar.Index());
|
||||||
|
double pPeak = fimaHelper.GetPeak(pBar.Index());
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValePassed = pVale <= support.upper &&
|
||||||
|
pVale >= support.upper &&
|
||||||
|
fimaParser.IsValeSame(pBar.Index());
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isPeakPassed = pPeak <= resistance.upper &&
|
||||||
|
pPeak >= resistance.upper &&
|
||||||
|
fimaParser.IsPeakSame(pBar.Index());
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
isBullish &&
|
||||||
|
isValePassed;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
isBearish &&
|
||||||
|
isPeakPassed;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summarize Result ...
|
||||||
|
result = isBullish || isBearish;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate by PV Change ...
|
||||||
|
if (result && validateByPVChange)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// bullish => p3, p2 vale under last ...
|
||||||
|
// bearish => p3, p2 peak over last ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValePassed =
|
||||||
|
fimaParser.IsValeUnderLast(p2Bar.Index()) ||
|
||||||
|
fimaParser.IsValeUnderLast(p3Bar.Index());
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isPeakPassed =
|
||||||
|
fimaParser.IsPeakOverLast(p2Bar.Index()) ||
|
||||||
|
fimaParser.IsPeakOverLast(p3Bar.Index());
|
||||||
|
|
||||||
|
//
|
||||||
|
isBullish =
|
||||||
|
isBullish &&
|
||||||
|
isValePassed;
|
||||||
|
|
||||||
|
//
|
||||||
|
isBearish =
|
||||||
|
isBearish &&
|
||||||
|
isPeakPassed;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summarize Result ...
|
||||||
|
result = isBullish || isBearish;
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -5497,6 +5497,37 @@ bool HasInside(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsZoneAffected(
|
||||||
|
XOHCL &bar,
|
||||||
|
XBoxZone &zone //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = bar.IsValid() &&
|
||||||
|
zone.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isActed = IsActed(bar, zone);
|
||||||
|
bool isTested = IsTested(bar, zone);
|
||||||
|
bool isFakeBreaked = IsFakeBreaked(bar, zone);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = isActed ||
|
||||||
|
isTested ||
|
||||||
|
isFakeBreaked;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract Affected Zones for Specified Bar ...
|
* Extract Affected Zones for Specified Bar ...
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -321,6 +321,194 @@ int GetAllBarPatters(ENUM_X_BAR_PATTERN &dest[])
|
|||||||
//
|
//
|
||||||
// Structures ...
|
// Structures ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model a Trend Line ...
|
||||||
|
**/
|
||||||
|
struct XTrend
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string symbol;
|
||||||
|
datetime time;
|
||||||
|
ENUM_TIMEFRAMES period;
|
||||||
|
|
||||||
|
//
|
||||||
|
double fromValue;
|
||||||
|
datetime fromTime;
|
||||||
|
|
||||||
|
//
|
||||||
|
double toValue;
|
||||||
|
datetime toTime;
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_X_DIRECTION dir;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor ...
|
||||||
|
XTrend()
|
||||||
|
{
|
||||||
|
Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize ...
|
||||||
|
*
|
||||||
|
* @param _symbol: string, Specified Symbol ...
|
||||||
|
* @param _period: ENUM_TIMEFRAMES, Specified Period ...
|
||||||
|
* @param _time: datetime, Detection Time ...
|
||||||
|
* @param _fromValue: double, From Value ...
|
||||||
|
* @param _fromTime: datetime, From Time ...
|
||||||
|
* @param _toValue: double, To Value ...
|
||||||
|
* @param _toTime: datetime, To Time ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool Init(
|
||||||
|
string _symbol,
|
||||||
|
ENUM_TIMEFRAMES _period,
|
||||||
|
datetime _time,
|
||||||
|
double _fromValue,
|
||||||
|
datetime _fromTime,
|
||||||
|
double _toValue,
|
||||||
|
datetime _toTime //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
time = _time;
|
||||||
|
symbol = _symbol;
|
||||||
|
period = _period;
|
||||||
|
toTime = _toTime;
|
||||||
|
toValue = _toValue;
|
||||||
|
fromTime = _fromTime;
|
||||||
|
fromValue = _fromValue;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Setting Direction ...
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
dir =
|
||||||
|
fromValue < toValue
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: fromValue > toValue
|
||||||
|
? X_DIRECTION_BEARISH
|
||||||
|
: X_DIRECTION_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleanup ...
|
||||||
|
*/
|
||||||
|
void Clean()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
time = NULL;
|
||||||
|
toValue = 0;
|
||||||
|
fromValue = 0;
|
||||||
|
symbol = NULL;
|
||||||
|
period = NULL;
|
||||||
|
toTime = NULL;
|
||||||
|
fromTime = NULL;
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
ZeroMemory(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsValid()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
IsXValid(time) &&
|
||||||
|
IsXValid(symbol) &&
|
||||||
|
IsXValid(period) &&
|
||||||
|
IsXValid(toTime) &&
|
||||||
|
IsXValid(fromTime) &&
|
||||||
|
NotEmptyZero(toValue) &&
|
||||||
|
NotEmptyZero(fromValue) &&
|
||||||
|
fromTime < toTime;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Trend Has Specific Direction ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool HasTrend()
|
||||||
|
{
|
||||||
|
return IsValid() &&
|
||||||
|
HasDirection(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Trend is Bullish ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsBullish()
|
||||||
|
{
|
||||||
|
return HasTrend() &&
|
||||||
|
IsXBullish(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check Trend is Bearish ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsBearish()
|
||||||
|
{
|
||||||
|
return HasTrend() &&
|
||||||
|
IsXBearish(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Unique Identifier ...
|
||||||
|
*
|
||||||
|
* @return ( string )
|
||||||
|
*/
|
||||||
|
string GetObjectID()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string result = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (IsValid())
|
||||||
|
{
|
||||||
|
result = "XTRND_" + ToXString(dir) + "_" + ToXString(TimeToSeconds(time));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represent a Pivot ...
|
* Represent a Pivot ...
|
||||||
**/
|
**/
|
||||||
|
|||||||
@@ -1098,6 +1098,43 @@ struct XPosition
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool IsLong()
|
||||||
|
{
|
||||||
|
return IsValid() &&
|
||||||
|
IsXBullish(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool IsBullish()
|
||||||
|
{
|
||||||
|
return IsLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool IsShort()
|
||||||
|
{
|
||||||
|
return IsValid() &&
|
||||||
|
IsXBearish(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool IsBearish()
|
||||||
|
{
|
||||||
|
return IsShort();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
ENUM_X_DIRECTION GetDirection()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
return IsBullish()
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: IsBearish()
|
||||||
|
? X_DIRECTION_BEARISH
|
||||||
|
: X_DIRECTION_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Retrieve Entry Price ...
|
// Retrieve Entry Price ...
|
||||||
double GetEntry()
|
double GetEntry()
|
||||||
@@ -1317,7 +1354,7 @@ struct XPosition
|
|||||||
//
|
//
|
||||||
double risk = GetRisk();
|
double risk = GetRisk();
|
||||||
int r2r = (int)GetRiskRewardRatio();
|
int r2r = (int)GetRiskRewardRatio();
|
||||||
bool isLong = IsLong(type);
|
bool isLong = IsLong();
|
||||||
for (int i = 0; i < r2r; i++)
|
for (int i = 0; i < r2r; i++)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1350,7 +1387,7 @@ struct XPosition
|
|||||||
reachedLevel = -1;
|
reachedLevel = -1;
|
||||||
reachedPrice = 0;
|
reachedPrice = 0;
|
||||||
double tps[];
|
double tps[];
|
||||||
bool isLong = IsLong(type);
|
bool isLong = IsLong();
|
||||||
double exitPrice = GetExit();
|
double exitPrice = GetExit();
|
||||||
int tpLevels = CalculateTPLevels(tps);
|
int tpLevels = CalculateTPLevels(tps);
|
||||||
if (!IsValidSize(tpLevels) || exitPrice <= 0)
|
if (!IsValidSize(tpLevels) || exitPrice <= 0)
|
||||||
@@ -3868,6 +3905,30 @@ bool IsValid(ENUM_X_ORDER_MODES value)
|
|||||||
return value != X_ORDER_MODE_NOTHING;
|
return value != X_ORDER_MODE_NOTHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool IsXBullish(ENUM_POSITION_TYPE type)
|
||||||
|
{
|
||||||
|
return type == POSITION_TYPE_BUY;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool IsXBullish(ENUM_X_POSITION_TYPES type)
|
||||||
|
{
|
||||||
|
return type == X_POSITION_TYPE_LONG;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool IsXBearish(ENUM_POSITION_TYPE type)
|
||||||
|
{
|
||||||
|
return type == POSITION_TYPE_SELL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool IsXBearish(ENUM_X_POSITION_TYPES type)
|
||||||
|
{
|
||||||
|
return type == X_POSITION_TYPE_SHORT;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Ages ...
|
// Ages ...
|
||||||
|
|
||||||
|
|||||||
@@ -2887,7 +2887,7 @@ class XCXFIMAHelperParser : XCBase
|
|||||||
//
|
//
|
||||||
double values[];
|
double values[];
|
||||||
GetBoundaryValuesArray(values, barIndex);
|
GetBoundaryValuesArray(values, barIndex);
|
||||||
result = GetMax(values);
|
result = GetMin(values);
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -2920,7 +2920,7 @@ class XCXFIMAHelperParser : XCBase
|
|||||||
//
|
//
|
||||||
double values[];
|
double values[];
|
||||||
GetBoundaryValuesArray(values, barIndex);
|
GetBoundaryValuesArray(values, barIndex);
|
||||||
result = GetMin(values);
|
result = GetMax(values);
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -478,6 +478,174 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DetectXPVZone(
|
||||||
|
XBoxZone &zone,
|
||||||
|
int barIndex = 0 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
zone.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
barIndex = fimaParser.NormalizeBarIndex(barIndex);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = fimaParser.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL bar;
|
||||||
|
result = bar.Init(fimaParser.symbol, fimaParser.period, barIndex);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bar.Clean();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Vale ...
|
||||||
|
bool isValeOverLast = fimaParser.IsValeOverLast(barIndex);
|
||||||
|
bool isValeUnderLast = fimaParser.IsValeUnderLast(barIndex);
|
||||||
|
bool isNewVale = isValeOverLast || isValeUnderLast;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Peak ...
|
||||||
|
bool isPeakOverLast = fimaParser.IsPeakOverLast(barIndex);
|
||||||
|
bool isPeakUnderLast = fimaParser.IsPeakUnderLast(barIndex);
|
||||||
|
bool isNewPeak = isPeakOverLast || isPeakUnderLast;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect new Peak or Vale ...
|
||||||
|
result = isNewVale || isNewPeak;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Count Same Peaks and Same Vales from Index of Prev ...
|
||||||
|
int pIDX = barIndex + 1;
|
||||||
|
int samePeaks = fimaParser.CountSamePeaks(pIDX);
|
||||||
|
int sameVales = fimaParser.CountSameVales(pIDX);
|
||||||
|
result =
|
||||||
|
result &&
|
||||||
|
IsValidSize(samePeaks) &&
|
||||||
|
IsValidSize(sameVales);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Try to Evaluate Zone ...
|
||||||
|
int peaksStartIndex = pIDX + samePeaks;
|
||||||
|
int valesStartIndex = pIDX + sameVales;
|
||||||
|
int fromIDX = MathMin(peaksStartIndex, valesStartIndex);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Assign Zone Symbol / Period ...
|
||||||
|
zone.symbol = fimaParser.symbol;
|
||||||
|
zone.period = fimaParser.period;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Zone Times ...
|
||||||
|
zone.to = GetBarTime(
|
||||||
|
zone.symbol,
|
||||||
|
zone.period,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
zone.from = GetBarTime(
|
||||||
|
zone.symbol,
|
||||||
|
zone.period,
|
||||||
|
fromIDX //
|
||||||
|
);
|
||||||
|
zone.at = zone.to;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Upper and Lower ...
|
||||||
|
zone.upper = fimaHelper.GetPeak(fromIDX);
|
||||||
|
zone.lower = fimaHelper.GetVale(fromIDX);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Zone Upper and Lower ...
|
||||||
|
for (int i = pIDX; i <= fromIDX; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (isValeUnderLast)
|
||||||
|
{
|
||||||
|
zone.lower = MathMin(zone.lower, fimaHelper.GetVale(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (isPeakOverLast)
|
||||||
|
{
|
||||||
|
zone.upper = MathMax(zone.upper, fimaHelper.GetPeak(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate Zone Direction ...
|
||||||
|
zone.dir =
|
||||||
|
isValeOverLast
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: isValeUnderLast
|
||||||
|
? X_DIRECTION_BEARISH
|
||||||
|
: isPeakOverLast
|
||||||
|
? X_DIRECTION_BULLISH
|
||||||
|
: isPeakUnderLast
|
||||||
|
? X_DIRECTION_BEARISH
|
||||||
|
: X_DIRECTION_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Refine Zone Upper / Lower based on Direction and Bars ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Highest High / Lowest Low ...
|
||||||
|
double ll = bar.FindLowest(fromIDX - barIndex, MODE_LOW);
|
||||||
|
double hh = bar.FindHighest(fromIDX - barIndex, MODE_HIGH);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (isNewVale)
|
||||||
|
{
|
||||||
|
zone.upper = MathMin(zone.upper, hh);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (isNewPeak)
|
||||||
|
{
|
||||||
|
zone.lower = MathMax(zone.lower, ll);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set Zone Type ...
|
||||||
|
zone.type = ToXString(XFIMA_PIVOT_PV);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Summarize result ...
|
||||||
|
result = zone.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = zone.IsValid();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
zone.Clean();
|
||||||
|
}
|
||||||
|
bar.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Analysors ...
|
// Analysors ...
|
||||||
|
|
||||||
@@ -1422,6 +1590,105 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CollectZonesBoundary(
|
||||||
|
XPivot &uppers[],
|
||||||
|
XPivot &lowers[],
|
||||||
|
XBoxZone &zone //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
XClean(uppers);
|
||||||
|
XClean(lowers);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool has = zone.IsValid() &&
|
||||||
|
fimaParser.IsValid();
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double iUpper;
|
||||||
|
double iLower;
|
||||||
|
datetime iTime;
|
||||||
|
XPivot upperPivot;
|
||||||
|
XPivot lowerPivot;
|
||||||
|
int start = zone.ToIndex();
|
||||||
|
int end = zone.FromIndex();
|
||||||
|
for (int i = start; i <= end; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
iUpper = fimaParser.GetBoundaryMax(i);
|
||||||
|
iLower = fimaParser.GetBoundaryMin(i);
|
||||||
|
iTime = GetBarTime(zone.symbol, zone.period, i);
|
||||||
|
|
||||||
|
//
|
||||||
|
has =
|
||||||
|
IsXValid(iTime) &&
|
||||||
|
NotEmptyZero(iUpper) &&
|
||||||
|
NotEmptyZero(iLower);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Upper Pivot ...
|
||||||
|
upperPivot.Clean();
|
||||||
|
has = upperPivot.Init(
|
||||||
|
iUpper,
|
||||||
|
iTime,
|
||||||
|
zone.symbol,
|
||||||
|
zone.dir,
|
||||||
|
zone.period,
|
||||||
|
X_PIVOT_TYPE_PEAK //
|
||||||
|
);
|
||||||
|
if (has) {
|
||||||
|
upperPivot.prefix = "XBNDUP";
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower Pivot ...
|
||||||
|
lowerPivot.Clean();
|
||||||
|
has = lowerPivot.Init(
|
||||||
|
iLower,
|
||||||
|
iTime,
|
||||||
|
zone.symbol,
|
||||||
|
zone.dir,
|
||||||
|
zone.period,
|
||||||
|
X_PIVOT_TYPE_VALE //
|
||||||
|
);
|
||||||
|
if (has) {
|
||||||
|
lowerPivot.prefix = "XBNDLO";
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
has = upperPivot.IsValid() &&
|
||||||
|
lowerPivot.IsValid();
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
AddRef(upperPivot, uppers);
|
||||||
|
AddRef(lowerPivot, lowers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = MathMin(ArraySize(uppers), ArraySize(lowers));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
upperPivot.Clean();
|
||||||
|
lowerPivot.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Others ...
|
// Others ...
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user