last works and apply fix on ZigZag Reading ...

This commit is contained in:
2025-09-20 13:55:34 +03:30
parent 6788675c4a
commit becac9983d
5 changed files with 851 additions and 41 deletions
+176 -2
View File
@@ -82,7 +82,9 @@ struct XZigZagPoint
// Props ...
double value; // Value
datetime time; // Time
string symbol; // Symbol
ENUM_X_DIRECTION dir; // Direction
ENUM_TIMEFRAMES period; // Period
ENUM_X_ZIGZAG_POINT_TYPE type; // Type
//
@@ -92,6 +94,52 @@ struct XZigZagPoint
Clean();
}
//
// Init ...
/**
* Initialize Structure ...
*
* @param _value: double, value of point ...
* @param _time: datetime, time of point ...
* @param _symbol: string, Symbol ...
* @param _dir: ENUM_X_DIRECTION, direction of point ...
* @param _period: ENUM_TIMEFRAMES, period ...
* @param _type: ENUM_X_ZIGZAG_POINT_TYPE, point type ...
*
* @return ( bool )
*/
bool Init(
double _value,
datetime _time,
string _symbol,
ENUM_X_DIRECTION _dir,
ENUM_TIMEFRAMES _period,
ENUM_X_ZIGZAG_POINT_TYPE _type //
)
{
//
bool result = false;
//
dir = _dir;
time = _time;
type = _type;
value = _value;
symbol = _symbol;
period = _period;
//
result = IsValid();
if (!result)
{
Clean();
}
//
return result;
}
//
// Tools ...
@@ -103,6 +151,8 @@ struct XZigZagPoint
//
value = 0;
time = NULL;
symbol = NULL;
period = NULL;
dir = X_DIRECTION_NONE;
type = X_ZIGZAG_POINT_TYPE_NONE;
@@ -125,7 +175,9 @@ struct XZigZagPoint
value > 0 &&
IsXValid(type) &&
HasDirection(dir) &&
IsSpecifiedValid(time);
IsSpecifiedValid(time) &&
IsSpecifiedValid(symbol) &&
IsSpecifiedValid(period);
//
return result;
@@ -167,6 +219,128 @@ struct XZigZagPoint
return result;
}
/**
* Check two Struct are Same or not ...
*
* @param item: XZigZagPoint ...
*
* @return ( bool )
*/
bool IsSameAs(XZigZagPoint &item)
{
//
bool result = false;
//
result =
IsValid() &&
item.IsValid() &&
dir == item.dir &&
type == item.type &&
time == item.time &&
value == item.value &&
symbol == item.symbol &&
period == item.period;
//
return result;
}
/**
* Check Structure Exists in Specified Collection or not ...
*
* @param items: XZigZagPoint, reference Array ...
* @param index: int, reference to Holds Founded Index ...
*
* @return ( bool )
*/
bool IsExists(
XZigZagPoint &items[],
int &index //
)
{
//
bool result = false;
//
// Prepare ...
index = -1;
//
// Validate ...
result =
IsValid() &&
HasChild(items);
if (!result)
{
return result;
}
//
int count = ArraySize(items);
for (int i = 0; i < count; i++)
{
//
result = IsSameAs(items[i]);
if (result)
{
//
index = i;
//
break;
}
}
//
result =
result &&
IsValidIndex(index);
//
return result;
}
/**
* Add Structure to Specified Collection only if not Exists ...
*
* @param items: XZigZagPoint, reference Array ...
*/
void AddIfNotExists(XZigZagPoint &items[])
{
//
// Validate ...
if (!IsValid())
{
return;
}
//
if (!HasChild(items))
{
//
AddRef(
this,
items //
);
//
return;
}
//
int index = -1;
bool isExists = IsExists(items, index);
if (!isExists)
{
//
AddRef(
this,
items //
);
}
}
/**
* Extract Specified Token of Struct ...
*
@@ -179,7 +353,7 @@ struct XZigZagPoint
/**
* Represent an String Unique Identifier for Chart Objects ...
*
*
* @return ( string )
*/
string GetObjectID()