add support for leg management in XFIMA1 Signaller ...
This commit is contained in:
@@ -1672,10 +1672,9 @@ class XCMarketPatternDetector : public XCBase
|
|||||||
*/
|
*/
|
||||||
bool IsLegPattern(
|
bool IsLegPattern(
|
||||||
XOHCL &bar,
|
XOHCL &bar,
|
||||||
XBoxZone &zone,
|
XLeg &leg,
|
||||||
int validationLength = 3,
|
int validationLength = 3,
|
||||||
int loopback = 10 //,
|
int loopback = 10 //
|
||||||
// Forces ...
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1683,7 +1682,7 @@ class XCMarketPatternDetector : public XCBase
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Prepare ...
|
// Prepare ...
|
||||||
zone.Clean();
|
leg.Clean();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Normalize ...
|
// Normalize ...
|
||||||
@@ -1717,6 +1716,7 @@ class XCMarketPatternDetector : public XCBase
|
|||||||
XOHCL iBar;
|
XOHCL iBar;
|
||||||
XOHCL pBar;
|
XOHCL pBar;
|
||||||
XOHCL iZBar;
|
XOHCL iZBar;
|
||||||
|
XBoxZone zone;
|
||||||
XBoxZone iZone;
|
XBoxZone iZone;
|
||||||
XBoxZone jZone;
|
XBoxZone jZone;
|
||||||
bool has = false;
|
bool has = false;
|
||||||
@@ -2032,6 +2032,31 @@ class XCMarketPatternDetector : public XCBase
|
|||||||
result = zone.IsValid();
|
result = zone.IsValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare XLeg ...
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
leg.dir = zone.dir;
|
||||||
|
leg.time = zone.from;
|
||||||
|
leg.upper = zone.upper;
|
||||||
|
leg.lower = zone.lower;
|
||||||
|
leg.symbol = zone.symbol;
|
||||||
|
leg.period = zone.period;
|
||||||
|
Copy(patterns, leg.patterns);
|
||||||
|
Copy(supports, leg.supports);
|
||||||
|
Copy(bullishBars, leg.bullishBars);
|
||||||
|
Copy(bearishBars, leg.bearishBars);
|
||||||
|
Copy(resistances, leg.resistances);
|
||||||
|
Copy(bullishFVGs, leg.bullishFVGs);
|
||||||
|
Copy(bearishFVGs, leg.bearishFVGs);
|
||||||
|
leg.sequentialBullishBars = sequentialsBullishBarsCount;
|
||||||
|
leg.sequentialBearishBars = sequentialsBearishBarsCount;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = leg.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Cleanup ...
|
// Cleanup ...
|
||||||
if (!result)
|
if (!result)
|
||||||
@@ -2040,6 +2065,7 @@ class XCMarketPatternDetector : public XCBase
|
|||||||
}
|
}
|
||||||
iBar.Clean();
|
iBar.Clean();
|
||||||
pBar.Clean();
|
pBar.Clean();
|
||||||
|
zone.Clean();
|
||||||
iZBar.Clean();
|
iZBar.Clean();
|
||||||
iZone.Clean();
|
iZone.Clean();
|
||||||
jZone.Clean();
|
jZone.Clean();
|
||||||
|
|||||||
@@ -2526,6 +2526,29 @@ class XCPOIDrawer : public XCBase
|
|||||||
patternPivot.Clean();
|
patternPivot.Clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = ArraySize(analysises);
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
DrawPatternAnalysis(analysises[i], config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw Specified Pivots Analysis ...
|
* Draw Specified Pivots Analysis ...
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -2323,10 +2323,10 @@ struct XPatternAnalysis
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract All Exists Patterns Pivots ...
|
* Extract All Exists Patterns Pivots ...
|
||||||
*
|
*
|
||||||
* @param dest: XPivot, collection reference to holds Extracted Patterns ...
|
* @param dest: XPivot, collection reference to holds Extracted Patterns ...
|
||||||
* @param forDir: ENUM_X_DIRECTION, Specified Direction of Extractions ...
|
* @param forDir: ENUM_X_DIRECTION, Specified Direction of Extractions ...
|
||||||
*
|
*
|
||||||
* @return ( int )
|
* @return ( int )
|
||||||
*/
|
*/
|
||||||
int GetPatterns(
|
int GetPatterns(
|
||||||
@@ -2584,7 +2584,8 @@ struct XPatternAnalysisConfig
|
|||||||
/**
|
/**
|
||||||
* Remove all Allowed Patterns and Directions ...
|
* Remove all Allowed Patterns and Directions ...
|
||||||
*/
|
*/
|
||||||
void CleanPatterns() {
|
void CleanPatterns()
|
||||||
|
{
|
||||||
//
|
//
|
||||||
XClean(allowedDirs);
|
XClean(allowedDirs);
|
||||||
XClean(allowedPatterns);
|
XClean(allowedPatterns);
|
||||||
@@ -2915,6 +2916,199 @@ struct XPatternAnalysisDrawConfig
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* an strucutre to Model Specified Leg Pattern ...
|
||||||
|
**/
|
||||||
|
struct XLeg
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
datetime time;
|
||||||
|
string symbol;
|
||||||
|
ENUM_X_DIRECTION dir;
|
||||||
|
ENUM_TIMEFRAMES period;
|
||||||
|
|
||||||
|
//
|
||||||
|
double upper;
|
||||||
|
double lower;
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL bullishBars[];
|
||||||
|
XOHCL bearishBars[];
|
||||||
|
|
||||||
|
//
|
||||||
|
XBoxZone supports[];
|
||||||
|
XBoxZone resistances[];
|
||||||
|
|
||||||
|
//
|
||||||
|
XBoxZone bullishFVGs[];
|
||||||
|
XBoxZone bearishFVGs[];
|
||||||
|
|
||||||
|
//
|
||||||
|
XPatternAnalysis patterns[];
|
||||||
|
|
||||||
|
//
|
||||||
|
int sequentialBullishBars;
|
||||||
|
int sequentialBearishBars;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleanup ...
|
||||||
|
*/
|
||||||
|
void Clean()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
time = NULL;
|
||||||
|
symbol = NULL;
|
||||||
|
period = NULL;
|
||||||
|
dir = X_DIRECTION_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
upper = 0;
|
||||||
|
lower = 0;
|
||||||
|
sequentialBullishBars = 0;
|
||||||
|
sequentialBearishBars = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
XClean(patterns);
|
||||||
|
XClean(supports);
|
||||||
|
XClean(bullishBars);
|
||||||
|
XClean(bearishBars);
|
||||||
|
XClean(resistances);
|
||||||
|
XClean(bullishFVGs);
|
||||||
|
XClean(bearishFVGs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsValid()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
IsXValid(time) &&
|
||||||
|
IsXValid(symbol) &&
|
||||||
|
IsXValid(period) &&
|
||||||
|
HasDirection(dir) &&
|
||||||
|
NotEmptyZero(upper) &&
|
||||||
|
NotEmptyZero(lower) &&
|
||||||
|
upper > lower;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check is Bullish ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsBullish()
|
||||||
|
{
|
||||||
|
return IsValid() &&
|
||||||
|
IsXBullish(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check is Bearish ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsBearish()
|
||||||
|
{
|
||||||
|
return IsValid() &&
|
||||||
|
IsXBearish(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a Leg to XBoxZone ...
|
||||||
|
*
|
||||||
|
* @param zone: XBoxZone, reference to holds Converted ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool ToBox(XBoxZone &zone)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
zone.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
zone.at = time;
|
||||||
|
zone.dir = dir;
|
||||||
|
zone.from = time;
|
||||||
|
zone.upper = upper;
|
||||||
|
zone.lower = lower;
|
||||||
|
zone.symbol = symbol;
|
||||||
|
zone.period = period;
|
||||||
|
zone.to = TimeCurrent();
|
||||||
|
zone.type = ToXString(X_BAR_PATTERN_LEG);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = zone.IsValid();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
zone.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Times of Collections ...
|
||||||
|
*
|
||||||
|
* @param value: datetime, Specified Time ...
|
||||||
|
*/
|
||||||
|
void UpdateTimes(datetime value = NULL)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
value = NormalizeTime(value);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
if (!IsValid())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
UpdateToTime(supports, value);
|
||||||
|
UpdateToTime(resistances, value);
|
||||||
|
UpdateToTime(bullishFVGs, value);
|
||||||
|
UpdateToTime(bearishFVGs, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Extensions ...
|
// Extensions ...
|
||||||
|
|
||||||
|
|||||||
@@ -343,6 +343,10 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Manage Leg ...
|
||||||
|
ManageLeg(iBar);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Strategy X ...
|
// Strategy X ...
|
||||||
has = HasSignal(
|
has = HasSignal(
|
||||||
@@ -516,6 +520,118 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
//
|
//
|
||||||
// Props ...
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XLeg leg; // Exists Leg ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool HasLeg()
|
||||||
|
{
|
||||||
|
return leg.IsValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool ValidateLeg(XOHCL &bar)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = HasLeg() && bar.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
leg.IsBullish()
|
||||||
|
? bar.low > leg.lower
|
||||||
|
: leg.IsBearish()
|
||||||
|
? bar.high < leg.upper
|
||||||
|
: false;
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
void DrawLeg()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (!HasLeg())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update to Times ...
|
||||||
|
leg.UpdateTimes();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw Leg Box ...
|
||||||
|
XBoxZone legZone;
|
||||||
|
leg.ToBox(legZone);
|
||||||
|
if (legZone.IsValid())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
legZone.to = TimeCurrent();
|
||||||
|
poiDrawer.DrawZone(legZone, structureDrawConfig.drawConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw Legs Other Stufs ...
|
||||||
|
return;
|
||||||
|
|
||||||
|
//
|
||||||
|
// FVGs ...
|
||||||
|
poiDrawer.DrawZones(leg.bullishFVGs, structureDrawConfig.drawConfig);
|
||||||
|
poiDrawer.DrawZones(leg.bearishFVGs, structureDrawConfig.drawConfig);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Support and Resistances ...
|
||||||
|
poiDrawer.DrawZones(leg.supports, structureDrawConfig.drawConfig);
|
||||||
|
poiDrawer.DrawZones(leg.resistances, structureDrawConfig.drawConfig);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Patterns ...
|
||||||
|
poiDrawer.DrawPatternAnalysises(leg.patterns, structureDrawConfig.barAnalysisDrawConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
void ManageLeg(XOHCL &bar)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (HasLeg())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (!ValidateLeg(bar))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Invalidate XLeg ...
|
||||||
|
leg.Clean();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect New Leg ...
|
||||||
|
if (!HasLeg())
|
||||||
|
{
|
||||||
|
poiDetector.IsLegPattern(bar, leg);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update Exists Leg ...
|
||||||
|
if (HasLeg())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Update to Times ...
|
||||||
|
leg.UpdateTimes();
|
||||||
|
|
||||||
|
//
|
||||||
|
DrawLeg();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Implementing Strategies ...
|
// Implementing Strategies ...
|
||||||
|
|
||||||
@@ -1905,51 +2021,80 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
//
|
//
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
//
|
// //
|
||||||
UpdateToTime(orderFlow, bar.time);
|
// UpdateToTime(orderFlow, bar.time);
|
||||||
poiDrawer.DrawZones(orderFlow, structureDrawConfig.drawConfig);
|
// poiDrawer.DrawZones(orderFlow, structureDrawConfig.drawConfig);
|
||||||
poiDrawer.DrawPatternAnalysis(pBarPatterns, structureDrawConfig.barAnalysisDrawConfig);
|
// poiDrawer.DrawPatternAnalysis(pBarPatterns, structureDrawConfig.barAnalysisDrawConfig);
|
||||||
|
|
||||||
//
|
// //
|
||||||
// Draw ATR Band Middle ...
|
// // Draw ATR Band Middle ...
|
||||||
if (NotEmptyZero(atrBandMiddle))
|
// if (NotEmptyZero(atrBandMiddle))
|
||||||
{
|
// {
|
||||||
//
|
// //
|
||||||
XPOIDrawConfig iConfig = structureDrawConfig.drawConfig;
|
// XPOIDrawConfig iConfig = structureDrawConfig.drawConfig;
|
||||||
iConfig.trendRayLeft = false;
|
// iConfig.trendRayLeft = false;
|
||||||
iConfig.trendRayRight = false;
|
// iConfig.trendRayRight = false;
|
||||||
|
|
||||||
//
|
// //
|
||||||
datetime to = bar.time;
|
// datetime to = bar.time;
|
||||||
datetime from = p2Bar.BeforeOn();
|
// datetime from = p2Bar.BeforeOn();
|
||||||
string trendName = "ATRBandMiddle_" + ToXString(TimeToSeconds(p2Bar.time));
|
// string trendName = "ATRBandMiddle_" + ToXString(TimeToSeconds(p2Bar.time));
|
||||||
poiDrawer.DrawTrendLine(
|
// poiDrawer.DrawTrendLine(
|
||||||
trendName,
|
// trendName,
|
||||||
atrBandMiddle,
|
// atrBandMiddle,
|
||||||
from,
|
// from,
|
||||||
atrBandMiddle,
|
// atrBandMiddle,
|
||||||
to,
|
// to,
|
||||||
iConfig,
|
// iConfig,
|
||||||
clrYellow //
|
// clrYellow //
|
||||||
);
|
// );
|
||||||
|
|
||||||
//
|
// //
|
||||||
iConfig.Clean();
|
// iConfig.Clean();
|
||||||
}
|
// }
|
||||||
|
|
||||||
//
|
// //
|
||||||
Print("OrderFlow ...");
|
// Print("OrderFlow ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// //
|
||||||
XBoxZone legZone;
|
// XLeg leg;
|
||||||
result = poiDetector.IsLegPattern(pBar, legZone);
|
// result = poiDetector.IsLegPattern(pBar, leg);
|
||||||
if (result)
|
// if (result)
|
||||||
{
|
// {
|
||||||
//
|
// //
|
||||||
poiDrawer.DrawZone(legZone, structureDrawConfig.drawConfig);
|
// // Update to Times ...
|
||||||
Print("Leg Pattern Detected ...");
|
// leg.UpdateTimes(bar.time);
|
||||||
}
|
|
||||||
|
// //
|
||||||
|
// // Draw Leg Box ...
|
||||||
|
// XBoxZone legZone;
|
||||||
|
// leg.ToBox(legZone);
|
||||||
|
// if (legZone.IsValid())
|
||||||
|
// {
|
||||||
|
// poiDrawer.DrawZone(legZone, structureDrawConfig.drawConfig);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Draw Legs Other Stufs ...
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // FVGs ...
|
||||||
|
// poiDrawer.DrawZones(leg.bullishFVGs, structureDrawConfig.drawConfig);
|
||||||
|
// poiDrawer.DrawZones(leg.bearishFVGs, structureDrawConfig.drawConfig);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Support and Resistances ...
|
||||||
|
// poiDrawer.DrawZones(leg.supports, structureDrawConfig.drawConfig);
|
||||||
|
// poiDrawer.DrawZones(leg.resistances, structureDrawConfig.drawConfig);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Patterns ...
|
||||||
|
// poiDrawer.DrawPatternAnalysises(leg.patterns, structureDrawConfig.barAnalysisDrawConfig);
|
||||||
|
|
||||||
|
// //
|
||||||
|
// Print("Leg Pattern Detected ...");
|
||||||
|
// }
|
||||||
|
|
||||||
//
|
//
|
||||||
isBullish =
|
isBullish =
|
||||||
|
|||||||
Reference in New Issue
Block a user