last works on major/minor Support and Resistances in Pattern Detector Class ...
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -74,6 +74,56 @@ int GetOldest(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Oldest Index of Specified Collection ...
|
||||
*
|
||||
* @param source: Specified Collection ...
|
||||
* @param forDir: ENUM_X_DIRECTION, Specified Direction ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int GetOldestByDir(
|
||||
XBoxZone &source[],
|
||||
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone selected;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
bool canSet =
|
||||
(!HasDirection(forDir)
|
||||
? true
|
||||
: forDir == source[i].dir) &&
|
||||
(!selected.IsValid()
|
||||
? true
|
||||
: selected.from > source[i].from);
|
||||
if (canSet)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
selected = source[i];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
selected.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Oldest Index of Specified Collection ...
|
||||
*
|
||||
@@ -253,6 +303,56 @@ int GetYoungest(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Youngest Index of Specified Collection ...
|
||||
*
|
||||
* @param source: Specified Collection ...
|
||||
* @param forDir: ENUM_X_DIRECTION, Specified Direction ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int GetYoungestByDir(
|
||||
XBoxZone &source[],
|
||||
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone selected;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
bool canSet =
|
||||
(!HasDirection(forDir)
|
||||
? true
|
||||
: forDir == source[i].dir) &&
|
||||
(!selected.IsValid()
|
||||
? true
|
||||
: selected.from < source[i].from);
|
||||
if (canSet)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
selected = source[i];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
selected.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Youngest Index of Specified Collection ...
|
||||
*
|
||||
@@ -432,6 +532,56 @@ int GetHighest(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Highest Index of Specified Collection ...
|
||||
*
|
||||
* @param source: Specified Collection ...
|
||||
* @param forDir: ENUM_X_DIRECTION, Specified Direction ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int GetHighestByDir(
|
||||
XBoxZone &source[],
|
||||
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone selected;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
bool canSet =
|
||||
(!HasDirection(forDir)
|
||||
? true
|
||||
: forDir == source[i].dir) &&
|
||||
(!selected.IsValid()
|
||||
? true
|
||||
: selected.upper < source[i].upper);
|
||||
if (canSet)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
selected = source[i];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
selected.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Highest Index of Specified Collection ...
|
||||
*
|
||||
@@ -627,6 +777,62 @@ int GetLowest(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Lowest Index of Specified Collection ...
|
||||
*
|
||||
* @param source: Specified Collection ...
|
||||
* @param forDir: ENUM_X_DIRECTION, Specified Direction ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int GetLowestByDir(
|
||||
XBoxZone &source[],
|
||||
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
int count = ArraySize(source);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone selected;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
//
|
||||
XBoxZone iBox = source[i];
|
||||
|
||||
//
|
||||
bool canSet =
|
||||
(!HasDirection(forDir)
|
||||
? true
|
||||
: forDir == source[i].dir) &&
|
||||
(!selected.IsValid()
|
||||
? true
|
||||
: selected.lower > iBox.lower);
|
||||
if (canSet)
|
||||
{
|
||||
//
|
||||
result = i;
|
||||
selected = iBox;
|
||||
}
|
||||
|
||||
//
|
||||
iBox.Clean();
|
||||
}
|
||||
|
||||
//
|
||||
selected.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Lowest Index of Specified Collection ...
|
||||
*
|
||||
@@ -4566,6 +4772,59 @@ bool ToResistanceBox(
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove Breaked Zones from a Collection ...
|
||||
*
|
||||
* @param source: XBoxZone, reference to Specified Collection ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int RemoveBreakedZones(XBoxZone &source[])
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool has = HasChild(source);
|
||||
if (!has)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XBoxZone iZone;
|
||||
XBoxZone tmps[];
|
||||
Copy(
|
||||
source,
|
||||
tmps //
|
||||
);
|
||||
XClean(source);
|
||||
while (HasChild(tmps))
|
||||
{
|
||||
//
|
||||
iZone.Clean();
|
||||
iZone = tmps[0];
|
||||
ArrayRemove(tmps, 0, 1);
|
||||
has = iZone.IsValid() &&
|
||||
!IsXValid(iZone.breakAt);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
AddIfNotExists(
|
||||
iZone,
|
||||
source //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(source);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Zone is Breaked by Specified Bar or not ...
|
||||
*
|
||||
@@ -4957,12 +5216,12 @@ bool HasInside(
|
||||
|
||||
/**
|
||||
* Extract Affected Zones for Specified Bar ...
|
||||
*
|
||||
*
|
||||
* @param bar: XOHCL, reference to Specified Bar ...
|
||||
* @param source: XBoxZone, reference collection to Provide Data Source ...
|
||||
* @param dest: XBoxZone, reference collection to holds result ...
|
||||
* @param forDir: ENUM_X_DIRECTION, Specified Zones Direction to Lookup ...
|
||||
*
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int ExtractAffectedZones(
|
||||
|
||||
@@ -804,6 +804,7 @@ struct XBoxZone
|
||||
datetime acteds[];
|
||||
datetime breaks[];
|
||||
datetime insides[];
|
||||
datetime refines[];
|
||||
datetime fakeBreaks[];
|
||||
|
||||
//
|
||||
@@ -849,6 +850,7 @@ struct XBoxZone
|
||||
XClean(acteds);
|
||||
XClean(breaks);
|
||||
XClean(insides);
|
||||
XClean(refines);
|
||||
XClean(fakeBreaks);
|
||||
}
|
||||
|
||||
|
||||
@@ -348,6 +348,187 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Manage Zones of Pattern Detector ...
|
||||
ENUM_X_DETECTOR_ZONE_ACTION zoneActions[];
|
||||
int zoneActionsCount = poiDetector.UpdateZones(
|
||||
iBar,
|
||||
zoneActions,
|
||||
3, // Validation Length ...
|
||||
20, // Required Zones ...
|
||||
1500 // Loopback ...
|
||||
);
|
||||
has = IsValidSize(zoneActionsCount);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
// Sample Draws ...
|
||||
|
||||
//
|
||||
// Support ...
|
||||
if (poiDetector.majorSupport.IsValid())
|
||||
{
|
||||
//
|
||||
XPOIDrawConfig iConfig = structureDrawConfig.drawConfig;
|
||||
iConfig.zonesWidth = 3;
|
||||
|
||||
//
|
||||
poiDrawer.DrawZone(
|
||||
poiDetector.majorSupport,
|
||||
iConfig //
|
||||
);
|
||||
}
|
||||
if (poiDetector.minorSupport.IsValid())
|
||||
{
|
||||
//
|
||||
XPOIDrawConfig iConfig = structureDrawConfig.drawConfig;
|
||||
iConfig.zonesStyle = STYLE_DASH;
|
||||
|
||||
//
|
||||
poiDrawer.DrawZone(
|
||||
poiDetector.minorSupport,
|
||||
iConfig //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance ...
|
||||
if (poiDetector.majorResistance.IsValid())
|
||||
{
|
||||
//
|
||||
XPOIDrawConfig iConfig = structureDrawConfig.drawConfig;
|
||||
iConfig.zonesWidth = 3;
|
||||
|
||||
//
|
||||
poiDrawer.DrawZone(
|
||||
poiDetector.majorResistance,
|
||||
iConfig //
|
||||
);
|
||||
}
|
||||
if (poiDetector.minorResistance.IsValid())
|
||||
{
|
||||
//
|
||||
XPOIDrawConfig iConfig = structureDrawConfig.drawConfig;
|
||||
iConfig.zonesStyle = STYLE_DASH;
|
||||
|
||||
//
|
||||
poiDrawer.DrawZone(
|
||||
poiDetector.minorResistance,
|
||||
iConfig //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Quarter Line ...
|
||||
if (poiDetector.majorSupport.IsValid() &&
|
||||
poiDetector.majorResistance.IsValid())
|
||||
{
|
||||
//
|
||||
double quarter = poiDetector.CalculateQuarter();
|
||||
|
||||
//
|
||||
datetime quarterFrom = MathMin(poiDetector.majorResistance.from,
|
||||
poiDetector.majorSupport.from);
|
||||
datetime quarterTo = MathMax(poiDetector.majorResistance.to,
|
||||
poiDetector.majorSupport.to);
|
||||
string quarterName = "XQuarter_" + ToXString(quarter) + "_" + ToXString(TimeToSeconds(quarterFrom));
|
||||
|
||||
//
|
||||
CChartObjectTrend *iObj;
|
||||
has = poiDrawer.DrawTrendLine(
|
||||
quarter,
|
||||
quarterFrom,
|
||||
quarter,
|
||||
quarterTo,
|
||||
iObj,
|
||||
quarterName,
|
||||
false, // Ray Right ...
|
||||
false // Ray Left ...
|
||||
);
|
||||
if (has) {
|
||||
//
|
||||
iObj.Width(2);
|
||||
iObj.Color(clrYellow);
|
||||
|
||||
//
|
||||
poiDrawer.drawnObjects.Add(iObj);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check Actions for Debugging ...
|
||||
has = HasXValid(zoneActions) &&
|
||||
(Contains(
|
||||
X_DETECTOR_ZONE_ACTION_MINOR_SUPPORT_RETESTED,
|
||||
zoneActions) ||
|
||||
Contains(
|
||||
X_DETECTOR_ZONE_ACTION_MINOR_RESISTANCE_RETESTED,
|
||||
zoneActions));
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Draw Bar Arrow Based On Action ...
|
||||
XPivot msPivot;
|
||||
XPivot mrPivot;
|
||||
|
||||
//
|
||||
// Support ReTest ...
|
||||
has = Contains(
|
||||
X_DETECTOR_ZONE_ACTION_MINOR_SUPPORT_RETESTED,
|
||||
zoneActions //
|
||||
);
|
||||
has =
|
||||
has &&
|
||||
ToPivot(
|
||||
iBar,
|
||||
msPivot,
|
||||
X_DIRECTION_BULLISH,
|
||||
X_BAR_PATTERN_SUPPORT //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
poiDrawer.DrawPivot(
|
||||
msPivot,
|
||||
structureDrawConfig.drawConfig //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance ReTest ...
|
||||
has = Contains(
|
||||
X_DETECTOR_ZONE_ACTION_MINOR_RESISTANCE_RETESTED,
|
||||
zoneActions //
|
||||
);
|
||||
has =
|
||||
has &&
|
||||
ToPivot(
|
||||
iBar,
|
||||
mrPivot,
|
||||
X_DIRECTION_BEARISH,
|
||||
X_BAR_PATTERN_RESISTANCE //
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
poiDrawer.DrawPivot(
|
||||
mrPivot,
|
||||
structureDrawConfig.drawConfig //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Pivots ...
|
||||
msPivot.Clean();
|
||||
mrPivot.Clean();
|
||||
|
||||
//
|
||||
Print("Hot Zone Actions ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Conditions ...
|
||||
has = fimaHelper.GetConditions(
|
||||
|
||||
Reference in New Issue
Block a user