last works ...
This commit is contained in:
@@ -374,6 +374,16 @@ class XCAccount : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Specified Message for Report Balance ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GetBalanceReportMessage()
|
||||
{
|
||||
return "Balance: " + ToXString(GetBalance()) + " " + GetCurrency();
|
||||
}
|
||||
|
||||
//
|
||||
// END Provided Functions ...
|
||||
//
|
||||
|
||||
@@ -56,6 +56,16 @@ class XCBaseSignaller : public XCBase
|
||||
string symbol; // Symbol ...
|
||||
ENUM_TIMEFRAMES period; // Period ...
|
||||
|
||||
//
|
||||
double slAdditionDistance; // SL Addition Distance ...
|
||||
|
||||
//
|
||||
// Restrictions ...
|
||||
datetime restUntil; // Resting Time ...
|
||||
int restingSignals; // Resting Signals ...
|
||||
datetime lastSignalAt; // Holding Last Signal's Time ...
|
||||
int restingDelay; // Resting Bars After Last Signal ...
|
||||
|
||||
//
|
||||
TCanAnalyse canAnalyseEventListener;
|
||||
|
||||
@@ -80,6 +90,9 @@ class XCBaseSignaller : public XCBase
|
||||
symbol = _symbol;
|
||||
period = _period;
|
||||
|
||||
//
|
||||
slAdditionDistance = 0;
|
||||
|
||||
//
|
||||
processAllTicks = _processAllTicks;
|
||||
defaultSignalR2R = _defaultSignalR2R;
|
||||
@@ -350,12 +363,27 @@ class XCBaseSignaller : public XCBase
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Restrictions ...
|
||||
if (HasRestrictions())
|
||||
{
|
||||
//
|
||||
bool ignore = HandleRestrictions(signal);
|
||||
if (ignore)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Do Notify ...
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
onSignalEventListeners[i](signal);
|
||||
}
|
||||
|
||||
//
|
||||
lastSignalAt = signal.time;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -526,6 +554,139 @@ class XCBaseSignaller : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Signaller Has Restrictions or not ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasRestrictions()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
// Rest Delay ...
|
||||
restingDelay > 0 ||
|
||||
//
|
||||
// Resting Signals ...
|
||||
restingSignals > 0 ||
|
||||
//
|
||||
// Rest Until ...
|
||||
IsXValid(restUntil)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Restrictions On Signal ...
|
||||
*
|
||||
* @param signal: XSignal, reference to Provided Sginal ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HandleRestrictions(XSignal &signal)
|
||||
{
|
||||
//
|
||||
// Ignore Signal Execution ...
|
||||
bool result = true;
|
||||
|
||||
//
|
||||
// Check Restrictions Exists ...
|
||||
if (!HasRestrictions())
|
||||
{
|
||||
//
|
||||
// Disable Signal Ignoring and Allow Notify Signal ...
|
||||
result = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
datetime cTime = TimeCurrent();
|
||||
|
||||
//
|
||||
// Resting Signals ...
|
||||
if (restingSignals > 0)
|
||||
{
|
||||
//
|
||||
restingSignals--;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Rest Until ...
|
||||
if (IsXValid(restUntil))
|
||||
{
|
||||
//
|
||||
if (cTime > restUntil)
|
||||
{
|
||||
//
|
||||
restUntil = NULL;
|
||||
|
||||
//
|
||||
// Disable Signal Ignoring and Allow Notify Signal ...
|
||||
result = false;
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Ignore Signal ...
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Resting Delay ...
|
||||
if (restingDelay > 0 &&
|
||||
IsXValid(lastSignalAt))
|
||||
{
|
||||
//
|
||||
int lastSignalIDX = GetBarIndex(
|
||||
signal.symbol,
|
||||
signal.period,
|
||||
lastSignalAt //
|
||||
);
|
||||
if (IsValidIndex(lastSignalIDX))
|
||||
{
|
||||
//
|
||||
if (lastSignalIDX > restingDelay)
|
||||
{
|
||||
//
|
||||
restingDelay = 0;
|
||||
//
|
||||
// Disable Signal Ignoring and Allow Notify Signal ...
|
||||
result = false;
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Ignore Signal ...
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset All Restrictions ...
|
||||
*/
|
||||
void ResetRestrictions()
|
||||
{
|
||||
//
|
||||
restingDelay = 0;
|
||||
restUntil = NULL;
|
||||
restingSignals = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user