This commit is contained in:
2024-06-21 06:45:33 +03:30
parent e9e313fa58
commit a5cb716d0b
7 changed files with 1268 additions and 761 deletions
File diff suppressed because it is too large Load Diff
+4 -5
View File
@@ -4032,7 +4032,7 @@ public:
// Handle Support of Supports here ... // Handle Support of Supports here ...
void OnPositionsChangedHandler(int count) override void OnPositionsChangedHandler(int count) override
{ {
EQMHandleSupportProtection(count); // EQMHandleSupportProtection(count);
} }
// //
@@ -4784,9 +4784,8 @@ private:
} }
// //
bool isDIRInDIRSupport = position.provider == XEQMSupportToken + XDirectionalToken || bool isINDIRSupport = position.provider == XEQMSupportToken + XINDirectionalToken;
position.provider == XEQMSupportToken + XINDirectionalToken; if (!isINDIRSupport)
if (!isDIRInDIRSupport)
{ {
return; return;
} }
@@ -4828,7 +4827,7 @@ private:
// //
XSignal signal; XSignal signal;
X121SignalGenerator signalGenerator; X121SignalGenerator signalGenerator;
bool hasSupport = signalGenerator.UpdateSupportSignals( bool hasSupport = signalGenerator.PrepareDirectionalSupportSignals(
position, position,
parent, parent,
signal // signal //
+13 -10
View File
@@ -1099,16 +1099,16 @@ protected:
// //
// Check At Least One Support Positions Open For Hedging ... // Check At Least One Support Positions Open For Hedging ...
XPosition supports[]; // XPosition supports[];
int supportsCount = ExtractSupports( // int supportsCount = ExtractSupports(
positions, // positions,
supports // // supports //
); // );
result = IsValidSize(supportsCount); // result = IsValidSize(supportsCount);
if (!result) // if (!result)
{ // {
return result; // return result;
} // }
// //
double profits = SpecifiedCalculatePositionsProfit(positions); double profits = SpecifiedCalculatePositionsProfit(positions);
@@ -1139,6 +1139,9 @@ protected:
return result; return result;
} }
//
SyncSupports();
// //
string message = XEQMSupportToken + " Hedge: " + ToString(profits) + " ..."; string message = XEQMSupportToken + " Hedge: " + ToString(profits) + " ...";
+132 -6
View File
@@ -120,7 +120,8 @@ public:
// //
// Deconstructor ... // Deconstructor ...
void ~XSCTrend() { void ~XSCTrend()
{
Remove(); Remove();
} }
@@ -340,6 +341,77 @@ public:
return result; return result;
} }
//
// Retrieve Chart Line Values ...
//
// Get Lows Line Price at Specific Time ...
double GetLows(datetime time = NULL)
{
//
double result = 0;
//
result = GetObjectPrice(
lowsName,
time //
);
//
return result;
}
//
// Get Highs Line Price at Specific Time ...
double GetHighs(datetime time = NULL)
{
//
double result = 0;
//
result = GetObjectPrice(
highsName,
time //
);
//
return result;
}
//
// Get Support Line Price at Specific Time ...
double GetSupport(datetime time = NULL)
{
//
double result = 0;
//
result = GetObjectPrice(
supportName,
time //
);
//
return result;
}
//
// Get Resistance Line Price at Specific Time ...
double GetResistance(datetime time = NULL)
{
//
double result = 0;
//
result = GetObjectPrice(
resistanceName,
time //
);
//
return result;
}
// //
// Remove Draws ... // Remove Draws ...
bool Remove( bool Remove(
@@ -377,6 +449,7 @@ public:
} }
// //
// Draw Trend Object on Chart ...
bool Draw( bool Draw(
long chartId = 0, long chartId = 0,
string prefix = NULL, string prefix = NULL,
@@ -438,7 +511,7 @@ public:
secondSwingLowBar.time > secondSwingHighBar.time secondSwingLowBar.time > secondSwingHighBar.time
? secondSwingHighBar.time ? secondSwingHighBar.time
: secondSwingLowBar.time; : secondSwingLowBar.time;
string supportName = supportName =
// //
identifier + identifier +
(IsSpecifiedValid(prefix) (IsSpecifiedValid(prefix)
@@ -455,8 +528,7 @@ public:
secondSwingLowBar.time > secondSwingHighBar.time secondSwingLowBar.time > secondSwingHighBar.time
? secondSwingHighBar.time ? secondSwingHighBar.time
: secondSwingLowBar.time; : secondSwingLowBar.time;
resistanceName =
string resistanceName =
// //
identifier + identifier +
(IsSpecifiedValid(prefix) (IsSpecifiedValid(prefix)
@@ -474,7 +546,7 @@ public:
// //
double oldLow = secondSwingLowBar.low; double oldLow = secondSwingLowBar.low;
datetime oldLowTime = secondSwingLowBar.time; datetime oldLowTime = secondSwingLowBar.time;
string lowsName = lowsName =
// //
identifier + identifier +
(IsSpecifiedValid(prefix) (IsSpecifiedValid(prefix)
@@ -492,7 +564,7 @@ public:
// //
double oldHigh = secondSwingHighBar.high; double oldHigh = secondSwingHighBar.high;
datetime oldHighTime = secondSwingHighBar.time; datetime oldHighTime = secondSwingHighBar.time;
string highsName = highsName =
// //
identifier + identifier +
(IsSpecifiedValid(prefix) (IsSpecifiedValid(prefix)
@@ -598,6 +670,53 @@ public:
// //
// Protected ... // Protected ...
protected: protected:
//
// Tools ...
//
double GetObjectPrice(
string objName,
datetime objTime,
long chartId = 0,
int subWindow = 0 //
)
{
//
double result = 0;
//
if (!IsValid())
{
return result;
}
//
if (!IsSpecifiedValid(objName))
{
return result;
}
//
objTime = NormalizeTime(objTime);
//
string objectName = FindObjectName(
objName,
chartId,
subWindow //
);
//
result = ObjectGetValueByTime(
chartId,
objectName,
objTime //
);
//
return result;
}
// //
// Private ... // Private ...
private: private:
@@ -615,6 +734,13 @@ private:
XOHCL secondSwingLowBar; XOHCL secondSwingLowBar;
XOHCL firstSwingHighBar; XOHCL firstSwingHighBar;
XOHCL secondSwingHighBar; XOHCL secondSwingHighBar;
//
// Object Names ...
string lowsName;
string highsName;
string supportName;
string resistanceName;
}; };
// //
+731
View File
@@ -2339,3 +2339,734 @@
rEntry = 0; rEntry = 0;
isSignalPrepared = false; isSignalPrepared = false;
} }
///////////////////////////////////////////////////////////////////////
//
if (canUseCF)
{
//
signal.cf.Draw();
XOHCL cfBULLBar = signal.cf.GetBullishBar();
XOHCL cfBEARBar = signal.cf.GetBearishBar();
//
if (isLong)
{
//
// Supports For Longs ...
//
// CF Bullish ...
//
// HIGH ...
//
condition = entryPrice < cfBULLBar.high;
if (condition)
{
//
// InDirectional ...
rEntry = cfBULLBar.high;
rType = POSITION_TYPE_SELL;
rMode = X_ORDER_MODE_LIMIT;
rVolume = signal.volume * inDirectionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken + XINDirectionalToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
}
//
condition = entryPrice > cfBULLBar.high;
if (condition)
{
//
// InDirectional ...
rEntry = cfBULLBar.high;
rType = POSITION_TYPE_SELL;
rMode = X_ORDER_MODE_STOP;
rVolume = signal.volume * inDirectionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken + XINDirectionalToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
}
//
// LOW ...
//
condition = entryPrice > cfBULLBar.low;
if (condition)
{
//
// InDirectional ...
rEntry = cfBULLBar.low;
rType = POSITION_TYPE_SELL;
rMode = X_ORDER_MODE_STOP;
rVolume = signal.volume * inDirectionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken + XINDirectionalToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
}
//
condition = entryPrice < cfBULLBar.low;
if (condition)
{
//
// InDirectional ...
rEntry = cfBULLBar.low;
rType = POSITION_TYPE_SELL;
rMode = X_ORDER_MODE_LIMIT;
rVolume = signal.volume * inDirectionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken + XINDirectionalToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
}
//
// CF Bearish ...
//
// HIGH ...
//
condition = entryPrice < cfBEARBar.high;
if (condition)
{
//
// InDirectional ...
rEntry = cfBEARBar.high;
rType = POSITION_TYPE_SELL;
rMode = X_ORDER_MODE_LIMIT;
rVolume = signal.volume * inDirectionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken + XINDirectionalToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
}
//
condition = entryPrice > cfBEARBar.high;
if (condition)
{
//
// InDirectional ...
rEntry = cfBEARBar.high;
rType = POSITION_TYPE_SELL;
rMode = X_ORDER_MODE_STOP;
rVolume = signal.volume * inDirectionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken + XINDirectionalToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
}
//
// LOW ...
//
condition = entryPrice > cfBEARBar.low;
if (condition)
{
//
// InDirectional ...
rEntry = cfBEARBar.low;
rType = POSITION_TYPE_SELL;
rMode = X_ORDER_MODE_STOP;
rVolume = signal.volume * inDirectionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken + XINDirectionalToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
}
//
condition = entryPrice < cfBEARBar.low;
if (condition)
{
//
// InDirectional ...
rEntry = cfBEARBar.low;
rType = POSITION_TYPE_SELL;
rMode = X_ORDER_MODE_LIMIT;
rVolume = signal.volume * inDirectionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken + XINDirectionalToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
}
}
else
{
//
// Supports For Shorts ...
//
// CF Bullish ...
//
// HIGH ...
//
condition = entryPrice < cfBULLBar.high;
if (condition)
{
//
// InDirectional ...
rEntry = cfBULLBar.high;
rType = POSITION_TYPE_BUY;
rMode = X_ORDER_MODE_STOP;
rVolume = signal.volume * inDirectionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken + XINDirectionalToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
}
//
condition = entryPrice > cfBULLBar.high;
if (condition)
{
//
// InDirectional ...
rEntry = cfBULLBar.high;
rType = POSITION_TYPE_BUY;
rMode = X_ORDER_MODE_LIMIT;
rVolume = signal.volume * inDirectionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken + XINDirectionalToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
}
//
// LOW ...
//
condition = entryPrice > cfBULLBar.low;
if (condition)
{
//
// InDirectional ...
rEntry = cfBULLBar.low;
rType = POSITION_TYPE_BUY;
rMode = X_ORDER_MODE_LIMIT;
rVolume = signal.volume * inDirectionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken + XINDirectionalToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
}
//
condition = entryPrice < cfBULLBar.low;
if (condition)
{
//
// InDirectional ...
rEntry = cfBULLBar.low;
rType = POSITION_TYPE_BUY;
rMode = X_ORDER_MODE_STOP;
rVolume = signal.volume * inDirectionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken + XINDirectionalToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
}
//
// CF Bearish ...
//
// HIGH ...
//
condition = entryPrice < cfBEARBar.high;
if (condition)
{
//
// InDirectional ...
rEntry = cfBEARBar.high;
rType = POSITION_TYPE_BUY;
rMode = X_ORDER_MODE_STOP;
rVolume = signal.volume * inDirectionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken + XINDirectionalToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
}
//
condition = entryPrice > cfBEARBar.high;
if (condition)
{
//
// InDirectional ...
rEntry = cfBEARBar.high;
rType = POSITION_TYPE_BUY;
rMode = X_ORDER_MODE_LIMIT;
rVolume = signal.volume * inDirectionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken + XINDirectionalToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
}
//
// LOW ...
//
condition = entryPrice > cfBEARBar.low;
if (condition)
{
//
// InDirectional ...
rEntry = cfBEARBar.low;
rType = POSITION_TYPE_BUY;
rMode = X_ORDER_MODE_LIMIT;
rVolume = signal.volume * inDirectionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken + XINDirectionalToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
}
//
condition = entryPrice < cfBEARBar.low;
if (condition)
{
//
// InDirectional ...
rEntry = cfBEARBar.low;
rType = POSITION_TYPE_BUY;
rMode = X_ORDER_MODE_STOP;
rVolume = signal.volume * inDirectionalVolumeMultiplier;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
XEQMSupportToken + XINDirectionalToken,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
}
}
}
+39
View File
@@ -0,0 +1,39 @@
# Supporting Senarios
first check current Position Direction's
## Short
InDirectional
for short positions we only have Long Supports;
entry price must below the Lines;
and Lines Must below the SL of Positions, if it's Exists;
### Long Orders
after putting orders of InDirectionals;
set EQM Provider;
### Long Orders Supporting
now we have to find out when orders Executed;
after each InDirectional EQM Order Execution, we Have to Prepare a Directional Order
by it's volume on Signal Entry.
## Long
InDirectional
for long positions we only have short Supports;
entry price must above the Lines;
and Lines Must Above the SL of Positions, if it's Exists;
### Short Orders
after putting orders of InDirectionals;
set EQM Provider;
### Short Orders Supporting
now we have to find out when orders Executed;
after each InDirectional EQM Order Execution, we Have to Prepare a Directional Order
by it's volume on Signal Entry.
+33
View File
@@ -485,6 +485,39 @@ bool IsDrawExists(
return result; return result;
} }
//
// Find Specific Object Name ...
string FindObjectName(
string suggest,
long chartId = 0,
int subWindow = 0 //
)
{
//
string result = NULL;
//
int objectsCount = ObjectsTotal(chartId, subWindow);
if (objectsCount <= 0) {
return result;
}
//
for (int i = objectsCount - 1; i >= 0; i--) {
//
string iObjectName = ObjectName(chartId, i, subWindow);
bool isExists = StringFind(iObjectName, suggest) >= 0;
if (isExists) {
//
result = iObjectName;
break;
}
}
//
return result;
}
// //
// Regular Draws ... // Regular Draws ...