last ...
This commit is contained in:
@@ -299,16 +299,16 @@ class XC121SMCCycleHelper : public XCBase
|
||||
string symbol,
|
||||
ENUM_TIMEFRAMES period,
|
||||
X121Inputs &x121Inputs,
|
||||
int requiredPOIS = 50 //
|
||||
int requiredPOIs = 50 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
if (requiredPOIS < 10)
|
||||
if (requiredPOIs < 10)
|
||||
{
|
||||
requiredPOIS = 10;
|
||||
requiredPOIs = 10;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -341,8 +341,21 @@ class XC121SMCCycleHelper : public XCBase
|
||||
symbol,
|
||||
period //
|
||||
);
|
||||
mPOIDetector.MaxNumberOfPOIs(requiredPOIS);
|
||||
mPOIDetector.MaxNumberOfRequiredPOIs(requiredPOIS);
|
||||
mPOIDetector.MaxRequiredPOIs(requiredPOIs);
|
||||
|
||||
//
|
||||
int maxLoopbackBars = mPOIDetector.MaxAllowedLoopbackForInit();
|
||||
int periodSeconds = PeriodSeconds(period);
|
||||
if (periodSeconds > PeriodSeconds(PERIOD_M15)) {
|
||||
//
|
||||
int multiplier = periodSeconds / PeriodSeconds(PERIOD_M15);
|
||||
|
||||
//
|
||||
if (multiplier >= 1) {
|
||||
maxLoopbackBars *= 2;
|
||||
}
|
||||
}
|
||||
mPOIDetector.MaxAllowedLoopbackForInit(maxLoopbackBars);
|
||||
mPOIDetector.Init();
|
||||
|
||||
//
|
||||
|
||||
@@ -48,7 +48,7 @@ struct X121SMCTradeData
|
||||
double commission; // Commission
|
||||
string conditions; // Signal Conditions
|
||||
double maxDrawdown; // Max Position Drawdown
|
||||
bool isTargeted; // Check Targetted Before Or Not
|
||||
double lastTarget; // Check Last Targetted
|
||||
double lastTrailedTPLevel; // Hold Last Trailed TP Level
|
||||
|
||||
//
|
||||
@@ -115,7 +115,7 @@ struct X121SMCTradeData
|
||||
conditions = NULL;
|
||||
|
||||
//
|
||||
isTargeted = false;
|
||||
lastTarget = 0;
|
||||
|
||||
//
|
||||
signal.Clean();
|
||||
@@ -644,9 +644,22 @@ struct X121SMCTradeData
|
||||
*
|
||||
* @return ( double )
|
||||
*/
|
||||
double Target()
|
||||
int Targets(double &targets[])
|
||||
{
|
||||
return signal.target;
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
Copy(
|
||||
signal.targets,
|
||||
targets //
|
||||
);
|
||||
|
||||
//
|
||||
result = ArraySize(targets);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3722,50 +3735,72 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
||||
|
||||
//
|
||||
// Handle RF On Target ...
|
||||
double target = iData.Target();
|
||||
double targetDelta = isLong
|
||||
? target + (15 * points)
|
||||
: target - (15 * points);
|
||||
bool canRF =
|
||||
target > 0 &&
|
||||
!iData.isTargeted &&
|
||||
(isLong ? target > entry
|
||||
: target < entry) &&
|
||||
(isLong
|
||||
? iPosition.sl < target
|
||||
: iPosition.sl > target) &&
|
||||
(isLong
|
||||
? iPosition.price > targetDelta
|
||||
: iPosition.price < targetDelta);
|
||||
if (canRF)
|
||||
double targets[];
|
||||
int targetsCount = iData.Targets(targets);
|
||||
bool hasTargets = IsValidSize(targetsCount);
|
||||
if (hasTargets)
|
||||
{
|
||||
//
|
||||
double sl = target;
|
||||
double tp = iPosition.tp;
|
||||
string comment = "RF On Target ...";
|
||||
bool isModified = mTrader.Modify(
|
||||
iData.ticket,
|
||||
sl,
|
||||
tp,
|
||||
comment //
|
||||
);
|
||||
if (isModified)
|
||||
for (int k = 0; k < targetsCount; k++)
|
||||
{
|
||||
//
|
||||
isProtected = true;
|
||||
double target = targets[k];
|
||||
bool isValidTarget =
|
||||
iData.lastTarget == 0
|
||||
? true
|
||||
: isLong
|
||||
? target > iData.lastTarget
|
||||
: target < iData.lastTarget;
|
||||
if (!isValidTarget)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// Update mData ...
|
||||
mData[i].isTargeted = true;
|
||||
double targetDelta = isLong
|
||||
? target + (15 * points)
|
||||
: target - (15 * points);
|
||||
bool canRF =
|
||||
target > 0 &&
|
||||
(isLong ? target > entry
|
||||
: target < entry) &&
|
||||
(isLong
|
||||
? iPosition.sl < target
|
||||
: iPosition.sl > target) &&
|
||||
(isLong
|
||||
? iPosition.price > targetDelta
|
||||
: iPosition.price < targetDelta);
|
||||
if (canRF)
|
||||
{
|
||||
//
|
||||
double sl = target;
|
||||
double tp = iPosition.tp;
|
||||
string comment = "RF On Target ...";
|
||||
bool isModified = mTrader.Modify(
|
||||
iData.ticket,
|
||||
sl,
|
||||
tp,
|
||||
comment //
|
||||
);
|
||||
if (isModified)
|
||||
{
|
||||
//
|
||||
isProtected = true;
|
||||
|
||||
//
|
||||
string message = prefix +
|
||||
ToString(iData.Type()) +
|
||||
" Position: " +
|
||||
ToString(iData.ticket) +
|
||||
" RF On Traget: " + ToString(target) +
|
||||
" Successfully ...";
|
||||
Alert(message);
|
||||
//
|
||||
// Update mData ...
|
||||
mData[i].lastTarget = target;
|
||||
|
||||
//
|
||||
string message = prefix +
|
||||
ToString(iData.Type()) +
|
||||
" Position: " +
|
||||
ToString(iData.ticket) +
|
||||
" RF On Traget: " + ToString(target) +
|
||||
" Successfully ...";
|
||||
Alert(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user