Add support for Draw Trend Line for Order Flow ...

This commit is contained in:
2025-02-19 03:17:38 +03:30
parent 5d0b655ad9
commit bf8b74d4e7
4 changed files with 613 additions and 504 deletions
+212 -16
View File
@@ -232,26 +232,47 @@ class XCX121SMCXWZSignalDetector : public XCBase
// Setup Conditions ...
//
int bullishFlowCount = mConditions.DetectOrderFlow(
X_DIRECTION_BULLISH,
consolidationState,
analyseState,
decisionState,
zIndex,
period,
ENUM_X_DIRECTION trend = X_DIRECTION_NONE;
bool hasOrderFlow = mConditions.HasOrderFlow(trend);
if (!hasOrderFlow)
{
//
int orderFlowCount = mConditions.DetectOrderFlow(
trend,
consolidationState,
analyseState,
decisionState //
);
hasOrderFlow = IsValidSize(orderFlowCount);
}
//
result = hasOrderFlow;
if (!result)
{
//
// TODO: Implement Clean ...
//
return result;
}
//
isBullish = IsBullish(trend);
isBearish = IsBearish(trend);
//
// Has Order Flow ...
//
// TODO: Remove this ...
DrawConditions(
mConditions,
visionCycleHelper.mPOIDrawer //
);
//
int bearishFlowCount = mConditions.DetectOrderFlow(
X_DIRECTION_BEARISH,
consolidationState,
analyseState,
decisionState,
zIndex,
period,
visionCycleHelper.mPOIDrawer //
);
//
return false;
@@ -1535,6 +1556,7 @@ class XCX121SMCXWZSignalDetector : public XCBase
void DrawConditions(
X121SMCStrategyXWZSignalConditions &conditions,
XCPOIDrawer *drawer,
bool drawTrendLine = true,
bool forceClean = false //
)
{
@@ -1551,6 +1573,8 @@ class XCX121SMCXWZSignalDetector : public XCBase
}
//
int count = 0;
bool has = false;
bool isCreated = false;
//
@@ -1558,6 +1582,160 @@ class XCX121SMCXWZSignalDetector : public XCBase
int subWindow = drawer.SubWindowIdentification();
color bullishColor = drawer.BarBullishColor();
color bearishColor = drawer.BarBearishColor();
//
ENUM_X_DIRECTION trend;
has = conditions.HasOrderFlow(trend);
if (has)
{
//
bool isBullish = IsBullish(trend);
//
count = conditions.CountOrderFlow();
for (int i = 0; i < count; i++)
{
//
XOBFVG iOBFVG = conditions.orderFlow[i];
//
XCBaseObject *drawnObjects[];
int drawnObjectsCount = drawer
.DrawOBFVG(
//
iOBFVG,
drawnObjects,
//
true, // Draw Order Block ...
true, // Draw Fair Value Gap ...
false, // Draw Supply Zones ...
false, // Draw Demand Zones ...
false, // Draw Support Zones ...
false // Draw Resistance Zones ...
);
if (IsValidSize(drawnObjectsCount))
{
AddDrawnObjects(drawnObjects);
}
}
//
if (drawTrendLine)
{
//
XOBFVGPivot pivots[];
count = conditions.GetSwings(pivots);
has = count >= 2;
if (has)
{
//
// Get Max / Min ...
double max = 0;
double min = 0;
datetime maxAt = NULL;
datetime minAt = NULL;
for (int i = 0; i < count; i++)
{
//
XOBFVGPivot iPivot = pivots[i];
//
if (!iPivot.IsValid())
{
//
iPivot.Clean();
continue;
}
//
// Min ...
bool canSetMin =
min == 0
? true
: min > iPivot.value;
if (canSetMin)
{
//
minAt = iPivot.at;
min = iPivot.value;
}
//
// Max ...
bool canSetMax =
max == 0
? true
: max < iPivot.value;
if (canSetMax)
{
//
maxAt = iPivot.at;
max = iPivot.value;
}
//
iPivot.Clean();
}
//
double price1 =
isBullish
? min
: max;
double price2 =
isBullish
? max
: min;
datetime time1 =
isBullish
? minAt
: maxAt;
datetime time2 =
isBullish
? maxAt
: minAt;
//
color clrTrend =
isBullish
? bullishColor
: bearishColor;
//
string trendName =
ToString(trend) + "_" + "XTRNDL_" +
ToString(conditions.period) + "_" +
ToString(price1) + "_" +
ToString(price2) + "_" +
ToMD5(ToString(time1));
//
CChartObjectTrend *mTrend;
mTrend = new CChartObjectTrend();
isCreated = mTrend.Create(
chartID,
trendName,
subWindow,
time1,
price1,
time2,
price2 //
);
//
if (isCreated)
{
//
mTrend.Width(2);
mTrend.Color(clrTrend);
mTrend.RayRight(true);
//
mObjects.Add(mTrend);
}
}
}
}
}
//
@@ -1663,6 +1841,24 @@ class XCX121SMCXWZSignalDetector : public XCBase
return result;
}
//
void AddDrawnObjects(XCBaseObject *&objects[])
{
//
int count = ArraySize(objects);
bool has = IsValidSize(count);
if (!has)
{
return;
}
//
for (int i = 0; i < count; i++)
{
mObjects.Add(objects[i]);
}
}
//
};