last works on Detecting Pivots ...

- Pivots Detection works Fine;
- Analyse Pivots Has some issues and i have to Fix them ...
This commit is contained in:
2025-09-23 16:36:53 +03:30
parent 1a948307f2
commit 3812246e5c
9 changed files with 1934 additions and 143 deletions
+245 -1
View File
@@ -1458,13 +1458,21 @@ class XCPivotAnalysisObject : public XCBaseObject
* @param chart_id: Long, Specified Chart ID ... * @param chart_id: Long, Specified Chart ID ...
* @param window: Integer, Specified Chart Window ID ... * @param window: Integer, Specified Chart Window ID ...
* @param model: XPivotAnalysis, reference model ... * @param model: XPivotAnalysis, reference model ...
* @param drawPivots: Specified to Draw Pivots or not ...
* @param peakArrow: int, Specified Arrow Code for Peak Pivots ...
* @param valeArrow: int, Specified Arrow Code for Vale Pivots ...
* @param threshold: int, distance between price and arrow in Point ...
* *
* @return ( bool ) * @return ( bool )
*/ */
bool Create( bool Create(
long chart_id, long chart_id,
int window, int window,
XPivotAnalysis &model // XPivotAnalysis &model,
bool drawPivots = true,
int peakArrow = 159,
int valeArrow = 159,
int threshold = 5 //
) )
{ {
// //
@@ -1562,6 +1570,70 @@ class XCPivotAnalysisObject : public XCBaseObject
); );
} }
//
// Draw Pivots ...
if (drawPivots &&
model.HasPivots())
{
//
XOHCL iBar;
int arrow = 0;
bool has = false;
string name = NULL;
XCBarArrowObject *iObj;
ENUM_X_PRICE type = X_PRICE_NONE;
int pivotsCount = ArraySize(model.pivots);
for (int i = 0; i < pivotsCount; i++)
{
//
has = model.pivots[i].GetBar(iBar);
if (!has)
{
continue;
}
//
arrow = model.pivots[i].IsPeak()
? peakArrow
: valeArrow;
name = model.pivots[i].GetObjectID();
type = model.pivots[i].IsPeak()
? X_PRICE_HIGH
: X_PRICE_LOW;
iObj = new XCBarArrowObject();
has = iObj.CreateByBar(
chart_id,
name,
window,
arrow,
iBar,
type,
threshold //
);
if (has)
{
//
if (model.pivots[i].IsPeak())
{
mPeaks.Add(iObj);
}
else
{
mVales.Add(iObj);
}
}
//
iBar.Clean();
ZeroMemory(iObj);
}
//
// Cleanup Resources ...
iBar.Clean();
ZeroMemory(iObj);
}
// //
// Setting Object Name ... // Setting Object Name ...
if (result) if (result)
@@ -1821,9 +1893,181 @@ class XCPivotAnalysisObject : public XCBaseObject
mResistanceBox.Style(value); mResistanceBox.Style(value);
} }
/**
* Set Width ...
*
* @param value: Integer ...
*/
void PeaksWidth(int value)
{
//
// Normalize ...
value = NormalizeInt(value, 1);
//
// Validate ...
int count = mPeaks.Total();
bool has = IsValidSize(count);
if (!has)
{
return;
}
//
XCBarArrowObject *iPeak;
for (int i = 0; i < count; i++)
{
//
iPeak = (XCBarArrowObject *)mPeaks.At(i);
iPeak.ArrowWidth(value);
ZeroMemory(iPeak);
}
}
/**
* Set Color ...
*
* @param value: Color ...
*/
void PeaksColor(color value)
{
//
// Validate ...
int count = mPeaks.Total();
bool has = IsValidSize(count);
if (!has)
{
return;
}
//
XCBarArrowObject *iPeak;
for (int i = 0; i < count; i++)
{
//
iPeak = (XCBarArrowObject *)mPeaks.At(i);
iPeak.ArrowColor(value);
ZeroMemory(iPeak);
}
}
/**
* Set Arrow Anchor ...
*
* @param value: ENUM_ARROW_ANCHOR member ...
*/
void PeaksAnchor(ENUM_ARROW_ANCHOR value)
{
//
// Validate ...
int count = mPeaks.Total();
bool has = IsValidSize(count);
if (!has)
{
return;
}
//
XCBarArrowObject *iPeak;
for (int i = 0; i < count; i++)
{
//
iPeak = (XCBarArrowObject *)mPeaks.At(i);
iPeak.ArrowAnchor(value);
ZeroMemory(iPeak);
}
}
/**
* Set Width ...
*
* @param value: Integer ...
*/
void ValesWidth(int value)
{
//
// Normalize ...
value = NormalizeInt(value, 1);
//
// Validate ...
int count = mVales.Total();
bool has = IsValidSize(count);
if (!has)
{
return;
}
//
XCBarArrowObject *iVale;
for (int i = 0; i < count; i++)
{
//
iVale = (XCBarArrowObject *)mVales.At(i);
iVale.ArrowWidth(value);
ZeroMemory(iVale);
}
}
/**
* Set Color ...
*
* @param value: Color ...
*/
void ValesColor(color value)
{
//
// Validate ...
int count = mVales.Total();
bool has = IsValidSize(count);
if (!has)
{
return;
}
//
XCBarArrowObject *iVale;
for (int i = 0; i < count; i++)
{
//
iVale = (XCBarArrowObject *)mVales.At(i);
iVale.ArrowColor(value);
ZeroMemory(iVale);
}
}
/**
* Set Arrow Anchor ...
*
* @param value: ENUM_ARROW_ANCHOR member ...
*/
void ValesAnchor(ENUM_ARROW_ANCHOR value)
{
//
// Validate ...
int count = mVales.Total();
bool has = IsValidSize(count);
if (!has)
{
return;
}
//
XCBarArrowObject *iVale;
for (int i = 0; i < count; i++)
{
//
iVale = (XCBarArrowObject *)mVales.At(i);
iVale.ArrowAnchor(value);
ZeroMemory(iVale);
}
}
// //
private: private:
// //
CArrayObj mPeaks;
CArrayObj mVales;
CChartObjectTrend mUpper; CChartObjectTrend mUpper;
CChartObjectTrend mLower; CChartObjectTrend mLower;
XCBoxObject *mSupportBox; XCBoxObject *mSupportBox;
+98 -5
View File
@@ -397,8 +397,8 @@ class XCPOIDrawer : public XCBase
? X_PRICE_HIGH ? X_PRICE_HIGH
: X_PRICE_LOW; : X_PRICE_LOW;
XPOIStyle style = pivot.IsPeak() XPOIStyle style = pivot.IsPeak()
? defaultBullishStyle ? defaultBearishStyle
: defaultBearishStyle; : defaultBullishStyle;
ENUM_ARROW_ANCHOR anchor = pivot.IsPeak() ENUM_ARROW_ANCHOR anchor = pivot.IsPeak()
? ANCHOR_BOTTOM ? ANCHOR_BOTTOM
: ANCHOR_TOP; : ANCHOR_TOP;
@@ -431,6 +431,72 @@ class XCPOIDrawer : public XCBase
return result; return result;
} }
/**
* Draw Specified Pivot Collection ...
*
* @param pivots: XPivot, reference Collection to Draw ...
* @param draws: CArrayObj, pointer reference to Hold Drawn Objects ...
* @param peakArrow: int, Specified Arrow Code for Peak Pivots ...
* @param valeArrow: int, Specified Arrow Code for Vale Pivots ...
* @param threshold: int, distance between price and arrow in Point ...
*
* @return ( int )
*/
int DrawPivots(
XPivot &pivots[],
CArrayObj *&draws,
int peakArrow = 159,
int valeArrow = 159,
int threshold = 5 //
)
{
//
int result = 0;
//
// Prepare ...
draws.Clear();
//
// Validate ...
if (!HasChild(pivots))
{
return result;
}
//
bool has = false;
XCBarArrowObject *iObj;
int count = ArraySize(pivots);
for (int i = 0; i < count; i++)
{
//
// Draw Indexed Pivot ...
has = DrawPivot(
pivots[i],
iObj,
peakArrow,
valeArrow,
threshold //
);
//
if (has)
{
draws.Add(iObj);
}
//
ZeroMemory(iObj);
}
//
result = draws.Total();
//
return result;
}
/** /**
* Draw Specified Box ... * Draw Specified Box ...
* *
@@ -811,12 +877,21 @@ class XCPOIDrawer : public XCBase
* Draw Pivot Analysis ... * Draw Pivot Analysis ...
* *
* @param analysis: XPivotAnalysis, referece Specified Pivot Analysis ... * @param analysis: XPivotAnalysis, referece Specified Pivot Analysis ...
* @param object: XCPivotAnalysisObject, pointer reference for Drawn Object ...
* @param drawPivots: Specified to Draw Pivots or not ...
* @param peakArrow: int, Specified Arrow Code for Peak Pivots ...
* @param valeArrow: int, Specified Arrow Code for Vale Pivots ...
* @param threshold: int, distance between price and arrow in Point ...
* *
* @return ( bool ) * @return ( bool )
*/ */
bool DrawXPivotAnalysis( bool DrawPivotAnalysis(
XPivotAnalysis &analysis, XPivotAnalysis &analysis,
XCPivotAnalysisObject *&object // XCPivotAnalysisObject *&object,
bool drawPivots = true,
int peakArrow = 159,
int valeArrow = 159,
int threshold = 5 //
) )
{ {
// //
@@ -843,7 +918,11 @@ class XCPOIDrawer : public XCBase
result = object.Create( result = object.Create(
ChartIdentification(), ChartIdentification(),
SubWindowIdentification(), SubWindowIdentification(),
analysis // analysis,
drawPivots,
peakArrow,
valeArrow,
threshold //
); );
if (result) if (result)
{ {
@@ -1263,6 +1342,20 @@ class XCPOIDrawer : public XCBase
object.LowerRayRight(true); object.LowerRayRight(true);
} }
//
// Peak Pivots ...
style = defaultBearishStyle;
object.PeaksColor(style.clr);
object.PeaksWidth(style.width);
object.PeaksAnchor(ANCHOR_BOTTOM);
//
// Vale Pivots ...
style = defaultBullishStyle;
object.ValesColor(style.clr);
object.ValesWidth(style.width);
object.ValesAnchor(ANCHOR_TOP);
// //
style.Clean(); style.Clean();
} }
+273 -24
View File
@@ -147,8 +147,8 @@ XCXFIMAStrategy1Signaller *fima1Signaller; // XFIMA1 Signaller ...
XCXFIMAStrategy2Signaller *fima2Signaller; // XFIMA2 Signaller ... XCXFIMAStrategy2Signaller *fima2Signaller; // XFIMA2 Signaller ...
// //
// Drawer and Draws ... // Drawer and eaDraws ...
CArrayObj draws; // Drawn Objects ... CArrayObj eaDraws; // Drawn Objects ...
// //
XBarTracker eaBarTracker; // EA Bar Traker ... XBarTracker eaBarTracker; // EA Bar Traker ...
@@ -258,6 +258,7 @@ int OnInit()
// This is Default Configuration ... // This is Default Configuration ...
fimaInputs.Default(); fimaInputs.Default();
fimaInputs.Hide(); fimaInputs.Hide();
fimaInputs.showPV = true;
fimaInputs.showZigZag = true; fimaInputs.showZigZag = true;
// //
@@ -612,9 +613,9 @@ void OnSignalTriggered(XSignal &signal)
// //
bool has = iObj.Create( bool has = iObj.Create(
fima2Signaller.fimaPOIDrawer.ChartIdentification(), fima2Signaller.poiDrawer.ChartIdentification(),
iName, iName,
fima2Signaller.fimaPOIDrawer.SubWindowIdentification(), fima2Signaller.poiDrawer.SubWindowIdentification(),
signal.time // signal.time //
); );
if (has) if (has)
@@ -624,7 +625,7 @@ void OnSignalTriggered(XSignal &signal)
iObj.Color(iColor); iObj.Color(iColor);
// //
draws.Add(iObj); eaDraws.Add(iObj);
} }
// //
@@ -815,13 +816,23 @@ void DetectPatterns()
// //
// XFIMA Patetrns ... // XFIMA Patetrns ...
bool detectFIMAPatterns = true; bool detectFIMAPatterns = true;
//
bool detectFIMAPVPatterns = false;
bool detectFIMAMAPatterns = false;
bool detectFIMASARPatterns = false;
bool detectFIMAZigZagPatterns = false;
//
bool analyseFIMAPVPivots = true;
bool analyseFIMAMAPivots = true;
bool analyseFIMASARPivots = true;
bool analyseFIMAZigZagPivots = true;
// //
// Checking Momentum Bar ... // Checking Momentum Bar ...
if (detectMomentum) if (detectMomentum)
{ {
// //
bool isMomentum = fima2Signaller.fimaPOIDetector.IsMomentumBar( bool isMomentum = fima2Signaller.poiDetector.IsMomentumBar(
cBar, cBar,
iDir // iDir //
); );
@@ -840,7 +851,7 @@ void DetectPatterns()
if (detectEngulfed) if (detectEngulfed)
{ {
// //
bool isEngulfed = fima2Signaller.fimaPOIDetector.IsEngulfedBar( bool isEngulfed = fima2Signaller.poiDetector.IsEngulfedBar(
cBar, cBar,
iDir // iDir //
); );
@@ -859,7 +870,7 @@ void DetectPatterns()
if (detectTrueGaped) if (detectTrueGaped)
{ {
// //
bool isTrueGaped = fima2Signaller.fimaPOIDetector.IsTrueGapedBar( bool isTrueGaped = fima2Signaller.poiDetector.IsTrueGapedBar(
cBar, cBar,
iDir // iDir //
); );
@@ -877,7 +888,7 @@ void DetectPatterns()
// Checking Pinned Bar ... // Checking Pinned Bar ...
if (detectPinned) if (detectPinned)
{ {
bool isPinned = fima2Signaller.fimaPOIDetector.IsPinnedBar( bool isPinned = fima2Signaller.poiDetector.IsPinnedBar(
cBar, cBar,
iDir // iDir //
); );
@@ -895,7 +906,7 @@ void DetectPatterns()
// Checking Star Pattern ... // Checking Star Pattern ...
if (detectStarPattern) if (detectStarPattern)
{ {
bool isStarPattern = fima2Signaller.fimaPOIDetector.IsStartPattern( bool isStarPattern = fima2Signaller.poiDetector.IsStartPattern(
cBar, cBar,
iDir // iDir //
); );
@@ -914,7 +925,7 @@ void DetectPatterns()
if (detectPiercingPattern) if (detectPiercingPattern)
{ {
// //
bool isPiercingPattern = fima2Signaller.fimaPOIDetector.IsPiercingPattern( bool isPiercingPattern = fima2Signaller.poiDetector.IsPiercingPattern(
cBar, cBar,
iDir // iDir //
); );
@@ -933,7 +944,7 @@ void DetectPatterns()
if (detectRisingPattern) if (detectRisingPattern)
{ {
// //
bool isRisingPattern = fima2Signaller.fimaPOIDetector.IsRisingPattern( bool isRisingPattern = fima2Signaller.poiDetector.IsRisingPattern(
cBar, cBar,
iDir // iDir //
); );
@@ -953,7 +964,7 @@ void DetectPatterns()
{ {
// //
XOHCL swingBar; XOHCL swingBar;
bool isFlagPattern = fima2Signaller.fimaPOIDetector.IsFlagPattern( bool isFlagPattern = fima2Signaller.poiDetector.IsFlagPattern(
cBar, cBar,
iDir, iDir,
swingBar // swingBar //
@@ -974,7 +985,7 @@ void DetectPatterns()
if (detectSignalKeyBarPattern) if (detectSignalKeyBarPattern)
{ {
// //
bool isSignalKeyBar = fima2Signaller.fimaPOIDetector.IsSignalKeyBarPattern( bool isSignalKeyBar = fima2Signaller.poiDetector.IsSignalKeyBarPattern(
cBar, cBar,
iDir // iDir //
); );
@@ -994,7 +1005,7 @@ void DetectPatterns()
{ {
// //
XOHCL swings[]; XOHCL swings[];
bool hasSwingTrend = fima2Signaller.fimaPOIDetector.HasSwingTrend( bool hasSwingTrend = fima2Signaller.poiDetector.HasSwingTrend(
cBar, cBar,
iDir, iDir,
swings // swings //
@@ -1010,7 +1021,7 @@ void DetectPatterns()
// //
CChartObjectTrend *iObj; CChartObjectTrend *iObj;
has = fima2Signaller.fimaPOIDrawer.DrawSwingTrend( has = fima2Signaller.poiDrawer.DrawSwingTrend(
swings, swings,
iDir, iDir,
iObj, iObj,
@@ -1018,7 +1029,7 @@ void DetectPatterns()
); );
if (has) if (has)
{ {
draws.Add(iObj); eaDraws.Add(iObj);
} }
} }
SpecifiedClean(swings); SpecifiedClean(swings);
@@ -1030,7 +1041,7 @@ void DetectPatterns()
{ {
// //
XOHCL swings[]; XOHCL swings[];
bool hasSwingTrend = fima2Signaller.fimaPOIDetector.HasSwingTrend( bool hasSwingTrend = fima2Signaller.poiDetector.HasSwingTrend(
cBar, cBar,
iDir, iDir,
swings // swings //
@@ -1067,7 +1078,7 @@ void DetectPatterns()
{ {
// //
XOHCL support; XOHCL support;
bool hasSupport = fima2Signaller.fimaPOIDetector.HasSupport( bool hasSupport = fima2Signaller.poiDetector.HasSupport(
cBar, cBar,
support // support //
); );
@@ -1081,13 +1092,13 @@ void DetectPatterns()
// //
// Draw Box ... // Draw Box ...
XCBoxObject *iObj; XCBoxObject *iObj;
has = fima2Signaller.fimaPOIDrawer.DrawBox( has = fima2Signaller.poiDrawer.DrawBox(
supportBox, supportBox,
iObj // iObj //
); );
if (has) if (has)
{ {
draws.Add(iObj); eaDraws.Add(iObj);
} }
// //
@@ -1106,7 +1117,7 @@ void DetectPatterns()
{ {
// //
XOHCL resistance; XOHCL resistance;
bool hasResistance = fima2Signaller.fimaPOIDetector.HasResistance( bool hasResistance = fima2Signaller.poiDetector.HasResistance(
cBar, cBar,
resistance // resistance //
); );
@@ -1120,13 +1131,13 @@ void DetectPatterns()
// //
// Draw Box ... // Draw Box ...
XCBoxObject *iObj; XCBoxObject *iObj;
has = fima2Signaller.fimaPOIDrawer.DrawBox( has = fima2Signaller.poiDrawer.DrawBox(
resistanceBox, resistanceBox,
iObj // iObj //
); );
if (has) if (has)
{ {
draws.Add(iObj); eaDraws.Add(iObj);
} }
// //
@@ -1143,6 +1154,244 @@ void DetectPatterns()
// Detecting FIMA Patterns ... // Detecting FIMA Patterns ...
if (detectFIMAPatterns) if (detectFIMAPatterns)
{ {
//
// Check For PV Pivots ...
if (detectFIMAPVPatterns)
{
//
XPivot pivots[];
int pivotsCount = fima2Signaller.poiDetector.ExtractPVPivots(
pivots, // Result ...
cBar.Index(), // Bar Index ...
50, // Required Number of Pivots ...
1500, // Max Allowed Loopback ...
10 // Validation Length ...
);
has = IsValidSize(pivotsCount);
if (has)
{
//
CArrayObj *drawnPivots = new CArrayObj();
int drawnPivotsCount = fima2Signaller.poiDrawer.DrawPivots(
pivots,
drawnPivots //
);
has = IsValidSize(drawnPivotsCount);
if (has)
{
//
AddObjects(
drawnPivots,
eaDraws //
);
//
Print("Pivots Extracted ...");
}
//
ZeroMemory(drawnPivots);
}
}
//
// Check for MA Patterns ...
if (detectFIMAMAPatterns)
{
//
XPivot pivots[];
int pivotsCount = fima2Signaller.poiDetector.ExtractMAPivots(
pivots, // Result ...
cBar.Index(), // Bar Index ...
50, // Required Number of Pivots ...
1500, // Max Allowed Loopback ...
0 // Validation Length ...
);
has = IsValidSize(pivotsCount);
if (has)
{
//
CArrayObj *drawnPivots = new CArrayObj();
int drawnPivotsCount = fima2Signaller.poiDrawer.DrawPivots(
pivots,
drawnPivots //
);
has = IsValidSize(drawnPivotsCount);
if (has)
{
//
AddObjects(
drawnPivots,
eaDraws //
);
//
Print("Pivots Extracted ...");
}
//
ZeroMemory(drawnPivots);
}
}
//
// Check for SAR Pivots ...
if (detectFIMASARPatterns)
{
//
XPivot pivots[];
int pivotsCount = fima2Signaller.poiDetector.ExtractSARPivots(
pivots, // Result ...
cBar.Index(), // Bar Index ...
50, // Required Number of Pivots ...
1500 // Max Allowed Loopback ...
);
has = IsValidSize(pivotsCount);
if (has)
{
//
CArrayObj *drawnPivots = new CArrayObj();
int drawnPivotsCount = fima2Signaller.poiDrawer.DrawPivots(
pivots,
drawnPivots //
);
has = IsValidSize(drawnPivotsCount);
if (has)
{
//
AddObjects(
drawnPivots,
eaDraws //
);
//
Print("Pivots Extracted ...");
}
//
ZeroMemory(drawnPivots);
}
}
//
// Check for ZigZag Pivots ...
if (detectFIMAZigZagPatterns)
{
//
XPivot pivots[];
int pivotsCount = fima2Signaller.poiDetector.ExtractZigZagPivots(
pivots,
0,
50,
1500 //
);
has = IsValidSize(pivotsCount);
if (has)
{
//
CArrayObj *drawnPivots = new CArrayObj();
int drawnPivotsCount = fima2Signaller.poiDrawer.DrawPivots(
pivots,
drawnPivots //
);
has = IsValidSize(drawnPivotsCount);
if (has)
{
//
AddObjects(
drawnPivots,
eaDraws //
);
//
Print("Pivots Extracted ...");
}
//
ZeroMemory(drawnPivots);
}
}
//
// Analysers ...
//
// Analyse Based on PV ...
if (analyseFIMAPVPivots && false)
{
//
XPivotAnalysis analysis;
has = fima2Signaller.poiDetector.AnalysePVPivots(
analysis, // Result ...
cBar.Index(), // Bar Index ...
50, // Required Number of Pivots ...
1500, // Max Allowed Loopback ...
10 // Validation Length ...
);
if (has)
{
//
// Draw Analysis ...
XCPivotAnalysisObject *iObj;
has = fima2Signaller.poiDrawer.DrawPivotAnalysis(
analysis,
iObj //
);
if (has)
{
//
eaDraws.Add(iObj);
//
Print("FIMA PV Pivots Analysed ...");
}
}
}
//
// Analyse Based on MA ...
if (analyseFIMAMAPivots)
{
}
//
// Analyse Based on SAR ...
if (analyseFIMASARPivots)
{
}
//
// Analyse Based on ZigZag ...
if (analyseFIMAZigZagPivots)
{
//
XPivotAnalysis analysis;
has = fima2Signaller.poiDetector.AnalyseZigZagPivots(
analysis, // Result ...
cBar.Index(), // Bar Index ...
50, // Required Number of Pivots ...
1500 // Max Allowed Loopback ...
);
if (has)
{
//
// Draw Analysis ...
XCPivotAnalysisObject *iObj;
has = fima2Signaller.poiDrawer.DrawPivotAnalysis(
analysis,
iObj,
true // Draw Pivots ...
);
if (has)
{
//
eaDraws.Add(iObj);
//
Print("FIMA ZigZag Pivots Analysed ...");
}
}
}
} }
// //
File diff suppressed because it is too large Load Diff
@@ -5218,7 +5218,8 @@ void AddIfNotExists(
void AddsIfNotExists( void AddsIfNotExists(
double &source[], double &source[],
double &dest[], double &dest[],
double smoothingPoint = 3) double smoothingPoint = 3 //
)
{ {
// //
double smoothingValue = smoothingPoint * GetPoints(_Symbol); double smoothingValue = smoothingPoint * GetPoints(_Symbol);
@@ -674,7 +674,7 @@ struct XPivotAnalysis
// //
NotEmpty(peakTo) && NotEmpty(peakTo) &&
NotEmpty(peakFrom) && NotEmpty(peakFrom) &&
HasDirection(peakDir) && // HasDirection(peakDir) &&
IsSpecifiedValid(toTime) && IsSpecifiedValid(toTime) &&
IsSpecifiedValid(fromTime) IsSpecifiedValid(fromTime)
// //
@@ -702,7 +702,7 @@ struct XPivotAnalysis
// //
NotEmpty(valeTo) && NotEmpty(valeTo) &&
NotEmpty(valeFrom) && NotEmpty(valeFrom) &&
HasDirection(valeDir) && // HasDirection(valeDir) &&
IsSpecifiedValid(toTime) && IsSpecifiedValid(toTime) &&
IsSpecifiedValid(fromTime) IsSpecifiedValid(fromTime)
// //
-95
View File
@@ -239,101 +239,6 @@ struct XPivot
return result; return result;
} }
/**
* Check Structure Exists in Specified Collection or not ...
*
* @param items: XPivot, reference Array ...
* @param index: int, reference to Holds Founded Index ...
*
* @return ( bool )
*/
bool IsExists(
XPivot &items[],
int &index //
)
{
//
bool result = false;
//
// Prepare ...
index = -1;
//
// Validate ...
result =
IsValid() &&
HasChild(items);
if (!result)
{
return result;
}
//
int count = ArraySize(items);
for (int i = 0; i < count; i++)
{
//
result = IsSameAs(items[i]);
if (result)
{
//
index = i;
//
break;
}
}
//
result =
result &&
IsValidIndex(index);
//
return result;
}
/**
* Add Structure to Specified Collection only if not Exists ...
*
* @param items: XPivot, reference Array ...
*/
void AddIfNotExists(XPivot &items[])
{
//
// Validate ...
if (!IsValid())
{
return;
}
//
if (!HasChild(items))
{
//
AddRef(
this,
items //
);
//
return;
}
//
int index = -1;
bool isExists = IsExists(items, index);
if (!isExists)
{
//
AddRef(
this,
items //
);
}
}
/** /**
* Calculate Pivot Age ... * Calculate Pivot Age ...
* *
@@ -43,8 +43,8 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
// //
XFIMAInputs fimaInputs; // XFIMA Inputs ... XFIMAInputs fimaInputs; // XFIMA Inputs ...
XCXFIMAHelper *fimaHelper; // XFIMA Indicator Helper ... XCXFIMAHelper *fimaHelper; // XFIMA Indicator Helper ...
XCXFIMAPOIDrawer *fimaPOIDrawer; // XFIMA POI Drawer ... XCXFIMAPOIDrawer *poiDrawer; // XFIMA POI Drawer ...
XCXFIMAPOIDetector *fimaPOIDetector; // XFIMA POI Detector ... XCXFIMAPOIDetector *poiDetector; // XFIMA POI Detector ...
// //
// Constructor ... // Constructor ...
@@ -90,8 +90,8 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
} }
// //
fimaPOIDrawer = new XCXFIMAPOIDrawer(); poiDrawer = new XCXFIMAPOIDrawer();
fimaPOIDetector = new XCXFIMAPOIDetector(); poiDetector = new XCXFIMAPOIDetector(fimaHelper);
} }
// //
@@ -123,12 +123,12 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
ZeroMemory(fimaHelper); ZeroMemory(fimaHelper);
// //
delete fimaPOIDrawer; delete poiDrawer;
ZeroMemory(fimaPOIDrawer); ZeroMemory(poiDrawer);
// //
delete fimaPOIDetector; delete poiDetector;
ZeroMemory(fimaPOIDetector); ZeroMemory(poiDetector);
} }
// //
@@ -199,7 +199,7 @@ class XCXFIMABaseSignaller : public XCBaseSignaller
// Validate Fima Helper Requirements ... // Validate Fima Helper Requirements ...
result = fimaInputs.IsValid() && result = fimaInputs.IsValid() &&
fimaHelper != NULL && fimaHelper != NULL &&
fimaPOIDetector != NULL; poiDetector != NULL;
// //
return result; return result;
@@ -36,14 +36,18 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
public: public:
// //
// Props ... // Props ...
XCBarAnalyser *barAnalyser; // Bar Analyser ... XCBarAnalyser *barAnalyser; // Bar Analyser ...
XCXFIMAHelper *fimaHelper; // XFIMA Helper ...
// //
// Constructor ... // Constructor ...
XCXFIMAPOIDetector() XCXFIMAPOIDetector(
XCXFIMAHelper *_fimaHelper //
) : XCMarketPatternDetector()
{ {
// //
barAnalyser = new XCBarAnalyser(); barAnalyser = new XCBarAnalyser();
fimaHelper = _fimaHelper;
} }
// //
@@ -57,7 +61,279 @@ class XCXFIMAPOIDetector : public XCMarketPatternDetector
// Actions and Tools ... // Actions and Tools ...
// //
// 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 = 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 ...
*
* @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 = 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;
}
//
// Pivot Extractors ...
/**
* Extract Specified Kind of Pivots ...
*
* @param pivots: XPivot, refrence Collection to hold Extracted pivots ...
* @param barIndex: int, Specified 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 ( int )
*/
int ExtractPVPivots(
XPivot &pivots[],
int barIndex = 0,
int requiredNumberOFPivots = 50,
int maxAllowedLoopbackLength = 1500,
int validationLength = 0 //
)
{
//
int result = 0;
//
result = fimaHelper.ExtractPVPivots(
pivots,
barIndex,
requiredNumberOFPivots,
maxAllowedLoopbackLength,
validationLength //
);
//
return result;
}
/**
* Extract Specified Kind of Pivots ...
*
* @param pivots: XPivot, refrence Collection to hold Extracted pivots ...
* @param barIndex: int, Specified 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 ( int )
*/
int ExtractMAPivots(
XPivot &pivots[],
int barIndex = 0,
int requiredNumberOFPivots = 50,
int maxAllowedLoopbackLength = 1500,
int validationLength = 0 //
)
{
//
int result = 0;
//
result = fimaHelper.ExtractMAPivots(
pivots,
barIndex,
requiredNumberOFPivots,
maxAllowedLoopbackLength,
validationLength //
);
//
return result;
}
/**
* Extract Specified Kind of Pivots ...
*
* @param pivots: XPivot, refrence Collection to hold Extracted pivots ...
* @param barIndex: int, Specified Bar Index ...
* @param requiredNumberOFPivots: int, Specified which Number of Pivots must be Extracted ...
* @param maxAllowedLoopbackLength: int, Specified Maximum Loopback Length for Pivot Extraction ...
*
* @return ( int )
*/
int ExtractSARPivots(
XPivot &pivots[],
int barIndex = 0,
int requiredNumberOFPivots = 50,
int maxAllowedLoopbackLength = 1500 //
)
{
//
int result = 0;
//
result = fimaHelper.ExtractSARPivots(
pivots,
barIndex,
requiredNumberOFPivots,
maxAllowedLoopbackLength //
);
//
return result;
}
/**
* Extract Specified Kind of Pivots ...
*
* @param pivots: XPivot, refrence Collection to hold Extracted pivots ...
* @param barIndex: int, Specified Bar Index ...
* @param requiredNumberOFPivots: int, Specified which Number of Pivots must be Extracted ...
* @param maxAllowedLoopbackLength: int, Specified Maximum Loopback Length for Pivot Extraction ...
*
* @return ( int )
*/
int ExtractZigZagPivots(
XPivot &pivots[],
int barIndex = 0,
int requiredNumberOFPivots = 50,
int maxAllowedLoopbackLength = 1500 //
)
{
//
int result = 0;
//
result = fimaHelper.ExtractZigZagPivots(
pivots,
barIndex,
requiredNumberOFPivots,
maxAllowedLoopbackLength //
);
//
return result;
}
/** /**
* Destroy ... * Destroy ...