last ...
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user