This commit is contained in:
2024-06-24 17:08:46 +03:30
parent 1e424c4c71
commit ba23e2d9e9
4 changed files with 672 additions and 433 deletions
+87 -1
View File
@@ -323,6 +323,15 @@ public:
return;
}
//
// Check Sleeping State ...
bool isSlept = IsSlept();
if (isSlept)
{
Print("Slept");
return;
}
//
// Second Check For Signals ...
// then Execute Signals if Provided ...
@@ -580,7 +589,7 @@ public:
//
// Tools ...
//
// Calculate Max Drawdown and it's Percent ...
double CalculateMaxDrawdown()
@@ -1657,6 +1666,83 @@ protected:
}
}
//
// Sleeping Context ...
//
// Sleeping Mode ...
int mSleepingDuration;
datetime mSleepingStartAt;
bool Sleeping(int seconds = -1)
{
//
bool result = false;
//
mSleepingDuration =
seconds > 0
? seconds
: mRestingAfterHedge > 0
? mRestingAfterHedge
: 0;
result = mSleepingDuration > 0;
if (!result)
{
//
ResetSleeping();
return result;
}
//
// Check Doesnt Sleep Before ...
result = mSleepingStartAt == NULL;
if (!result)
{
//
ResetSleeping();
return result;
}
//
datetime cTime = TimeCurrent();
mSleepingStartAt = cTime;
//
return result;
}
bool IsSlept()
{
//
bool result = false;
//
result = mSleepingDuration > 0 &&
mSleepingStartAt != NULL;
if (!result)
{
//
ResetSleeping();
return result;
}
//
datetime cTime = TimeCurrent();
result = (int)cTime < (int)mSleepingStartAt + mSleepingDuration;
if (!result)
{
ResetSleeping();
}
//
return result;
}
void ResetSleeping()
{
//
mSleepingDuration = 0;
mSleepingStartAt = NULL;
}
//
// Private ...
private: