This commit is contained in:
2025-02-22 01:13:26 +03:30
parent 627e9c4706
commit c371004b3b
10 changed files with 2701 additions and 4 deletions
+159 -2
View File
@@ -233,8 +233,9 @@ class XCBarArrowObject : public XCBaseObject
//
result =
//
bar.IsValid()
//
bar.IsValid() &&
IsValid(name)
//
;
if (!result)
@@ -2872,6 +2873,162 @@ class XCTrendObject : public XCBaseObject
public:
//
/**
* Creator ...
*
* @param chart_id: Long, Specified Chart ID ...
* @param window: Integer, Specified Chart Window ID ...
* @param rr: XRR instance Reference ...
* @param prefix: String ...
*
* @return ( bool )
*/
bool Create(
long chart_id,
int window,
XPoint &swings[],
bool useMinAsStart = true,
string prefix = NULL //
)
{
//
bool result = false;
//
int count = ArraySize(swings);
result =
count >= 2 &&
IsValidSize(count);
if (!result)
{
return result;
}
//
double min = 0;
datetime minAt = NULL;
//
double max = 0;
datetime maxAt = NULL;
//
// Etract Min/Max ...
for (int i = 0; i < count; i++)
{
//
XPoint iPoint = swings[i];
//
if (!iPoint.IsValid())
{
//
iPoint.Clean();
continue;
}
//
bool canSetMin =
min == 0
? true
: min > iPoint.value;
if (canSetMin)
{
//
minAt = iPoint.at;
min = iPoint.value;
}
//
bool canSetMax =
max == 0
? true
: max < iPoint.value;
if (canSetMax)
{
//
maxAt = iPoint.at;
max = iPoint.value;
}
//
iPoint.Clean();
}
//
double first =
useMinAsStart
? min
: max;
datetime firstTime =
useMinAsStart
? minAt
: maxAt;
//
double second =
useMinAsStart
? max
: min;
datetime secondTime =
useMinAsStart
? maxAt
: minAt;
//
// Validate Points ...
result =
//
first > 0 &&
second > 0 &&
(useMinAsStart
? first <= second
: first >= second) &&
IsSpecifiedValid(firstTime) &&
IsSpecifiedValid(secondTime)
//
;
if (!result)
{
return result;
}
//
ENUM_X_DIRECTION dir =
useMinAsStart
? X_DIRECTION_BULLISH
: X_DIRECTION_BEARISH;
//
string name = "XTRND" + ToString(dir) + "_" + ToString(first) + "_" + ToString(second);
if (IsValid(prefix))
{
name = prefix + "_" + name;
}
string nameMD5 = ToMD5(name);
//
result = mTrend.Create(
chart_id,
name,
window,
firstTime,
first,
secondTime,
second //
);
if (!result)
{
return result;
}
//
ObjName(name);
//
return result;
}
/**
* Creator ...
*