Complete XSMC SMPV Strategy and Prepare for Testing Phase 1 ...
This commit is contained in:
@@ -3943,6 +3943,163 @@ struct XConsolidationZone
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Model Value Changed ...
|
||||
struct XValueChange
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
double before; // Before Change Value ...
|
||||
double after; // After Change Value ...
|
||||
datetime time; // Change Time ...
|
||||
ENUM_X_DIRECTION dir; // Change Direction ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XValueChange()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Initialize ...
|
||||
*
|
||||
* @param _before: Double, Value Before Change ...
|
||||
* @param _after: Double, Value After Change ...
|
||||
* @param _time: Datetime, Change Time ...
|
||||
* @param _dir: ENUM_X_DIRECTION member, Specified Changed Direction ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool Init(
|
||||
double _before, // Before Change Value ...
|
||||
double _after, // After Change Value ...
|
||||
ENUM_X_DIRECTION _dir, // Change Direction ...
|
||||
datetime _time = NULL // Change Time ...
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
_time = NormalizeTime(_time);
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
result =
|
||||
//
|
||||
_after > 0 &&
|
||||
_before > 0 &&
|
||||
IsValid(_time) &&
|
||||
_after != _before &&
|
||||
HasDirection(_dir)
|
||||
//
|
||||
;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Set Validated Values ...
|
||||
dir = _dir;
|
||||
time = _time;
|
||||
after = _after;
|
||||
before = _before;
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleaning Up ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
after = 0;
|
||||
before = 0;
|
||||
time = NULL;
|
||||
dir = X_DIRECTION_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Model ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
after > 0 &&
|
||||
before > 0 &&
|
||||
IsValid(time) &&
|
||||
after != before &&
|
||||
HasDirection(dir)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill Change Bar ...
|
||||
*
|
||||
* @param bar: XOHCL instance Reference, holds Change Bar ...
|
||||
* @param _symbol: String, Specified Symbol ...
|
||||
* @param _period: ENUM_TIMEFRAMES _period member, Specified Period ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool FillBar(
|
||||
XOHCL &bar,
|
||||
string _symbol = NULL,
|
||||
ENUM_TIMEFRAMES _period = NULL //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
bar.Clean();
|
||||
_symbol = NormalizeSymbol(_symbol);
|
||||
_period = NormalizePeriod(_period);
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
IsValid(_symbol) &&
|
||||
IsValid(_period);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = bar.Init(
|
||||
_symbol,
|
||||
_period,
|
||||
time //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Extensions ...
|
||||
|
||||
@@ -4196,6 +4353,74 @@ string ToString(ENUM_XPOI_EVENTS value)
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Value Change instance to Exists Collection if it's not Exists ...
|
||||
*
|
||||
* @param item: XValueChange instance Reference ...
|
||||
* @param items: XValueChange instance Array Reference ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int AddIfNotExists(
|
||||
XValueChange &item,
|
||||
XValueChange &items[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = item.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool canAdd = false;
|
||||
int count = ArraySize(items);
|
||||
if (!IsValidSize(count))
|
||||
{
|
||||
canAdd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
XValueChange last;
|
||||
bool hasItem = GetLastItem(
|
||||
last,
|
||||
items //
|
||||
);
|
||||
if (!hasItem)
|
||||
{
|
||||
canAdd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Compare Last Item with Current ...
|
||||
canAdd = item.time > last.time;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Add Item if Allowed ...
|
||||
if (canAdd)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
item,
|
||||
items //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(items);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine a Collection of States into dest ...
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user