last works ...

This commit is contained in:
2025-10-27 05:02:51 +03:30
parent 8f317a3b1d
commit 31f1abb8d3
11 changed files with 5766 additions and 261 deletions
@@ -5497,6 +5497,37 @@ bool HasInside(
return result;
}
bool IsZoneAffected(
XOHCL &bar,
XBoxZone &zone //
)
{
//
bool result = false;
//
// Validate ...
result = bar.IsValid() &&
zone.IsValid();
if (!result)
{
return result;
}
//
bool isActed = IsActed(bar, zone);
bool isTested = IsTested(bar, zone);
bool isFakeBreaked = IsFakeBreaked(bar, zone);
//
result = isActed ||
isTested ||
isFakeBreaked;
//
return result;
}
/**
* Extract Affected Zones for Specified Bar ...
*
+188
View File
@@ -321,6 +321,194 @@ int GetAllBarPatters(ENUM_X_BAR_PATTERN &dest[])
//
// Structures ...
/**
* Model a Trend Line ...
**/
struct XTrend
{
//
string symbol;
datetime time;
ENUM_TIMEFRAMES period;
//
double fromValue;
datetime fromTime;
//
double toValue;
datetime toTime;
//
ENUM_X_DIRECTION dir;
//
// Constructor ...
XTrend()
{
Clean();
}
//
// Tools ...
/**
* Initialize ...
*
* @param _symbol: string, Specified Symbol ...
* @param _period: ENUM_TIMEFRAMES, Specified Period ...
* @param _time: datetime, Detection Time ...
* @param _fromValue: double, From Value ...
* @param _fromTime: datetime, From Time ...
* @param _toValue: double, To Value ...
* @param _toTime: datetime, To Time ...
*
* @return ( bool )
*/
bool Init(
string _symbol,
ENUM_TIMEFRAMES _period,
datetime _time,
double _fromValue,
datetime _fromTime,
double _toValue,
datetime _toTime //
)
{
//
bool result = false;
//
time = _time;
symbol = _symbol;
period = _period;
toTime = _toTime;
toValue = _toValue;
fromTime = _fromTime;
fromValue = _fromValue;
//
result = IsValid();
if (!result)
{
Clean();
}
//
// Setting Direction ...
if (result)
{
//
dir =
fromValue < toValue
? X_DIRECTION_BULLISH
: fromValue > toValue
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
}
//
return result;
}
/**
* Cleanup ...
*/
void Clean()
{
//
time = NULL;
toValue = 0;
fromValue = 0;
symbol = NULL;
period = NULL;
toTime = NULL;
fromTime = NULL;
dir = X_DIRECTION_NONE;
//
ZeroMemory(this);
}
/**
* Validate ...
*
* @return ( bool )
*/
bool IsValid()
{
//
bool result = false;
//
result =
IsXValid(time) &&
IsXValid(symbol) &&
IsXValid(period) &&
IsXValid(toTime) &&
IsXValid(fromTime) &&
NotEmptyZero(toValue) &&
NotEmptyZero(fromValue) &&
fromTime < toTime;
//
return result;
}
/**
* Check Trend Has Specific Direction ...
*
* @return ( bool )
*/
bool HasTrend()
{
return IsValid() &&
HasDirection(dir);
}
/**
* Check Trend is Bullish ...
*
* @return ( bool )
*/
bool IsBullish()
{
return HasTrend() &&
IsXBullish(dir);
}
/**
* Check Trend is Bearish ...
*
* @return ( bool )
*/
bool IsBearish()
{
return HasTrend() &&
IsXBearish(dir);
}
/**
* Get Unique Identifier ...
*
* @return ( string )
*/
string GetObjectID()
{
//
string result = NULL;
//
if (IsValid())
{
result = "XTRND_" + ToXString(dir) + "_" + ToXString(TimeToSeconds(time));
}
//
return result;
}
};
/**
* Represent a Pivot ...
**/
+63 -2
View File
@@ -1098,6 +1098,43 @@ struct XPosition
return result;
}
//
bool IsLong()
{
return IsValid() &&
IsXBullish(type);
}
//
bool IsBullish()
{
return IsLong();
}
//
bool IsShort()
{
return IsValid() &&
IsXBearish(type);
}
//
bool IsBearish()
{
return IsShort();
}
//
ENUM_X_DIRECTION GetDirection()
{
//
return IsBullish()
? X_DIRECTION_BULLISH
: IsBearish()
? X_DIRECTION_BEARISH
: X_DIRECTION_NONE;
}
//
// Retrieve Entry Price ...
double GetEntry()
@@ -1317,7 +1354,7 @@ struct XPosition
//
double risk = GetRisk();
int r2r = (int)GetRiskRewardRatio();
bool isLong = IsLong(type);
bool isLong = IsLong();
for (int i = 0; i < r2r; i++)
{
//
@@ -1350,7 +1387,7 @@ struct XPosition
reachedLevel = -1;
reachedPrice = 0;
double tps[];
bool isLong = IsLong(type);
bool isLong = IsLong();
double exitPrice = GetExit();
int tpLevels = CalculateTPLevels(tps);
if (!IsValidSize(tpLevels) || exitPrice <= 0)
@@ -3868,6 +3905,30 @@ bool IsValid(ENUM_X_ORDER_MODES value)
return value != X_ORDER_MODE_NOTHING;
}
//
bool IsXBullish(ENUM_POSITION_TYPE type)
{
return type == POSITION_TYPE_BUY;
}
//
bool IsXBullish(ENUM_X_POSITION_TYPES type)
{
return type == X_POSITION_TYPE_LONG;
}
//
bool IsXBearish(ENUM_POSITION_TYPE type)
{
return type == POSITION_TYPE_SELL;
}
//
bool IsXBearish(ENUM_X_POSITION_TYPES type)
{
return type == X_POSITION_TYPE_SHORT;
}
//
// Ages ...