This commit is contained in:
2025-12-31 21:28:54 +03:30
parent ad945b90b2
commit a0876d5a05
12 changed files with 1789 additions and 185 deletions
+585
View File
@@ -0,0 +1,585 @@
/**
* Check Bar Has Signal Based on Strategy 1 ...
*
* Pattern‑based reversal:
* - Detects Pin Bar or Signal Key Bar.
* - Confirms with POI detector.
* - Good for reversals at support/resistance.
*
* @param bar: XOHCL, reference to Bar ...
* @param zone: XBoxZone, reference to holds affected zone ...
* @param targets: XTarget, reference to detected Signal's Targets collections ...
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
*
* @return ( bool )
*/
bool Strategy1HasSignal(
XOHCL &bar,
XBoxZone &zone,
XTarget &targets[],
ENUM_X_DIRECTION &dir //
)
{
//
bool result = false;
//
zone.Clean();
XClean(targets);
dir = X_DIRECTION_NONE;
//
result = bar.IsValid();
if (!result)
{
return result;
}
//
result = poiDetector.IsKISignal(
dir,
bar.Index() //
);
bool isBullish = result &&
IsXBullish(dir);
bool isBearish = result &&
IsXBearish(dir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Detect Nearest Directional ...
int nearestDirectionalSwitchIndex = -1;
if (isBullish)
{
//
isBullish = poiDetector.NearestKIFastSwitchedToBullish(
nearestDirectionalSwitchIndex,
bar.Index() + 2 //
);
}
else
{
//
isBearish = poiDetector.NearestKIFastSwitchedToBearish(
nearestDirectionalSwitchIndex,
bar.Index() + 2 //
);
}
result =
IsValidIndex(nearestDirectionalSwitchIndex) &&
(isBullish ||
isBearish);
if (!result)
{
//
bar.Clean();
return result;
}
//
// Preparing Zone ...
double upper = bar.FindHighest(nearestDirectionalSwitchIndex - bar.Index(), MODE_HIGH);
double lower = bar.FindLowest(nearestDirectionalSwitchIndex - bar.Index(), MODE_LOW);
//
result = zone.Init(
symbol,
period,
upper,
lower,
GetBarTime(symbol, period, nearestDirectionalSwitchIndex),
bar.time,
dir,
"XKI1" //
);
//
// Support and Resistance ...
XBoxZone supports[];
XBoxZone resistances[];
if (result)
{
//
// Supports ...
poiDetector.DetectSupports(
supports,
bar.Index(),
50, // Loopback ...
true, // Force Validation ...
7, // Validation Length ...
symbol, // For Symbol ...
period // For Period ...
);
//
// Resistances ...
poiDetector.DetectResistances(
resistances,
bar.Index(),
50, // Loopback ...
true, // Force Validation ...
7, // Validation Length ...
symbol, // For Symbol ...
period // For Period ...
);
}
//
// TODO: Rempve ...
if (result)
{
//
// Other Drawing Materials ...
XPOIDrawConfig drawConfig;
drawConfig.Default();
//
// this for Selected Zone ...
poiDrawer.DrawZone(zone, drawConfig);
//
// Drawing Supports and Resistances ...
drawConfig.bearishColor = clrRed;
drawConfig.bullishColor = clrLime;
//
if (HasChild(supports))
{
poiDrawer.DrawZones(supports, drawConfig);
}
//
if (HasChild(resistances))
{
poiDrawer.DrawZones(resistances, drawConfig);
}
//
drawConfig.Clean();
//
DebugBreak();
}
//
result =
result &&
zone.IsValid() &&
HasDirection(dir);
//
return result;
}
/**
* Check Bar Has Signal Based on Strategy 1 ...
*
* Pattern‑based reversal:
* - Detects Pin Bar or Signal Key Bar.
* - Confirms with POI detector.
* - Good for reversals at support/resistance.
*
* @param bar: XOHCL, reference to Bar ...
* @param zone: XBoxZone, reference to holds affected zone ...
* @param targets: XTarget, reference to detected Signal's Targets collections ...
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
*
* @return ( bool )
*/
bool Strategy1HasSignal(
XOHCL &bar,
XBoxZone &zone,
XTarget &targets[],
ENUM_X_DIRECTION &dir //
)
{
//
bool result = false;
//
zone.Clean();
XClean(targets);
dir = X_DIRECTION_NONE;
//
result = bar.IsValid();
if (!result)
{
return result;
}
//
result = poiDetector.IsKISignal(
dir,
bar.Index() //
);
bool isBullish = result &&
IsXBullish(dir);
bool isBearish = result &&
IsXBearish(dir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Detect Nearest Directional ...
int nearestDirectionalSwitchIndex = -1;
if (isBullish)
{
//
isBullish = poiDetector.NearestKIFastSwitchedToBullish(
nearestDirectionalSwitchIndex,
bar.Index() + 2 //
);
}
else
{
//
isBearish = poiDetector.NearestKIFastSwitchedToBearish(
nearestDirectionalSwitchIndex,
bar.Index() + 2 //
);
}
result =
IsValidIndex(nearestDirectionalSwitchIndex) &&
(isBullish ||
isBearish);
if (!result)
{
//
bar.Clean();
return result;
}
//
// Preparing Zone ...
double upper = bar.FindHighest(nearestDirectionalSwitchIndex - bar.Index(), MODE_HIGH);
double lower = bar.FindLowest(nearestDirectionalSwitchIndex - bar.Index(), MODE_LOW);
//
result = zone.Init(
symbol,
period,
upper,
lower,
GetBarTime(symbol, period, nearestDirectionalSwitchIndex),
bar.time,
dir,
"XKI1" //
);
//
// Support and Resistance ...
XBoxZone supports[];
XBoxZone resistances[];
XBoxZone minorSupport;
XBoxZone majorSupport;
XBoxZone minorResistance;
XBoxZone majorResistance;
if (result)
{
//
// Supports ...
poiDetector.GetCurrentStructure(
supports,
resistances,
minorSupport,
majorSupport,
minorResistance,
majorResistance,
bar.Index(),
symbol, // For Symbol ...
period, // For Period ...
50, // Loopback ...
7, // Minor Validation Length ...
14 // Major Validation Length ...
);
}
//
// TODO: Rempve ...
if (result)
{
//
// Other Drawing Materials ...
XPOIDrawConfig drawConfig;
drawConfig.Default();
//
// this for Selected Zone ...
poiDrawer.DrawZone(zone, drawConfig);
//
// Drawing Supports and Resistances ...
drawConfig.bearishColor = clrRed;
drawConfig.bullishColor = clrLime;
//
// Minors ...
//
drawConfig.zonesStyle = STYLE_DOT;
if (minorSupport.IsValid())
{
poiDrawer.DrawZone(minorSupport, drawConfig);
}
if (minorResistance.IsValid())
{
poiDrawer.DrawZone(minorResistance, drawConfig);
}
//
// Majors ...
//
drawConfig.zonesStyle = STYLE_DASH;
if (majorSupport.IsValid())
{
poiDrawer.DrawZone(majorSupport, drawConfig);
}
if (majorResistance.IsValid())
{
poiDrawer.DrawZone(majorResistance, drawConfig);
}
// //
// if (HasChild(supports))
// {
// poiDrawer.DrawZones(supports, drawConfig);
// }
// //
// if (HasChild(resistances))
// {
// poiDrawer.DrawZones(resistances, drawConfig);
// }
//
drawConfig.Clean();
//
DebugBreak();
}
//
result =
result &&
zone.IsValid() &&
HasDirection(dir);
//
return result;
}
/**
* Check Bar Has Signal Based on Strategy 1 ...
*
* Pattern‑based reversal:
* - Detects Pin Bar or Signal Key Bar.
* - Confirms with POI detector.
* - Good for reversals at support/resistance.
*
* @param bar: XOHCL, reference to Bar ...
* @param zone: XBoxZone, reference to holds affected zone ...
* @param targets: XTarget, reference to detected Signal's Targets collections ...
* @param dir: ENUM_X_DIRECTION, detected Signal's direction ...
*
* @return ( bool )
*/
bool Strategy1HasSignal(
XOHCL &bar,
XBoxZone &zone,
XTarget &targets[],
ENUM_X_DIRECTION &dir //
)
{
//
bool result = false;
//
zone.Clean();
XClean(targets);
dir = X_DIRECTION_NONE;
//
result = bar.IsValid();
if (!result)
{
return result;
}
//
result = poiDetector.IsKISignal(
dir,
bar.Index() //
);
bool isBullish = result &&
IsXBullish(dir);
bool isBearish = result &&
IsXBearish(dir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
//
// Detect Nearest Directional ...
int nearestDirectionalSwitchIndex = -1;
if (isBullish)
{
//
isBullish = poiDetector.NearestKIFastSwitchedToBullish(
nearestDirectionalSwitchIndex,
bar.Index() + 2 //
);
}
else
{
//
isBearish = poiDetector.NearestKIFastSwitchedToBearish(
nearestDirectionalSwitchIndex,
bar.Index() + 2 //
);
}
result =
IsValidIndex(nearestDirectionalSwitchIndex) &&
(isBullish ||
isBearish);
if (!result)
{
//
bar.Clean();
return result;
}
//
// Preparing Zone ...
double upper = bar.FindHighest(nearestDirectionalSwitchIndex - bar.Index(), MODE_HIGH);
double lower = bar.FindLowest(nearestDirectionalSwitchIndex - bar.Index(), MODE_LOW);
//
result = zone.Init(
symbol,
period,
upper,
lower,
GetBarTime(symbol, period, nearestDirectionalSwitchIndex),
bar.time,
dir,
"XKI1" //
);
//
// Support and Resistance ...
XBoxZone supports[];
XBoxZone resistances[];
XBoxZone minorSupport;
XBoxZone majorSupport;
XBoxZone minorResistance;
XBoxZone majorResistance;
if (result)
{
//
// Supports ...
poiDetector.GetCurrentStructure(
supports,
resistances,
minorSupport,
majorSupport,
minorResistance,
majorResistance,
bar.Index(),
symbol, // For Symbol ...
period, // For Period ...
50, // Loopback ...
7, // Minor Validation Length ...
14 // Major Validation Length ...
);
}
//
// TODO: Rempve ...
if (result)
{
//
// Other Drawing Materials ...
XPOIDrawConfig drawConfig;
drawConfig.Default();
//
// this for Selected Zone ...
poiDrawer.DrawZone(zone, drawConfig);
//
// Drawing Supports and Resistances ...
drawConfig.bearishColor = clrRed;
drawConfig.bullishColor = clrLime;
//
// Minors ...
//
drawConfig.zonesStyle = STYLE_DOT;
if (minorSupport.IsValid())
{
poiDrawer.DrawZone(minorSupport, drawConfig);
}
if (minorResistance.IsValid())
{
poiDrawer.DrawZone(minorResistance, drawConfig);
}
//
// Majors ...
//
drawConfig.zonesStyle = STYLE_DASH;
if (majorSupport.IsValid())
{
poiDrawer.DrawZone(majorSupport, drawConfig);
}
if (majorResistance.IsValid())
{
poiDrawer.DrawZone(majorResistance, drawConfig);
}
// //
// if (HasChild(supports))
// {
// poiDrawer.DrawZones(supports, drawConfig);
// }
// //
// if (HasChild(resistances))
// {
// poiDrawer.DrawZones(resistances, drawConfig);
// }
//
drawConfig.Clean();
//
DebugBreak();
}
//
result =
result &&
zone.IsValid() &&
HasDirection(dir);
//
return result;
}
@@ -0,0 +1,76 @@
if (result)
{
//
XOHCL tmpBar;
int tmpIDX = -1;
bool has = false;
double upper = 0;
double lower = 0;
int length = zone.GetAge();
//
// Support ...
tmpIDX = bar.FindLowestIndex(length, MODE_LOW);
if (IsValidIndex(tmpIDX))
{
//
if (tmpBar.Init(symbol, period, tmpIDX))
{
//
lower = iLow(symbol, period, tmpIDX);
upper = bar.FindLowest(length, MODE_CLOSE);
if (upper <= lower)
{
upper = tmpBar.GetDown();
}
//
has = support.Init(
symbol,
period,
upper,
lower,
tmpBar.time,
bar.time,
X_DIRECTION_BULLISH,
ToXString(X_BAR_PATTERN_SUPPORT) //
);
//
tmpBar.Clean();
}
}
//
// Resistance ...
tmpIDX = bar.FindHighestIndex(length, MODE_HIGH);
if (IsValidIndex(tmpIDX))
{
//
if (tmpBar.Init(symbol, period, tmpIDX))
{
//
upper = iHigh(symbol, period, tmpIDX);
lower = bar.FindHighest(length, MODE_CLOSE);
if (upper <= lower)
{
upper = tmpBar.GetUp();
}
//
has = resistance.Init(
symbol,
period,
upper,
lower,
tmpBar.time,
bar.time,
X_DIRECTION_BEARISH,
ToXString(X_BAR_PATTERN_RESISTANCE) //
);
//
tmpBar.Clean();
}
}
}
@@ -0,0 +1,138 @@
{
"lists": [
{
"id": "d66f2925-aa4e-46e4-8f3e-f2c0ba6c9454",
"title": "Backlog",
"cards": []
},
{
"id": "61ca33e6-05e4-4b44-b88d-3bc8ae5cba86",
"title": "To Do",
"cards": []
},
{
"id": "6f8db3d6-fcaa-4522-bee5-0e3e38c96e73",
"title": "Doing",
"cards": [
{
"id": "1b86f94a-a66e-482c-9172-c9dbb338bb63",
"listId": "6f8db3d6-fcaa-4522-bee5-0e3e38c96e73",
"title": "Testing POI(s) for Strategies ...",
"description": "we have some POIs in POI Detectors ...\nin this task we have to test them Works ...",
"labels": [],
"checkboxes": [
{
"id": "224b6c66-341f-4dda-aa25-6b45ab034a6e",
"title": "Add Support Testing them;",
"checked": true
},
{
"id": "50caaa08-a3a4-4be5-85d8-4ab41e8dd945",
"title": "Add Support for Safe Entry;",
"checked": true
},
{
"id": "95ee0eba-4e0d-4a6a-be62-93aa562ab767",
"title": "POI",
"checked": true
},
{
"id": "aec8ebe5-0d88-4ea7-bfd3-eb1a26af8a55",
"title": "Breakout POI",
"checked": true
},
{
"id": "6104db5f-95b2-401a-9efd-354b685e7a5f",
"title": "Reversal POI",
"checked": false
},
{
"id": "05aaad69-af4d-4253-89a7-e46a80cae593",
"title": "Continuation POI",
"checked": true
},
{
"id": "a7a75d64-00dd-4004-bab2-5040a47b8441",
"title": "Exhaustion POI",
"checked": false
},
{
"id": "a9c52b07-9a50-4c30-abf9-cd8e3febb6aa",
"title": "TrendExhausted POI",
"checked": false
}
],
"comments": []
}
]
},
{
"id": "c6b07a7f-d2e7-4f67-a5a9-0d93cd8bf981",
"title": "Test",
"cards": [
{
"id": "128af636-5cd8-4311-a565-e822ba380d59",
"listId": "c6b07a7f-d2e7-4f67-a5a9-0d93cd8bf981",
"title": "Add Support for ATR MA in XKI Indicator ...",
"description": "since we have to Calculate Volatility of ATR for Reversal or Breakouts,\nwe Have to Compare ATR by it's Moving Averages ...\n\nhere in this task we need to add support for atr MA ...",
"labels": [],
"checkboxes": [
{
"id": "f3aabe70-9df5-405d-a737-55e9cc6b2027",
"title": "Add Buffer;",
"checked": true
},
{
"id": "d6d295c4-b3e9-4946-b305-20df0858db59",
"title": "Calculate;",
"checked": true
},
{
"id": "d0e3f5b6-56c9-41a6-95c0-71de279bc70c",
"title": "Implement in Conditions;",
"checked": true
},
{
"id": "4827fc2b-e71d-468c-a069-ec5f17bc6962",
"title": "Implement in Helper;",
"checked": true
},
{
"id": "3fb4bac7-32c5-43be-b6ac-ccf4a15a117b",
"title": "Use in Parser;",
"checked": true
},
{
"id": "b98a8eee-1cbf-455b-9e8f-e4d42ba3f327",
"title": "Remove threshold;",
"checked": true
},
{
"id": "c3636ee3-d577-4728-9b2b-a9237687fd1a",
"title": "Refactor Side Affects;",
"checked": true
}
],
"comments": [
{
"id": "128f3338-1b62-4c2c-8ce4-723ed97fd41c",
"comment": "here we are going to test changes ..."
}
]
}
]
},
{
"id": "89823cc9-39a6-4d8b-bd5e-b6a14c03b01d",
"title": "Done",
"cards": []
}
],
"archive": {
"lists": [],
"cards": []
},
"settings": {
"labels": []
}
}
@@ -0,0 +1,46 @@
{
"lists": [
{
"id": "291ee671-37c7-45eb-bd40-24df3cb445ca",
"title": "BackLog",
"cards": []
},
{
"id": "53bb4f6a-34b9-48b8-9391-642c42d222d1",
"title": "ToDO",
"cards": [
{
"id": "b13fa9ba-5a66-42a6-a5eb-50789a59fad3",
"listId": "53bb4f6a-34b9-48b8-9391-642c42d222d1",
"title": "Apply Fix on XRR Tools",
"description": "Try to Recompile XRR Tools and Check it Works Currently or not;",
"labels": [],
"checkboxes": [],
"comments": []
}
]
},
{
"id": "ca095e9c-39f3-44dd-862c-d6c4af1dffff",
"title": "Doing",
"cards": []
},
{
"id": "842e4cfc-aee9-4fa7-9321-cc8ba0d194de",
"title": "Test",
"cards": []
},
{
"id": "b99e6c6c-ec5c-4f7c-b937-5bbba1551004",
"title": "Done",
"cards": []
}
],
"archive": {
"lists": [],
"cards": []
},
"settings": {
"labels": []
}
}
+41
View File
@@ -54,6 +54,7 @@ enum ENUM_X121_XKI_BUFFERS
//
// ATR ...
X121_XKI_ATR_LINE = 11,
X121_XKI_ATR_SMOOTHED_LINE = 17,
X121_XKI_ATR_RAW_UPPER_LINE = 12,
X121_XKI_ATR_RAW_LOWER_LINE = 13,
//
@@ -225,6 +226,7 @@ struct X121XKIConditions
double maFastBuffer[];
double maSlowBuffer[];
double atrBuffer[];
double atrSmoothedBuffer[];
double atrRawUpperBuffer[];
double atrRawLowerBuffer[];
double rsiBuffer[];
@@ -270,6 +272,7 @@ struct X121XKIConditions
XClean(maFastBuffer);
XClean(maSlowBuffer);
XClean(atrBuffer);
XClean(atrSmoothedBuffer);
XClean(atrRawUpperBuffer);
XClean(atrRawLowerBuffer);
XClean(rsiBuffer);
@@ -290,6 +293,7 @@ struct X121XKIConditions
ArraySetAsSeries(maFastBuffer, true);
ArraySetAsSeries(maSlowBuffer, true);
ArraySetAsSeries(atrBuffer, true);
ArraySetAsSeries(atrSmoothedBuffer, true);
ArraySetAsSeries(atrRawUpperBuffer, true);
ArraySetAsSeries(atrRawLowerBuffer, true);
ArraySetAsSeries(rsiBuffer, true);
@@ -552,6 +556,11 @@ class XCX121XKIHelper : public XCBaseHelper
loopback,
conditions.atrBuffer //
);
CopyATRSmoothed(
zIndex,
loopback,
conditions.atrSmoothedBuffer //
);
CopyATRRawUpper(
zIndex,
loopback,
@@ -1082,6 +1091,38 @@ class XCX121XKIHelper : public XCBaseHelper
}
// #endregion
// #region ATRSmoothed ...
//
double GetATRSmoothed(
int barIndex // Bar Index
)
{
//
return ReadValue(
(int)X121_XKI_ATR_SMOOTHED_LINE,
barIndex //
);
}
//
int CopyATRSmoothed(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool asSeries = true // As Series Flag
)
{
//
return ReadValues(
buffer,
(int)X121_XKI_ATR_SMOOTHED_LINE,
start,
count,
asSeries //
);
}
// #endregion
// #region ATR Raw Upper...
//
double GetATRRawUpper(
+22 -1
View File
@@ -87,7 +87,7 @@ input int startCalculationForLastBars = 1500; // Calculate Last n Bars
#property indicator_chart_window
//
#property indicator_buffers 18
#property indicator_buffers 19
#property indicator_plots 7
// #region Plot Buffers ...
@@ -237,6 +237,10 @@ double kiWaveStateBuffer[];
//
#define kiSlowStateBufferIndex mLastBufferIndex + 8
double kiSlowStateBuffer[];
//
#define atrSmoothedBufferIndex mLastBufferIndex + 9
double atrSmoothedBuffer[];
// #endregion
// #endregion
@@ -667,6 +671,10 @@ void DefineBuffers()
ArraySetAsSeries(atrBuffer, true);
SetIndexBuffer(atrBufferIndex, atrBuffer, INDICATOR_CALCULATIONS);
//
ArraySetAsSeries(atrSmoothedBuffer, true);
SetIndexBuffer(atrSmoothedBufferIndex, atrSmoothedBuffer, INDICATOR_CALCULATIONS);
//
ArraySetAsSeries(atrRawUpperBuffer, true);
SetIndexBuffer(atrRawUpperBufferIndex, atrRawUpperBuffer, INDICATOR_CALCULATIONS);
@@ -1214,6 +1222,18 @@ void CalculateATR(
if (IsXValid(atrSmoothingMode) &&
atrSmoothingLength > 0)
{
//
// Smoothed ATR ...
iMAOnBuffer(
ratesTotal,
prevCalculated,
barIndex,
atrSmoothingLength,
atrBuffer,
atrSmoothedBuffer,
atrSmoothingMode //
);
//
// Upper ...
iMAOnBuffer(
@@ -1241,6 +1261,7 @@ void CalculateATR(
else
{
//
atrSmoothedBuffer[barIndex] = iAtr;
kiUpperBuffer[barIndex] = iUpperValue;
kiLowerBuffer[barIndex] = iLowerValue;
}
@@ -274,7 +274,6 @@ class XCX121XKIHelperParser : XCBase
//
return result;
}
// #endregion
// #region KI Slow ...
@@ -875,10 +874,7 @@ class XCX121XKIHelperParser : XCBase
return result;
}
bool IsVolatilityHigh(
int barIndex = 0,
double threshold = 20 //
)
bool IsVolatilityHigh(int barIndex = 0)
{
//
bool result = false;
@@ -894,16 +890,17 @@ class XCX121XKIHelperParser : XCBase
{
return result;
}
//
double atr = helper.GetATR(barIndex);
double atrMa = helper.GetATRSmoothed(barIndex);
result = atr > atrMa;
//
result = helper.GetATR(barIndex) > threshold;
return result;
}
bool IsVolatilityLow(
int barIndex = 0,
double threshold = 20 //
)
bool IsVolatilityLow(int barIndex = 0)
{
//
bool result = false;
@@ -921,7 +918,11 @@ class XCX121XKIHelperParser : XCBase
}
//
result = helper.GetATR(barIndex) < threshold;
double atr = helper.GetATR(barIndex);
double atrMa = helper.GetATRSmoothed(barIndex);
result = atr < atrMa;
//
return result;
}
// #endregion
@@ -1157,7 +1158,7 @@ class XCX121XKIHelperParser : XCBase
//
result = IsTrendBearish(barIndex) &&
IsRSIBearish(barIndex);
IsRSIBearish(barIndex);
//
return result;
@@ -1184,7 +1185,7 @@ class XCX121XKIHelperParser : XCBase
result =
IsPriceAboveKIUpper(barIndex) &&
IsATRBreakoutUp(barIndex) &&
IsVolatilityHigh(barIndex, 20);
IsVolatilityHigh(barIndex);
//
return result;
@@ -1211,7 +1212,7 @@ class XCX121XKIHelperParser : XCBase
result =
IsPriceBelowKILower(barIndex) &&
IsATRBreakoutDown(barIndex) &&
IsVolatilityHigh(barIndex, 20);
IsVolatilityHigh(barIndex);
return result;
}
@@ -1331,7 +1332,7 @@ class XCX121XKIHelperParser : XCBase
IsKISlowBullish(barIndex) &&
IsMACrossoverBullish(barIndex) &&
(helper.GetRSI(barIndex) > 60) &&
IsVolatilityHigh(barIndex, 20);
IsVolatilityHigh(barIndex);
//
return result;
@@ -1365,7 +1366,7 @@ class XCX121XKIHelperParser : XCBase
IsKISlowBearish(barIndex) &&
IsMACrossoverBearish(barIndex) &&
(helper.GetRSI(barIndex) < 40) &&
IsVolatilityHigh(barIndex, 20);
IsVolatilityHigh(barIndex);
//
return result;
@@ -907,180 +907,110 @@ class XCX121XKIStrategy1Signaller : public XCX121XKIBaseSignaller
}
//
result = poiDetector.IsKISignal(
dir,
bar.Index() //
);
bool isBullish = result &&
IsXBullish(dir);
bool isBearish = result &&
IsXBearish(dir);
result = isBullish ||
isBearish;
if (!result)
{
return result;
}
int barIndex = bar.Index() + 1;
//
// Detect Nearest Directional ...
int nearestDirectionalSwitchIndex = -1;
if (isBullish)
{
//
isBullish = poiDetector.NearestKIFastSwitchedToBullish(
nearestDirectionalSwitchIndex,
bar.Index() + 2 //
);
}
else
{
//
isBearish = poiDetector.NearestKIFastSwitchedToBearish(
nearestDirectionalSwitchIndex,
bar.Index() + 2 //
);
}
result =
IsValidIndex(nearestDirectionalSwitchIndex) &&
(isBullish ||
isBearish);
if (!result)
{
//
bar.Clean();
return result;
}
// Safe for Entry ...
bool isSafe = false;
bool isSafeForBullishEntry = kiParser.IsSafeBullishEntry(barIndex);
bool isSafeForBearishEntry = kiParser.IsSafeBearishEntry(barIndex);
//
// Preparing Zone ...
double upper = bar.FindHighest(nearestDirectionalSwitchIndex - bar.Index(), MODE_HIGH);
double lower = bar.FindLowest(nearestDirectionalSwitchIndex - bar.Index(), MODE_LOW);
//
result = zone.Init(
symbol,
period,
upper,
lower,
GetBarTime(symbol, period, nearestDirectionalSwitchIndex),
bar.time,
dir,
"XKI1" //
);
//
// Support and Resistance ...
XBoxZone support;
XBoxZone resistance;
if (result)
// POI ...
bool isPOI = poiDetector.IsPOI(dir, barIndex);
bool isBullishPOI = isPOI &&
IsXBullish(dir);
bool isBearishPOI = isPOI &&
IsXBearish(dir);
isSafe = (isBullishPOI && isSafeForBullishEntry) ||
(isBearishPOI && isSafeForBearishEntry);
if (isPOI && isSafe)
{
//
XOHCL tmpBar;
int tmpIDX = -1;
bool has = false;
double upper = 0;
double lower = 0;
int length = zone.GetAge();
//
// Support ...
tmpIDX = bar.FindLowestIndex(length, MODE_LOW);
if (IsValidIndex(tmpIDX))
{
//
if (tmpBar.Init(symbol, period, tmpIDX))
{
//
lower = iLow(symbol, period, tmpIDX);
upper = bar.FindLowest(length, MODE_CLOSE);
if (upper <= lower)
{
upper = tmpBar.GetDown();
}
//
has = support.Init(
symbol,
period,
upper,
lower,
tmpBar.time,
bar.time,
X_DIRECTION_BULLISH,
X_BAR_PATTERN_SUPPORT //
);
//
tmpBar.Clean();
}
}
//
// Resistance ...
tmpIDX = bar.FindHighestIndex(length, MODE_HIGH);
if (IsValidIndex(tmpIDX))
{
//
if (tmpBar.Init(symbol, period, tmpIDX))
{
//
upper = iHigh(symbol, period, tmpIDX);
lower = bar.FindHighest(length, MODE_CLOSE);
if (upper <= lower)
{
upper = tmpBar.GetUp();
}
//
has = resistance.Init(
symbol,
period,
upper,
lower,
tmpBar.time,
bar.time,
X_DIRECTION_BEARISH,
X_BAR_PATTERN_RESISTANCE //
);
//
tmpBar.Clean();
}
}
}
//
// TODO: Rempve ...
if (result)
{
//
// Other Drawing Materials ...
XPOIDrawConfig drawConfig;
drawConfig.Default();
//
poiDrawer.DrawZone(zone, drawConfig);
//
if (support.IsValid())
{
poiDrawer.DrawZone(support, drawConfig);
}
//
if (resistance.IsValid())
{
poiDrawer.DrawZone(resistance, drawConfig);
}
//
drawConfig.Clean();
//
// Print("isPOI: ", ToXString(dir));
// DebugBreak();
}
//
// Breakout POI ...
bool isBreakoutPOI = poiDetector.IsBreakoutPOI(dir, barIndex);
bool isBullishBreakoutPOI = isBreakoutPOI &&
IsXBullish(dir);
bool isBearishBreakoutPOI = isBreakoutPOI &&
IsXBearish(dir);
isSafe = (isBullishBreakoutPOI && isSafeForBullishEntry) ||
(isBearishBreakoutPOI && isSafeForBearishEntry);
if (isBreakoutPOI && isSafe)
{
//
// Print("isBreakoutPOI: ", ToXString(dir));
// DebugBreak();
}
//
// Reversal POI ...
bool isReversalPOI = poiDetector.IsReversalPOI(dir, barIndex);
bool isBullishReversalPOI = isReversalPOI &&
IsXBullish(dir);
bool isBearishReversalPOI = isReversalPOI &&
IsXBearish(dir);
isSafe = (isBullishReversalPOI && isSafeForBullishEntry) ||
(isBearishReversalPOI && isSafeForBearishEntry);
if (isReversalPOI && isSafe)
{
//
Print("isReversalPOI: ", ToXString(dir));
DebugBreak();
}
//
// Continuation POI ...
bool isContinuationPOI = poiDetector.IsContinuationPOI(dir, barIndex);
bool isBullishContinuationPOI = isContinuationPOI &&
IsXBullish(dir);
bool isBearishContinuationPOI = isContinuationPOI &&
IsXBearish(dir);
isSafe = (isBullishContinuationPOI && isSafeForBullishEntry) ||
(isBearishContinuationPOI && isSafeForBearishEntry);
if (isContinuationPOI && isSafe)
{
//
// Print("isContinuationPOI: ", ToXString(dir));
// DebugBreak();
}
//
// Exhaustion POI ...
bool isExhaustionPOI = poiDetector.IsExhaustionPOI(dir, barIndex);
bool isBullishExhaustionPOI = isExhaustionPOI &&
IsXBullish(dir);
bool isBearishExhaustionPOI = isExhaustionPOI &&
IsXBearish(dir);
isSafe = (isBullishExhaustionPOI && isSafeForBullishEntry) ||
(isBearishExhaustionPOI && isSafeForBearishEntry);
if (isExhaustionPOI && isSafe)
{
//
Print("isExhaustionPOI: ", ToXString(dir));
DebugBreak();
}
//
// TrendExhausted POI ...
bool isTrendExhaustedPOI = poiDetector.IsTrendExhaustedPOI(dir, barIndex);
bool isBullishTrendExhaustedPOI = isTrendExhaustedPOI &&
IsXBullish(dir);
bool isBearishTrendExhaustedPOI = isTrendExhaustedPOI &&
IsXBearish(dir);
isSafe = (isBullishTrendExhaustedPOI && isSafeForBullishEntry) ||
(isBearishTrendExhaustedPOI && isSafeForBearishEntry);
if (isTrendExhaustedPOI && isSafe)
{
//
Print("isTrendExhaustedPOI: ", ToXString(dir));
DebugBreak();
}
//
result =
result &&
@@ -384,6 +384,41 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
// #endregion
// #region Detectors ...
bool IsPOI(
ENUM_X_DIRECTION &forDir,
int barIndex = 0 //
)
{
//
bool result = false;
//
// Normalize ...
forDir = X_DIRECTION_NONE;
barIndex = kiParser.NormalizeBarIndex(barIndex);
//
bool isBullish = IsBullishPOI(barIndex);
bool isBearish = IsBearishPOI(barIndex);
result = isBullish || isBearish;
if (!result)
{
return result;
}
//
forDir =
isBullish
? X_DIRECTION_BULLISH
: isBearish
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
result = HasDirection(forDir);
//
return result;
}
bool IsBullishPOI(int barIndex = 0)
{
//
@@ -462,6 +497,41 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
return result;
}
bool IsBreakoutPOI(
ENUM_X_DIRECTION &forDir,
int barIndex = 0 //
)
{
//
bool result = false;
//
// Normalize ...
forDir = X_DIRECTION_NONE;
barIndex = kiParser.NormalizeBarIndex(barIndex);
//
bool isBullish = IsBullishBreakoutPOI(barIndex);
bool isBearish = IsBearishBreakoutPOI(barIndex);
result = isBullish || isBearish;
if (!result)
{
return result;
}
//
forDir =
isBullish
? X_DIRECTION_BULLISH
: isBearish
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
result = HasDirection(forDir);
//
return result;
}
bool IsBullishBreakoutPOI(int barIndex = 0)
{
//
@@ -538,6 +608,41 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
return result;
}
bool IsReversalPOI(
ENUM_X_DIRECTION &forDir,
int barIndex = 0 //
)
{
//
bool result = false;
//
// Normalize ...
forDir = X_DIRECTION_NONE;
barIndex = kiParser.NormalizeBarIndex(barIndex);
//
bool isBullish = IsBullishReversalPOI(barIndex);
bool isBearish = IsBearishReversalPOI(barIndex);
result = isBullish || isBearish;
if (!result)
{
return result;
}
//
forDir =
isBullish
? X_DIRECTION_BULLISH
: isBearish
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
result = HasDirection(forDir);
//
return result;
}
bool IsBullishReversalPOI(int barIndex = 0)
{
//
@@ -614,6 +719,41 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
return result;
}
bool IsContinuationPOI(
ENUM_X_DIRECTION &forDir,
int barIndex = 0 //
)
{
//
bool result = false;
//
// Normalize ...
forDir = X_DIRECTION_NONE;
barIndex = kiParser.NormalizeBarIndex(barIndex);
//
bool isBullish = IsBullishContinuationPOI(barIndex);
bool isBearish = IsBearishContinuationPOI(barIndex);
result = isBullish || isBearish;
if (!result)
{
return result;
}
//
forDir =
isBullish
? X_DIRECTION_BULLISH
: isBearish
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
result = HasDirection(forDir);
//
return result;
}
bool IsBullishContinuationPOI(int barIndex = 0)
{
//
@@ -694,6 +834,41 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
return result;
}
bool IsExhaustionPOI(
ENUM_X_DIRECTION &forDir,
int barIndex = 0 //
)
{
//
bool result = false;
//
// Normalize ...
forDir = X_DIRECTION_NONE;
barIndex = kiParser.NormalizeBarIndex(barIndex);
//
bool isBullish = IsBullishExhaustionPOI(barIndex);
bool isBearish = IsBearishExhaustionPOI(barIndex);
result = isBullish || isBearish;
if (!result)
{
return result;
}
//
forDir =
isBullish
? X_DIRECTION_BULLISH
: isBearish
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
result = HasDirection(forDir);
//
return result;
}
bool IsBullishExhaustionPOI(int barIndex = 0)
{
//
@@ -772,6 +947,41 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
return result;
}
bool IsTrendExhaustedPOI(
ENUM_X_DIRECTION &forDir,
int barIndex = 0 //
)
{
//
bool result = false;
//
// Normalize ...
forDir = X_DIRECTION_NONE;
barIndex = kiParser.NormalizeBarIndex(barIndex);
//
bool isBullish = IsBullishTrendExhaustedPOI(barIndex);
bool isBearish = IsBearishTrendExhaustedPOI(barIndex);
result = isBullish || isBearish;
if (!result)
{
return result;
}
//
forDir =
isBullish
? X_DIRECTION_BULLISH
: isBearish
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
result = HasDirection(forDir);
//
return result;
}
bool IsBullishTrendExhaustedPOI(int barIndex = 0)
{
//
@@ -782,7 +992,7 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
//
result = kiParser.IsTrendStrongBullish(barIndex) &&
kiParser.IsVolatilityLow(barIndex, 20) &&
kiParser.IsVolatilityLow(barIndex) &&
kiParser.IsRSIOverbought(barIndex);
if (!result)
{
@@ -822,7 +1032,7 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
//
result = kiParser.IsTrendStrongBearish(barIndex) &&
kiParser.IsVolatilityLow(barIndex, 20) &&
kiParser.IsVolatilityLow(barIndex) &&
kiParser.IsRSIOversold(barIndex);
if (!result)
{
@@ -936,6 +1146,533 @@ class XCX121XKIPOIDetector : public XCMarketPatternDetector
}
// #endregion
// #region Zone Detectors ...
int DetectSupports(
XBoxZone &zones[],
int barIndex,
int loopback = 50,
bool forceValidation = true,
int validationLength = 7,
string forSymbol = NULL,
ENUM_TIMEFRAMES forPeriod = NULL //
)
{
//
int result = 0;
//
XClean(zones);
//
// Normalize ...
//
if (barIndex < 0)
{
barIndex = 0;
}
//
if (!IsXValid(forSymbol))
{
forSymbol = symbol;
}
//
if (!IsXValid(forPeriod))
{
forPeriod = period;
}
//
if (loopback < 2)
{
loopback = 2;
}
//
if (validationLength < 2)
{
validationLength = 2;
}
//
// Preparing Loops ...
XOHCL tmpBar;
bool has = false;
double upper = 0;
double lower = 0;
XBoxZone tmpZone;
string type = NULL;
double tmpValue = 0;
datetime from = NULL;
int start = barIndex;
int end = barIndex + loopback;
datetime to = GetBarTime(forSymbol, forPeriod, barIndex);
for (int i = start; i < end; i++)
{
//
// Initialize Bar ...
if (tmpBar.Init(forSymbol, forPeriod, i))
{
//
// Check Has Shadow ...
has = tmpBar.GetHighShadow() > 0 ||
tmpBar.GetLowShadow() > 0;
if (has)
{
//
// Check Support or Resistance ...
//
// Support ...
tmpValue = tmpBar.FindLowest(validationLength, MODE_LOW);
has = NotEmptyZero(tmpValue) &&
tmpValue == tmpBar.low;
if (has)
{
//
tmpZone.Clean();
lower = tmpValue;
from = tmpBar.time;
upper = tmpBar.GetDown();
type = ToXString(X_BAR_PATTERN_SUPPORT);
has = tmpZone.Init(
forSymbol,
forPeriod,
upper,
lower,
from,
to,
X_DIRECTION_BULLISH,
type //
);
if (has)
{
//
AddRef(
tmpZone,
zones //
);
//
tmpZone.Clean();
}
}
}
//
tmpBar.Clean();
}
}
//
// Validate ...
if (HasChild(zones) && forceValidation)
{
ValidateZones(zones, barIndex);
}
//
result = ArraySize(zones);
//
return result;
}
int DetectResistances(
XBoxZone &zones[],
int barIndex,
int loopback = 50,
bool forceValidation = true,
int validationLength = 7,
string forSymbol = NULL,
ENUM_TIMEFRAMES forPeriod = NULL //
)
{
//
int result = 0;
//
XClean(zones);
//
// Normalize ...
//
if (barIndex < 0)
{
barIndex = 0;
}
//
if (!IsXValid(forSymbol))
{
forSymbol = symbol;
}
//
if (!IsXValid(forPeriod))
{
forPeriod = period;
}
//
if (loopback < 2)
{
loopback = 2;
}
//
if (validationLength < 2)
{
validationLength = 2;
}
//
// Preparing Loops ...
XOHCL tmpBar;
bool has = false;
double upper = 0;
double lower = 0;
XBoxZone tmpZone;
string type = NULL;
double tmpValue = 0;
datetime from = NULL;
int start = barIndex;
int end = barIndex + loopback;
datetime to = GetBarTime(forSymbol, forPeriod, barIndex);
for (int i = start; i < end; i++)
{
//
// Initialize Bar ...
if (tmpBar.Init(forSymbol, forPeriod, i))
{
//
// Check Has Shadow ...
has = tmpBar.GetHighShadow() > 0 ||
tmpBar.GetLowShadow() > 0;
if (has)
{
//
// Check Support or Resistance ...
//
// Resistance ...
tmpValue = tmpBar.FindHighest(validationLength, MODE_HIGH);
has = NotEmptyZero(tmpValue) &&
tmpValue == tmpBar.high;
if (has)
{
//
tmpZone.Clean();
upper = tmpValue;
from = tmpBar.time;
lower = tmpBar.GetUp();
type = ToXString(X_BAR_PATTERN_RESISTANCE);
has = tmpZone.Init(
forSymbol,
forPeriod,
upper,
lower,
from,
to,
X_DIRECTION_BEARISH,
type //
);
if (has)
{
//
AddRef(
tmpZone,
zones //
);
//
tmpZone.Clean();
}
}
}
//
tmpBar.Clean();
}
}
//
// Validate ...
if (HasChild(zones) && forceValidation)
{
ValidateZones(zones, barIndex);
}
//
result = ArraySize(zones);
//
return result;
}
void ValidateZones(
XBoxZone &zones[],
int barIndex = 0,
ENUM_X_BOUNDARY_PRICE forPriceType = X_BOUNDARY_PRICE_UP_DOWN //
)
{
//
bool has = false;
//
barIndex = kiParser.NormalizeBarIndex(barIndex);
//
has = HasChild(zones) &&
IsXValid(forPriceType);
if (!has)
{
return;
}
//
XOHCL tmpBar;
XBoxZone tmp;
XBoxZone tmps[];
double tmpValue = 0;
for (int i = 0; i < ArraySize(zones); i++)
{
//
tmp = zones[i];
//
// Validate Zone ...
has = false;
for (int j = barIndex; j < tmp.FromIndex(); j++)
{
//
// Initial Bar ...
if (tmpBar.Init(tmp.symbol, tmp.period, j))
{
//
tmpValue = forPriceType == X_BOUNDARY_PRICE_UP_DOWN
? tmp.IsBullish()
? tmpBar.GetDown()
: tmpBar.GetUp()
: forPriceType == X_BOUNDARY_PRICE_HIGH_LOW
? tmp.IsBullish()
? tmpBar.low
: tmpBar.high
: EMPTY_VALUE;
if (NotEmptyZero(tmpValue))
{
//
// Check Break ...
has = tmp.IsBullish()
? tmpValue < tmp.lower
: tmpValue > tmp.upper;
//
// If Breakes ...
if (has)
{
break;
}
}
//
tmpBar.Clean();
}
}
//
// Not Breaked ...
if (!has)
{
//
AddIfNotExists(
tmp,
tmps //
);
}
//
tmp.Clean();
}
//
// Update Zones ...
XClean(zones);
Copy(
tmps,
zones //
);
XClean(tmps);
}
void GetCurrentStructure(
XBoxZone &supports[],
XBoxZone &resistances[],
XBoxZone &minorSupport,
XBoxZone &majorSupport,
XBoxZone &minorResistance,
XBoxZone &majorResistance,
int barIndex = 0,
string forSymbol = NULL,
ENUM_TIMEFRAMES forPeriod = NULL,
int loopback = 50,
int minorValidation = 7,
int majorValidation = 14 //
)
{
//
bool has = false;
//
XClean(supports);
XClean(resistances);
minorSupport.Clean();
majorSupport.Clean();
minorResistance.Clean();
majorResistance.Clean();
//
// Normalize ...
barIndex = kiParser.NormalizeBarIndex(barIndex);
if (!IsXValid(forSymbol))
{
forSymbol = symbol;
}
if (!IsXValid(forPeriod))
{
forPeriod = period;
}
//
int tmpIDX = -1;
int supportsCount = 0;
XBoxZone tmpSupports[];
int resistancesCount = 0;
XBoxZone tmpResistances[];
//
// Detect Minors ...
//
supportsCount = DetectSupports(
tmpSupports,
barIndex,
loopback,
true, // Force Validation ...
minorValidation,
forSymbol,
forPeriod //
);
if (IsValidSize(supportsCount))
{
//
FillNotExists(
supports,
tmpSupports //
);
//
tmpIDX = GetYoungest(tmpSupports);
if (IsValidIndex(tmpIDX))
{
minorSupport = tmpSupports[tmpIDX];
}
}
//
resistancesCount = DetectResistances(
tmpResistances,
barIndex,
loopback,
true, // Force Validation ...
minorValidation,
forSymbol,
forPeriod //
);
if (IsValidSize(resistancesCount))
{
//
FillNotExists(
resistances,
tmpResistances //
);
//
tmpIDX = GetYoungest(tmpResistances);
if (IsValidIndex(tmpIDX))
{
minorResistance = tmpResistances[tmpIDX];
}
}
//
XClean(tmpSupports);
XClean(tmpResistances);
//
// Detect Majors ...
//
supportsCount = DetectSupports(
tmpSupports,
barIndex,
loopback,
true, // Force Validation ...
majorValidation,
forSymbol,
forPeriod //
);
if (IsValidSize(supportsCount))
{
//
FillNotExists(
supports,
tmpSupports //
);
//
tmpIDX = GetLowest(tmpSupports);
if (IsValidIndex(tmpIDX))
{
majorSupport = tmpSupports[tmpIDX];
}
}
//
resistancesCount = DetectResistances(
tmpResistances,
barIndex,
loopback,
true, // Force Validation ...
majorValidation,
forSymbol,
forPeriod //
);
if (IsValidSize(resistancesCount))
{
//
FillNotExists(
resistances,
tmpResistances //
);
//
tmpIDX = GetHighest(tmpResistances);
if (IsValidIndex(tmpIDX))
{
majorResistance = tmpResistances[tmpIDX];
}
}
//
XClean(tmpSupports);
XClean(tmpResistances);
}
// #endregion
//
// Others ...
+1
View File
@@ -19,6 +19,7 @@
"repackXFIMAEA": "node prepareXFIMAEA.js",
"repackXCATBEA": "node prepareXCATBEA.js",
"repackXOM1EA": "node prepareXOM1EA.js",
"repackXRRTools": "node prepareXRRTools.js",
"repackX121XKIEA": "node prepareX121XKIEA.js"
},
"repository": {
+27
View File
@@ -0,0 +1,27 @@
//
// Import Requirements ...
const XProjectTools = require("./x-mql-project.tools");
//
// define constants ...
const projectName = "XRRTools";
//
// Projects Resources ...
const projectResources = [
"Libraries/*", // Required Libraries
"Classes/*", // Required Classes
"Indicators/x-saherelm.x121.xcc", // Required Indicators
"Experts/x-saherelm.rr.tools", // Expert Advisers
];
//
run();
/**
* Main Project Function ...
*/
async function run() {
//
await XProjectTools.prepareProject(projectName, projectResources);
}
+1
View File
@@ -24,6 +24,7 @@ const workspacePaths = [
"Helpers", // Indicator's Helpers Classes
"Indicators", // Required Indicators
"Libraries", // Required Libraries
"X121KIEA", // X121KIEA Projects ...
"XCATBEA", // XCATBEA Projects ...
"XOM1EA", // XOM1EA Projects ...
"XFIMAEA", // XOM1EA Projects ...