last ...
This commit is contained in:
@@ -5471,4 +5471,15 @@ else if (isPriceInsideDemandZone)
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
int tSLTPIndex = (int)reachedTPLevel - 1;
|
||||
double tSLTPPrice = tps[tSLTPIndex];
|
||||
canTrailSL =
|
||||
reachedTPLevel >= startTrailTPLevel &&
|
||||
(isLong
|
||||
? iPosition.sl < tSLTPPrice
|
||||
: iPosition.sl > tSLTPPrice);
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -36,19 +36,20 @@
|
||||
struct X121SMCTradeData
|
||||
{
|
||||
//
|
||||
double ask; // Ask Price on Start Time
|
||||
double bid; // bid Price on Start Time
|
||||
ulong ticket; // Position Ticket
|
||||
double swap; // Swap
|
||||
double profit; // Profit on Close
|
||||
XSignal signal; // Signal Object
|
||||
string message; // Message
|
||||
datetime endTime; // End Time
|
||||
datetime startTime; // Start Time
|
||||
double commission; // Commission
|
||||
string conditions; // Signal Conditions
|
||||
double maxDrawdown; // Max Position Drawdown
|
||||
bool isTargeted; // Check Targetted Before Or Not
|
||||
double ask; // Ask Price on Start Time
|
||||
double bid; // bid Price on Start Time
|
||||
ulong ticket; // Position Ticket
|
||||
double swap; // Swap
|
||||
double profit; // Profit on Close
|
||||
XSignal signal; // Signal Object
|
||||
string message; // Message
|
||||
datetime endTime; // End Time
|
||||
datetime startTime; // Start Time
|
||||
double commission; // Commission
|
||||
string conditions; // Signal Conditions
|
||||
double maxDrawdown; // Max Position Drawdown
|
||||
bool isTargeted; // Check Targetted Before Or Not
|
||||
double lastTrailedTPLevel; // Hold Last Trailed TP Level
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
@@ -105,6 +106,7 @@ struct X121SMCTradeData
|
||||
ticket = 0;
|
||||
commission = 0;
|
||||
maxDrawdown = 0;
|
||||
lastTrailedTPLevel = 0;
|
||||
|
||||
//
|
||||
endTime = NULL;
|
||||
@@ -3453,6 +3455,9 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
||||
*/
|
||||
void HandleProtection()
|
||||
{
|
||||
//
|
||||
string prefix = "Protector: ";
|
||||
|
||||
//
|
||||
// Implement Protection Senario Here ...
|
||||
int count = Count();
|
||||
@@ -3476,6 +3481,7 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
||||
double volumeSummary = 0;
|
||||
double profitSummary = 0;
|
||||
XPosition positions[];
|
||||
bool isProtected = false;
|
||||
|
||||
//
|
||||
// Loop through Open Positions ...
|
||||
@@ -3514,13 +3520,22 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
||||
|
||||
//
|
||||
double tps[];
|
||||
double reachedTPLevel = -1;
|
||||
int reachedTPIndex = -1;
|
||||
double reachedTPPrice = 0;
|
||||
double reachedTPLevel = -1;
|
||||
int tpLevelsCount = iPosition.CalculateTPLevels(tps);
|
||||
iPosition.CalculateReahedTP(
|
||||
reachedTPLevel,
|
||||
reachedTPPrice //
|
||||
);
|
||||
if (reachedTPLevel > 0)
|
||||
{
|
||||
//
|
||||
reachedTPIndex = FindIndex(
|
||||
reachedTPPrice,
|
||||
tps //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
bepSummary += bep;
|
||||
@@ -3558,7 +3573,11 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
||||
if (isModified)
|
||||
{
|
||||
//
|
||||
string message = ToString(iData.Type()) +
|
||||
isProtected = true;
|
||||
|
||||
//
|
||||
string message = prefix +
|
||||
ToString(iData.Type()) +
|
||||
" Position: " +
|
||||
ToString(iData.ticket) +
|
||||
" RF On BEP Successfully ...";
|
||||
@@ -3594,7 +3613,11 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
||||
if (isModified)
|
||||
{
|
||||
//
|
||||
string message = ToString(iData.Type()) +
|
||||
isProtected = true;
|
||||
|
||||
//
|
||||
string message = prefix +
|
||||
ToString(iData.Type()) +
|
||||
" Position: " +
|
||||
ToString(iData.ticket) +
|
||||
" PC (" + ToString(closeVolume) + ") On TP Level: " +
|
||||
@@ -3624,15 +3647,46 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
||||
bool canTrailSL = iData.CanTrailSL();
|
||||
if (canTrailSL && reachedTPLevel > 0)
|
||||
{
|
||||
//
|
||||
double tSLTPPrice = 0;
|
||||
|
||||
//
|
||||
double startTrailTPLevel = iData.TrailSLStartOnReachTPLevel();
|
||||
int tSLTPIndex = (int)reachedTPLevel - 1;
|
||||
double tSLTPPrice = tps[tSLTPIndex];
|
||||
canTrailSL =
|
||||
reachedTPLevel >= startTrailTPLevel &&
|
||||
(isLong
|
||||
? iPosition.sl < tSLTPPrice
|
||||
: iPosition.sl > tSLTPPrice);
|
||||
if (iData.lastTrailedTPLevel > 0)
|
||||
{
|
||||
startTrailTPLevel = iData.lastTrailedTPLevel + 1;
|
||||
}
|
||||
|
||||
//
|
||||
canTrailSL = IsValidIndex(reachedTPIndex) &&
|
||||
reachedTPLevel >= startTrailTPLevel;
|
||||
if (canTrailSL)
|
||||
{
|
||||
//
|
||||
tSLTPPrice =
|
||||
reachedTPIndex == 0
|
||||
? tps[reachedTPIndex]
|
||||
: tps[reachedTPIndex - 1];
|
||||
|
||||
//
|
||||
canTrailSL =
|
||||
tSLTPPrice > 0 &&
|
||||
iPosition.sl == 0
|
||||
? (isLong
|
||||
? tSLTPPrice > iPosition.entry &&
|
||||
tSLTPPrice < iPosition.price
|
||||
: tSLTPPrice < iPosition.entry &&
|
||||
tSLTPPrice > iPosition.price)
|
||||
: (isLong
|
||||
? tSLTPPrice > iPosition.sl &&
|
||||
tSLTPPrice > iPosition.entry &&
|
||||
tSLTPPrice < iPosition.price
|
||||
: tSLTPPrice < iPosition.sl &&
|
||||
tSLTPPrice < iPosition.entry &&
|
||||
tSLTPPrice > iPosition.price);
|
||||
}
|
||||
|
||||
//
|
||||
if (canTrailSL)
|
||||
{
|
||||
//
|
||||
@@ -3648,7 +3702,15 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
||||
if (isModified)
|
||||
{
|
||||
//
|
||||
string message = ToString(iData.Type()) +
|
||||
isProtected = true;
|
||||
|
||||
//
|
||||
// Update Last Trailed TP Level ...
|
||||
mData[i].lastTrailedTPLevel = reachedTPLevel;
|
||||
|
||||
//
|
||||
string message = prefix +
|
||||
ToString(iData.Type()) +
|
||||
" Position: " +
|
||||
ToString(iData.ticket) +
|
||||
" Trailed SL On Reached TP: " + ToString(reachedTPLevel) +
|
||||
@@ -3690,10 +3752,15 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
||||
if (isModified)
|
||||
{
|
||||
//
|
||||
isProtected = true;
|
||||
|
||||
//
|
||||
// Update mData ...
|
||||
mData[i].isTargeted = true;
|
||||
|
||||
//
|
||||
string message = ToString(iData.Type()) +
|
||||
string message = prefix +
|
||||
ToString(iData.Type()) +
|
||||
" Position: " +
|
||||
ToString(iData.ticket) +
|
||||
" RF On Traget: " + ToString(target) +
|
||||
@@ -3722,7 +3789,8 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
||||
|
||||
//
|
||||
// Checking Hedge ...
|
||||
bool allowHedge = AllowHedging();
|
||||
bool allowHedge = AllowHedging() &&
|
||||
!isProtected;
|
||||
if (allowHedge)
|
||||
{
|
||||
//
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
//
|
||||
XConsolidationZone x121SMCConsolidationZone;
|
||||
bool DetectX121SMCGuards(
|
||||
//
|
||||
string provider, // Provider ...
|
||||
X121SMCGuard &guards[],
|
||||
const XPosition &positions[],
|
||||
|
||||
@@ -1698,6 +1698,7 @@ CArrayObj mX121SMCXSupDemOBSWorkingZoneObjects;
|
||||
//
|
||||
// Detect Setup Conditions ...
|
||||
bool DetectX121SMCXSupDemOBSSignalSetup(
|
||||
//
|
||||
string _symbol,
|
||||
ENUM_TIMEFRAMES _period,
|
||||
//
|
||||
@@ -4028,6 +4029,7 @@ bool DetectX121SMCXSupDemOBSSignalTrigger(
|
||||
//
|
||||
// Detect Guards ...
|
||||
bool DetectX121SMCXSupDemOBSGuards(
|
||||
//
|
||||
X121SMCGuard &guards[],
|
||||
const XPosition &positions[],
|
||||
//
|
||||
@@ -4151,7 +4153,9 @@ bool DetectX121SMCXSupDemOBSGuards(
|
||||
// Get Global and Common Guards ...
|
||||
|
||||
//
|
||||
ENUM_X_121_SMC_GUARD_ACTIONS ignoreGuards[];
|
||||
ENUM_X_121_SMC_GUARD_ACTIONS ignoreGuards[1] = {
|
||||
X_121_SMC_GUARD_ACTION_TRAIL_STOP
|
||||
};
|
||||
result = DetectX121SMCGuards(
|
||||
provider,
|
||||
guards,
|
||||
|
||||
Reference in New Issue
Block a user