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:
@@ -513,6 +513,32 @@ class XCBaseHelper : public XCBase
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalizing Bar Index ...
|
||||||
|
*
|
||||||
|
* @param barIndex: int, Provided Bar Index ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int NormalizeBarIndex(int barIndex)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = barIndex;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (!IsValid())
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = CountBars() - 1;
|
||||||
|
result = NormalizeInt(result, 0, count - 1);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Protected ...
|
// Protected ...
|
||||||
protected:
|
protected:
|
||||||
@@ -635,32 +661,6 @@ class XCBaseHelper : public XCBase
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Normalizing Bar Index ...
|
|
||||||
*
|
|
||||||
* @param barIndex: int, Provided Bar Index ...
|
|
||||||
*
|
|
||||||
* @return ( int )
|
|
||||||
*/
|
|
||||||
int NormalizeBarIndex(int barIndex)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
int result = barIndex;
|
|
||||||
|
|
||||||
//
|
|
||||||
if (!IsValid())
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
int count = CountBars() - 1;
|
|
||||||
result = NormalizeInt(result, 0, count - 1);
|
|
||||||
|
|
||||||
//
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Private ...
|
// Private ...
|
||||||
private:
|
private:
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1460,6 +1460,49 @@ class XCPOIDrawer : public XCBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw Pivots ...
|
||||||
|
*
|
||||||
|
* @param pivots: XPivot, collection reference to Draw ...
|
||||||
|
* @param config: XPOIDrawConfig, reference to Specified Draw Style ...
|
||||||
|
*/
|
||||||
|
void DrawPivots(
|
||||||
|
XPivot &pivots[],
|
||||||
|
XPOIDrawConfig &config //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool has = HasChild(pivots);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XPivot tmps[];
|
||||||
|
int count = ArraySize(pivots);
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XClean(tmps);
|
||||||
|
int sameCounts = ExtractSameTimePivots(pivots[i], tmps, pivots);
|
||||||
|
has = IsValidSize(sameCounts);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int j = 0; j < sameCounts; j++)
|
||||||
|
{
|
||||||
|
DrawPivot(tmps[j], config, j + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
XClean(tmps);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw Specified Pattern info ...
|
* Draw Specified Pattern info ...
|
||||||
*
|
*
|
||||||
|
|||||||
+5582
-463
File diff suppressed because it is too large
Load Diff
@@ -334,3 +334,46 @@
|
|||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Testing Draws ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XFIMAMarketStructure pivots[];
|
||||||
|
|
||||||
|
//
|
||||||
|
XPivot pvPivots[];
|
||||||
|
XPivot hkPivots[];
|
||||||
|
XPivot maPivots[];
|
||||||
|
XPivot zgPivots[];
|
||||||
|
XPivot sarPivots[];
|
||||||
|
|
||||||
|
//
|
||||||
|
poiDetector.CollectZGPivots(zgPivots);
|
||||||
|
poiDetector.CollectMAPivots(maPivots);
|
||||||
|
poiDetector.CollectHKPivots(hkPivots);
|
||||||
|
poiDetector.CollectPVPivots(pvPivots);
|
||||||
|
poiDetector.CollectSARPivots(sarPivots);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Merging All Pivots ...
|
||||||
|
Copy(pvPivots, pivots, false);
|
||||||
|
Copy(zgPivots, pivots, false);
|
||||||
|
Copy(maPivots, pivots, false);
|
||||||
|
Copy(hkPivots, pivots, false);
|
||||||
|
Copy(sarPivots, pivots, false);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (HasChild(pivots))
|
||||||
|
{
|
||||||
|
poiDrawer.DrawPivots(pivots, iDrawConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
XClean(pivots);
|
||||||
|
XClean(pvPivots);
|
||||||
|
XClean(hkPivots);
|
||||||
|
XClean(maPivots);
|
||||||
|
XClean(zgPivots);
|
||||||
|
XClean(sarPivots);
|
||||||
|
|||||||
+129
-5
@@ -5384,11 +5384,8 @@ class XCSession : public XCFromToZone
|
|||||||
//
|
//
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool ToBox(
|
bool ToBox(
|
||||||
T *&source[],
|
T *&source[],
|
||||||
@@ -6307,7 +6304,6 @@ void SpecifiedUpdateTo(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check a Box is Used or not ...
|
* Check a Box is Used or not ...
|
||||||
*
|
*
|
||||||
@@ -6682,7 +6678,6 @@ bool IsBoxPlaceValidForBar(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check Source Box is Below Dest ...
|
* Check Source Box is Below Dest ...
|
||||||
*
|
*
|
||||||
@@ -7056,3 +7051,132 @@ bool HasInsideBox(
|
|||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
|
||||||
|
//
|
||||||
|
// Analyse Bar Patterns ...
|
||||||
|
if (result && config.analyseBarPatterns)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Try to Detect Bars Analysis ...
|
||||||
|
int fromIndex = -1;
|
||||||
|
if (!IsXValid(fromTime))
|
||||||
|
{
|
||||||
|
fromIndex = barIndex + config.loopback;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fromIndex = GetBarIndex(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
fromTime //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
result = IsValidIndex(fromIndex);
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
fromIndex = MathMin(fromIndex, barIndex + config.requiredPivots);
|
||||||
|
|
||||||
|
//
|
||||||
|
for (int i = barIndex; i < fromIndex; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
tmpBar.Clean();
|
||||||
|
tmpBarAnalysis.Clean();
|
||||||
|
result = structure.bar.BarAt(i, tmpBar);
|
||||||
|
result = result &&
|
||||||
|
AnalyseBarPatterns(
|
||||||
|
tmpBar,
|
||||||
|
tmpBarAnalysis,
|
||||||
|
config.barsAnalysisConfig //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
AddRef(
|
||||||
|
tmpBarAnalysis,
|
||||||
|
structure.barsAnalysis //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,567 @@
|
|||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SaherElm IT Center MQL5 Library
|
||||||
|
// -------------------------------------------------
|
||||||
|
// Name: XCXFIMAEALib ...
|
||||||
|
// Description: XFIMAEA Library ...
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Maintainer:
|
||||||
|
// ------------
|
||||||
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Global Properties ...
|
||||||
|
#property library
|
||||||
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||||
|
#property link "https://saherelm.ir"
|
||||||
|
#property version "1.00"
|
||||||
|
#property description "SaherElm XFIMAEA Library"
|
||||||
|
#property strict
|
||||||
|
|
||||||
|
//
|
||||||
|
// Imports ...
|
||||||
|
#include "../../Classes/x-saherelm.x-cobject.class.mq5"
|
||||||
|
#include "../../Helpers/x-saherelm.xfima.helper.mq5"
|
||||||
|
#include "../Classes/x-saherelm.xfima.parser.class.mq5"
|
||||||
|
#include "../../Libraries/x-saherelm.x-pivot.analysis.lib.mq5"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Definitions ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* XFIMA Base Market Structure ...
|
||||||
|
* AnalyseMarket result ...
|
||||||
|
**/
|
||||||
|
struct XFIMAMarketStructure
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XOHCL bar; // Spacified Start Bar for Analysing ...
|
||||||
|
XPatternAnalysis barAnalysis; // Structure Bar Pattern Analysis ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XPivotAnalysis pvAnalysis; // PV Pivot Analysis Result ...
|
||||||
|
XPivotAnalysis zgAnalysis; // ZG Pivot Analysis Result ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XPatternAnalysis barsAnalysis[]; // Anaysed Bars ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor ...
|
||||||
|
XFIMAMarketStructure()
|
||||||
|
{
|
||||||
|
Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleanup ...
|
||||||
|
*/
|
||||||
|
void Clean()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bar.Clean();
|
||||||
|
barAnalysis.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
pvAnalysis.Clean();
|
||||||
|
zgAnalysis.Clean();
|
||||||
|
XClean(barsAnalysis);
|
||||||
|
|
||||||
|
//
|
||||||
|
ZeroMemory(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool IsValid()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = bar.IsValid() &&
|
||||||
|
barAnalysis.IsValid();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Collectors ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collect Required Zones from Structure ...
|
||||||
|
*
|
||||||
|
* @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 ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int CollectZones(
|
||||||
|
XBoxZone &dest[],
|
||||||
|
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE,
|
||||||
|
bool containsOB = false,
|
||||||
|
bool containsFVG = false //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
XClean(dest);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool has = IsValid();
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canCollectBullish =
|
||||||
|
IsXBullish(forDir) ||
|
||||||
|
!HasDirection(forDir);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canCollectBearish =
|
||||||
|
IsXBearish(forDir) ||
|
||||||
|
!HasDirection(forDir);
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = 0;
|
||||||
|
XBoxZone tmpBox;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Analysis ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// XPV ...
|
||||||
|
has = pvAnalysis.IsValid();
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// 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 //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// XZG ...
|
||||||
|
has = zgAnalysis.IsValid();
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Support ...
|
||||||
|
tmpBox.Clean();
|
||||||
|
has = zgAnalysis.HasSupportBox(tmpBox);
|
||||||
|
if (has && canCollectBullish)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
AddIfNotExists(
|
||||||
|
tmpBox,
|
||||||
|
dest //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Resistance ...
|
||||||
|
tmpBox.Clean();
|
||||||
|
has = zgAnalysis.HasResistanceBox(tmpBox);
|
||||||
|
if (has && canCollectBearish)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
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 //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Resistance ...
|
||||||
|
has = barsAnalysis[i].IsResistance();
|
||||||
|
if (has && canCollectBearish)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
AddIfNotExists(
|
||||||
|
barsAnalysis[i].resistance,
|
||||||
|
dest //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// OB ...
|
||||||
|
if (containsOB)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
has = barsAnalysis[i].IsOB();
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
has = (canCollectBullish && barsAnalysis[i].ob.IsBullish()) ||
|
||||||
|
(canCollectBearish && barsAnalysis[i].ob.IsBearish());
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
AddIfNotExists(
|
||||||
|
barsAnalysis[i].ob,
|
||||||
|
dest //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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 //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
};
|
||||||
|
|
||||||
|
struct XFIMAMarketStructureConfig
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detector Flags ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool analysePVPivots; // Analyse PV Pivots ...
|
||||||
|
bool analyseZGPivots; // Analyse ZG Pivots ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool analyseBarPatterns; // Analyse Bar Patterns ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detector Configs ...
|
||||||
|
|
||||||
|
//
|
||||||
|
int loopback; // Max Allowed Looping Back Length ...
|
||||||
|
int requiredPivots; // Required Extracted Pivots for Analysis ...
|
||||||
|
|
||||||
|
//
|
||||||
|
int pvPivotsValidationLength; // PV Pivots Validation Length ...
|
||||||
|
double maCrossValidationDiffMultiplier; // a Point Distance to Validate MA Crosses ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XPatternAnalysisConfig barsAnalysisConfig; // Bars Analyser Config ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor ...
|
||||||
|
XFIMAMarketStructureConfig()
|
||||||
|
{
|
||||||
|
Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function fulfills the will of the developer
|
||||||
|
*/
|
||||||
|
void Clean()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Detector Flags ...
|
||||||
|
analysePVPivots = false;
|
||||||
|
analyseZGPivots = false;
|
||||||
|
analyseBarPatterns = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Configure Detectors ...
|
||||||
|
loopback = 0;
|
||||||
|
requiredPivots = 0;
|
||||||
|
pvPivotsValidationLength = 0;
|
||||||
|
maCrossValidationDiffMultiplier = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
barsAnalysisConfig.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
ZeroMemory(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default Configurations ...
|
||||||
|
*/
|
||||||
|
void Default()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Detector Flags ...
|
||||||
|
analysePVPivots = true;
|
||||||
|
analyseZGPivots = true;
|
||||||
|
analyseBarPatterns = true;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Configure Detectors ...
|
||||||
|
loopback = 200;
|
||||||
|
requiredPivots = 10;
|
||||||
|
pvPivotsValidationLength = 5;
|
||||||
|
maCrossValidationDiffMultiplier = 4;
|
||||||
|
|
||||||
|
//
|
||||||
|
barsAnalysisConfig.Default();
|
||||||
|
barsAnalysisConfig.FullPattern();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No Draw Abilioty ...
|
||||||
|
*/
|
||||||
|
void Off()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Detector Flags ...
|
||||||
|
analysePVPivots = false;
|
||||||
|
analyseZGPivots = false;
|
||||||
|
analyseBarPatterns = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full Draw Abilioty ...
|
||||||
|
*/
|
||||||
|
void Full()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Detector Flags ...
|
||||||
|
analysePVPivots = true;
|
||||||
|
analyseZGPivots = true;
|
||||||
|
analyseBarPatterns = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure Market Structure Drawer ...
|
||||||
|
**/
|
||||||
|
struct XFIMAMarketStructureDrawerConfig
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool drawPVAnalysis;
|
||||||
|
bool drawZGAnalysis;
|
||||||
|
bool drawBarsAnalysis;
|
||||||
|
|
||||||
|
//
|
||||||
|
XPOIDrawConfig drawConfig;
|
||||||
|
XPivotAnalysisDrawConfig pivotAnalysisDrawConfig;
|
||||||
|
XPatternAnalysisDrawConfig barAnalysisDrawConfig;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor ...
|
||||||
|
XFIMAMarketStructureDrawerConfig()
|
||||||
|
{
|
||||||
|
Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function fulfills the will of the developer
|
||||||
|
*/
|
||||||
|
void Clean()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Drawing Flags ...
|
||||||
|
|
||||||
|
//
|
||||||
|
drawPVAnalysis = false;
|
||||||
|
drawZGAnalysis = false;
|
||||||
|
drawBarsAnalysis = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Drawing Configs ...
|
||||||
|
drawConfig.Clean();
|
||||||
|
barAnalysisDrawConfig.Clean();
|
||||||
|
pivotAnalysisDrawConfig.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
ZeroMemory(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default Configurations ...
|
||||||
|
*/
|
||||||
|
void Default()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Drawing Flags ...
|
||||||
|
|
||||||
|
//
|
||||||
|
drawPVAnalysis = true;
|
||||||
|
drawZGAnalysis = true;
|
||||||
|
drawBarsAnalysis = true;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Drawing Configs ...
|
||||||
|
drawConfig.Default();
|
||||||
|
pivotAnalysisDrawConfig.Default();
|
||||||
|
|
||||||
|
//
|
||||||
|
barAnalysisDrawConfig.Default();
|
||||||
|
barAnalysisDrawConfig.Full();
|
||||||
|
XClean(barAnalysisDrawConfig.allowedDrawZones);
|
||||||
|
Add(
|
||||||
|
X_BAR_PATTERN_SUPPORT,
|
||||||
|
barAnalysisDrawConfig.allowedDrawZones);
|
||||||
|
Add(
|
||||||
|
X_BAR_PATTERN_RESISTANCE,
|
||||||
|
barAnalysisDrawConfig.allowedDrawZones);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* No Draw Abilioty ...
|
||||||
|
*/
|
||||||
|
void Off()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Drawing Flags ...
|
||||||
|
|
||||||
|
//
|
||||||
|
drawPVAnalysis = false;
|
||||||
|
drawZGAnalysis = false;
|
||||||
|
drawBarsAnalysis = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Drawing Configs ...
|
||||||
|
barAnalysisDrawConfig.Off();
|
||||||
|
pivotAnalysisDrawConfig.Off();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Full Draw Abilioty ...
|
||||||
|
*/
|
||||||
|
void Full()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Drawing Flags ...
|
||||||
|
|
||||||
|
//
|
||||||
|
drawPVAnalysis = false;
|
||||||
|
drawZGAnalysis = false;
|
||||||
|
drawBarsAnalysis = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Drawing Configs ...
|
||||||
|
barAnalysisDrawConfig.Full();
|
||||||
|
pivotAnalysisDrawConfig.Full();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplyDrawConfig()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
barAnalysisDrawConfig.drawConfig = drawConfig;
|
||||||
|
barAnalysisDrawConfig.ConfigureQuarterDraws();
|
||||||
|
pivotAnalysisDrawConfig.drawConfig = drawConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplyDrawConfig(XPOIDrawConfig &_drawConfig)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
drawConfig = _drawConfig;
|
||||||
|
ApplyDrawConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
@@ -0,0 +1,495 @@
|
|||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SaherElm IT Center MQL5 Class
|
||||||
|
// -------------------------------------------------
|
||||||
|
// Name: XCXFIMAPoiDetector ...
|
||||||
|
// Description: XFIMA POI Detector Class ...
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Maintainer:
|
||||||
|
// ------------
|
||||||
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Global Properties ...
|
||||||
|
#property library
|
||||||
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||||
|
#property link "https://saherelm.ir"
|
||||||
|
#property version "1.00"
|
||||||
|
#property description "SaherElm XFIMA POI Detector Class"
|
||||||
|
#property strict
|
||||||
|
|
||||||
|
//
|
||||||
|
// Imports ...
|
||||||
|
#include "../../Classes/x-saherelm.base.class.mq5"
|
||||||
|
#include "../../Classes/x-saherelm.x-bar.analyser.class.mq5"
|
||||||
|
#include "../../Classes/x-saherelm.x-market.pattern.class.mq5"
|
||||||
|
#include "../Libraries/x-saherelm.xfima.lib.mq5"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Implementation ...
|
||||||
|
class XCXFIMAPOIDetector : public XCMarketPatternDetector
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Public ...
|
||||||
|
public:
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
XCBarAnalyser *barAnalyser; // Bar Analyser ...
|
||||||
|
XCXFIMAHelper *fimaHelper; // XFIMA Helper ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constructor ...
|
||||||
|
XCXFIMAPOIDetector(
|
||||||
|
XCXFIMAHelper *_fimaHelper //
|
||||||
|
) : XCMarketPatternDetector()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
barAnalyser = new XCBarAnalyser();
|
||||||
|
fimaHelper = _fimaHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Deconstructor ...
|
||||||
|
~XCXFIMAPOIDetector()
|
||||||
|
{
|
||||||
|
Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Actions and Tools ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Pivot Analysors ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Analyse Market based on Specified Kind of Pivots ...
|
||||||
|
*
|
||||||
|
* @param analysis: XPivotAnalysis, reference to hold result ...
|
||||||
|
* @param barIndex: int, Bar Index ...
|
||||||
|
* @param requiredNumberOFPivots: int, Specified which Number of Pivots must be Extracted ...
|
||||||
|
* @param maxAllowedLoopbackLength: int, Specified Maximum Loopback Length for Pivot Extraction ...
|
||||||
|
* @param validationLength: int, Specified Pivots Validation Length ignore if <= 0 ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool AnalysePVPivots(
|
||||||
|
XPivotAnalysis &analysis,
|
||||||
|
int barIndex = 0,
|
||||||
|
int requiredNumberOFPivots = 50,
|
||||||
|
int maxAllowedLoopbackLength = 1500,
|
||||||
|
int validationLength = 0 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
analysis.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reading Pivots ...
|
||||||
|
XPivot pivots[];
|
||||||
|
int count = fimaHelper.ExtractPVPivots(
|
||||||
|
pivots, // Result ...
|
||||||
|
barIndex, // Bar Index ...
|
||||||
|
requiredNumberOFPivots, // Required Number of Pivots ...
|
||||||
|
maxAllowedLoopbackLength, // Max Allowed Loopback ...
|
||||||
|
validationLength // Validation Length ...
|
||||||
|
);
|
||||||
|
result = IsValidSize(count);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
SpecifiedClean(pivots);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = fimaHelper.GetSymbol();
|
||||||
|
ENUM_TIMEFRAMES period = fimaHelper.GetPeriod();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize Analysis ...
|
||||||
|
result = analysis.Init(
|
||||||
|
"XFIMA_XPV",
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
pivots //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup Resources ...
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
analysis.Clean();
|
||||||
|
}
|
||||||
|
SpecifiedClean(pivots);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Analyse Market based on Specified Kind of Pivots ...
|
||||||
|
*
|
||||||
|
* @param analysis: XPivotAnalysis, reference to hold result ...
|
||||||
|
* @param barIndex: int, Bar Index ...
|
||||||
|
* @param requiredNumberOFPivots: int, Specified which Number of Pivots must be Extracted ...
|
||||||
|
* @param maxAllowedLoopbackLength: int, Specified Maximum Loopback Length for Pivot Extraction ...
|
||||||
|
* @param validationLength: int, Specified Pivots Validation Length ignore if <= 0 ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool AnalyseMAPivots(
|
||||||
|
XPivotAnalysis &analysis,
|
||||||
|
int barIndex = 0,
|
||||||
|
int requiredNumberOFPivots = 50,
|
||||||
|
int maxAllowedLoopbackLength = 1500,
|
||||||
|
int validationLength = 0 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
analysis.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reading Pivots ...
|
||||||
|
XPivot pivots[];
|
||||||
|
int count = fimaHelper.ExtractMAPivots(
|
||||||
|
pivots, // Result ...
|
||||||
|
barIndex, // Bar Index ...
|
||||||
|
requiredNumberOFPivots, // Required Number of Pivots ...
|
||||||
|
maxAllowedLoopbackLength, // Max Allowed Loopback ...
|
||||||
|
validationLength // Validation Length ...
|
||||||
|
);
|
||||||
|
result = IsValidSize(count);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
SpecifiedClean(pivots);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = fimaHelper.GetSymbol();
|
||||||
|
ENUM_TIMEFRAMES period = fimaHelper.GetPeriod();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize Analysis ...
|
||||||
|
result = analysis.Init(
|
||||||
|
"XFIMA_XMA",
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
pivots //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup Resources ...
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
analysis.Clean();
|
||||||
|
}
|
||||||
|
SpecifiedClean(pivots);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Analyse Market based on Specified Kind of Pivots ...
|
||||||
|
*
|
||||||
|
* @param analysis: XPivotAnalysis, reference to hold result ...
|
||||||
|
* @param barIndex: int, Bar Index ...
|
||||||
|
* @param requiredNumberOFPivots: int, Specified which Number of Pivots must be Extracted ...
|
||||||
|
* @param maxAllowedLoopbackLength: int, Specified Maximum Loopback Length for Pivot Extraction ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool AnalyseSARPivots(
|
||||||
|
XPivotAnalysis &analysis,
|
||||||
|
int barIndex = 0,
|
||||||
|
int requiredNumberOFPivots = 50,
|
||||||
|
int maxAllowedLoopbackLength = 1500 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
analysis.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reading Pivots ...
|
||||||
|
XPivot pivots[];
|
||||||
|
int count = fimaHelper.ExtractSARPivots(
|
||||||
|
pivots, // Result ...
|
||||||
|
barIndex, // Bar Index ...
|
||||||
|
requiredNumberOFPivots, // Required Number of Pivots ...
|
||||||
|
maxAllowedLoopbackLength // Max Allowed Loopback ...
|
||||||
|
);
|
||||||
|
result = IsValidSize(count);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
SpecifiedClean(pivots);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = fimaHelper.GetSymbol();
|
||||||
|
ENUM_TIMEFRAMES period = fimaHelper.GetPeriod();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize Analysis ...
|
||||||
|
result = analysis.Init(
|
||||||
|
"XFIMA_XSAR",
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
pivots //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup Resources ...
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
analysis.Clean();
|
||||||
|
}
|
||||||
|
SpecifiedClean(pivots);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Analyse Market based on Specified Kind of Pivots ...
|
||||||
|
*
|
||||||
|
* @param analysis: XPivotAnalysis, reference to hold result ...
|
||||||
|
* @param barIndex: int, Bar Index ...
|
||||||
|
* @param requiredNumberOFPivots: int, Specified which Number of Pivots must be Extracted ...
|
||||||
|
* @param maxAllowedLoopbackLength: int, Specified Maximum Loopback Length for Pivot Extraction ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool AnalyseZigZagPivots(
|
||||||
|
XPivotAnalysis &analysis,
|
||||||
|
int barIndex = 0,
|
||||||
|
int requiredNumberOFPivots = 50,
|
||||||
|
int maxAllowedLoopbackLength = 1500 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
analysis.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reading Pivots ...
|
||||||
|
XPivot pivots[];
|
||||||
|
int count = fimaHelper.ExtractZigZagPivots(
|
||||||
|
pivots, // Result ...
|
||||||
|
barIndex, // Bar Index ...
|
||||||
|
requiredNumberOFPivots, // Required Number of Pivots ...
|
||||||
|
maxAllowedLoopbackLength // Max Allowed Loopback ...
|
||||||
|
);
|
||||||
|
result = IsValidSize(count);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
SpecifiedClean(pivots);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = fimaHelper.GetSymbol();
|
||||||
|
ENUM_TIMEFRAMES period = fimaHelper.GetPeriod();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize Analysis ...
|
||||||
|
result = analysis.Init(
|
||||||
|
"XFIMA_XZG",
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
pivots //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup Resources ...
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
analysis.Clean();
|
||||||
|
}
|
||||||
|
SpecifiedClean(pivots);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroy ...
|
||||||
|
*/
|
||||||
|
void Destroy()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
delete barAnalyser;
|
||||||
|
ZeroMemory(barAnalyser);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Testers ...
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Analyse Market based on Specified Bar ...
|
||||||
|
*
|
||||||
|
* @param structure: XFIMAMarketStructure, reference to holds result ...
|
||||||
|
* @param config: XFIMAMarketStructureConfig, reference to Configure Detector ...
|
||||||
|
* @param barIndex: int, Bar Index ...
|
||||||
|
*/
|
||||||
|
void AnalyseMarket(
|
||||||
|
XFIMAMarketStructure &structure,
|
||||||
|
XFIMAMarketStructureConfig &config,
|
||||||
|
int barIndex = 0 //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
structure.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Normalize ...
|
||||||
|
barIndex = NormalizeInt(barIndex, 0);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool has = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
string symbol = fimaHelper.GetSymbol();
|
||||||
|
ENUM_TIMEFRAMES period = fimaHelper.GetPeriod();
|
||||||
|
has = structure.bar.Init(
|
||||||
|
symbol,
|
||||||
|
period,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
structure.Clean();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Reading Bar Patterns ...
|
||||||
|
XOHCL iBar;
|
||||||
|
XPatternAnalysis iPatternAnalysis;
|
||||||
|
for (int i = barIndex; i < barIndex + config.loopback; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
iBar.Clean();
|
||||||
|
iPatternAnalysis.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize Indexed Bar ...
|
||||||
|
//
|
||||||
|
has = structure.bar.BarAt(i, iBar);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Analyse Indexed Bar ...
|
||||||
|
has = AnalyseBarPatterns(iBar, iPatternAnalysis, config.barsAnalysisConfig);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
AddRef(
|
||||||
|
iPatternAnalysis,
|
||||||
|
structure.barsAnalysis //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
if (i == barIndex)
|
||||||
|
{
|
||||||
|
structure.barAnalysis = iPatternAnalysis;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Satisfied ...
|
||||||
|
has = ArraySize(structure.barsAnalysis) >= config.requiredPivots;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle Pivot Analysis ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// XPV ...
|
||||||
|
if (config.analysePVPivots)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Reading Pivots ...
|
||||||
|
has = AnalysePVPivots(
|
||||||
|
structure.pvAnalysis,
|
||||||
|
barIndex,
|
||||||
|
config.requiredPivots,
|
||||||
|
config.loopback,
|
||||||
|
config.pvPivotsValidationLength //
|
||||||
|
);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
structure.pvAnalysis.Clean();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// XZG ...
|
||||||
|
if (config.analyseZGPivots)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Reading Pivots ...
|
||||||
|
has = AnalyseZigZagPivots(
|
||||||
|
structure.zgAnalysis,
|
||||||
|
barIndex,
|
||||||
|
config.requiredPivots,
|
||||||
|
config.loopback //
|
||||||
|
);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
structure.zgAnalysis.Clean();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
iBar.Clean();
|
||||||
|
iPatternAnalysis.Clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Protected ...
|
||||||
|
protected:
|
||||||
|
//
|
||||||
|
// Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Private ...
|
||||||
|
private:
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
@@ -111,7 +111,7 @@ input ENUM_MA_METHOD maMethod = MODE_EMA; // MA Method
|
|||||||
input ENUM_APPLIED_PRICE maAppliedTo = PRICE_CLOSE; // MA Applied To
|
input ENUM_APPLIED_PRICE maAppliedTo = PRICE_CLOSE; // MA Applied To
|
||||||
input int maFastLength = 7; // Fast MA Length
|
input int maFastLength = 7; // Fast MA Length
|
||||||
input int maSlowLength = 20; // Slow MA Length
|
input int maSlowLength = 20; // Slow MA Length
|
||||||
input int maBondLength = 7; // MA Bond Length
|
input int maBandLength = 7; // MA Band Length
|
||||||
input int zigzagDepth = 12; // ZigZag Depth
|
input int zigzagDepth = 12; // ZigZag Depth
|
||||||
input int zigzagDeviation = 5; // ZigZag Deviation
|
input int zigzagDeviation = 5; // ZigZag Deviation
|
||||||
input int zigzagBackStep = 3; // ZigZag Back Step
|
input int zigzagBackStep = 3; // ZigZag Back Step
|
||||||
@@ -137,8 +137,8 @@ input bool showSAR = false; // Show Sar
|
|||||||
input bool showBars = true; // Show Bars
|
input bool showBars = true; // Show Bars
|
||||||
input bool showMAFast = false; // Show MA Fast
|
input bool showMAFast = false; // Show MA Fast
|
||||||
input bool showMASlow = false; // Show MA Slow
|
input bool showMASlow = false; // Show MA Slow
|
||||||
input bool showMABond = false; // Show MA Bond
|
input bool showMABand = false; // Show MA Band
|
||||||
input bool showHKBond = false; // Show HK Bond
|
input bool showHKBand = false; // Show HK Band
|
||||||
input bool showBarTime = true; // Show Bar Time
|
input bool showBarTime = true; // Show Bar Time
|
||||||
input bool showZigZag = false; // Show ZigZag
|
input bool showZigZag = false; // Show ZigZag
|
||||||
input bool showFiboZone = false; // Show Fibo Zone
|
input bool showFiboZone = false; // Show Fibo Zone
|
||||||
@@ -312,7 +312,7 @@ int OnInit()
|
|||||||
fimaInputs.maAppliedTo = maAppliedTo;
|
fimaInputs.maAppliedTo = maAppliedTo;
|
||||||
fimaInputs.maFastLength = maFastLength;
|
fimaInputs.maFastLength = maFastLength;
|
||||||
fimaInputs.maSlowLength = maSlowLength;
|
fimaInputs.maSlowLength = maSlowLength;
|
||||||
fimaInputs.maBondLength = maBondLength;
|
fimaInputs.maBandLength = maBandLength;
|
||||||
fimaInputs.zigzagDepth = zigzagDepth;
|
fimaInputs.zigzagDepth = zigzagDepth;
|
||||||
fimaInputs.zigzagDeviation = zigzagDeviation;
|
fimaInputs.zigzagDeviation = zigzagDeviation;
|
||||||
fimaInputs.zigzagBackStep = zigzagBackStep;
|
fimaInputs.zigzagBackStep = zigzagBackStep;
|
||||||
@@ -326,8 +326,8 @@ int OnInit()
|
|||||||
fimaInputs.showSAR = showSAR;
|
fimaInputs.showSAR = showSAR;
|
||||||
fimaInputs.showMAFast = showMAFast;
|
fimaInputs.showMAFast = showMAFast;
|
||||||
fimaInputs.showMASlow = showMASlow;
|
fimaInputs.showMASlow = showMASlow;
|
||||||
fimaInputs.showMABond = showMABond;
|
fimaInputs.showMABand = showMABand;
|
||||||
fimaInputs.showHKBond = showHKBond;
|
fimaInputs.showHKBand = showHKBand;
|
||||||
fimaInputs.showZigZag = showZigZag;
|
fimaInputs.showZigZag = showZigZag;
|
||||||
fimaInputs.showFiboZone = showFiboZone;
|
fimaInputs.showFiboZone = showFiboZone;
|
||||||
fimaInputs.startCalculationForLastBars = startCalculationForLastBars;
|
fimaInputs.startCalculationForLastBars = startCalculationForLastBars;
|
||||||
@@ -354,7 +354,7 @@ int OnInit()
|
|||||||
// Configure Signaller ...
|
// Configure Signaller ...
|
||||||
fima1Signaller.ignoreTargets = false;
|
fima1Signaller.ignoreTargets = false;
|
||||||
fima1Signaller.slAdditionDistance = 30;
|
fima1Signaller.slAdditionDistance = 30;
|
||||||
fima1Signaller.maxAllowedRiskDistance = 200;
|
fima1Signaller.maxAllowedRiskDistance = 350;
|
||||||
fima1Signaller.AddOnSignalEventHandler(OnSignalTriggered);
|
fima1Signaller.AddOnSignalEventHandler(OnSignalTriggered);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
+295
-6138
File diff suppressed because it is too large
Load Diff
+331
-105
@@ -83,7 +83,7 @@ input ENUM_MA_METHOD maMethod = MODE_EMA; // MA Method
|
|||||||
input ENUM_APPLIED_PRICE maAppliedTo = PRICE_CLOSE; // MA Applied To
|
input ENUM_APPLIED_PRICE maAppliedTo = PRICE_CLOSE; // MA Applied To
|
||||||
input int maFastLength = 7; // Fast MA Length
|
input int maFastLength = 7; // Fast MA Length
|
||||||
input int maSlowLength = 21; // Slow MA Length
|
input int maSlowLength = 21; // Slow MA Length
|
||||||
input int maBondLength = 21; // MA Bond Length
|
input int maBandLength = 21; // MA Band Length
|
||||||
input int zigzagDepth = 12; // ZigZag Depth
|
input int zigzagDepth = 12; // ZigZag Depth
|
||||||
input int zigzagDeviation = 5; // ZigZag Deviation
|
input int zigzagDeviation = 5; // ZigZag Deviation
|
||||||
input int zigzagBackStep = 3; // ZigZag Back Step
|
input int zigzagBackStep = 3; // ZigZag Back Step
|
||||||
@@ -92,6 +92,12 @@ input ENUM_X_PRICE zigzagLowersMode = X_PRICE_LOW; // ZigZag Low D
|
|||||||
input bool hkIgnoreShadows = true; // HK Remove noises
|
input bool hkIgnoreShadows = true; // HK Remove noises
|
||||||
input int hkSmoothingLength = 21; // HK Smoothing Length
|
input int hkSmoothingLength = 21; // HK Smoothing Length
|
||||||
input ENUM_X_MA_METHOD hkSmoothingMode = X_MA_MODE_EMA; // HK Smoothing Method
|
input ENUM_X_MA_METHOD hkSmoothingMode = X_MA_MODE_EMA; // HK Smoothing Method
|
||||||
|
input int atrLength = 14; // ATR Length
|
||||||
|
input double atrMultiplier = 1.5; // ATR Band Multiplier
|
||||||
|
input int atrSmoothingLength = 21; // ATR Smoothing Length
|
||||||
|
input ENUM_X_PRICE atrUpperPriceType = X_PRICE_HIGH; // ATR Upper Zone Applied To
|
||||||
|
input ENUM_X_PRICE atrLowerPriceType = X_PRICE_LOW; // ATR Lower Zone Applied To
|
||||||
|
input ENUM_X_MA_METHOD atrSmoothingMode = X_MA_MODE_EMA; // ATR Smoothing Method
|
||||||
|
|
||||||
//
|
//
|
||||||
// Presentation ...
|
// Presentation ...
|
||||||
@@ -101,8 +107,9 @@ input bool showHK = true; // Show HK
|
|||||||
input bool showSAR = true; // Show Sar
|
input bool showSAR = true; // Show Sar
|
||||||
input bool showMAFast = true; // Show MA Fast
|
input bool showMAFast = true; // Show MA Fast
|
||||||
input bool showMASlow = true; // Show MA Slow
|
input bool showMASlow = true; // Show MA Slow
|
||||||
input bool showMABond = true; // Show MA Bond
|
input bool showMABand = true; // Show MA Band
|
||||||
input bool showHKBond = true; // Show HK Bond
|
input bool showHKBand = true; // Show HK Band
|
||||||
|
input bool showATRBand = true; // Show ATR Band
|
||||||
input bool showZigZag = true; // Show ZigZag
|
input bool showZigZag = true; // Show ZigZag
|
||||||
input bool showFiboZone = true; // Show Fibo Zone
|
input bool showFiboZone = true; // Show Fibo Zone
|
||||||
|
|
||||||
@@ -138,8 +145,8 @@ input int valeArrowCode = 159; // Vales Arrow Code
|
|||||||
#property indicator_chart_window
|
#property indicator_chart_window
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_buffers 44
|
#property indicator_buffers 49
|
||||||
#property indicator_plots 16
|
#property indicator_plots 18
|
||||||
|
|
||||||
//
|
//
|
||||||
// Plot Buffers ...
|
// Plot Buffers ...
|
||||||
@@ -160,7 +167,7 @@ double maFastColorBuffer[];
|
|||||||
#property indicator_label1 "FastMA"
|
#property indicator_label1 "FastMA"
|
||||||
#property indicator_type1 DRAW_COLOR_LINE
|
#property indicator_type1 DRAW_COLOR_LINE
|
||||||
#property indicator_color1 CLR_NONE, clrLime, clrLime, clrLime // clrYellow, clrOrangeRed, clrGray
|
#property indicator_color1 CLR_NONE, clrLime, clrLime, clrLime // clrYellow, clrOrangeRed, clrGray
|
||||||
#property indicator_width1 3
|
#property indicator_width1 2
|
||||||
|
|
||||||
//
|
//
|
||||||
// Slow MA ...
|
// Slow MA ...
|
||||||
@@ -178,7 +185,7 @@ double maSlowColorBuffer[];
|
|||||||
#property indicator_label2 "SlowMA"
|
#property indicator_label2 "SlowMA"
|
||||||
#property indicator_type2 DRAW_COLOR_LINE
|
#property indicator_type2 DRAW_COLOR_LINE
|
||||||
#property indicator_color2 CLR_NONE, clrRed, clrRed, clrRed // clrLime, clrRed, clrGray
|
#property indicator_color2 CLR_NONE, clrRed, clrRed, clrRed // clrLime, clrRed, clrGray
|
||||||
#property indicator_width2 3
|
#property indicator_width2 2
|
||||||
|
|
||||||
//
|
//
|
||||||
// SAR ...
|
// SAR ...
|
||||||
@@ -286,29 +293,29 @@ double zigzagBuffer[];
|
|||||||
// MA Upper ...
|
// MA Upper ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define maBondUpperBufferIndex 12
|
#define maBandUpperBufferIndex 12
|
||||||
double maBondUpperBuffer[];
|
double maBandUpperBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#define maBondUpperBufferPlotIndex 9
|
#define maBandUpperBufferPlotIndex 9
|
||||||
#property indicator_label10 "UpperMA"
|
#property indicator_label10 "UpperMA"
|
||||||
#property indicator_type10 DRAW_LINE
|
#property indicator_type10 DRAW_LINE
|
||||||
#property indicator_color10 clrLime
|
#property indicator_color10 clrLime
|
||||||
#property indicator_width10 3
|
#property indicator_width10 2
|
||||||
|
|
||||||
//
|
//
|
||||||
// MA Lower ...
|
// MA Lower ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define maBondLowerBufferIndex 13
|
#define maBandLowerBufferIndex 13
|
||||||
double maBondLowerBuffer[];
|
double maBandLowerBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#define maBondLowerBufferPlotIndex 10
|
#define maBandLowerBufferPlotIndex 10
|
||||||
#property indicator_label11 "LowerMA"
|
#property indicator_label11 "LowerMA"
|
||||||
#property indicator_type11 DRAW_LINE
|
#property indicator_type11 DRAW_LINE
|
||||||
#property indicator_color11 clrRed
|
#property indicator_color11 clrRed
|
||||||
#property indicator_width11 3
|
#property indicator_width11 2
|
||||||
|
|
||||||
//
|
//
|
||||||
// XHK ...
|
// XHK ...
|
||||||
@@ -340,60 +347,88 @@ double hkColorBuffer[];
|
|||||||
#property indicator_color12 CLR_NONE, clrAqua, clrMagenta, clrGray
|
#property indicator_color12 CLR_NONE, clrAqua, clrMagenta, clrGray
|
||||||
|
|
||||||
//
|
//
|
||||||
#define hkBondUpperBufferIndex 19
|
#define hkBandUpperBufferIndex 19
|
||||||
double hkBondUpperBuffer[];
|
double hkBandUpperBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#define hkBondUpperBufferPlotIndex 12
|
#define hkBandUpperBufferPlotIndex 12
|
||||||
#property indicator_label13 "UpperHK"
|
#property indicator_label13 "UpperHK"
|
||||||
#property indicator_type13 DRAW_LINE
|
#property indicator_type13 DRAW_LINE
|
||||||
#property indicator_color13 clrAqua
|
#property indicator_color13 clrAqua
|
||||||
#property indicator_width13 3
|
#property indicator_width13 2
|
||||||
|
|
||||||
//
|
//
|
||||||
#define hkBondLowerBufferIndex 20
|
#define hkBandLowerBufferIndex 20
|
||||||
double hkBondLowerBuffer[];
|
double hkBandLowerBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#define hkBondLowerBufferPlotIndex 13
|
#define hkBandLowerBufferPlotIndex 13
|
||||||
#property indicator_label14 "LowerHK"
|
#property indicator_label14 "LowerHK"
|
||||||
#property indicator_type14 DRAW_LINE
|
#property indicator_type14 DRAW_LINE
|
||||||
#property indicator_color14 clrMagenta
|
#property indicator_color14 clrMagenta
|
||||||
#property indicator_width14 3
|
#property indicator_width14 2
|
||||||
|
|
||||||
//
|
//
|
||||||
// PB Upper ...
|
// PB Upper ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define pbBondUpperBufferIndex 21
|
#define pbBandUpperBufferIndex 21
|
||||||
double pbBondUpperBuffer[];
|
double pbBandUpperBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#define pbBondUpperBufferPlotIndex 14
|
#define pbBandUpperBufferPlotIndex 14
|
||||||
#property indicator_label15 "UpperPB"
|
#property indicator_label15 "UpperPB"
|
||||||
#property indicator_type15 DRAW_LINE
|
#property indicator_type15 DRAW_LINE
|
||||||
#property indicator_color15 clrRoyalBlue
|
#property indicator_color15 clrRoyalBlue
|
||||||
#property indicator_width15 3
|
#property indicator_width15 2
|
||||||
|
|
||||||
//
|
//
|
||||||
// PB Lower ...
|
// PB Lower ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define pbBondLowerBufferIndex 22
|
#define pbBandLowerBufferIndex 22
|
||||||
double pbBondLowerBuffer[];
|
double pbBandLowerBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#define pbBondLowerBufferPlotIndex 15
|
#define pbBandLowerBufferPlotIndex 15
|
||||||
#property indicator_label16 "LowerPB"
|
#property indicator_label16 "LowerPB"
|
||||||
#property indicator_type16 DRAW_LINE
|
#property indicator_type16 DRAW_LINE
|
||||||
#property indicator_color16 clrOrangeRed
|
#property indicator_color16 clrRoyalBlue
|
||||||
#property indicator_width16 3
|
#property indicator_width16 2
|
||||||
|
|
||||||
|
//
|
||||||
|
// ATR Upper ...
|
||||||
|
|
||||||
|
//
|
||||||
|
#define atrBandUpperBufferIndex 23
|
||||||
|
double atrBandUpperBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
#define atrBandUpperBufferPlotIndex 16
|
||||||
|
#property indicator_label17 "UpperATR"
|
||||||
|
#property indicator_type17 DRAW_LINE
|
||||||
|
#property indicator_color17 clrOrange
|
||||||
|
#property indicator_width17 2
|
||||||
|
|
||||||
|
//
|
||||||
|
// ATR Lower ...
|
||||||
|
|
||||||
|
//
|
||||||
|
#define atrBandLowerBufferIndex 24
|
||||||
|
double atrBandLowerBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
#define atrBandLowerBufferPlotIndex 17
|
||||||
|
#property indicator_label18 "LowerATR"
|
||||||
|
#property indicator_type18 DRAW_LINE
|
||||||
|
#property indicator_color18 clrOrange
|
||||||
|
#property indicator_width18 2
|
||||||
|
|
||||||
//
|
//
|
||||||
// Data Buffers ...
|
// Data Buffers ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define mLastBufferIndex 22
|
#define mLastBufferIndex 24
|
||||||
|
|
||||||
//
|
//
|
||||||
// MA ...
|
// MA ...
|
||||||
@@ -502,12 +537,27 @@ double hkRawCloseBuffer[];
|
|||||||
// XPB Data ...
|
// XPB Data ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define pbBondRawUpperBufferIndex mLastBufferIndex + 20
|
#define pbBandRawUpperBufferIndex mLastBufferIndex + 20
|
||||||
double pbBondRawUpperBuffer[];
|
double pbBandRawUpperBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
#define pbBondRawLowerBufferIndex mLastBufferIndex + 21
|
#define pbBandRawLowerBufferIndex mLastBufferIndex + 21
|
||||||
double pbBondRawLowerBuffer[];
|
double pbBandRawLowerBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// XATR Data ...
|
||||||
|
|
||||||
|
//
|
||||||
|
#define atrBufferIndex mLastBufferIndex + 22
|
||||||
|
double atrBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
#define atrBandRawUpperBufferIndex mLastBufferIndex + 23
|
||||||
|
double atrBandRawUpperBuffer[];
|
||||||
|
|
||||||
|
//
|
||||||
|
#define atrBandRawLowerBufferIndex mLastBufferIndex + 24
|
||||||
|
double atrBandRawLowerBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
// Variables, Properties and etc ...
|
// Variables, Properties and etc ...
|
||||||
@@ -534,6 +584,7 @@ ENUM_TIMEFRAMES mHCPeriod = NULL;
|
|||||||
|
|
||||||
//
|
//
|
||||||
int sarHandler = INVALID_HANDLE;
|
int sarHandler = INVALID_HANDLE;
|
||||||
|
int atrHandler = INVALID_HANDLE;
|
||||||
int maFastHandler = INVALID_HANDLE;
|
int maFastHandler = INVALID_HANDLE;
|
||||||
int maSlowHandler = INVALID_HANDLE;
|
int maSlowHandler = INVALID_HANDLE;
|
||||||
int maUpperHandler = INVALID_HANDLE;
|
int maUpperHandler = INVALID_HANDLE;
|
||||||
@@ -662,6 +713,7 @@ void OnDeinit(const int reason)
|
|||||||
//
|
//
|
||||||
// De Initialize all Handlers and etc ...
|
// De Initialize all Handlers and etc ...
|
||||||
IndicatorRelease(sarHandler);
|
IndicatorRelease(sarHandler);
|
||||||
|
IndicatorRelease(atrHandler);
|
||||||
IndicatorRelease(maFastHandler);
|
IndicatorRelease(maFastHandler);
|
||||||
IndicatorRelease(maSlowHandler);
|
IndicatorRelease(maSlowHandler);
|
||||||
IndicatorRelease(maUpperHandler);
|
IndicatorRelease(maUpperHandler);
|
||||||
@@ -739,6 +791,10 @@ int OnCalculate(
|
|||||||
// SAR ...
|
// SAR ...
|
||||||
int sarCalculatedBars = BarsCalculated(sarHandler);
|
int sarCalculatedBars = BarsCalculated(sarHandler);
|
||||||
|
|
||||||
|
//
|
||||||
|
// ATR ...
|
||||||
|
int atrCalculatedBars = BarsCalculated(atrHandler);
|
||||||
|
|
||||||
//
|
//
|
||||||
bool isPassedRequiredCalculatedBars =
|
bool isPassedRequiredCalculatedBars =
|
||||||
//
|
//
|
||||||
@@ -749,7 +805,10 @@ int OnCalculate(
|
|||||||
maLowerCalculatedBars >= maxLength &&
|
maLowerCalculatedBars >= maxLength &&
|
||||||
//
|
//
|
||||||
// SAR ...
|
// SAR ...
|
||||||
sarCalculatedBars >= maxLength
|
sarCalculatedBars >= maxLength &&
|
||||||
|
//
|
||||||
|
// ATR ...
|
||||||
|
atrCalculatedBars >= maxLength
|
||||||
//
|
//
|
||||||
;
|
;
|
||||||
if (!isPassedRequiredCalculatedBars)
|
if (!isPassedRequiredCalculatedBars)
|
||||||
@@ -769,13 +828,17 @@ int OnCalculate(
|
|||||||
// MA ...
|
// MA ...
|
||||||
int copiedMAFasts = CopyBuffer(maFastHandler, MAIN_LINE, 0, limit, maFastBuffer);
|
int copiedMAFasts = CopyBuffer(maFastHandler, MAIN_LINE, 0, limit, maFastBuffer);
|
||||||
int copiedMASlows = CopyBuffer(maSlowHandler, MAIN_LINE, 0, limit, maSlowBuffer);
|
int copiedMASlows = CopyBuffer(maSlowHandler, MAIN_LINE, 0, limit, maSlowBuffer);
|
||||||
int copiedMAUppers = CopyBuffer(maUpperHandler, MAIN_LINE, 0, limit, maBondUpperBuffer);
|
int copiedMAUppers = CopyBuffer(maUpperHandler, MAIN_LINE, 0, limit, maBandUpperBuffer);
|
||||||
int copiedMALowers = CopyBuffer(maLowerHandler, MAIN_LINE, 0, limit, maBondLowerBuffer);
|
int copiedMALowers = CopyBuffer(maLowerHandler, MAIN_LINE, 0, limit, maBandLowerBuffer);
|
||||||
|
|
||||||
//
|
//
|
||||||
// SAR ...
|
// SAR ...
|
||||||
int copiedSARs = CopyBuffer(sarHandler, MAIN_LINE, 0, limit, sarBuffer);
|
int copiedSARs = CopyBuffer(sarHandler, MAIN_LINE, 0, limit, sarBuffer);
|
||||||
|
|
||||||
|
//
|
||||||
|
// ATR ...
|
||||||
|
int copiedATRs = CopyBuffer(atrHandler, MAIN_LINE, 0, limit, atrBuffer);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Validate Copied Items ...
|
// Validate Copied Items ...
|
||||||
bool isPassedRequiredCopiedItems =
|
bool isPassedRequiredCopiedItems =
|
||||||
@@ -787,7 +850,10 @@ int OnCalculate(
|
|||||||
copiedMALowers >= limit &&
|
copiedMALowers >= limit &&
|
||||||
//
|
//
|
||||||
// SAR ...
|
// SAR ...
|
||||||
copiedSARs >= limit
|
copiedSARs >= limit &&
|
||||||
|
//
|
||||||
|
// ATR ...
|
||||||
|
copiedATRs >= limit
|
||||||
//
|
//
|
||||||
;
|
;
|
||||||
if (!isPassedRequiredCopiedItems)
|
if (!isPassedRequiredCopiedItems)
|
||||||
@@ -846,7 +912,7 @@ bool ValidateInputs()
|
|||||||
// MA ...
|
// MA ...
|
||||||
maFastLength >= 2 &&
|
maFastLength >= 2 &&
|
||||||
maSlowLength >= 2 &&
|
maSlowLength >= 2 &&
|
||||||
maBondLength >= 2 &&
|
maBandLength >= 2 &&
|
||||||
maSlowLength > maFastLength &&
|
maSlowLength > maFastLength &&
|
||||||
//
|
//
|
||||||
// SAR ...
|
// SAR ...
|
||||||
@@ -854,6 +920,12 @@ bool ValidateInputs()
|
|||||||
sarStep > 0 &&
|
sarStep > 0 &&
|
||||||
sarMax > sarStep &&
|
sarMax > sarStep &&
|
||||||
//
|
//
|
||||||
|
// ATR ...
|
||||||
|
atrLength > 0 &&
|
||||||
|
atrMultiplier >= 1 &&
|
||||||
|
IsXValid(atrUpperPriceType) &&
|
||||||
|
IsXValid(atrLowerPriceType) &&
|
||||||
|
//
|
||||||
// CYCLES ...
|
// CYCLES ...
|
||||||
(IsValid(scMethod, scPeriod) &&
|
(IsValid(scMethod, scPeriod) &&
|
||||||
IsValid(mcMethod, mcPeriod) &&
|
IsValid(mcMethod, mcPeriod) &&
|
||||||
@@ -893,7 +965,8 @@ int ExtractMaxLengthOfInputs()
|
|||||||
result = MathMax(result, mHCLength);
|
result = MathMax(result, mHCLength);
|
||||||
result = MathMax(result, maFastLength);
|
result = MathMax(result, maFastLength);
|
||||||
result = MathMax(result, maSlowLength);
|
result = MathMax(result, maSlowLength);
|
||||||
result = MathMax(result, maBondLength);
|
result = MathMax(result, maBandLength);
|
||||||
|
result = MathMax(result, atrLength);
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
@@ -1039,63 +1112,63 @@ void DefineBuffers()
|
|||||||
PlotIndexSetDouble(zigzagBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
PlotIndexSetDouble(zigzagBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
||||||
|
|
||||||
//
|
//
|
||||||
// MA Bond ...
|
// MA Band ...
|
||||||
|
|
||||||
//
|
//
|
||||||
ENUM_DRAW_TYPE maBondDrawType = showMABond ? DRAW_LINE : DRAW_NONE;
|
ENUM_DRAW_TYPE maBandDrawType = showMABand ? DRAW_LINE : DRAW_NONE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Upper Bond ...
|
// Upper Band ...
|
||||||
|
|
||||||
//
|
//
|
||||||
ArraySetAsSeries(maBondUpperBuffer, true);
|
ArraySetAsSeries(maBandUpperBuffer, true);
|
||||||
SetIndexBuffer(maBondUpperBufferIndex, maBondUpperBuffer, INDICATOR_DATA);
|
SetIndexBuffer(maBandUpperBufferIndex, maBandUpperBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
//
|
//
|
||||||
PlotIndexSetInteger(maBondUpperBufferPlotIndex, PLOT_SHOW_DATA, showMABond);
|
PlotIndexSetInteger(maBandUpperBufferPlotIndex, PLOT_SHOW_DATA, showMABand);
|
||||||
PlotIndexSetInteger(maBondUpperBufferPlotIndex, PLOT_DRAW_TYPE, maBondDrawType);
|
PlotIndexSetInteger(maBandUpperBufferPlotIndex, PLOT_DRAW_TYPE, maBandDrawType);
|
||||||
PlotIndexSetInteger(maBondUpperBufferPlotIndex, PLOT_DRAW_BEGIN, 0);
|
PlotIndexSetInteger(maBandUpperBufferPlotIndex, PLOT_DRAW_BEGIN, 0);
|
||||||
PlotIndexSetDouble(maBondUpperBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
PlotIndexSetDouble(maBandUpperBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Lower Bond ...
|
// Lower Band ...
|
||||||
|
|
||||||
//
|
//
|
||||||
ArraySetAsSeries(maBondLowerBuffer, true);
|
ArraySetAsSeries(maBandLowerBuffer, true);
|
||||||
SetIndexBuffer(maBondLowerBufferIndex, maBondLowerBuffer, INDICATOR_DATA);
|
SetIndexBuffer(maBandLowerBufferIndex, maBandLowerBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
//
|
//
|
||||||
PlotIndexSetInteger(maBondLowerBufferPlotIndex, PLOT_SHOW_DATA, showMABond);
|
PlotIndexSetInteger(maBandLowerBufferPlotIndex, PLOT_SHOW_DATA, showMABand);
|
||||||
PlotIndexSetInteger(maBondLowerBufferPlotIndex, PLOT_DRAW_TYPE, maBondDrawType);
|
PlotIndexSetInteger(maBandLowerBufferPlotIndex, PLOT_DRAW_TYPE, maBandDrawType);
|
||||||
PlotIndexSetInteger(maBondLowerBufferPlotIndex, PLOT_DRAW_BEGIN, 0);
|
PlotIndexSetInteger(maBandLowerBufferPlotIndex, PLOT_DRAW_BEGIN, 0);
|
||||||
PlotIndexSetDouble(maBondLowerBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
PlotIndexSetDouble(maBandLowerBufferPlotIndex, PLOT_EMPTY_VALUE, 0);
|
||||||
|
|
||||||
//
|
//
|
||||||
// XPB Bond ...
|
// XPB Band ...
|
||||||
|
|
||||||
//
|
//
|
||||||
// Upper Bond ...
|
// Upper Band ...
|
||||||
|
|
||||||
//
|
//
|
||||||
ArraySetAsSeries(pbBondUpperBuffer, true);
|
ArraySetAsSeries(pbBandUpperBuffer, true);
|
||||||
SetIndexBuffer(pbBondUpperBufferIndex, pbBondUpperBuffer, INDICATOR_DATA);
|
SetIndexBuffer(pbBandUpperBufferIndex, pbBandUpperBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
//
|
//
|
||||||
PlotIndexSetInteger(pbBondUpperBufferPlotIndex, PLOT_SHOW_DATA, showMABond);
|
PlotIndexSetInteger(pbBandUpperBufferPlotIndex, PLOT_SHOW_DATA, showMABand);
|
||||||
PlotIndexSetInteger(pbBondUpperBufferPlotIndex, PLOT_DRAW_TYPE, maBondDrawType);
|
PlotIndexSetInteger(pbBandUpperBufferPlotIndex, PLOT_DRAW_TYPE, maBandDrawType);
|
||||||
PlotIndexSetDouble(pbBondUpperBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
PlotIndexSetDouble(pbBandUpperBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Lower Bond ...
|
// Lower Band ...
|
||||||
|
|
||||||
//
|
//
|
||||||
ArraySetAsSeries(pbBondLowerBuffer, true);
|
ArraySetAsSeries(pbBandLowerBuffer, true);
|
||||||
SetIndexBuffer(pbBondLowerBufferIndex, pbBondLowerBuffer, INDICATOR_DATA);
|
SetIndexBuffer(pbBandLowerBufferIndex, pbBandLowerBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
//
|
//
|
||||||
PlotIndexSetInteger(pbBondLowerBufferPlotIndex, PLOT_SHOW_DATA, showMABond);
|
PlotIndexSetInteger(pbBandLowerBufferPlotIndex, PLOT_SHOW_DATA, showMABand);
|
||||||
PlotIndexSetInteger(pbBondLowerBufferPlotIndex, PLOT_DRAW_TYPE, maBondDrawType);
|
PlotIndexSetInteger(pbBandLowerBufferPlotIndex, PLOT_DRAW_TYPE, maBandDrawType);
|
||||||
PlotIndexSetDouble(pbBondLowerBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
PlotIndexSetDouble(pbBandLowerBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||||
|
|
||||||
//
|
//
|
||||||
// XHK ...
|
// XHK ...
|
||||||
@@ -1131,29 +1204,54 @@ void DefineBuffers()
|
|||||||
SetIndexBuffer(hkCloseBufferIndex, hkCloseBuffer, INDICATOR_DATA);
|
SetIndexBuffer(hkCloseBufferIndex, hkCloseBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
//
|
//
|
||||||
// XHK Bond ...
|
// XHK Band ...
|
||||||
//
|
//
|
||||||
ENUM_DRAW_TYPE hkBondDrawType = showHKBond ? DRAW_LINE : DRAW_NONE;
|
ENUM_DRAW_TYPE hkBandDrawType = showHKBand ? DRAW_LINE : DRAW_NONE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Upper ...
|
// Upper ...
|
||||||
ArraySetAsSeries(hkBondUpperBuffer, true);
|
ArraySetAsSeries(hkBandUpperBuffer, true);
|
||||||
SetIndexBuffer(hkBondUpperBufferIndex, hkBondUpperBuffer, INDICATOR_DATA);
|
SetIndexBuffer(hkBandUpperBufferIndex, hkBandUpperBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
//
|
//
|
||||||
PlotIndexSetInteger(hkBondUpperBufferPlotIndex, PLOT_SHOW_DATA, showHKBond);
|
PlotIndexSetInteger(hkBandUpperBufferPlotIndex, PLOT_SHOW_DATA, showHKBand);
|
||||||
PlotIndexSetInteger(hkBondUpperBufferPlotIndex, PLOT_DRAW_TYPE, hkBondDrawType);
|
PlotIndexSetInteger(hkBandUpperBufferPlotIndex, PLOT_DRAW_TYPE, hkBandDrawType);
|
||||||
PlotIndexSetDouble(hkBondUpperBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
PlotIndexSetDouble(hkBandUpperBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Lower ...
|
// Lower ...
|
||||||
ArraySetAsSeries(hkBondLowerBuffer, true);
|
ArraySetAsSeries(hkBandLowerBuffer, true);
|
||||||
SetIndexBuffer(hkBondLowerBufferIndex, hkBondLowerBuffer, INDICATOR_DATA);
|
SetIndexBuffer(hkBandLowerBufferIndex, hkBandLowerBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
//
|
//
|
||||||
PlotIndexSetInteger(hkBondLowerBufferPlotIndex, PLOT_SHOW_DATA, showHKBond);
|
PlotIndexSetInteger(hkBandLowerBufferPlotIndex, PLOT_SHOW_DATA, showHKBand);
|
||||||
PlotIndexSetInteger(hkBondLowerBufferPlotIndex, PLOT_DRAW_TYPE, hkBondDrawType);
|
PlotIndexSetInteger(hkBandLowerBufferPlotIndex, PLOT_DRAW_TYPE, hkBandDrawType);
|
||||||
PlotIndexSetDouble(hkBondLowerBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
PlotIndexSetDouble(hkBandLowerBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||||
|
|
||||||
|
//
|
||||||
|
// XATR Band ...
|
||||||
|
//
|
||||||
|
ENUM_DRAW_TYPE atrBandDrawType = showATRBand ? DRAW_LINE : DRAW_NONE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Upper ...
|
||||||
|
ArraySetAsSeries(atrBandUpperBuffer, true);
|
||||||
|
SetIndexBuffer(atrBandUpperBufferIndex, atrBandUpperBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
|
//
|
||||||
|
PlotIndexSetInteger(atrBandUpperBufferPlotIndex, PLOT_SHOW_DATA, showATRBand);
|
||||||
|
PlotIndexSetInteger(atrBandUpperBufferPlotIndex, PLOT_DRAW_TYPE, atrBandDrawType);
|
||||||
|
PlotIndexSetDouble(atrBandUpperBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower ...
|
||||||
|
ArraySetAsSeries(atrBandLowerBuffer, true);
|
||||||
|
SetIndexBuffer(atrBandLowerBufferIndex, atrBandLowerBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
|
//
|
||||||
|
PlotIndexSetInteger(atrBandLowerBufferPlotIndex, PLOT_SHOW_DATA, showATRBand);
|
||||||
|
PlotIndexSetInteger(atrBandLowerBufferPlotIndex, PLOT_DRAW_TYPE, atrBandDrawType);
|
||||||
|
PlotIndexSetDouble(atrBandLowerBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Data Buffers ...
|
// Data Buffers ...
|
||||||
@@ -1250,12 +1348,27 @@ void DefineBuffers()
|
|||||||
// XPB Data ...
|
// XPB Data ...
|
||||||
|
|
||||||
//
|
//
|
||||||
ArraySetAsSeries(pbBondRawUpperBuffer, true);
|
ArraySetAsSeries(pbBandRawUpperBuffer, true);
|
||||||
SetIndexBuffer(pbBondRawUpperBufferIndex, pbBondRawUpperBuffer, INDICATOR_CALCULATIONS);
|
SetIndexBuffer(pbBandRawUpperBufferIndex, pbBandRawUpperBuffer, INDICATOR_CALCULATIONS);
|
||||||
|
|
||||||
//
|
//
|
||||||
ArraySetAsSeries(pbBondRawLowerBuffer, true);
|
ArraySetAsSeries(pbBandRawLowerBuffer, true);
|
||||||
SetIndexBuffer(pbBondRawLowerBufferIndex, pbBondRawLowerBuffer, INDICATOR_CALCULATIONS);
|
SetIndexBuffer(pbBandRawLowerBufferIndex, pbBandRawLowerBuffer, INDICATOR_CALCULATIONS);
|
||||||
|
|
||||||
|
//
|
||||||
|
// XATR Data ...
|
||||||
|
|
||||||
|
//
|
||||||
|
ArraySetAsSeries(atrBuffer, true);
|
||||||
|
SetIndexBuffer(atrBufferIndex, atrBuffer, INDICATOR_CALCULATIONS);
|
||||||
|
|
||||||
|
//
|
||||||
|
ArraySetAsSeries(atrBandRawUpperBuffer, true);
|
||||||
|
SetIndexBuffer(atrBandRawUpperBufferIndex, atrBandRawUpperBuffer, INDICATOR_CALCULATIONS);
|
||||||
|
|
||||||
|
//
|
||||||
|
ArraySetAsSeries(atrBandRawLowerBuffer, true);
|
||||||
|
SetIndexBuffer(atrBandRawLowerBufferIndex, atrBandRawLowerBuffer, INDICATOR_CALCULATIONS);
|
||||||
|
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
@@ -1418,11 +1531,11 @@ bool InitRequirements()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// MA Bond Upper ...
|
// MA Band Upper ...
|
||||||
maUpperHandler = iMA(
|
maUpperHandler = iMA(
|
||||||
_Symbol,
|
_Symbol,
|
||||||
_Period,
|
_Period,
|
||||||
maBondLength,
|
maBandLength,
|
||||||
0,
|
0,
|
||||||
maMethod,
|
maMethod,
|
||||||
PRICE_HIGH //
|
PRICE_HIGH //
|
||||||
@@ -1434,11 +1547,11 @@ bool InitRequirements()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// MA Bond Lower ...
|
// MA Band Lower ...
|
||||||
maLowerHandler = iMA(
|
maLowerHandler = iMA(
|
||||||
_Symbol,
|
_Symbol,
|
||||||
_Period,
|
_Period,
|
||||||
maBondLength,
|
maBandLength,
|
||||||
0,
|
0,
|
||||||
maMethod,
|
maMethod,
|
||||||
PRICE_LOW //
|
PRICE_LOW //
|
||||||
@@ -1463,6 +1576,19 @@ bool InitRequirements()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// ATR ...
|
||||||
|
atrHandler = iATR(
|
||||||
|
_Symbol,
|
||||||
|
_Period,
|
||||||
|
atrLength //
|
||||||
|
);
|
||||||
|
result = atrHandler != INVALID_HANDLE;
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
mDrawer = new XCPOIDrawer();
|
mDrawer = new XCPOIDrawer();
|
||||||
|
|
||||||
@@ -1620,6 +1746,19 @@ void CalculateValues(
|
|||||||
tickVolume //
|
tickVolume //
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// XATR ...
|
||||||
|
CalculateATR(
|
||||||
|
barIndex,
|
||||||
|
prevCalculated,
|
||||||
|
ratesTotal,
|
||||||
|
open,
|
||||||
|
high,
|
||||||
|
close,
|
||||||
|
low,
|
||||||
|
tickVolume //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fast MA ...
|
// Fast MA ...
|
||||||
double iFastMa = maFastBuffer[barIndex];
|
double iFastMa = maFastBuffer[barIndex];
|
||||||
@@ -1718,15 +1857,15 @@ void CalculateValues(
|
|||||||
double iPBLower = MathMin(close[barIndex], open[barIndex]);
|
double iPBLower = MathMin(close[barIndex], open[barIndex]);
|
||||||
|
|
||||||
//
|
//
|
||||||
pbBondUpperBuffer[barIndex] = iPBUpper;
|
pbBandUpperBuffer[barIndex] = iPBUpper;
|
||||||
pbBondRawUpperBuffer[barIndex] = iPBUpper;
|
pbBandRawUpperBuffer[barIndex] = iPBUpper;
|
||||||
|
|
||||||
//
|
//
|
||||||
pbBondLowerBuffer[barIndex] = iPBLower;
|
pbBandLowerBuffer[barIndex] = iPBLower;
|
||||||
pbBondRawLowerBuffer[barIndex] = iPBLower;
|
pbBandRawLowerBuffer[barIndex] = iPBLower;
|
||||||
|
|
||||||
//
|
//
|
||||||
if (IsXValid(iPBMethod) && maBondLength > 0)
|
if (IsXValid(iPBMethod) && maBandLength > 0)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// XPB Upper ...
|
// XPB Upper ...
|
||||||
@@ -1734,9 +1873,9 @@ void CalculateValues(
|
|||||||
ratesTotal,
|
ratesTotal,
|
||||||
prevCalculated,
|
prevCalculated,
|
||||||
barIndex,
|
barIndex,
|
||||||
maBondLength,
|
maBandLength,
|
||||||
pbBondRawUpperBuffer,
|
pbBandRawUpperBuffer,
|
||||||
pbBondUpperBuffer,
|
pbBandUpperBuffer,
|
||||||
iPBMethod //
|
iPBMethod //
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1746,9 +1885,9 @@ void CalculateValues(
|
|||||||
ratesTotal,
|
ratesTotal,
|
||||||
prevCalculated,
|
prevCalculated,
|
||||||
barIndex,
|
barIndex,
|
||||||
maBondLength,
|
maBandLength,
|
||||||
pbBondRawLowerBuffer,
|
pbBandRawLowerBuffer,
|
||||||
pbBondLowerBuffer,
|
pbBandLowerBuffer,
|
||||||
iPBMethod //
|
iPBMethod //
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -2334,8 +2473,8 @@ void CalculateHKBar(
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
hkBondUpperBuffer[barIndex] = hkHighBuffer[barIndex];
|
hkBandUpperBuffer[barIndex] = hkHighBuffer[barIndex];
|
||||||
hkBondLowerBuffer[barIndex] = hkLowBuffer[barIndex];
|
hkBandLowerBuffer[barIndex] = hkLowBuffer[barIndex];
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculate HK Color ...
|
// Calculate HK Color ...
|
||||||
@@ -2351,6 +2490,93 @@ void CalculateHKBar(
|
|||||||
: hideColorIDX;
|
: hideColorIDX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
void CalculateATR(
|
||||||
|
int barIndex,
|
||||||
|
const int prevCalculated,
|
||||||
|
const int ratesTotal,
|
||||||
|
const double &open[],
|
||||||
|
const double &high[],
|
||||||
|
const double &close[],
|
||||||
|
const double &low[],
|
||||||
|
const long &tickVolume[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int lastBarIndex = barIndex + 1;
|
||||||
|
bool isFirstBar =
|
||||||
|
startCalculationForLastBars > 0
|
||||||
|
? barIndex == startCalculationForLastBars
|
||||||
|
: barIndex == firstBarIndex;
|
||||||
|
|
||||||
|
//
|
||||||
|
double iAtr = atrBuffer[barIndex];
|
||||||
|
double iAppliedAtr = atrMultiplier <= 0
|
||||||
|
? iAtr
|
||||||
|
: atrMultiplier * iAtr;
|
||||||
|
double iUpperPrice = GetAppliedPrice(
|
||||||
|
atrUpperPriceType,
|
||||||
|
open,
|
||||||
|
high,
|
||||||
|
low,
|
||||||
|
close,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
double iLowerPrice = GetAppliedPrice(
|
||||||
|
atrLowerPriceType,
|
||||||
|
open,
|
||||||
|
high,
|
||||||
|
low,
|
||||||
|
close,
|
||||||
|
barIndex //
|
||||||
|
);
|
||||||
|
double iPriceMid = iLowerPrice + ((iUpperPrice - iLowerPrice) / 2);
|
||||||
|
|
||||||
|
//
|
||||||
|
double iUpperAtr = iPriceMid + iAppliedAtr;
|
||||||
|
double iLowerAtr = iPriceMid - iAppliedAtr;
|
||||||
|
|
||||||
|
//
|
||||||
|
atrBandRawUpperBuffer[barIndex] = iUpperAtr;
|
||||||
|
atrBandRawLowerBuffer[barIndex] = iLowerAtr;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Can Smooth Atr ...
|
||||||
|
if (IsXValid(atrSmoothingMode) &&
|
||||||
|
atrSmoothingLength > 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Upper ...
|
||||||
|
iMAOnBuffer(
|
||||||
|
ratesTotal,
|
||||||
|
prevCalculated,
|
||||||
|
barIndex,
|
||||||
|
atrSmoothingLength,
|
||||||
|
atrBandRawUpperBuffer,
|
||||||
|
atrBandUpperBuffer,
|
||||||
|
atrSmoothingMode //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower ...
|
||||||
|
iMAOnBuffer(
|
||||||
|
ratesTotal,
|
||||||
|
prevCalculated,
|
||||||
|
barIndex,
|
||||||
|
atrSmoothingLength,
|
||||||
|
atrBandRawLowerBuffer,
|
||||||
|
atrBandLowerBuffer,
|
||||||
|
atrSmoothingMode //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
atrBandUpperBuffer[barIndex] = iUpperAtr;
|
||||||
|
atrBandLowerBuffer[barIndex] = iLowerAtr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
void CalculateCycleRanges(
|
void CalculateCycleRanges(
|
||||||
int barIndex,
|
int barIndex,
|
||||||
|
|||||||
@@ -2452,6 +2452,64 @@ struct XPatternAnalysis
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract All Exists Patterns Pivots ...
|
||||||
|
*
|
||||||
|
* @param dest: XPivot, collection reference to holds Extracted Patterns ...
|
||||||
|
* @param forDir: ENUM_X_DIRECTION, Specified Direction of Extractions ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int GetPatterns(
|
||||||
|
XPivot &dest[],
|
||||||
|
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
XClean(dest);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool has = IsValid() &&
|
||||||
|
HasChild(patterns);
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do ...
|
||||||
|
XOHCL iBar;
|
||||||
|
XPivot iPivot;
|
||||||
|
XBoxZone iZone;
|
||||||
|
int count = ArraySize(patterns);
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
has = GetPattern(iBar, iPivot, iZone, patterns[i], forDir);
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
AddIfNotExists(iPivot, dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = ArraySize(dest);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
iBar.Clean();
|
||||||
|
iZone.Clean();
|
||||||
|
iPivot.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2460,12 +2518,6 @@ struct XPatternAnalysisConfig
|
|||||||
//
|
//
|
||||||
// Props ...
|
// Props ...
|
||||||
|
|
||||||
//
|
|
||||||
// Quarter ...
|
|
||||||
int quarterZonesRequiredToStart;
|
|
||||||
int quarterZoneDetectionLoopback;
|
|
||||||
int quarterZonesValidationLength;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// PV ...
|
// PV ...
|
||||||
int pvValidationLength;
|
int pvValidationLength;
|
||||||
@@ -2523,12 +2575,6 @@ struct XPatternAnalysisConfig
|
|||||||
*/
|
*/
|
||||||
void Clean()
|
void Clean()
|
||||||
{
|
{
|
||||||
//
|
|
||||||
// Quarter ...
|
|
||||||
quarterZonesRequiredToStart = 0;
|
|
||||||
quarterZoneDetectionLoopback = 0;
|
|
||||||
quarterZonesValidationLength = 0;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// PV ...
|
// PV ...
|
||||||
pvValidationLength = 0;
|
pvValidationLength = 0;
|
||||||
@@ -2580,12 +2626,6 @@ struct XPatternAnalysisConfig
|
|||||||
*/
|
*/
|
||||||
void Default()
|
void Default()
|
||||||
{
|
{
|
||||||
//
|
|
||||||
// Quarter ...
|
|
||||||
quarterZonesRequiredToStart = 20;
|
|
||||||
quarterZonesValidationLength = 3;
|
|
||||||
quarterZoneDetectionLoopback = 1500;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// PV ...
|
// PV ...
|
||||||
pvValidationLength = 5;
|
pvValidationLength = 5;
|
||||||
@@ -3073,4 +3113,51 @@ struct XPatternAnalysisDrawConfig
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Extensions ...
|
||||||
|
|
||||||
|
bool FindByTime(
|
||||||
|
int &index,
|
||||||
|
datetime time,
|
||||||
|
XPatternAnalysis &source[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
index = -1;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
result = IsXValid(time) &&
|
||||||
|
HasChild(source);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do ...
|
||||||
|
int count = ArraySize(source);
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result = source[i].bar.time == time;
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = IsValidIndex(index);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -2271,6 +2271,7 @@ void SortBar(
|
|||||||
//+------------------------------------------------------------------+
|
//+------------------------------------------------------------------+
|
||||||
//| Extraction |
|
//| Extraction |
|
||||||
//+------------------------------------------------------------------+
|
//+------------------------------------------------------------------+
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract Specific Types of Pivots From a Collection ...
|
* Extract Specific Types of Pivots From a Collection ...
|
||||||
*
|
*
|
||||||
@@ -2329,6 +2330,61 @@ int ExtractPivots(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract Same Time Pivots ...
|
||||||
|
*
|
||||||
|
* @param item: XPivot, reference to Specified Pivot for Detect Same Times ...
|
||||||
|
* @param dest: XPivot, collection reference to holds Same Times Pivots ...
|
||||||
|
* @param source: XPivot, collection reference to Provide Data Source ...
|
||||||
|
*
|
||||||
|
* @return ( int )
|
||||||
|
*/
|
||||||
|
int ExtractSameTimePivots(
|
||||||
|
XPivot &item,
|
||||||
|
XPivot &dest[],
|
||||||
|
XPivot &source[] //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Prepare ...
|
||||||
|
XClean(dest);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate ...
|
||||||
|
bool has = HasChild(source) &&
|
||||||
|
item.IsValid();
|
||||||
|
if (!has)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Do ...
|
||||||
|
int count = ArraySize(source);
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
has = item.time == source[i].time;
|
||||||
|
if (has)
|
||||||
|
{
|
||||||
|
AddIfNotExists(source[i], dest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Add item as a Child ...
|
||||||
|
AddIfNotExists(item, dest);
|
||||||
|
|
||||||
|
//
|
||||||
|
result = ArraySize(dest);
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract Pivots Data for Linear Regression Calculations ...
|
* Extract Pivots Data for Linear Regression Calculations ...
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -333,9 +333,9 @@ enum ENUM_X_DETECTOR_ZONE_ACTION
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate an ENUM member ...
|
* Validate an ENUM member ...
|
||||||
*
|
*
|
||||||
* @param value: ENUM_X_DETECTOR_ZONE_ACTION ...
|
* @param value: ENUM_X_DETECTOR_ZONE_ACTION ...
|
||||||
*
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
*/
|
*/
|
||||||
bool IsXValid(ENUM_X_DETECTOR_ZONE_ACTION value)
|
bool IsXValid(ENUM_X_DETECTOR_ZONE_ACTION value)
|
||||||
@@ -636,6 +636,15 @@ struct XPivot
|
|||||||
symbol == item.symbol &&
|
symbol == item.symbol &&
|
||||||
period == item.period;
|
period == item.period;
|
||||||
|
|
||||||
|
//
|
||||||
|
if (result && IsXValid(prefix))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
result =
|
||||||
|
result &&
|
||||||
|
prefix == item.prefix;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -24,6 +24,7 @@
|
|||||||
// Imports ...
|
// Imports ...
|
||||||
#include "../../Classes/x-saherelm.x-signaller.class.mq5"
|
#include "../../Classes/x-saherelm.x-signaller.class.mq5"
|
||||||
#include "../../Helpers/x-saherelm.xfima.helper.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.detector.class.mq5"
|
||||||
#include "../Classes/x-saherelm.xfima.x-poi.drawer.class.mq5"
|
#include "../Classes/x-saherelm.xfima.x-poi.drawer.class.mq5"
|
||||||
|
|
||||||
@@ -45,6 +46,7 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
|
|||||||
XFIMAInputs fimaInputs; // XFIMA Inputs ...
|
XFIMAInputs fimaInputs; // XFIMA Inputs ...
|
||||||
XCXFIMAHelper *fimaHelper; // XFIMA Indicator Helper ...
|
XCXFIMAHelper *fimaHelper; // XFIMA Indicator Helper ...
|
||||||
XCXFIMAPOIDrawer *poiDrawer; // XFIMA POI Drawer ...
|
XCXFIMAPOIDrawer *poiDrawer; // XFIMA POI Drawer ...
|
||||||
|
XCXFIMAHelperParser *fimaParser; // XFIMA Helper Parser ...
|
||||||
XCXFIMAPOIDetector *poiDetector; // XFIMA POI Detector ...
|
XCXFIMAPOIDetector *poiDetector; // XFIMA POI Detector ...
|
||||||
XFIMAMarketStructureConfig structureConfig; // XFIMA Market Structure Detector Config ...
|
XFIMAMarketStructureConfig structureConfig; // XFIMA Market Structure Detector Config ...
|
||||||
XFIMAMarketStructureDrawerConfig structureDrawConfig; // XFIMA Market Structure Draw 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();
|
poiDrawer = new XCXFIMAPOIDrawer();
|
||||||
poiDetector = new XCXFIMAPOIDetector(fimaHelper);
|
poiDetector = new XCXFIMAPOIDetector(fimaHelper, fimaParser);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Configure ...
|
// Configure ...
|
||||||
@@ -556,25 +562,17 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
// Draw Flags ...
|
// Draw Flags ...
|
||||||
bool draw = true;
|
bool draw = true;
|
||||||
bool drawZone = true;
|
bool drawZone = true;
|
||||||
bool drawOrderFlow = true;
|
bool drawMarketStructurePivots = true;
|
||||||
|
bool drawMarketStructureAnalysis = true;
|
||||||
|
bool drawMarketStructureOrderFlow = true;
|
||||||
XPOIDrawConfig iDrawConfig;
|
XPOIDrawConfig iDrawConfig;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Signal Checking ...
|
// Signal Checking ...
|
||||||
|
|
||||||
//
|
//
|
||||||
// Detecting OrderFlow ...
|
// Analyse Market Strucutre ...
|
||||||
XBoxZone orderFlow[];
|
XFIMAMarketStructure marketStructure;
|
||||||
ENUM_X_DIRECTION orderFlowDir;
|
|
||||||
bool hasOrderFlow = poiDetector.HasOrderFlow(
|
|
||||||
bar,
|
|
||||||
orderFlowDir,
|
|
||||||
orderFlow,
|
|
||||||
2,
|
|
||||||
false, // Contains OB ...
|
|
||||||
true, // Contains FVG ...
|
|
||||||
false // Contains Support and Resistances ...
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Signaller 1 ...
|
// Signaller 1 ...
|
||||||
@@ -660,14 +658,24 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
if (result && validateByOrderFlow)
|
if (result && validateByOrderFlow)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
bool isBullish = hasOrderFlow &&
|
// Analyse Market Structure if Required ...
|
||||||
IsXBullish(dir) &&
|
if (!marketStructure.IsValid())
|
||||||
IsXBullish(orderFlowDir);
|
{
|
||||||
|
//
|
||||||
|
poiDetector.AnalyseMarket(
|
||||||
|
marketStructure,
|
||||||
|
structureConfig,
|
||||||
|
bar.Index() //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
bool isBearish = hasOrderFlow &&
|
bool isBullish = IsXBullish(dir) &&
|
||||||
IsXBearish(dir) &&
|
marketStructure.HasBullishOrderFlow();
|
||||||
IsXBearish(orderFlowDir);
|
|
||||||
|
//
|
||||||
|
bool isBearish = IsXBearish(dir) &&
|
||||||
|
marketStructure.HasBearishOrderFlow();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Summarizing result ...
|
// Summarizing result ...
|
||||||
@@ -749,7 +757,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Partial Close on TP 1 ...
|
// Partial Close on TP 1 ...
|
||||||
if (hasPartialCloseOnTp1 && tp > tp1)
|
if (hasPartialCloseOnTp1)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
iTarget.Clean();
|
iTarget.Clean();
|
||||||
@@ -814,10 +822,52 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Draw Order Flow ...
|
// Draw Market Structure ...
|
||||||
if (drawOrderFlow && HasChild(orderFlow))
|
//
|
||||||
|
// 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();
|
DebugBreak();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Cleanup ...
|
||||||
|
iDrawConfig.Clean();
|
||||||
|
marketStructure.Clean();
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -918,13 +973,13 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Reading HK Bond ...
|
// Reading HK Band ...
|
||||||
|
|
||||||
//
|
//
|
||||||
double pHKBondUpper = fimaHelper.GetHKBondUpper(pBar.Index());
|
double pHKBandUpper = fimaHelper.GetHKBandUpper(pBar.Index());
|
||||||
double pHKBondLower = fimaHelper.GetHKBondLower(pBar.Index());
|
double pHKBandLower = fimaHelper.GetHKBandLower(pBar.Index());
|
||||||
int overHKBondUpperCount = fimaHelper.CountOverHKBondUpper(pullBackStartBar, X_PRICE_LOW);
|
int overHKBandUpperCount = fimaParser.CountOverHKBandUpper(pullBackStartBar, X_PRICE_LOW);
|
||||||
int underHKBondLowerCount = fimaHelper.CountUnderHKBondLower(pullBackStartBar, X_PRICE_HIGH);
|
int underHKBandLowerCount = fimaParser.CountUnderHKBandLower(pullBackStartBar, X_PRICE_HIGH);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Reading PV Requirements ...
|
// Reading PV Requirements ...
|
||||||
@@ -934,10 +989,10 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
int lastValeUnderLastIDX = -1;
|
int lastValeUnderLastIDX = -1;
|
||||||
double pPeak = fimaHelper.GetPeak(pBar.Index());
|
double pPeak = fimaHelper.GetPeak(pBar.Index());
|
||||||
double pVale = fimaHelper.GetVale(pBar.Index());
|
double pVale = fimaHelper.GetVale(pBar.Index());
|
||||||
int samePeaks = fimaHelper.CountSamePeaks(pBar.Index());
|
int samePeaks = fimaParser.CountSamePeaks(pBar.Index());
|
||||||
int sameVales = fimaHelper.CountSameVales(pBar.Index());
|
int sameVales = fimaParser.CountSameVales(pBar.Index());
|
||||||
fimaHelper.FindLastPeakOverLast(lastPeakOverLastIDX, pBar.Index());
|
fimaParser.FindLastPeakOverLast(lastPeakOverLastIDX, pBar.Index());
|
||||||
fimaHelper.FindLastValeUnderLast(lastValeUnderLastIDX, pBar.Index());
|
fimaParser.FindLastValeUnderLast(lastValeUnderLastIDX, pBar.Index());
|
||||||
|
|
||||||
//
|
//
|
||||||
// Reading pBar Patterns ...
|
// Reading pBar Patterns ...
|
||||||
@@ -1040,7 +1095,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
hasBullishInside &&
|
hasBullishInside &&
|
||||||
isPullbackBullish &&
|
isPullbackBullish &&
|
||||||
isPBarHasBullishPatterns &&
|
isPBarHasBullishPatterns &&
|
||||||
fimaHelper.IsSarBullish(pBar.Index()) &&
|
fimaParser.IsSARBullish(pBar.Index()) &&
|
||||||
(pVale >= affectedZonesBullish[insideBullishIDX].lower &&
|
(pVale >= affectedZonesBullish[insideBullishIDX].lower &&
|
||||||
pVale <= affectedZonesBullish[insideBullishIDX].upper)
|
pVale <= affectedZonesBullish[insideBullishIDX].upper)
|
||||||
//
|
//
|
||||||
@@ -1052,7 +1107,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
hasBearishInside &&
|
hasBearishInside &&
|
||||||
isPullbackBearish &&
|
isPullbackBearish &&
|
||||||
isPBarHasBearishPatterns &&
|
isPBarHasBearishPatterns &&
|
||||||
fimaHelper.IsSarBearish(pBar.Index()) &&
|
fimaParser.IsSARBearish(pBar.Index()) &&
|
||||||
(pPeak >= affectedZonesBearish[insideBearishIDX].lower &&
|
(pPeak >= affectedZonesBearish[insideBearishIDX].lower &&
|
||||||
pPeak <= affectedZonesBearish[insideBearishIDX].upper)
|
pPeak <= affectedZonesBearish[insideBearishIDX].upper)
|
||||||
//
|
//
|
||||||
@@ -1064,24 +1119,6 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
isBearish;
|
isBearish;
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
if (isBullish)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
poiDrawer.DrawZone(
|
|
||||||
affectedZonesBullish[insideBullishIDX],
|
|
||||||
structureDrawConfig.drawConfig //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//
|
|
||||||
poiDrawer.DrawZone(
|
|
||||||
affectedZonesBearish[insideBearishIDX],
|
|
||||||
structureDrawConfig.drawConfig //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
dir =
|
dir =
|
||||||
isBullish
|
isBullish
|
||||||
@@ -1238,10 +1275,10 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
double pVale = fimaHelper.GetVale(pBar.Index());
|
double pVale = fimaHelper.GetVale(pBar.Index());
|
||||||
double p2Peak = fimaHelper.GetPeak(p2Bar.Index());
|
double p2Peak = fimaHelper.GetPeak(p2Bar.Index());
|
||||||
double p2Vale = fimaHelper.GetVale(p2Bar.Index());
|
double p2Vale = fimaHelper.GetVale(p2Bar.Index());
|
||||||
bool isPPeakOverLast = fimaHelper.IsPeakOverLast(pBar.Index());
|
bool isPPeakOverLast = fimaParser.IsPeakOverLast(pBar.Index());
|
||||||
bool isPValeUnderLast = fimaHelper.IsValeUnderLast(pBar.Index());
|
bool isPValeUnderLast = fimaParser.IsValeUnderLast(pBar.Index());
|
||||||
bool isP2PeakOverLast = fimaHelper.IsPeakOverLast(p2Bar.Index());
|
bool isP2PeakOverLast = fimaParser.IsPeakOverLast(p2Bar.Index());
|
||||||
bool isP2ValeUnderLast = fimaHelper.IsValeUnderLast(p2Bar.Index());
|
bool isP2ValeUnderLast = fimaParser.IsValeUnderLast(p2Bar.Index());
|
||||||
bool isPeakOverLast = isPPeakOverLast ||
|
bool isPeakOverLast = isPPeakOverLast ||
|
||||||
isP2PeakOverLast;
|
isP2PeakOverLast;
|
||||||
bool isValeUnderLast = isPValeUnderLast ||
|
bool isValeUnderLast = isPValeUnderLast ||
|
||||||
@@ -1473,7 +1510,7 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
// XFIMA Consolidation ...
|
// XFIMA Consolidation ...
|
||||||
|
|
||||||
//
|
//
|
||||||
bool isConsolidation = fimaHelper.HasPVConsolidationZone(
|
bool isConsolidation = poiDetector.DetectPVConsolidationZone(
|
||||||
zone,
|
zone,
|
||||||
pBar.Index(),
|
pBar.Index(),
|
||||||
true, // Force PV Break ...
|
true, // Force PV Break ...
|
||||||
@@ -1707,12 +1744,6 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
|||||||
//
|
//
|
||||||
result = isBullish ||
|
result = isBullish ||
|
||||||
isBearish;
|
isBearish;
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
poiDrawer.DrawZones(orderFlow, structureDrawConfig.drawConfig);
|
|
||||||
Print("OrderFlow Detected ...");
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
isBullish =
|
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 "../../Classes/x-saherelm.x-cobject.class.mq5"
|
||||||
#include "../../Helpers/x-saherelm.xfima.helper.mq5"
|
#include "../../Helpers/x-saherelm.xfima.helper.mq5"
|
||||||
#include "../../Libraries/x-saherelm.x-pivot.analysis.lib.mq5"
|
#include "../../Libraries/x-saherelm.x-pivot.analysis.lib.mq5"
|
||||||
|
#include "../Classes/x-saherelm.xfima.parser.class.mq5"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Definitions ...
|
// Definitions ...
|
||||||
@@ -40,8 +41,22 @@ struct XFIMAMarketStructure
|
|||||||
XPatternAnalysis barAnalysis; // Structure Bar Pattern Analysis ...
|
XPatternAnalysis barAnalysis; // Structure Bar Pattern Analysis ...
|
||||||
|
|
||||||
//
|
//
|
||||||
XPivotAnalysis pvAnalysis; // PV Pivot Analysis Result ...
|
XBoxZone orderFlow[]; // Specified Order Flow Zones ...
|
||||||
XPivotAnalysis zgAnalysis; // ZG Pivot Analysis Result ...
|
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 ...
|
XPatternAnalysis barsAnalysis[]; // Anaysed Bars ...
|
||||||
@@ -65,11 +80,27 @@ struct XFIMAMarketStructure
|
|||||||
bar.Clean();
|
bar.Clean();
|
||||||
barAnalysis.Clean();
|
barAnalysis.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
|
XClean(pvPivots);
|
||||||
|
XClean(zgPivots);
|
||||||
|
XClean(maPivots);
|
||||||
|
XClean(hkPivots);
|
||||||
|
XClean(sarPivots);
|
||||||
|
|
||||||
//
|
//
|
||||||
pvAnalysis.Clean();
|
pvAnalysis.Clean();
|
||||||
zgAnalysis.Clean();
|
zgAnalysis.Clean();
|
||||||
|
maAnalysis.Clean();
|
||||||
|
hkAnalysis.Clean();
|
||||||
|
sarAnalysis.Clean();
|
||||||
|
|
||||||
|
//
|
||||||
XClean(barsAnalysis);
|
XClean(barsAnalysis);
|
||||||
|
|
||||||
|
//
|
||||||
|
XClean(orderFlow);
|
||||||
|
orderFlowDir = X_DIRECTION_NONE;
|
||||||
|
|
||||||
//
|
//
|
||||||
ZeroMemory(this);
|
ZeroMemory(this);
|
||||||
}
|
}
|
||||||
@@ -85,31 +116,73 @@ struct XFIMAMarketStructure
|
|||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
result = bar.IsValid() &&
|
result = bar.IsValid() &&
|
||||||
barAnalysis.IsValid();
|
barAnalysis.IsValid();
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
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 ...
|
// Collectors ...
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collect Required Zones from Structure ...
|
* Collect all Pivots ...
|
||||||
*
|
*
|
||||||
* @param dest: XBoxZone, reference collection to holds result ...
|
* @param dest: XPivot, collection reference to holds result ...
|
||||||
* @param forDir: ENUM_X_DIRECTION, Specified Collectiong ones Direction ...
|
* @param containsPatterns: bool, Specified to Add Pivots Bar Directionl Patterns ...
|
||||||
* @param containsOB: bool, Contains OB Zones ...
|
* @param forDir: ENUM_X_DIRECTION, Specified Extraction Direction ...
|
||||||
* @param containsFVG: bool, Contains FVG Zones ...
|
|
||||||
*
|
*
|
||||||
* @return ( int )
|
* @return ( int )
|
||||||
*/
|
*/
|
||||||
int CollectZones(
|
int CollectPivots(
|
||||||
XBoxZone &dest[],
|
XPivot &dest[],
|
||||||
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE,
|
bool containsPatterns = false,
|
||||||
bool containsOB = false,
|
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE //
|
||||||
bool containsFVG = false //
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -120,7 +193,7 @@ struct XFIMAMarketStructure
|
|||||||
XClean(dest);
|
XClean(dest);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Validate ...
|
// Normalize ...
|
||||||
bool has = IsValid();
|
bool has = IsValid();
|
||||||
if (!has)
|
if (!has)
|
||||||
{
|
{
|
||||||
@@ -128,182 +201,80 @@ struct XFIMAMarketStructure
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
bool canCollectBullish =
|
// Do ...
|
||||||
IsXBullish(forDir) ||
|
|
||||||
!HasDirection(forDir);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
bool canCollectBearish =
|
Copy(pvPivots, dest, false);
|
||||||
IsXBearish(forDir) ||
|
Copy(hkPivots, dest, false);
|
||||||
!HasDirection(forDir);
|
Copy(maPivots, dest, false);
|
||||||
|
Copy(zgPivots, dest, false);
|
||||||
|
Copy(sarPivots, dest, false);
|
||||||
|
|
||||||
//
|
//
|
||||||
int count = 0;
|
// Apply Direction Filtering ...
|
||||||
XBoxZone tmpBox;
|
if (HasDirection(forDir))
|
||||||
|
|
||||||
//
|
|
||||||
// Check Analysis ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// XPV ...
|
|
||||||
has = pvAnalysis.IsValid();
|
|
||||||
if (has)
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Support ...
|
XPivot tmps[];
|
||||||
tmpBox.Clean();
|
ExtractByDirection(
|
||||||
has = pvAnalysis.HasSupportBox(tmpBox);
|
tmps,
|
||||||
if (has && canCollectBullish)
|
dest,
|
||||||
{
|
forDir //
|
||||||
//
|
);
|
||||||
AddIfNotExists(
|
XClean(dest);
|
||||||
tmpBox,
|
Copy(tmps, dest);
|
||||||
dest //
|
XClean(tmps);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Resistance ...
|
|
||||||
tmpBox.Clean();
|
|
||||||
has = pvAnalysis.HasResistanceBox(tmpBox);
|
|
||||||
if (has && canCollectBearish)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
AddIfNotExists(
|
|
||||||
tmpBox,
|
|
||||||
dest //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// XZG ...
|
// Contains Pattern Pivots ...
|
||||||
has = zgAnalysis.IsValid();
|
if (containsPatterns && HasChild(dest) && HasChild(barsAnalysis))
|
||||||
if (has)
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Support ...
|
XPivot tmp;
|
||||||
tmpBox.Clean();
|
int idx = -1;
|
||||||
has = zgAnalysis.HasSupportBox(tmpBox);
|
XPivot tmps[];
|
||||||
if (has && canCollectBullish)
|
XPivot sames[];
|
||||||
{
|
XPivot patterns[];
|
||||||
//
|
Copy(dest, tmps);
|
||||||
AddIfNotExists(
|
XClean(dest);
|
||||||
tmpBox,
|
|
||||||
dest //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Resistance ...
|
while (HasChild(tmps))
|
||||||
tmpBox.Clean();
|
|
||||||
has = zgAnalysis.HasResistanceBox(tmpBox);
|
|
||||||
if (has && canCollectBearish)
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
AddIfNotExists(
|
tmp.Clean();
|
||||||
tmpBox,
|
tmp = tmps[0];
|
||||||
dest //
|
ArrayRemove(tmps, 0, 1);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// 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 //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Resistance ...
|
XClean(sames);
|
||||||
has = barsAnalysis[i].IsResistance();
|
ExtractSameTimePivots(tmp, sames, tmps);
|
||||||
if (has && canCollectBearish)
|
if (HasChild(sames))
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
AddIfNotExists(
|
has = FindByTime(idx, tmp.time, barsAnalysis);
|
||||||
barsAnalysis[i].resistance,
|
|
||||||
dest //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// OB ...
|
|
||||||
if (containsOB)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
has = barsAnalysis[i].IsOB();
|
|
||||||
if (has)
|
if (has)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
has = (canCollectBullish && barsAnalysis[i].ob.IsBullish()) ||
|
barsAnalysis[idx].GetPatterns(patterns, sames[0].dir);
|
||||||
(canCollectBearish && barsAnalysis[i].ob.IsBearish());
|
Copy(patterns, dest, false);
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
AddIfNotExists(
|
|
||||||
barsAnalysis[i].ob,
|
|
||||||
dest //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// FVG ...
|
Copy(sames, dest, false);
|
||||||
if (containsFVG)
|
Removes(sames, tmps);
|
||||||
{
|
|
||||||
has = barsAnalysis[i].IsFVG();
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
has = (canCollectBullish && barsAnalysis[i].fvg.IsBullish()) ||
|
|
||||||
(canCollectBearish && barsAnalysis[i].fvg.IsBearish());
|
|
||||||
if (has)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
AddIfNotExists(
|
|
||||||
barsAnalysis[i].fvg,
|
|
||||||
dest //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XClean(tmps);
|
||||||
|
XClean(sames);
|
||||||
|
XClean(patterns);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
result = ArraySize(dest);
|
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;
|
return result;
|
||||||
@@ -312,6 +283,9 @@ struct XFIMAMarketStructure
|
|||||||
//
|
//
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure How to Detect Market Structure ...
|
||||||
|
**/
|
||||||
struct XFIMAMarketStructureConfig
|
struct XFIMAMarketStructureConfig
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -321,12 +295,18 @@ struct XFIMAMarketStructureConfig
|
|||||||
// Detector Flags ...
|
// Detector Flags ...
|
||||||
|
|
||||||
//
|
//
|
||||||
bool analysePVPivots; // Analyse PV Pivots ...
|
bool analysePVPivots; // Analyse PV Pivots ...
|
||||||
bool analyseZGPivots; // Analyse ZG 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 analyseBarPatterns; // Analyse Bar Patterns ...
|
||||||
|
|
||||||
|
//
|
||||||
|
bool detectOrderFlow; // Detect Order Flow ...
|
||||||
|
|
||||||
//
|
//
|
||||||
// Detector Configs ...
|
// Detector Configs ...
|
||||||
|
|
||||||
@@ -335,8 +315,10 @@ struct XFIMAMarketStructureConfig
|
|||||||
int requiredPivots; // Required Extracted Pivots for Analysis ...
|
int requiredPivots; // Required Extracted Pivots for Analysis ...
|
||||||
|
|
||||||
//
|
//
|
||||||
int pvPivotsValidationLength; // PV Pivots Validation Length ...
|
int orderFlowValidation; // Order Flow Sequential Validation ...
|
||||||
double maCrossValidationDiffMultiplier; // a Point Distance to Validate MA Crosses ...
|
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 ...
|
XPatternAnalysisConfig barsAnalysisConfig; // Bars Analyser Config ...
|
||||||
@@ -358,16 +340,24 @@ struct XFIMAMarketStructureConfig
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Detector Flags ...
|
// Detector Flags ...
|
||||||
|
detectOrderFlow = false;
|
||||||
analysePVPivots = false;
|
analysePVPivots = false;
|
||||||
analyseZGPivots = false;
|
analyseZGPivots = false;
|
||||||
|
analyseHKPivots = false;
|
||||||
|
analyseMAPivots = false;
|
||||||
|
analyseSARPivots = false;
|
||||||
analyseBarPatterns = false;
|
analyseBarPatterns = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Configure Detectors ...
|
// Configure Detectors ...
|
||||||
loopback = 0;
|
loopback = 0;
|
||||||
requiredPivots = 0;
|
requiredPivots = 0;
|
||||||
pvPivotsValidationLength = 0;
|
|
||||||
maCrossValidationDiffMultiplier = 0;
|
//
|
||||||
|
orderFlowValidation = 0;
|
||||||
|
orderFlowUseOB = false;
|
||||||
|
orderFlowUseFVG = false;
|
||||||
|
orderFlowUseSupportAndResistance = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
barsAnalysisConfig.Clean();
|
barsAnalysisConfig.Clean();
|
||||||
@@ -383,20 +373,32 @@ struct XFIMAMarketStructureConfig
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Detector Flags ...
|
// Detector Flags ...
|
||||||
|
detectOrderFlow = true;
|
||||||
analysePVPivots = true;
|
analysePVPivots = true;
|
||||||
analyseZGPivots = true;
|
analyseZGPivots = true;
|
||||||
|
analyseHKPivots = true;
|
||||||
|
analyseMAPivots = true;
|
||||||
|
analyseSARPivots = true;
|
||||||
analyseBarPatterns = true;
|
analyseBarPatterns = true;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Configure Detectors ...
|
// Configure Detectors ...
|
||||||
loopback = 200;
|
loopback = 200;
|
||||||
requiredPivots = 10;
|
requiredPivots = 10;
|
||||||
pvPivotsValidationLength = 5;
|
|
||||||
maCrossValidationDiffMultiplier = 4;
|
//
|
||||||
|
orderFlowValidation = 2;
|
||||||
|
orderFlowUseOB = false;
|
||||||
|
orderFlowUseFVG = true;
|
||||||
|
orderFlowUseSupportAndResistance = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
barsAnalysisConfig.Default();
|
barsAnalysisConfig.Default();
|
||||||
barsAnalysisConfig.FullPattern();
|
barsAnalysisConfig.FullPattern();
|
||||||
|
|
||||||
|
//
|
||||||
|
barsAnalysisConfig.supportAndResistanceLoopbackLength = 5;
|
||||||
|
barsAnalysisConfig.supportAndResistanceValidationLength = 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -406,8 +408,12 @@ struct XFIMAMarketStructureConfig
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Detector Flags ...
|
// Detector Flags ...
|
||||||
|
detectOrderFlow = false;
|
||||||
analysePVPivots = false;
|
analysePVPivots = false;
|
||||||
analyseZGPivots = false;
|
analyseZGPivots = false;
|
||||||
|
analyseHKPivots = false;
|
||||||
|
analyseMAPivots = false;
|
||||||
|
analyseSARPivots = false;
|
||||||
analyseBarPatterns = false;
|
analyseBarPatterns = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,8 +424,12 @@ struct XFIMAMarketStructureConfig
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Detector Flags ...
|
// Detector Flags ...
|
||||||
|
detectOrderFlow = true;
|
||||||
analysePVPivots = true;
|
analysePVPivots = true;
|
||||||
analyseZGPivots = true;
|
analyseZGPivots = true;
|
||||||
|
analyseHKPivots = true;
|
||||||
|
analyseMAPivots = true;
|
||||||
|
analyseSARPivots = true;
|
||||||
analyseBarPatterns = true;
|
analyseBarPatterns = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,6 +447,9 @@ struct XFIMAMarketStructureDrawerConfig
|
|||||||
//
|
//
|
||||||
bool drawPVAnalysis;
|
bool drawPVAnalysis;
|
||||||
bool drawZGAnalysis;
|
bool drawZGAnalysis;
|
||||||
|
bool drawMAAnalysis;
|
||||||
|
bool drawHKAnalysis;
|
||||||
|
bool drawSARAnalysis;
|
||||||
bool drawBarsAnalysis;
|
bool drawBarsAnalysis;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -465,6 +478,9 @@ struct XFIMAMarketStructureDrawerConfig
|
|||||||
//
|
//
|
||||||
drawPVAnalysis = false;
|
drawPVAnalysis = false;
|
||||||
drawZGAnalysis = false;
|
drawZGAnalysis = false;
|
||||||
|
drawMAAnalysis = false;
|
||||||
|
drawHKAnalysis = false;
|
||||||
|
drawSARAnalysis = false;
|
||||||
drawBarsAnalysis = false;
|
drawBarsAnalysis = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -488,6 +504,9 @@ struct XFIMAMarketStructureDrawerConfig
|
|||||||
//
|
//
|
||||||
drawPVAnalysis = true;
|
drawPVAnalysis = true;
|
||||||
drawZGAnalysis = true;
|
drawZGAnalysis = true;
|
||||||
|
drawMAAnalysis = true;
|
||||||
|
drawHKAnalysis = true;
|
||||||
|
drawSARAnalysis = true;
|
||||||
drawBarsAnalysis = true;
|
drawBarsAnalysis = true;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -518,6 +537,9 @@ struct XFIMAMarketStructureDrawerConfig
|
|||||||
//
|
//
|
||||||
drawPVAnalysis = false;
|
drawPVAnalysis = false;
|
||||||
drawZGAnalysis = false;
|
drawZGAnalysis = false;
|
||||||
|
drawMAAnalysis = false;
|
||||||
|
drawHKAnalysis = false;
|
||||||
|
drawSARAnalysis = false;
|
||||||
drawBarsAnalysis = false;
|
drawBarsAnalysis = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -535,9 +557,12 @@ struct XFIMAMarketStructureDrawerConfig
|
|||||||
// Drawing Flags ...
|
// Drawing Flags ...
|
||||||
|
|
||||||
//
|
//
|
||||||
drawPVAnalysis = false;
|
drawPVAnalysis = true;
|
||||||
drawZGAnalysis = false;
|
drawZGAnalysis = true;
|
||||||
drawBarsAnalysis = false;
|
drawMAAnalysis = true;
|
||||||
|
drawHKAnalysis = true;
|
||||||
|
drawSARAnalysis = true;
|
||||||
|
drawBarsAnalysis = true;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Drawing Configs ...
|
// Drawing Configs ...
|
||||||
|
|||||||
Reference in New Issue
Block a user