last works ...
This commit is contained in:
@@ -1556,14 +1556,24 @@ class XCGuard : public XCBase
|
||||
//
|
||||
// Validate Action and Requirements ...
|
||||
has =
|
||||
guard.sl > 0 &&
|
||||
guard.sl >= 0 &&
|
||||
NotEmpty(guard.ticket) &&
|
||||
(guard.sl <= 0
|
||||
? guard.force
|
||||
: true) &&
|
||||
guard.action == X_GUARD_ACTION_TRAIL_STOP;
|
||||
if (!has)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Normalize SL ...
|
||||
if (guard.sl < 0)
|
||||
{
|
||||
guard.sl = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Position ...
|
||||
XPosition position;
|
||||
@@ -1582,6 +1592,16 @@ class XCGuard : public XCBase
|
||||
|
||||
//
|
||||
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 ...
|
||||
@@ -1594,13 +1614,7 @@ class XCGuard : public XCBase
|
||||
position.profit > 0 &&
|
||||
//
|
||||
// Validate SL based on Position Type ...
|
||||
(isLong
|
||||
? position.price > guard.sl &&
|
||||
(position.sl == 0 ||
|
||||
position.sl < guard.sl)
|
||||
: position.price < guard.sl &&
|
||||
(position.sl == 0 ||
|
||||
position.sl > guard.sl));
|
||||
isGuardPassed;
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
@@ -1668,14 +1682,24 @@ class XCGuard : public XCBase
|
||||
//
|
||||
// Validate Action and Requirements ...
|
||||
has =
|
||||
guard.tp > 0 &&
|
||||
guard.tp >= 0 &&
|
||||
NotEmpty(guard.ticket) &&
|
||||
(guard.tp <= 0
|
||||
? guard.force
|
||||
: true) &&
|
||||
guard.action == X_GUARD_ACTION_TRAIL_TARGET;
|
||||
if (!has)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
if (guard.tp < 0)
|
||||
{
|
||||
guard.tp = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Position ...
|
||||
XPosition position;
|
||||
@@ -1694,6 +1718,12 @@ class XCGuard : public XCBase
|
||||
|
||||
//
|
||||
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 ...
|
||||
@@ -1706,9 +1736,7 @@ class XCGuard : public XCBase
|
||||
guard.tp != position.tp &&
|
||||
//
|
||||
// Validate TP based on Current Price ...
|
||||
(isLong
|
||||
? guard.tp > position.price
|
||||
: guard.tp < position.price);
|
||||
isGuardPassed;
|
||||
if (!has)
|
||||
{
|
||||
//
|
||||
|
||||
@@ -4264,6 +4264,100 @@ class XCMarketPatternDetector : public XCBase
|
||||
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:
|
||||
|
||||
@@ -1557,7 +1557,61 @@ class XCPOIDrawer : public XCBase
|
||||
{
|
||||
//
|
||||
// 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.Style(config.trendStyle);
|
||||
|
||||
@@ -2528,23 +2582,26 @@ class XCPOIDrawer : public XCBase
|
||||
|
||||
/**
|
||||
* Draw a Collection of Pattern Analysis ...
|
||||
*
|
||||
*
|
||||
* @param analysises: XPatternAnalysis, collection reference to Data Source ...
|
||||
* @param config: XPatternAnalysisDrawConfig, reference to Specified Drawing Config ...
|
||||
*/
|
||||
void DrawPatternAnalysises(
|
||||
XPatternAnalysis &analysises[],
|
||||
XPatternAnalysisDrawConfig &config //
|
||||
) {
|
||||
)
|
||||
{
|
||||
//
|
||||
bool has = HasChild(analysises);
|
||||
if (!has) {
|
||||
if (!has)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
int count = ArraySize(analysises);
|
||||
for (int i = 0; i < count; i++) {
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
DrawPatternAnalysis(analysises[i], config);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user