Complete and Test Trading Days POI ...

This commit is contained in:
2024-10-20 19:04:13 +03:30
parent 474dabbeb6
commit b86e8d5c6b
4 changed files with 2276 additions and 4 deletions
+98
View File
@@ -1105,6 +1105,59 @@ struct XOHCL
return result;
}
//
// Calculate Last Bar Open Time in Smaller Period ...
datetime GetLastBarTimeOfPeriod(
ENUM_TIMEFRAMES smallerPeriod //
)
{
//
datetime result = NULL;
//
if (!IsValid())
{
return result;
}
//
int sourceSeconds = PeriodSeconds(period);
int destSeconds = PeriodSeconds(smallerPeriod);
if (destSeconds >= sourceSeconds)
{
return result;
}
//
result = (datetime)((((int)time) + sourceSeconds) - destSeconds);
//
return result;
}
//
// Calculate Close Time ...
datetime GetCloseTime()
{
//
datetime result = NULL;
//
if (!IsValid())
{
return result;
}
//
int seconds = PeriodSeconds(period);
//
result = (datetime)(((int)time) + seconds);
//
return result;
}
//
// Find Current Bar Index on Chart ...
int Index()
@@ -8145,6 +8198,51 @@ MqlDateTime GetBarTimeStruct(
return result;
}
//
// Retrieve Last Available Bar Time of
// Dest Period inside Source Period ...
datetime GetLastBarTime(
ENUM_TIMEFRAMES sourcePeriod,
ENUM_TIMEFRAMES destPeriod //
)
{
//
datetime result = NULL;
//
if (!IsValid(sourcePeriod) ||
!IsValid(destPeriod))
{
return result;
}
//
int sourceSeconds = PeriodSeconds(sourcePeriod);
int destSeconds = PeriodSeconds(destPeriod);
if (sourceSeconds < destSeconds)
{
return result;
}
//
XOHCL sourceBar;
bool isInited = sourceBar.Init(
_Symbol,
sourcePeriod,
0 //
);
if (!isInited)
{
return result;
}
//
result = (datetime)((((int)sourceBar.time) + sourceSeconds) - destSeconds);
//
return result;
}
//
// Other Tools ...