last works on XFima Strategy 2 Signalling ...
This commit is contained in:
@@ -2685,40 +2685,47 @@ class XCMarketPatternDetector : public XCBase
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// Update Quarter ...
|
||||
UpdateZones(
|
||||
bar,
|
||||
analysis.quarterActions,
|
||||
config.quarterZonesValidationLength, // Zones Validation Length ...
|
||||
config.quarterZonesRequiredToStart, // Zones Count to Start Processing ...
|
||||
config.quarterZoneDetectionLoopback // Zones Detection Loopback ...
|
||||
);
|
||||
// Retrieve Previous Bar ...
|
||||
XOHCL pBar;
|
||||
has = bar.GetPreviousBar(pBar);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Update Quarter ...
|
||||
UpdateZones(
|
||||
bar,
|
||||
analysis.quarterActions,
|
||||
config.quarterZonesValidationLength, // Zones Validation Length ...
|
||||
config.quarterZonesRequiredToStart, // Zones Count to Start Processing ...
|
||||
config.quarterZoneDetectionLoopback // Zones Detection Loopback ...
|
||||
);
|
||||
|
||||
//
|
||||
// Fill Quarter Props ...
|
||||
analysis.majorSupport = majorSupport;
|
||||
analysis.minorSupport = minorSupport;
|
||||
analysis.quarter = CalculateQuarter();
|
||||
analysis.majorResistance = majorResistance;
|
||||
analysis.minorResistance = minorResistance;
|
||||
//
|
||||
// Fill Quarter Props ...
|
||||
analysis.majorSupport = majorSupport;
|
||||
analysis.minorSupport = minorSupport;
|
||||
analysis.quarter = CalculateQuarter();
|
||||
analysis.majorResistance = majorResistance;
|
||||
analysis.minorResistance = minorResistance;
|
||||
|
||||
//
|
||||
// Update To Times ...
|
||||
if (analysis.majorSupport.IsValid())
|
||||
{
|
||||
analysis.majorSupport.to = bar.time;
|
||||
}
|
||||
if (analysis.minorSupport.IsValid())
|
||||
{
|
||||
analysis.minorSupport.to = bar.time;
|
||||
}
|
||||
if (analysis.majorResistance.IsValid())
|
||||
{
|
||||
analysis.majorResistance.to = bar.time;
|
||||
}
|
||||
if (analysis.minorResistance.IsValid())
|
||||
{
|
||||
analysis.minorResistance.to = bar.time;
|
||||
//
|
||||
// Update To Times ...
|
||||
if (analysis.majorSupport.IsValid())
|
||||
{
|
||||
analysis.majorSupport.to = bar.time;
|
||||
}
|
||||
if (analysis.minorSupport.IsValid())
|
||||
{
|
||||
analysis.minorSupport.to = bar.time;
|
||||
}
|
||||
if (analysis.majorResistance.IsValid())
|
||||
{
|
||||
analysis.majorResistance.to = bar.time;
|
||||
}
|
||||
if (analysis.minorResistance.IsValid())
|
||||
{
|
||||
analysis.minorResistance.to = bar.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3160,7 +3167,6 @@ class XCMarketPatternDetector : public XCBase
|
||||
X_DETECTOR_ZONE_ACTION_MINOR_SUPPORT_RETESTED,
|
||||
actions //
|
||||
);
|
||||
Print("Quarter: ", quarter);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -3352,7 +3358,6 @@ class XCMarketPatternDetector : public XCBase
|
||||
X_DETECTOR_ZONE_ACTION_MINOR_RESISTANCE_RETESTED,
|
||||
actions //
|
||||
);
|
||||
Print("Quarter: ", quarter);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -1296,7 +1296,6 @@ class XCPOIDrawer : public XCBase
|
||||
style.Clean();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// SPecial Draws Functions ...
|
||||
|
||||
@@ -1513,6 +1512,7 @@ class XCPOIDrawer : public XCBase
|
||||
ENUM_X_DIRECTION patternDir;
|
||||
|
||||
//
|
||||
datetime cTime = TimeCurrent();
|
||||
int patternsPivotThresholdMultiplier = 0;
|
||||
|
||||
//
|
||||
@@ -2379,6 +2379,114 @@ class XCPOIDrawer : public XCBase
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Quarters ...
|
||||
has = config.drawQuarterZones &&
|
||||
analysis.IsQuarterReady();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Draw Majors ...
|
||||
has = config.drawQuarterMajors;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
// Support ...
|
||||
has = analysis.HasMajorSupport();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
analysis.majorSupport.to = cTime;
|
||||
DrawZone(
|
||||
analysis.majorSupport,
|
||||
config.quarterMajorsDrawConfig //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance ...
|
||||
has = analysis.HasMajorResistance();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
analysis.majorResistance.to = cTime;
|
||||
DrawZone(
|
||||
analysis.majorResistance,
|
||||
config.quarterMajorsDrawConfig //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Minors ...
|
||||
if (config.drawQuarterMinors)
|
||||
{
|
||||
//
|
||||
// Support ...
|
||||
has = analysis.HasMinorSupport();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
analysis.minorSupport.to = cTime;
|
||||
DrawZone(
|
||||
analysis.minorSupport,
|
||||
config.quarterMinorsDrawConfig //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance ...
|
||||
has = analysis.HasMinorResistance();
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
analysis.minorResistance.to = cTime;
|
||||
DrawZone(
|
||||
analysis.minorResistance,
|
||||
config.quarterMinorsDrawConfig //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Quarter ...
|
||||
if (config.drawQuarter &&
|
||||
analysis.quarter > 0)
|
||||
{
|
||||
//
|
||||
double quarter = analysis.quarter;
|
||||
|
||||
//
|
||||
datetime quarterFrom = MathMin(analysis.majorResistance.from,
|
||||
analysis.majorSupport.from);
|
||||
datetime quarterTo = cTime;
|
||||
string quarterName = "XQuarter_" + ToXString(quarter) + "_" + ToXString(TimeToSeconds(quarterFrom));
|
||||
|
||||
//
|
||||
CChartObjectTrend *iObj;
|
||||
has = DrawTrendLine(
|
||||
quarter,
|
||||
quarterFrom,
|
||||
quarter,
|
||||
quarterTo,
|
||||
iObj,
|
||||
quarterName,
|
||||
false, // Ray Right ...
|
||||
false // Ray Left ...
|
||||
);
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
iObj.Width(config.quarterWidth);
|
||||
iObj.Color(config.quarterColor);
|
||||
iObj.Style(config.quarterStyle);
|
||||
|
||||
//
|
||||
drawnObjects.Add(iObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup Resources ...
|
||||
patternBar.Clean();
|
||||
|
||||
@@ -577,7 +577,8 @@ class XCTarget : public XCBase
|
||||
|
||||
//
|
||||
// Do Risk Free if Provided ...
|
||||
if (target.doRF)
|
||||
if (result &&
|
||||
target.doRF)
|
||||
{
|
||||
//
|
||||
comment = "Taregt Manager do RF ...";
|
||||
@@ -590,13 +591,48 @@ class XCTarget : public XCBase
|
||||
|
||||
//
|
||||
// Handle Alert ...
|
||||
message = "Target Manager do RF " + ToXString(position.type) + " Position (" + ToXString(position.ticket) + ") on: " + ToXString(position.price);
|
||||
alert.SendAlert(message);
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
message = "Target Manager do RF " + ToXString(position.type) + " Position (" + ToXString(position.ticket) + ") on: " + ToXString(position.price);
|
||||
alert.SendAlert(message);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Do Risk Free on Entry if Provided ...
|
||||
if (result &&
|
||||
target.doRFOnEntry)
|
||||
{
|
||||
//
|
||||
comment = "Target Manager do RF on Entry ...";
|
||||
double actingDistance = position.GetPointsValue() * target.actingDistance;
|
||||
bool isLong = IsLong(position.type);
|
||||
double sl = position.entry + (isLong
|
||||
? actingDistance
|
||||
: (-1 * actingDistance) //
|
||||
);
|
||||
result = trader.Modify(
|
||||
position.ticket,
|
||||
sl, // SL ...
|
||||
position.tp, // TP ...
|
||||
comment //
|
||||
);
|
||||
|
||||
//
|
||||
// Handle Alert ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
message = "Target Manager do RF " + ToXString(position.type) + " Position (" + ToXString(position.ticket) + ") on Entry ...";
|
||||
alert.SendAlert(message);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Do Partial Close if Provided ...
|
||||
if (result && target.volumeMultiplier > 0)
|
||||
if (result &&
|
||||
target.volumeMultiplier > 0)
|
||||
{
|
||||
//
|
||||
double volume = NormalizeVolume((position.volume * target.volumeMultiplier), position.symbol);
|
||||
@@ -612,8 +648,47 @@ class XCTarget : public XCBase
|
||||
|
||||
//
|
||||
// Handle Alert ...
|
||||
message = "Target Manager do Partial Close " + ToXString(position.type) + " Position (" + ToXString(position.ticket) + ") by: " + ToXString(volume);
|
||||
alert.SendAlert(message);
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
message = "Target Manager do Partial Close " + ToXString(position.type) + " Position (" + ToXString(position.ticket) + ") by: " + ToXString(volume);
|
||||
alert.SendAlert(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Handle Replace TP ...
|
||||
if (result &&
|
||||
target.tpValue > 0)
|
||||
{
|
||||
//
|
||||
// Validate TP Value ...
|
||||
bool isLong = IsLong(position.type);
|
||||
bool isValid = isLong
|
||||
? target.tpValue > position.price &&
|
||||
target.tpValue > position.tp
|
||||
: target.tpValue < position.price &&
|
||||
target.tpValue < position.tp;
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
comment = "Target Manager Change TP ...";
|
||||
result = trader.Modify(
|
||||
position.ticket,
|
||||
position.sl, // SL ...
|
||||
target.tpValue, // TP ...
|
||||
comment //
|
||||
);
|
||||
|
||||
//
|
||||
// Handle Alert ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
message = "Target Manager Change TP of" + ToXString(position.type) + " Position (" + ToXString(position.ticket) + ") to: " + ToXString(target.tpValue) + " ...";
|
||||
alert.SendAlert(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2650,6 +2650,430 @@ class XCXFIMAHelper : public XCBaseHelper
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Has Higher Low Based On ZigZag ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param forceBarValidation: bool, Force Bar Price based on Pivot ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasZigZagHigherLow(
|
||||
int barIndex = 0,
|
||||
bool forceBarValidation = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
XOHCL bar;
|
||||
result = IsValid() &&
|
||||
bar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
barIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Pivots ...
|
||||
XPivot pivots[];
|
||||
int count = ExtractZigZagPivots(
|
||||
pivots,
|
||||
barIndex,
|
||||
10,
|
||||
200 //
|
||||
);
|
||||
|
||||
//
|
||||
// Validate Pivots and Nearest Pivot is Low ...
|
||||
result = IsValidSize(count) &&
|
||||
pivots[0].IsVale();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Directional Pivots ...
|
||||
XPivot vales[];
|
||||
count = ExtractPivots(
|
||||
vales,
|
||||
pivots,
|
||||
X_PIVOT_TYPE_VALE //
|
||||
);
|
||||
result = IsValidSize(count) &&
|
||||
count >= 2;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
XClean(vales);
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Result ...
|
||||
result =
|
||||
vales[0].value > vales[1].value;
|
||||
if (forceBarValidation)
|
||||
{
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
bar.open > vales[0].value &&
|
||||
bar.close > vales[0].value;
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
bar.Clean();
|
||||
XClean(vales);
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Has Lower Low Based On ZigZag ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param forceBarValidation: bool, Force Bar Price based on Pivot ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasZigZagLowerLow(
|
||||
int barIndex = 0,
|
||||
bool forceBarValidation = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
XOHCL bar;
|
||||
result = IsValid() &&
|
||||
bar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
barIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Pivots ...
|
||||
XPivot pivots[];
|
||||
int count = ExtractZigZagPivots(
|
||||
pivots,
|
||||
barIndex,
|
||||
10,
|
||||
200 //
|
||||
);
|
||||
|
||||
//
|
||||
// Validate Pivots and Nearest Pivot is Low ...
|
||||
result = IsValidSize(count) &&
|
||||
pivots[0].IsVale();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Directional Pivots ...
|
||||
XPivot vales[];
|
||||
count = ExtractPivots(
|
||||
vales,
|
||||
pivots,
|
||||
X_PIVOT_TYPE_VALE //
|
||||
);
|
||||
result = IsValidSize(count) &&
|
||||
count >= 2;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
XClean(vales);
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Result ...
|
||||
result =
|
||||
vales[0].value < vales[1].value;
|
||||
if (forceBarValidation)
|
||||
{
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
bar.open < vales[0].value &&
|
||||
bar.close < vales[0].value;
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
bar.Clean();
|
||||
XClean(vales);
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Has Higher High Based On ZigZag ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param forceBarValidation: bool, Force Bar Price based on Pivot ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasZigZagHigherHigh(
|
||||
int barIndex = 0,
|
||||
bool forceBarValidation = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
XOHCL bar;
|
||||
result = IsValid() &&
|
||||
bar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
barIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Pivots ...
|
||||
XPivot pivots[];
|
||||
int count = ExtractZigZagPivots(
|
||||
pivots,
|
||||
barIndex,
|
||||
10,
|
||||
200 //
|
||||
);
|
||||
|
||||
//
|
||||
// Validate Pivots and Nearest Pivot is Low ...
|
||||
result = IsValidSize(count) &&
|
||||
pivots[0].IsPeak();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Directional Pivots ...
|
||||
XPivot peaks[];
|
||||
count = ExtractPivots(
|
||||
peaks,
|
||||
pivots,
|
||||
X_PIVOT_TYPE_PEAK //
|
||||
);
|
||||
result = IsValidSize(count) &&
|
||||
count >= 2;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
XClean(peaks);
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Result ...
|
||||
result =
|
||||
peaks[0].value > peaks[1].value;
|
||||
if (forceBarValidation)
|
||||
{
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
bar.open > peaks[0].value &&
|
||||
bar.close > peaks[0].value;
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
bar.Clean();
|
||||
XClean(peaks);
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Has Lower High Based On ZigZag ...
|
||||
*
|
||||
* @param barIndex: int, Specified Bar Index ...
|
||||
* @param forceBarValidation: bool, Force Bar Price based on Pivot ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasZigZagLowerHigh(
|
||||
int barIndex = 0,
|
||||
bool forceBarValidation = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
barIndex = NormalizeBarIndex(barIndex);
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
XOHCL bar;
|
||||
result = IsValid() &&
|
||||
bar.Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
barIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Pivots ...
|
||||
XPivot pivots[];
|
||||
int count = ExtractZigZagPivots(
|
||||
pivots,
|
||||
barIndex,
|
||||
10,
|
||||
200 //
|
||||
);
|
||||
|
||||
//
|
||||
// Validate Pivots and Nearest Pivot is Low ...
|
||||
result = IsValidSize(count) &&
|
||||
pivots[0].IsPeak();
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extract Directional Pivots ...
|
||||
XPivot peaks[];
|
||||
count = ExtractPivots(
|
||||
peaks,
|
||||
pivots,
|
||||
X_PIVOT_TYPE_PEAK //
|
||||
);
|
||||
result = IsValidSize(count) &&
|
||||
count >= 2;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bar.Clean();
|
||||
XClean(peaks);
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Result ...
|
||||
result =
|
||||
peaks[0].value < peaks[1].value;
|
||||
if (forceBarValidation)
|
||||
{
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
bar.open < peaks[0].value &&
|
||||
bar.close < peaks[0].value;
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
bar.Clean();
|
||||
XClean(peaks);
|
||||
XClean(pivots);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extractions ...
|
||||
|
||||
|
||||
@@ -539,12 +539,18 @@ struct XPivotAnalysis
|
||||
|
||||
//
|
||||
// Calculating Slope and Intercept ...
|
||||
CalculateSlopeAndIntercept(
|
||||
peakSlope,
|
||||
peakIntercept,
|
||||
xData,
|
||||
yData //
|
||||
);
|
||||
has = ArraySize(xData) >= 2 &&
|
||||
ArraySize(yData) >= 2;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
CalculateSlopeAndIntercept(
|
||||
peakSlope,
|
||||
peakIntercept,
|
||||
xData,
|
||||
yData //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -570,12 +576,18 @@ struct XPivotAnalysis
|
||||
|
||||
//
|
||||
// Calculating Slope and Intercept ...
|
||||
CalculateSlopeAndIntercept(
|
||||
valeSlope,
|
||||
valeIntercept,
|
||||
xData,
|
||||
yData //
|
||||
);
|
||||
has = ArraySize(xData) >= 2 &&
|
||||
ArraySize(yData) >= 2;
|
||||
if (has)
|
||||
{
|
||||
//
|
||||
CalculateSlopeAndIntercept(
|
||||
valeSlope,
|
||||
valeIntercept,
|
||||
xData,
|
||||
yData //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1482,7 +1494,13 @@ struct XPatternAnalysis
|
||||
//
|
||||
// Pattern Actions ...
|
||||
|
||||
//
|
||||
/**
|
||||
* Count Directional Patterns ...
|
||||
*
|
||||
* @param forDir: ENUM_X_DIRECTION, Specified Direction ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int Count(
|
||||
ENUM_X_DIRECTION forDir = X_DIRECTION_NONE //
|
||||
)
|
||||
@@ -2826,6 +2844,21 @@ struct XPatternAnalysisDrawConfig
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Quarters ...
|
||||
bool drawQuarterZones; // Draw Quarters ...
|
||||
bool drawQuarterMajors; // Draw Quarter Majors ...
|
||||
bool drawQuarterMinors; // Draw Quarter Minors ...
|
||||
bool drawQuarter; // Draw Quarter Trend Line ...
|
||||
|
||||
//
|
||||
int quarterWidth;
|
||||
color quarterColor;
|
||||
ENUM_LINE_STYLE quarterStyle;
|
||||
|
||||
//
|
||||
// Patterns ...
|
||||
|
||||
//
|
||||
ENUM_X_BAR_PATTERN allowedDraws[]; // Allowed Draw Patterns
|
||||
ENUM_X_BAR_PATTERN allowedDrawZones[]; // Allowed Draw Pattern Zones
|
||||
@@ -2833,6 +2866,8 @@ struct XPatternAnalysisDrawConfig
|
||||
|
||||
//
|
||||
XPOIDrawConfig drawConfig;
|
||||
XPOIDrawConfig quarterMajorsDrawConfig;
|
||||
XPOIDrawConfig quarterMinorsDrawConfig;
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
@@ -2857,6 +2892,10 @@ struct XPatternAnalysisDrawConfig
|
||||
XClean(allowedDraws);
|
||||
XClean(allowedDrawZones);
|
||||
XClean(allowedDrawPivots);
|
||||
|
||||
//
|
||||
quarterMajorsDrawConfig.Clean();
|
||||
quarterMinorsDrawConfig.Clean();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2867,10 +2906,19 @@ struct XPatternAnalysisDrawConfig
|
||||
//
|
||||
// Drawing Configs ...
|
||||
drawConfig.Default();
|
||||
quarterMajorsDrawConfig.Default();
|
||||
quarterMinorsDrawConfig.Default();
|
||||
ConfigureQuarterDraws();
|
||||
|
||||
//
|
||||
Full();
|
||||
|
||||
//
|
||||
drawQuarter = true;
|
||||
drawQuarterZones = true;
|
||||
drawQuarterMajors = true;
|
||||
drawQuarterMinors = true;
|
||||
|
||||
//
|
||||
// Remove Unused From Zones ...
|
||||
Remove(X_BAR_PATTERN_PINNED, allowedDrawZones);
|
||||
@@ -2895,6 +2943,12 @@ struct XPatternAnalysisDrawConfig
|
||||
XClean(allowedDraws);
|
||||
XClean(allowedDrawZones);
|
||||
XClean(allowedDrawPivots);
|
||||
|
||||
//
|
||||
drawQuarter = false;
|
||||
drawQuarterZones = false;
|
||||
drawQuarterMajors = false;
|
||||
drawQuarterMinors = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2902,6 +2956,12 @@ struct XPatternAnalysisDrawConfig
|
||||
*/
|
||||
void Full()
|
||||
{
|
||||
//
|
||||
drawQuarter = true;
|
||||
drawQuarterZones = true;
|
||||
drawQuarterMajors = true;
|
||||
drawQuarterMinors = true;
|
||||
|
||||
//
|
||||
GetAllBarPatters(allowedDraws);
|
||||
GetAllBarPatters(allowedDrawZones);
|
||||
@@ -2974,6 +3034,43 @@ struct XPatternAnalysisDrawConfig
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Drawer Configs ...
|
||||
|
||||
/**
|
||||
* PreConfigure Default Drawer Configs of Quarters ...
|
||||
*/
|
||||
void ConfigureQuarterDraws()
|
||||
{
|
||||
//
|
||||
// Quarter ...
|
||||
quarterWidth = 2;
|
||||
quarterStyle = STYLE_DOT;
|
||||
quarterColor = clrYellow;
|
||||
|
||||
//
|
||||
// Majors ...
|
||||
|
||||
//
|
||||
quarterMajorsDrawConfig.Default();
|
||||
quarterMajorsDrawConfig = drawConfig;
|
||||
|
||||
//
|
||||
quarterMajorsDrawConfig.zonesWidth = 3;
|
||||
quarterMajorsDrawConfig.bearishColor = clrRed;
|
||||
quarterMajorsDrawConfig.bullishColor = clrLime;
|
||||
|
||||
//
|
||||
// Minors ...
|
||||
|
||||
//
|
||||
quarterMinorsDrawConfig.Default();
|
||||
quarterMinorsDrawConfig = drawConfig;
|
||||
|
||||
//
|
||||
quarterMinorsDrawConfig.zonesStyle = STYLE_DASH;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
@@ -719,9 +719,11 @@ struct XTarget
|
||||
//
|
||||
// Props ...
|
||||
bool doRF; // Do RF on Target
|
||||
bool doRFOnEntry; // Do RF on Entry
|
||||
double actingDistance; // Acting Distances
|
||||
double target; // Target Price for Actions
|
||||
double volumeMultiplier; // Volume Multiplier for Partial Close
|
||||
double tpValue; // TP Value Changed ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
@@ -739,8 +741,10 @@ struct XTarget
|
||||
{
|
||||
//
|
||||
target = 0;
|
||||
tpValue = 0;
|
||||
doRF = false;
|
||||
actingDistance = 0;
|
||||
doRFOnEntry = false;
|
||||
volumeMultiplier = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -372,111 +372,6 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
structureConfig,
|
||||
barIndex //
|
||||
);
|
||||
|
||||
//
|
||||
// Sample Draws ...
|
||||
|
||||
//
|
||||
// Support ...
|
||||
if (structure.barAnalysis.IsQuarterReady())
|
||||
{
|
||||
//
|
||||
// Majors ...
|
||||
|
||||
//
|
||||
XPOIDrawConfig iConfig = structureDrawConfig.drawConfig;
|
||||
iConfig.zonesWidth = 3;
|
||||
|
||||
//
|
||||
poiDrawer.DrawZone(
|
||||
structure.barAnalysis.majorSupport,
|
||||
iConfig //
|
||||
);
|
||||
|
||||
//
|
||||
poiDrawer.DrawZone(
|
||||
structure.barAnalysis.majorResistance,
|
||||
iConfig //
|
||||
);
|
||||
|
||||
//
|
||||
// Minors ...
|
||||
|
||||
//
|
||||
if (structure.barAnalysis.HasMinorSupport())
|
||||
{
|
||||
//
|
||||
XPOIDrawConfig iConfig = structureDrawConfig.drawConfig;
|
||||
iConfig.zonesStyle = STYLE_DASH;
|
||||
|
||||
//
|
||||
poiDrawer.DrawZone(
|
||||
structure.barAnalysis.minorSupport,
|
||||
iConfig //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (structure.barAnalysis.HasMinorResistance())
|
||||
{
|
||||
//
|
||||
XPOIDrawConfig iConfig = structureDrawConfig.drawConfig;
|
||||
iConfig.zonesStyle = STYLE_DASH;
|
||||
|
||||
//
|
||||
poiDrawer.DrawZone(
|
||||
structure.barAnalysis.minorResistance,
|
||||
iConfig //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Quarter Draw ...
|
||||
if (structure.barAnalysis.quarter > 0)
|
||||
{
|
||||
//
|
||||
double quarter = structure.barAnalysis.quarter;
|
||||
|
||||
//
|
||||
datetime quarterFrom = MathMin(poiDetector.majorResistance.from,
|
||||
poiDetector.majorSupport.from);
|
||||
datetime quarterTo = iBar.time;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance ...
|
||||
|
||||
//
|
||||
// Quarter Line ...
|
||||
if (poiDetector.majorSupport.IsValid() &&
|
||||
poiDetector.majorResistance.IsValid())
|
||||
{
|
||||
}
|
||||
|
||||
// poiDrawer.drawnObjects.Clear();
|
||||
// poiDrawer.DrawMarketStructure(
|
||||
// structure,
|
||||
@@ -978,13 +873,19 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
|
||||
//
|
||||
// Prepare ...
|
||||
XOHCL pBar;
|
||||
XOHCL p2Bar;
|
||||
zone.Clean();
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
XClean(targets);
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
result = bar.IsValid();
|
||||
result = bar.IsValid() &&
|
||||
bar.GetPreviousBar(pBar) &&
|
||||
pBar.GetPreviousBar(p2Bar);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
@@ -999,78 +900,177 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
// Do Signal Detection ...
|
||||
|
||||
//
|
||||
// result = fimaHelper.HasHKBasedTrend(dir, bar.Index(), 1);
|
||||
// bool isBullish = result &&
|
||||
// IsXBullish(dir);
|
||||
// bool isBearish = result &&
|
||||
// IsXBearish(dir);
|
||||
// Preparing Requirement Conditions ...
|
||||
// Here we Have to Prepare Some Directional Confirmations Using Indicators ...
|
||||
// for Validate Signals ...
|
||||
|
||||
//
|
||||
// Get Bar Pattern ...
|
||||
// XPatternAnalysis barAnalysis;
|
||||
// result =
|
||||
// poiDetector.AnalyseBarPatterns(
|
||||
// bar,
|
||||
// barAnalysis,
|
||||
// structureConfig.barsAnalysisConfig //
|
||||
// );
|
||||
// bool isBullish = barAnalysis.Count(X_DIRECTION_BULLISH) >= 4;
|
||||
// bool isBearish = barAnalysis.Count(X_DIRECTION_BEARISH) >= 4;
|
||||
bool hasZigZagHigherLow = fimaHelper.HasZigZagHigherLow(bar.Index(), true);
|
||||
bool hasZigZagLowerHigh = fimaHelper.HasZigZagLowerHigh(bar.Index(), true);
|
||||
|
||||
//
|
||||
// Validation Patterns ...
|
||||
int directionalPatternsValidations = 3;
|
||||
|
||||
//
|
||||
// Check Bullish Conditions ...
|
||||
isBullish =
|
||||
//
|
||||
_structure.barAnalysis.HasMinorSupport() &&
|
||||
bar.open > _structure.barAnalysis.minorSupport.upper &&
|
||||
bar.close > _structure.barAnalysis.minorSupport.upper &&
|
||||
(_structure.barsAnalysis[1].Count(X_DIRECTION_BULLISH) >= directionalPatternsValidations) &&
|
||||
//
|
||||
(IsTested(
|
||||
pBar,
|
||||
_structure.barAnalysis.minorSupport //
|
||||
) ||
|
||||
IsTested(
|
||||
p2Bar,
|
||||
_structure.barAnalysis.minorSupport //
|
||||
)) &&
|
||||
//
|
||||
(hasZigZagHigherLow)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Check Bearish Conditions ...
|
||||
isBearish =
|
||||
//
|
||||
_structure.barAnalysis.HasMinorResistance() &&
|
||||
bar.open < _structure.barAnalysis.minorResistance.lower &&
|
||||
bar.close < _structure.barAnalysis.minorResistance.lower &&
|
||||
(_structure.barsAnalysis[1].Count(X_DIRECTION_BEARISH) >= directionalPatternsValidations) &&
|
||||
//
|
||||
(IsTested(
|
||||
pBar,
|
||||
_structure.barAnalysis.minorResistance //
|
||||
) ||
|
||||
IsTested(
|
||||
p2Bar,
|
||||
_structure.barAnalysis.minorResistance //
|
||||
)) &&
|
||||
//
|
||||
(hasZigZagLowerHigh)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Summarize Conditions ...
|
||||
result =
|
||||
isBullish ||
|
||||
isBearish;
|
||||
|
||||
//
|
||||
// Assign Direction ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// Draw Bar Patterns Analysis ...
|
||||
// poiDrawer.DrawPatternAnalysis(
|
||||
// barAnalysis,
|
||||
// structureDrawConfig.barAnalysisDrawConfig //
|
||||
// );
|
||||
dir = isBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: isBearish
|
||||
? X_DIRECTION_BEARISH
|
||||
: X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
if (isBullish)
|
||||
{
|
||||
Print("Bullish HK Bond Trend ...");
|
||||
zone = _structure.barAnalysis.minorSupport;
|
||||
}
|
||||
|
||||
//
|
||||
if (isBearish)
|
||||
{
|
||||
Print("Bearish HK Bond Trend ...");
|
||||
zone = _structure.barAnalysis.minorResistance;
|
||||
}
|
||||
|
||||
//
|
||||
Print(ToXString(dir), " Detected ...");
|
||||
}
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
result = false;
|
||||
dir = X_DIRECTION_NONE;
|
||||
// Validate Result ...
|
||||
result =
|
||||
result &&
|
||||
zone.IsValid() &&
|
||||
HasDirection(dir);
|
||||
// if (result)
|
||||
// {
|
||||
// //
|
||||
// XPOIDrawConfig iConfig = structureDrawConfig
|
||||
// .barAnalysisDrawConfig
|
||||
// .quarterMinorsDrawConfig;
|
||||
// iConfig.zonesWidth = 3;
|
||||
// iConfig.zonesFill = true;
|
||||
// iConfig.bullishColor = clrYellow;
|
||||
// iConfig.bearishColor = clrYellow;
|
||||
|
||||
//
|
||||
// Draw Custom Requirements ...
|
||||
// //
|
||||
// if (isBullish)
|
||||
// {
|
||||
// //
|
||||
// poiDrawer.DrawZone(
|
||||
// _structure.barAnalysis.minorSupport,
|
||||
// iConfig //
|
||||
// );
|
||||
|
||||
//
|
||||
// Prepare Decision Zone ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// Create Decision Zone and Validate it ...
|
||||
// //
|
||||
// Print("Bullish Condition ...");
|
||||
// }
|
||||
|
||||
//
|
||||
result = zone.IsValid();
|
||||
}
|
||||
// //
|
||||
// if (isBearish)
|
||||
// {
|
||||
// //
|
||||
// poiDrawer.DrawZone(
|
||||
// _structure.barAnalysis.minorResistance,
|
||||
// iConfig //
|
||||
// );
|
||||
|
||||
// //
|
||||
// Print("Bearish Condition ...");
|
||||
// }
|
||||
|
||||
// //
|
||||
// Print(ToXString(dir), " Detected ...");
|
||||
// }
|
||||
|
||||
//
|
||||
// Provide Direction and Targets if Required ...
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// Handle Signal Direction ...
|
||||
// Handle Targets Detection ...
|
||||
|
||||
//
|
||||
// Handle Targets Detection ...
|
||||
double spread = GetSpread(zone.symbol);
|
||||
double entry = GetEntry(zone.symbol, dir);
|
||||
|
||||
//
|
||||
double risk = isBullish
|
||||
? entry - zone.lower
|
||||
: zone.upper - entry;
|
||||
double reward1 = entry + (isBullish
|
||||
? risk
|
||||
: (-1 * risk) //
|
||||
);
|
||||
double reward4 = entry + (isBullish
|
||||
? 4 * risk
|
||||
: (-4 * risk) //
|
||||
);
|
||||
double requiredDistance = PriceToPoint(spread * 2, zone.symbol);
|
||||
|
||||
//
|
||||
XTarget iRFOnEntryOnTP1;
|
||||
iRFOnEntryOnTP1.target = reward1;
|
||||
iRFOnEntryOnTP1.tpValue = reward4;
|
||||
iRFOnEntryOnTP1.doRFOnEntry = true;
|
||||
iRFOnEntryOnTP1.volumeMultiplier = 0.5;
|
||||
iRFOnEntryOnTP1.actingDistance = requiredDistance;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iRFOnEntryOnTP1,
|
||||
targets //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1081,6 +1081,8 @@ class XCXFIMAStrategy1Signaller : public XCXFIMABaseSignaller
|
||||
zone.Clean();
|
||||
XClean(targets);
|
||||
}
|
||||
pBar.Clean();
|
||||
p2Bar.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
|
||||
@@ -389,8 +389,8 @@ struct XFIMAMarketStructureConfig
|
||||
|
||||
//
|
||||
// Configure Detectors ...
|
||||
loopback = 500;
|
||||
requiredPivots = 25;
|
||||
loopback = 200;
|
||||
requiredPivots = 10;
|
||||
pvPivotsValidationLength = 5;
|
||||
maCrossValidationDiffMultiplier = 4;
|
||||
|
||||
@@ -549,6 +549,7 @@ struct XFIMAMarketStructureDrawerConfig
|
||||
{
|
||||
//
|
||||
barAnalysisDrawConfig.drawConfig = drawConfig;
|
||||
barAnalysisDrawConfig.ConfigureQuarterDraws();
|
||||
pivotAnalysisDrawConfig.drawConfig = drawConfig;
|
||||
}
|
||||
|
||||
@@ -561,3 +562,5 @@ struct XFIMAMarketStructureDrawerConfig
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user