refactor all requirements for draw and detect pois and also add Fima Helper, Parser Class Implementations for Separation of Concerns ...
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -24,6 +24,7 @@
|
||||
// Imports ...
|
||||
#include "../../Classes/x-saherelm.x-signaller.class.mq5"
|
||||
#include "../../Helpers/x-saherelm.xfima.helper.mq5"
|
||||
#include "../Classes/x-saherelm.xfima.parser.class.mq5"
|
||||
#include "../Classes/x-saherelm.xfima.x-poi.detector.class.mq5"
|
||||
#include "../Classes/x-saherelm.xfima.x-poi.drawer.class.mq5"
|
||||
|
||||
@@ -45,6 +46,7 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
|
||||
XFIMAInputs fimaInputs; // XFIMA Inputs ...
|
||||
XCXFIMAHelper *fimaHelper; // XFIMA Indicator Helper ...
|
||||
XCXFIMAPOIDrawer *poiDrawer; // XFIMA POI Drawer ...
|
||||
XCXFIMAHelperParser *fimaParser; // XFIMA Helper Parser ...
|
||||
XCXFIMAPOIDetector *poiDetector; // XFIMA POI Detector ...
|
||||
XFIMAMarketStructureConfig structureConfig; // XFIMA Market Structure Detector Config ...
|
||||
XFIMAMarketStructureDrawerConfig structureDrawConfig; // XFIMA Market Structure Draw Config ...
|
||||
@@ -92,9 +94,13 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Instantiate XFIMA Helper Parser ...
|
||||
fimaParser = new XCXFIMAHelperParser(fimaHelper);
|
||||
|
||||
//
|
||||
poiDrawer = new XCXFIMAPOIDrawer();
|
||||
poiDetector = new XCXFIMAPOIDetector(fimaHelper);
|
||||
poiDetector = new XCXFIMAPOIDetector(fimaHelper, fimaParser);
|
||||
|
||||
//
|
||||
// Configure ...
|
||||
@@ -556,25 +562,17 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
// Draw Flags ...
|
||||
bool draw = true;
|
||||
bool drawZone = true;
|
||||
bool drawOrderFlow = true;
|
||||
bool drawMarketStructurePivots = true;
|
||||
bool drawMarketStructureAnalysis = true;
|
||||
bool drawMarketStructureOrderFlow = true;
|
||||
XPOIDrawConfig iDrawConfig;
|
||||
|
||||
//
|
||||
// Signal Checking ...
|
||||
|
||||
//
|
||||
// Detecting OrderFlow ...
|
||||
XBoxZone orderFlow[];
|
||||
ENUM_X_DIRECTION orderFlowDir;
|
||||
bool hasOrderFlow = poiDetector.HasOrderFlow(
|
||||
bar,
|
||||
orderFlowDir,
|
||||
orderFlow,
|
||||
2,
|
||||
false, // Contains OB ...
|
||||
true, // Contains FVG ...
|
||||
false // Contains Support and Resistances ...
|
||||
);
|
||||
// Analyse Market Strucutre ...
|
||||
XFIMAMarketStructure marketStructure;
|
||||
|
||||
//
|
||||
// Signaller 1 ...
|
||||
@@ -660,14 +658,24 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
if (result && validateByOrderFlow)
|
||||
{
|
||||
//
|
||||
bool isBullish = hasOrderFlow &&
|
||||
IsXBullish(dir) &&
|
||||
IsXBullish(orderFlowDir);
|
||||
// Analyse Market Structure if Required ...
|
||||
if (!marketStructure.IsValid())
|
||||
{
|
||||
//
|
||||
poiDetector.AnalyseMarket(
|
||||
marketStructure,
|
||||
structureConfig,
|
||||
bar.Index() //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
bool isBearish = hasOrderFlow &&
|
||||
IsXBearish(dir) &&
|
||||
IsXBearish(orderFlowDir);
|
||||
bool isBullish = IsXBullish(dir) &&
|
||||
marketStructure.HasBullishOrderFlow();
|
||||
|
||||
//
|
||||
bool isBearish = IsXBearish(dir) &&
|
||||
marketStructure.HasBearishOrderFlow();
|
||||
|
||||
//
|
||||
// Summarizing result ...
|
||||
@@ -749,7 +757,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
|
||||
//
|
||||
// Partial Close on TP 1 ...
|
||||
if (hasPartialCloseOnTp1 && tp > tp1)
|
||||
if (hasPartialCloseOnTp1)
|
||||
{
|
||||
//
|
||||
iTarget.Clean();
|
||||
@@ -814,10 +822,52 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Order Flow ...
|
||||
if (drawOrderFlow && HasChild(orderFlow))
|
||||
// Draw Market Structure ...
|
||||
//
|
||||
// Analyse Market Structure if Required ...
|
||||
if (!marketStructure.IsValid())
|
||||
{
|
||||
poiDrawer.DrawZones(orderFlow, iDrawConfig);
|
||||
//
|
||||
poiDetector.AnalyseMarket(
|
||||
marketStructure,
|
||||
structureConfig,
|
||||
bar.Index() //
|
||||
);
|
||||
}
|
||||
if (marketStructure.IsValid())
|
||||
{
|
||||
//
|
||||
// Order Flow ...
|
||||
if (drawMarketStructureOrderFlow && marketStructure.HasOrderFlow())
|
||||
{
|
||||
poiDrawer.DrawZones(marketStructure.orderFlow, iDrawConfig);
|
||||
}
|
||||
|
||||
//
|
||||
// Pivots ...
|
||||
if (drawMarketStructurePivots)
|
||||
{
|
||||
//
|
||||
XPivot pivots[];
|
||||
int pivotsCount = marketStructure.CollectPivots(
|
||||
pivots,
|
||||
true // Contains Patterns ...
|
||||
);
|
||||
if (IsValidSize(pivotsCount))
|
||||
{
|
||||
poiDrawer.DrawPivots(pivots, iDrawConfig);
|
||||
}
|
||||
|
||||
//
|
||||
XClean(pivots);
|
||||
}
|
||||
|
||||
//
|
||||
// Analysis ...
|
||||
if (drawMarketStructureAnalysis)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -841,6 +891,11 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
DebugBreak();
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
iDrawConfig.Clean();
|
||||
marketStructure.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -918,13 +973,13 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
}
|
||||
|
||||
//
|
||||
// Reading HK Bond ...
|
||||
// Reading HK Band ...
|
||||
|
||||
//
|
||||
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);
|
||||
double pHKBandUpper = fimaHelper.GetHKBandUpper(pBar.Index());
|
||||
double pHKBandLower = fimaHelper.GetHKBandLower(pBar.Index());
|
||||
int overHKBandUpperCount = fimaParser.CountOverHKBandUpper(pullBackStartBar, X_PRICE_LOW);
|
||||
int underHKBandLowerCount = fimaParser.CountUnderHKBandLower(pullBackStartBar, X_PRICE_HIGH);
|
||||
|
||||
//
|
||||
// Reading PV Requirements ...
|
||||
@@ -934,10 +989,10 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
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());
|
||||
int samePeaks = fimaParser.CountSamePeaks(pBar.Index());
|
||||
int sameVales = fimaParser.CountSameVales(pBar.Index());
|
||||
fimaParser.FindLastPeakOverLast(lastPeakOverLastIDX, pBar.Index());
|
||||
fimaParser.FindLastValeUnderLast(lastValeUnderLastIDX, pBar.Index());
|
||||
|
||||
//
|
||||
// Reading pBar Patterns ...
|
||||
@@ -1040,7 +1095,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
hasBullishInside &&
|
||||
isPullbackBullish &&
|
||||
isPBarHasBullishPatterns &&
|
||||
fimaHelper.IsSarBullish(pBar.Index()) &&
|
||||
fimaParser.IsSARBullish(pBar.Index()) &&
|
||||
(pVale >= affectedZonesBullish[insideBullishIDX].lower &&
|
||||
pVale <= affectedZonesBullish[insideBullishIDX].upper)
|
||||
//
|
||||
@@ -1052,7 +1107,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
hasBearishInside &&
|
||||
isPullbackBearish &&
|
||||
isPBarHasBearishPatterns &&
|
||||
fimaHelper.IsSarBearish(pBar.Index()) &&
|
||||
fimaParser.IsSARBearish(pBar.Index()) &&
|
||||
(pPeak >= affectedZonesBearish[insideBearishIDX].lower &&
|
||||
pPeak <= affectedZonesBearish[insideBearishIDX].upper)
|
||||
//
|
||||
@@ -1064,24 +1119,6 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
isBearish;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
if (isBullish)
|
||||
{
|
||||
//
|
||||
poiDrawer.DrawZone(
|
||||
affectedZonesBullish[insideBullishIDX],
|
||||
structureDrawConfig.drawConfig //
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
poiDrawer.DrawZone(
|
||||
affectedZonesBearish[insideBearishIDX],
|
||||
structureDrawConfig.drawConfig //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
dir =
|
||||
isBullish
|
||||
@@ -1238,10 +1275,10 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
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 isPPeakOverLast = fimaParser.IsPeakOverLast(pBar.Index());
|
||||
bool isPValeUnderLast = fimaParser.IsValeUnderLast(pBar.Index());
|
||||
bool isP2PeakOverLast = fimaParser.IsPeakOverLast(p2Bar.Index());
|
||||
bool isP2ValeUnderLast = fimaParser.IsValeUnderLast(p2Bar.Index());
|
||||
bool isPeakOverLast = isPPeakOverLast ||
|
||||
isP2PeakOverLast;
|
||||
bool isValeUnderLast = isPValeUnderLast ||
|
||||
@@ -1473,7 +1510,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
// XFIMA Consolidation ...
|
||||
|
||||
//
|
||||
bool isConsolidation = fimaHelper.HasPVConsolidationZone(
|
||||
bool isConsolidation = poiDetector.DetectPVConsolidationZone(
|
||||
zone,
|
||||
pBar.Index(),
|
||||
true, // Force PV Break ...
|
||||
@@ -1707,12 +1744,6 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
//
|
||||
result = isBullish ||
|
||||
isBearish;
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
poiDrawer.DrawZones(orderFlow, structureDrawConfig.drawConfig);
|
||||
Print("OrderFlow Detected ...");
|
||||
}
|
||||
|
||||
//
|
||||
isBullish =
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -702,79 +702,6 @@ class XCXFIMAPOIDrawer : public XCPOIDrawer
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw Specified Market Structure Based on Given Configs ...
|
||||
*
|
||||
* @param structure: XFIMAMarketStructure, reference to Provide Specifid Market Structure ...
|
||||
* @param config: XFIMAMarketStructureDrawerConfig, reference to Provide Drawing Configurations ...
|
||||
*/
|
||||
void DrawMarketStructure(
|
||||
XFIMAMarketStructure &structure,
|
||||
XFIMAMarketStructureDrawerConfig &config //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
bool has = structure.IsValid();
|
||||
if (!has)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// PV Analysis ...
|
||||
if (config.drawPVAnalysis)
|
||||
{
|
||||
//
|
||||
has = structure.pvAnalysis.IsValid();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
DrawPivotAnalysis(
|
||||
structure.pvAnalysis,
|
||||
config.pivotAnalysisDrawConfig //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// ZG Analysis ...
|
||||
if (config.drawZGAnalysis)
|
||||
{
|
||||
//
|
||||
has = structure.zgAnalysis.IsValid();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
DrawPivotAnalysis(
|
||||
structure.zgAnalysis,
|
||||
config.pivotAnalysisDrawConfig //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Bars Analysis ...
|
||||
if (config.drawBarsAnalysis)
|
||||
{
|
||||
//
|
||||
int count = ArraySize(structure.barsAnalysis);
|
||||
has = IsValidSize(count);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
DrawPatternAnalysis(
|
||||
structure.barsAnalysis[i],
|
||||
config.barAnalysisDrawConfig //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "../../Classes/x-saherelm.x-cobject.class.mq5"
|
||||
#include "../../Helpers/x-saherelm.xfima.helper.mq5"
|
||||
#include "../../Libraries/x-saherelm.x-pivot.analysis.lib.mq5"
|
||||
#include "../Classes/x-saherelm.xfima.parser.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
@@ -40,8 +41,22 @@ struct XFIMAMarketStructure
|
||||
XPatternAnalysis barAnalysis; // Structure Bar Pattern Analysis ...
|
||||
|
||||
//
|
||||
XPivotAnalysis pvAnalysis; // PV Pivot Analysis Result ...
|
||||
XPivotAnalysis zgAnalysis; // ZG Pivot Analysis Result ...
|
||||
XBoxZone orderFlow[]; // Specified Order Flow Zones ...
|
||||
ENUM_X_DIRECTION orderFlowDir; // Specified Order Flow Direction ...
|
||||
|
||||
//
|
||||
XPivot pvPivots[]; // XPV Pivots ...
|
||||
XPivot zgPivots[]; // XZG Pivots ...
|
||||
XPivot maPivots[]; // XMA Pivots ...
|
||||
XPivot hkPivots[]; // XHK Pivots ...
|
||||
XPivot sarPivots[]; // XSAR Pivots ...
|
||||
|
||||
//
|
||||
XPivotAnalysis pvAnalysis; // XPV Pivot Analysis Result ...
|
||||
XPivotAnalysis zgAnalysis; // XZG Pivot Analysis Result ...
|
||||
XPivotAnalysis maAnalysis; // XMA Pivot Analysis Result ...
|
||||
XPivotAnalysis hkAnalysis; // XHK Pivot Analysis Result ...
|
||||
XPivotAnalysis sarAnalysis; // XSAR Pivot Analysis Result ...
|
||||
|
||||
//
|
||||
XPatternAnalysis barsAnalysis[]; // Anaysed Bars ...
|
||||
@@ -65,11 +80,27 @@ struct XFIMAMarketStructure
|
||||
bar.Clean();
|
||||
barAnalysis.Clean();
|
||||
|
||||
//
|
||||
XClean(pvPivots);
|
||||
XClean(zgPivots);
|
||||
XClean(maPivots);
|
||||
XClean(hkPivots);
|
||||
XClean(sarPivots);
|
||||
|
||||
//
|
||||
pvAnalysis.Clean();
|
||||
zgAnalysis.Clean();
|
||||
maAnalysis.Clean();
|
||||
hkAnalysis.Clean();
|
||||
sarAnalysis.Clean();
|
||||
|
||||
//
|
||||
XClean(barsAnalysis);
|
||||
|
||||
//
|
||||
XClean(orderFlow);
|
||||
orderFlowDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
ZeroMemory(this);
|
||||
}
|
||||
@@ -85,31 +116,73 @@ struct XFIMAMarketStructure
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid() &&
|
||||
barAnalysis.IsValid();
|
||||
result = bar.IsValid() &&
|
||||
barAnalysis.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Checkers ...
|
||||
|
||||
/**
|
||||
* Check Market Strucutre Has Order Flow or not ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasOrderFlow()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
HasChild(orderFlow) &&
|
||||
HasDirection(orderFlowDir);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Market Structure Has Bullish Order Flow or not ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasBullishOrderFlow()
|
||||
{
|
||||
return HasOrderFlow() &&
|
||||
IsXBullish(orderFlowDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Market Structure Has Bearish Order Flow or not ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasBearishOrderFlow()
|
||||
{
|
||||
return HasOrderFlow() &&
|
||||
IsXBearish(orderFlowDir);
|
||||
}
|
||||
|
||||
//
|
||||
// Collectors ...
|
||||
|
||||
/**
|
||||
* Collect Required Zones from Structure ...
|
||||
* Collect all Pivots ...
|
||||
*
|
||||
* @param dest: XBoxZone, reference collection to holds result ...
|
||||
* @param forDir: ENUM_X_DIRECTION, Specified Collectiong ones Direction ...
|
||||
* @param containsOB: bool, Contains OB Zones ...
|
||||
* @param containsFVG: bool, Contains FVG Zones ...
|
||||
* @param dest: XPivot, collection reference to holds result ...
|
||||
* @param containsPatterns: bool, Specified to Add Pivots Bar Directionl Patterns ...
|
||||
* @param forDir: ENUM_X_DIRECTION, Specified Extraction Direction ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int CollectZones(
|
||||
XBoxZone &dest[],
|
||||
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE,
|
||||
bool containsOB = false,
|
||||
bool containsFVG = false //
|
||||
int CollectPivots(
|
||||
XPivot &dest[],
|
||||
bool containsPatterns = false,
|
||||
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -120,7 +193,7 @@ struct XFIMAMarketStructure
|
||||
XClean(dest);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
// Normalize ...
|
||||
bool has = IsValid();
|
||||
if (!has)
|
||||
{
|
||||
@@ -128,182 +201,80 @@ struct XFIMAMarketStructure
|
||||
}
|
||||
|
||||
//
|
||||
bool canCollectBullish =
|
||||
IsXBullish(forDir) ||
|
||||
!HasDirection(forDir);
|
||||
// Do ...
|
||||
|
||||
//
|
||||
bool canCollectBearish =
|
||||
IsXBearish(forDir) ||
|
||||
!HasDirection(forDir);
|
||||
Copy(pvPivots, dest, false);
|
||||
Copy(hkPivots, dest, false);
|
||||
Copy(maPivots, dest, false);
|
||||
Copy(zgPivots, dest, false);
|
||||
Copy(sarPivots, dest, false);
|
||||
|
||||
//
|
||||
int count = 0;
|
||||
XBoxZone tmpBox;
|
||||
|
||||
//
|
||||
// Check Analysis ...
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
has = pvAnalysis.IsValid();
|
||||
if (has)
|
||||
// Apply Direction Filtering ...
|
||||
if (HasDirection(forDir))
|
||||
{
|
||||
//
|
||||
// Support ...
|
||||
tmpBox.Clean();
|
||||
has = pvAnalysis.HasSupportBox(tmpBox);
|
||||
if (has && canCollectBullish)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
tmpBox,
|
||||
dest //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance ...
|
||||
tmpBox.Clean();
|
||||
has = pvAnalysis.HasResistanceBox(tmpBox);
|
||||
if (has && canCollectBearish)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
tmpBox,
|
||||
dest //
|
||||
);
|
||||
}
|
||||
XPivot tmps[];
|
||||
ExtractByDirection(
|
||||
tmps,
|
||||
dest,
|
||||
forDir //
|
||||
);
|
||||
XClean(dest);
|
||||
Copy(tmps, dest);
|
||||
XClean(tmps);
|
||||
}
|
||||
|
||||
//
|
||||
// XZG ...
|
||||
has = zgAnalysis.IsValid();
|
||||
if (has)
|
||||
// Contains Pattern Pivots ...
|
||||
if (containsPatterns && HasChild(dest) && HasChild(barsAnalysis))
|
||||
{
|
||||
//
|
||||
// Support ...
|
||||
tmpBox.Clean();
|
||||
has = zgAnalysis.HasSupportBox(tmpBox);
|
||||
if (has && canCollectBullish)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
tmpBox,
|
||||
dest //
|
||||
);
|
||||
}
|
||||
XPivot tmp;
|
||||
int idx = -1;
|
||||
XPivot tmps[];
|
||||
XPivot sames[];
|
||||
XPivot patterns[];
|
||||
Copy(dest, tmps);
|
||||
XClean(dest);
|
||||
|
||||
//
|
||||
// Resistance ...
|
||||
tmpBox.Clean();
|
||||
has = zgAnalysis.HasResistanceBox(tmpBox);
|
||||
if (has && canCollectBearish)
|
||||
while (HasChild(tmps))
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
tmpBox,
|
||||
dest //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Bar Patterns ...
|
||||
has = HasChild(barsAnalysis);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
count = ArraySize(barsAnalysis);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
// Support ...
|
||||
has = barsAnalysis[i].IsSupport();
|
||||
if (has && canCollectBullish)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
barsAnalysis[i].support,
|
||||
dest //
|
||||
);
|
||||
}
|
||||
tmp.Clean();
|
||||
tmp = tmps[0];
|
||||
ArrayRemove(tmps, 0, 1);
|
||||
|
||||
//
|
||||
// Resistance ...
|
||||
has = barsAnalysis[i].IsResistance();
|
||||
if (has && canCollectBearish)
|
||||
XClean(sames);
|
||||
ExtractSameTimePivots(tmp, sames, tmps);
|
||||
if (HasChild(sames))
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
barsAnalysis[i].resistance,
|
||||
dest //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// OB ...
|
||||
if (containsOB)
|
||||
{
|
||||
//
|
||||
has = barsAnalysis[i].IsOB();
|
||||
has = FindByTime(idx, tmp.time, barsAnalysis);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
has = (canCollectBullish && barsAnalysis[i].ob.IsBullish()) ||
|
||||
(canCollectBearish && barsAnalysis[i].ob.IsBearish());
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
barsAnalysis[i].ob,
|
||||
dest //
|
||||
);
|
||||
}
|
||||
barsAnalysis[idx].GetPatterns(patterns, sames[0].dir);
|
||||
Copy(patterns, dest, false);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// FVG ...
|
||||
if (containsFVG)
|
||||
{
|
||||
has = barsAnalysis[i].IsFVG();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
has = (canCollectBullish && barsAnalysis[i].fvg.IsBullish()) ||
|
||||
(canCollectBearish && barsAnalysis[i].fvg.IsBearish());
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
barsAnalysis[i].fvg,
|
||||
dest //
|
||||
);
|
||||
}
|
||||
}
|
||||
//
|
||||
Copy(sames, dest, false);
|
||||
Removes(sames, tmps);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
XClean(tmps);
|
||||
XClean(sames);
|
||||
XClean(patterns);
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(dest);
|
||||
has = IsValidSize(result);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Update To Time ...
|
||||
// and also we Can Validate Zones Here ...
|
||||
datetime cTime = TimeCurrent();
|
||||
for (int i = 0; i < result; i++)
|
||||
{
|
||||
dest[i].to = cTime;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
tmpBox.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -312,6 +283,9 @@ struct XFIMAMarketStructure
|
||||
//
|
||||
};
|
||||
|
||||
/**
|
||||
* Configure How to Detect Market Structure ...
|
||||
**/
|
||||
struct XFIMAMarketStructureConfig
|
||||
{
|
||||
//
|
||||
@@ -321,12 +295,18 @@ struct XFIMAMarketStructureConfig
|
||||
// Detector Flags ...
|
||||
|
||||
//
|
||||
bool analysePVPivots; // Analyse PV Pivots ...
|
||||
bool analyseZGPivots; // Analyse ZG Pivots ...
|
||||
bool analysePVPivots; // Analyse PV Pivots ...
|
||||
bool analyseZGPivots; // Analyse ZG Pivots ...
|
||||
bool analyseHKPivots; // Analyse HK Pivots ...
|
||||
bool analyseMAPivots; // Analyse MA Pivots ...
|
||||
bool analyseSARPivots; // Analyse SAR Pivots ...
|
||||
|
||||
//
|
||||
bool analyseBarPatterns; // Analyse Bar Patterns ...
|
||||
|
||||
//
|
||||
bool detectOrderFlow; // Detect Order Flow ...
|
||||
|
||||
//
|
||||
// Detector Configs ...
|
||||
|
||||
@@ -335,8 +315,10 @@ struct XFIMAMarketStructureConfig
|
||||
int requiredPivots; // Required Extracted Pivots for Analysis ...
|
||||
|
||||
//
|
||||
int pvPivotsValidationLength; // PV Pivots Validation Length ...
|
||||
double maCrossValidationDiffMultiplier; // a Point Distance to Validate MA Crosses ...
|
||||
int orderFlowValidation; // Order Flow Sequential Validation ...
|
||||
bool orderFlowUseOB; // Order Flow Use Order Blocks ...
|
||||
bool orderFlowUseFVG; // Order Flow Use Fair Value Gaps ...
|
||||
bool orderFlowUseSupportAndResistance; // Order Flow Use Support and Resistance (s) ...
|
||||
|
||||
//
|
||||
XPatternAnalysisConfig barsAnalysisConfig; // Bars Analyser Config ...
|
||||
@@ -358,16 +340,24 @@ struct XFIMAMarketStructureConfig
|
||||
{
|
||||
//
|
||||
// Detector Flags ...
|
||||
detectOrderFlow = false;
|
||||
analysePVPivots = false;
|
||||
analyseZGPivots = false;
|
||||
analyseHKPivots = false;
|
||||
analyseMAPivots = false;
|
||||
analyseSARPivots = false;
|
||||
analyseBarPatterns = false;
|
||||
|
||||
//
|
||||
// Configure Detectors ...
|
||||
loopback = 0;
|
||||
requiredPivots = 0;
|
||||
pvPivotsValidationLength = 0;
|
||||
maCrossValidationDiffMultiplier = 0;
|
||||
|
||||
//
|
||||
orderFlowValidation = 0;
|
||||
orderFlowUseOB = false;
|
||||
orderFlowUseFVG = false;
|
||||
orderFlowUseSupportAndResistance = false;
|
||||
|
||||
//
|
||||
barsAnalysisConfig.Clean();
|
||||
@@ -383,20 +373,32 @@ struct XFIMAMarketStructureConfig
|
||||
{
|
||||
//
|
||||
// Detector Flags ...
|
||||
detectOrderFlow = true;
|
||||
analysePVPivots = true;
|
||||
analyseZGPivots = true;
|
||||
analyseHKPivots = true;
|
||||
analyseMAPivots = true;
|
||||
analyseSARPivots = true;
|
||||
analyseBarPatterns = true;
|
||||
|
||||
//
|
||||
// Configure Detectors ...
|
||||
loopback = 200;
|
||||
requiredPivots = 10;
|
||||
pvPivotsValidationLength = 5;
|
||||
maCrossValidationDiffMultiplier = 4;
|
||||
|
||||
//
|
||||
orderFlowValidation = 2;
|
||||
orderFlowUseOB = false;
|
||||
orderFlowUseFVG = true;
|
||||
orderFlowUseSupportAndResistance = false;
|
||||
|
||||
//
|
||||
barsAnalysisConfig.Default();
|
||||
barsAnalysisConfig.FullPattern();
|
||||
|
||||
//
|
||||
barsAnalysisConfig.supportAndResistanceLoopbackLength = 5;
|
||||
barsAnalysisConfig.supportAndResistanceValidationLength = 11;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -406,8 +408,12 @@ struct XFIMAMarketStructureConfig
|
||||
{
|
||||
//
|
||||
// Detector Flags ...
|
||||
detectOrderFlow = false;
|
||||
analysePVPivots = false;
|
||||
analyseZGPivots = false;
|
||||
analyseHKPivots = false;
|
||||
analyseMAPivots = false;
|
||||
analyseSARPivots = false;
|
||||
analyseBarPatterns = false;
|
||||
}
|
||||
|
||||
@@ -418,8 +424,12 @@ struct XFIMAMarketStructureConfig
|
||||
{
|
||||
//
|
||||
// Detector Flags ...
|
||||
detectOrderFlow = true;
|
||||
analysePVPivots = true;
|
||||
analyseZGPivots = true;
|
||||
analyseHKPivots = true;
|
||||
analyseMAPivots = true;
|
||||
analyseSARPivots = true;
|
||||
analyseBarPatterns = true;
|
||||
}
|
||||
|
||||
@@ -437,6 +447,9 @@ struct XFIMAMarketStructureDrawerConfig
|
||||
//
|
||||
bool drawPVAnalysis;
|
||||
bool drawZGAnalysis;
|
||||
bool drawMAAnalysis;
|
||||
bool drawHKAnalysis;
|
||||
bool drawSARAnalysis;
|
||||
bool drawBarsAnalysis;
|
||||
|
||||
//
|
||||
@@ -465,6 +478,9 @@ struct XFIMAMarketStructureDrawerConfig
|
||||
//
|
||||
drawPVAnalysis = false;
|
||||
drawZGAnalysis = false;
|
||||
drawMAAnalysis = false;
|
||||
drawHKAnalysis = false;
|
||||
drawSARAnalysis = false;
|
||||
drawBarsAnalysis = false;
|
||||
|
||||
//
|
||||
@@ -488,6 +504,9 @@ struct XFIMAMarketStructureDrawerConfig
|
||||
//
|
||||
drawPVAnalysis = true;
|
||||
drawZGAnalysis = true;
|
||||
drawMAAnalysis = true;
|
||||
drawHKAnalysis = true;
|
||||
drawSARAnalysis = true;
|
||||
drawBarsAnalysis = true;
|
||||
|
||||
//
|
||||
@@ -518,6 +537,9 @@ struct XFIMAMarketStructureDrawerConfig
|
||||
//
|
||||
drawPVAnalysis = false;
|
||||
drawZGAnalysis = false;
|
||||
drawMAAnalysis = false;
|
||||
drawHKAnalysis = false;
|
||||
drawSARAnalysis = false;
|
||||
drawBarsAnalysis = false;
|
||||
|
||||
//
|
||||
@@ -535,9 +557,12 @@ struct XFIMAMarketStructureDrawerConfig
|
||||
// Drawing Flags ...
|
||||
|
||||
//
|
||||
drawPVAnalysis = false;
|
||||
drawZGAnalysis = false;
|
||||
drawBarsAnalysis = false;
|
||||
drawPVAnalysis = true;
|
||||
drawZGAnalysis = true;
|
||||
drawMAAnalysis = true;
|
||||
drawHKAnalysis = true;
|
||||
drawSARAnalysis = true;
|
||||
drawBarsAnalysis = true;
|
||||
|
||||
//
|
||||
// Drawing Configs ...
|
||||
|
||||
Reference in New Issue
Block a user