This commit is contained in:
2024-06-23 12:20:48 +03:30
parent 96c154701c
commit 96f22dbc75
6 changed files with 669 additions and 452 deletions
+16 -8
View File
@@ -1616,8 +1616,6 @@ struct X121SignalGenerator
//
// XPVF ...
bool long18 =
//
false &&
//
// Starting Conditions ...
conditions.pvConditions.isFiboIncreased &&
@@ -1669,7 +1667,13 @@ struct X121SignalGenerator
//
// Starting Conditions ...
conditions.IsTrendBullish() &&
conditions.dmntConditions.isBullish
conditions.dmntConditions.isBullish &&
//
// Verifications ...
conditions.tdConditions.isBullish &&
conditions.adxtdConditions.isStrong &&
conditions.adxtdConditions.isBullish &&
conditions.vlmConditions.isVolumeBullish
//
;
if (long20)
@@ -2306,8 +2310,6 @@ struct X121SignalGenerator
//
// XPVF ...
bool short18 =
//
false &&
//
// Starting Conditions ...
conditions.pvConditions.isFiboDecreased &&
@@ -2359,7 +2361,13 @@ struct X121SignalGenerator
//
// Starting Conditions ...
conditions.IsTrendBearish() &&
conditions.dmntConditions.isBearish
conditions.dmntConditions.isBearish &&
//
// Verifications ...
conditions.tdConditions.isBearish &&
conditions.adxtdConditions.isStrong &&
conditions.adxtdConditions.isBearish &&
conditions.vlmConditions.isVolumeBearish
//
;
if (short20)
@@ -2989,7 +2997,7 @@ struct X121SignalGenerator
//
// TODO Filter ...
result = true; // provider == ToString(PROVIDER_XVLM);
result = false; // provider == ToString(PROVIDER_XHTSRD);
//
return result;
@@ -3008,7 +3016,7 @@ struct X121SignalGenerator
//
// TODO Filter ...
result = true; // provider == ToString(PROVIDER_XVLM);
result = false; // provider == ToString(PROVIDER_XHTSRD);
//
return result;
+413 -429
View File
@@ -1379,6 +1379,18 @@ public:
mAllowSupport = value;
}
//
bool SupportOnlyForces()
{
return mSupportOnlyForces;
}
//
void SupportOnlyForces(bool value)
{
mSupportOnlyForces = value;
}
//
double SupportDistance()
{
@@ -1490,6 +1502,18 @@ public:
mAllowGrid = value;
}
//
bool GridOnlyForces()
{
return mGridOnlyForces;
}
//
void GridOnlyForces(bool value)
{
mGridOnlyForces = value;
}
//
int MaxNumberOfGrids()
{
@@ -1602,6 +1626,18 @@ public:
mAllowRecovery = value;
}
//
bool RecoverOnlyForces()
{
return mRecoverOnlyForces;
}
//
void RecoverOnlyForces(bool value)
{
mRecoverOnlyForces = value;
}
//
int MaxNumberOfRecoveries()
{
@@ -2140,6 +2176,7 @@ protected:
//
// Supporting ...
bool mAllowSupport; // Allow Support Signals
bool mSupportOnlyForces; // Support Only Force Signals
double mSupportDistance; // Supporting Distance
int mMaxNumberOfSupports; // Max Number of Support Signals
double mSupportVolumeMultiplier; // Support Signals Volume Multiplier
@@ -2148,6 +2185,7 @@ protected:
//
// Grid ...
bool mAllowGrid; // Allow Grid Signals
bool mGridOnlyForces; // Grid Only Force Signals
int mMaxNumberOfGrids; // Max Number of Grid Signals
double mGridDistance; // Grid Distance
double mGridVolumeMultiplier; // Grid Volume Multiplier
@@ -2156,6 +2194,7 @@ protected:
//
// Recovery ...
bool mAllowRecovery; // Allow Recovery Signals
bool mRecoverOnlyForces; // Recover Only Force Signals
int mMaxNumberOfRecoveries; // Max Number of Recovery Signals
double mRecoveryDistance; // Recovery Distance
double mRecoveryVolumeMultiplier; // Recovery Volume Multiplier
@@ -2720,6 +2759,7 @@ class XSCX121SetupEA : public XSCBaseEA
public:
//
// Props ...
X121SignalGenerator signalGenerator;
//
// Constructors ...
@@ -3130,6 +3170,18 @@ public:
mTradeHandler.AllowSupport(value);
}
//
bool SupportOnlyForces()
{
return mTradeHandler.SupportOnlyForces();
}
//
void SupportOnlyForces(bool value)
{
mTradeHandler.SupportOnlyForces(value);
}
//
double SupportDistance()
{
@@ -3193,6 +3245,18 @@ public:
mTradeHandler.AllowGrid(value);
}
//
bool GridOnlyForces()
{
return mTradeHandle.GridOnlyForces();
}
//
void GridOnlyForces(bool value)
{
mTradeHandle.GridOnlyForces(value);
}
//
int MaxNumberOfGrids()
{
@@ -3256,6 +3320,18 @@ public:
mTradeHandler.AllowRecovery(value);
}
//
bool RecoverOnlyForces()
{
return mTradeHandler.RecoverOnlyForces();
}
//
void RecoverOnlyForces(bool value)
{
mTradeHandler.RecoverOnlyForces(value);
}
//
int MaxNumberOfRecoveries()
{
@@ -3460,9 +3536,6 @@ public:
return result;
}
//
string separator = "\n";
//
// Current ...
XSignal cSignal;
@@ -3677,260 +3750,171 @@ public:
bool hasSignal = cHasSignal || sHasSignal || mHasSignal || lHasSignal || hHasSignal;
if (hasSignal)
{
//
XSignal signal;
X121SetupConditions otherConditions[];
//
if (cHasSignal)
{
//
Print("Current Market Has Signal ...");
Print(ToString(mSetups[i].cCycle.cycle.period));
signal = cSignal;
//
AddRef(
sConditions,
otherConditions //
);
AddRef(
mConditions,
otherConditions //
);
AddRef(
lConditions,
otherConditions //
);
AddRef(
hConditions,
otherConditions //
);
}
//
if (sHasSignal)
{
//
Print("Short Market Has Signal ...");
Print(ToString(mSetups[i].sCycle.cycle.period));
signal = sSignal;
//
AddRef(
cConditions,
otherConditions //
);
AddRef(
mConditions,
otherConditions //
);
AddRef(
lConditions,
otherConditions //
);
AddRef(
hConditions,
otherConditions //
);
}
//
if (mHasSignal)
{
//
Print("Medium Market Has Signal ...");
Print(ToString(mSetups[i].mCycle.cycle.period));
signal = mSignal;
//
AddRef(
cConditions,
otherConditions //
);
AddRef(
sConditions,
otherConditions //
);
}
//
if (lHasSignal)
{
//
Print("Long Market Has Signal ...");
Print(ToString(mSetups[i].lCycle.cycle.period));
signal = lSignal;
//
AddRef(
cConditions,
otherConditions //
);
AddRef(
sConditions,
otherConditions //
);
AddRef(
mConditions,
otherConditions //
);
}
//
if (hHasSignal)
{
//
Print("Hind Market Has Signal ...");
Print(ToString(mSetups[i].hCycle.cycle.period));
signal = hSignal;
//
AddRef(
cConditions,
otherConditions //
);
AddRef(
sConditions,
otherConditions //
);
}
//
// Handle Creating a new Signal Info ...
// XSignal signal;
// X121SetupConditions otherConditions[];
// if (hHasSignal)
// {
// //
// signal = hSignal;
int pushers = cPusher + sPusher + mPusher + lPusher + hPusher;
// //
// AddRef(
// cConditions,
// otherConditions //
// );
// AddRef(
// sConditions,
// otherConditions //
// );
// }
// else if (lHasSignal)
// {
// //
// signal = lSignal;
//
bool isLong = IsLong(signal.type);
// //
// AddRef(
// cConditions,
// otherConditions //
// );
// AddRef(
// sConditions,
// otherConditions //
// );
// AddRef(
// mConditions,
// otherConditions //
// );
// }
// else if (mHasSignal)
// {
// //
// signal = mSignal;
//
// Validate Signal ...
bool isValid =
//
// Handle Pusher Validations ...
(mReuiredSignalVerifications <= 0
? true
: pushers >= mReuiredSignalVerifications)
//
&&
//
// Handle Other Conditions Validations ...
(!mGetVerificationFromOtherTimeFrames
? true
: isLong
? signalGenerator.HasLongVerifications(otherConditions)
: signalGenerator.HasShortVerifications(otherConditions))
//
;
// //
// AddRef(
// cConditions,
// otherConditions //
// );
// AddRef(
// sConditions,
// otherConditions //
// );
// }
// else if (sHasSignal)
// {
// //
// signal = sSignal;
//
bool forceState = ForceState();
// //
// AddRef(
// cConditions,
// otherConditions //
// );
// AddRef(
// mConditions,
// otherConditions //
// );
// AddRef(
// lConditions,
// otherConditions //
// );
// AddRef(
// hConditions,
// otherConditions //
// );
// }
// else if (cHasSignal)
// {
// //
// signal = cSignal;
//
if (!forceState)
{
//
// Add Signal to Execution Result ...
AddRef(
signal,
signals //
);
// //
// AddRef(
// sConditions,
// otherConditions //
// );
// AddRef(
// mConditions,
// otherConditions //
// );
// AddRef(
// lConditions,
// otherConditions //
// );
// AddRef(
// hConditions,
// otherConditions //
// );
// }
// //
// int pushers = cPusher + sPusher + mPusher + lPusher + hPusher;
// //
// bool isLong = IsLong(signal.type);
// //
// // Collecting Bullish/Bearish Signs ...
// if (isLong)
// {
// mBullishSigns += pushers;
// }
// else
// {
// mBearishSigns += pushers;
// }
// //
// // Validate Signal ...
// bool isValid =
// //
// // Handle Pusher Validations ...
// (mReuiredSignalVerifications <= 0
// ? true
// : pushers >= mReuiredSignalVerifications)
// //
// &&
// //
// // Handle Other Conditions Validations ...
// (!mGetVerificationFromOtherTimeFrames
// ? true
// : isLong
// ? signalGenerator.HasLongVerifications(otherConditions)
// : signalGenerator.HasShortVerifications(otherConditions))
// //
// ;
// //
// bool forceState = ForceState();
// //
// if (!isValid || (forceState && isValid))
// {
// //
// // Clear Other Conditions ...
// Clean(otherConditions);
// //
// // Fill All Conditions to Other Conditions ...
// AddRef(
// cConditions,
// otherConditions //
// );
// AddRef(
// sConditions,
// otherConditions //
// );
// AddRef(
// mConditions,
// otherConditions //
// );
// AddRef(
// lConditions,
// otherConditions //
// );
// AddRef(
// hConditions,
// otherConditions //
// );
// //
// // If Recieved Any Unverified Signal
// // we Passed it to EQM Manager ...
// EQMHandleInvalidSignal(
// signal,
// pushers,
// mVolumeOSC,
// mBullishScore,
// mBullishSigns,
// mBearishScore,
// mBearishSigns,
// otherConditions,
// isValid //
// );
// continue;
// }
// //
// if (!forceState)
// {
// //
// // Add Signal to Execution Result ...
// AddRef(
// signal,
// signals //
// );
// //
// // Add new Signal Info ...
// mTradeHandler.Add(
// signal,
// pushers,
// mVolumeOSC,
// mBullishSigns,
// mBearishSigns,
// mBullishScore,
// mBearishScore,
// cConditions,
// sConditions,
// mConditions,
// lConditions,
// hConditions //
// );
// }
//
// Add new Signal Info ...
mTradeHandler.Add(
signal,
pushers,
mVolumeOSC,
mBullishSigns,
mBearishSigns,
mBullishScore,
mBearishScore,
cConditions,
sConditions,
mConditions,
lConditions,
hConditions //
);
}
}
}
@@ -4718,243 +4702,243 @@ private:
return;
}
//
double profits = SpecifiedCalculatePositionsProfit(positions);
// //
// double profits = SpecifiedCalculatePositionsProfit(positions);
//
// Checking Force Sate Conditions ...
if (ForceState())
{
//
// Check Force State Hedging ...
bool isHedged = DoEQMForceClose();
if (isHedged)
{
//
ForceState(false);
return;
}
// //
// // Checking Force Sate Conditions ...
// if (ForceState())
// {
// //
// // Check Force State Hedging ...
// bool isHedged = DoEQMForceClose();
// if (isHedged)
// {
// //
// ForceState(false);
// return;
// }
//
// Handle Act Based On Drawdow ...
if (mMaxDrawdownForce > 0)
{
//
double drawdown = CalculateMaxDrawdown();
if (drawdown > mMaxDrawdownForce)
{
//
// Try to Hedge ...
if (profits > 0)
{
//
bool isHedged = DoEQMForceClose(profits);
if (isHedged)
{
//
ForceState(false);
return;
}
}
// //
// // Handle Act Based On Drawdow ...
// if (mMaxDrawdownForce > 0)
// {
// //
// double drawdown = CalculateMaxDrawdown();
// if (drawdown > mMaxDrawdownForce)
// {
// //
// // Try to Hedge ...
// if (profits > 0)
// {
// //
// bool isHedged = DoEQMForceClose(profits);
// if (isHedged)
// {
// //
// ForceState(false);
// return;
// }
// }
//
// Close Max In Drawdown Position ...
int maxInDIDX = FindMaxDrawdownIndex(positions);
if (IsValidIndex(maxInDIDX))
{
//
string comment = XEQMSupportToken + " Max In D ...";
// //
// // Close Max In Drawdown Position ...
// int maxInDIDX = FindMaxDrawdownIndex(positions);
// if (IsValidIndex(maxInDIDX))
// {
// //
// string comment = XEQMSupportToken + " Max In D ...";
//
bool isClosed = mTrader.Close(
positions[maxInDIDX].ticket,
comment //
);
if (isClosed)
{
//
string message = XEQMSupportToken + " Close " + ToString(positions[maxInDIDX].ticket) + " Due Max In Drawdown ...";
// //
// bool isClosed = mTrader.Close(
// positions[maxInDIDX].ticket,
// comment //
// );
// if (isClosed)
// {
// //
// string message = XEQMSupportToken + " Close " + ToString(positions[maxInDIDX].ticket) + " Due Max In Drawdown ...";
//
Alert(message);
}
// //
// Alert(message);
// }
//
return;
}
// //
// return;
// }
//
return;
}
}
// //
// return;
// }
// }
//
// Handle Act Based on Positions Count ...
if (mMaxPositionsForce > 0 && positionsCount > mMaxPositionsForce)
{
//
double requiredProfit = SpecifiedCalculateRequiredProfitForHedge(
positions,
MinRequiredProfitPerTrade(),
MinRequiredProfitPerVolumeFactor() //
);
// //
// // Handle Act Based on Positions Count ...
// if (mMaxPositionsForce > 0 && positionsCount > mMaxPositionsForce)
// {
// //
// double requiredProfit = SpecifiedCalculateRequiredProfitForHedge(
// positions,
// MinRequiredProfitPerTrade(),
// MinRequiredProfitPerVolumeFactor() //
// );
//
double halfProfit = requiredProfit / 2;
if (halfProfit > 0 && profits > halfProfit)
{
//
bool isHedged = DoEQMForceClose(halfProfit);
if (isHedged)
{
//
ForceState(false);
return;
}
}
// //
// double halfProfit = requiredProfit / 2;
// if (halfProfit > 0 && profits > halfProfit)
// {
// //
// bool isHedged = DoEQMForceClose(halfProfit);
// if (isHedged)
// {
// //
// ForceState(false);
// return;
// }
// }
//
// Close Min In Profit Position ...
int minInPIDX = FindMinProfitIndex(positions);
if (IsValidIndex(minInPIDX))
{
//
string comment = XEQMSupportToken + " Min In P ...";
// //
// // Close Min In Profit Position ...
// int minInPIDX = FindMinProfitIndex(positions);
// if (IsValidIndex(minInPIDX))
// {
// //
// string comment = XEQMSupportToken + " Min In P ...";
//
bool isClosed = mTrader.Close(
positions[minInPIDX].ticket,
comment //
);
if (isClosed)
{
//
string message = XEQMSupportToken + " Close " + ToString(positions[minInPIDX].ticket) + " Due Min In Profit ...";
// //
// bool isClosed = mTrader.Close(
// positions[minInPIDX].ticket,
// comment //
// );
// if (isClosed)
// {
// //
// string message = XEQMSupportToken + " Close " + ToString(positions[minInPIDX].ticket) + " Due Min In Profit ...";
//
Alert(message);
// //
// Alert(message);
//
return;
}
}
// //
// return;
// }
// }
//
// Close Max In Drawdown Position ...
int maxInDIDX = FindMaxDrawdownIndex(positions);
if (IsValidIndex(maxInDIDX))
{
//
string comment = XEQMSupportToken + " Max In D ...";
// //
// // Close Max In Drawdown Position ...
// int maxInDIDX = FindMaxDrawdownIndex(positions);
// if (IsValidIndex(maxInDIDX))
// {
// //
// string comment = XEQMSupportToken + " Max In D ...";
//
bool isClosed = mTrader.Close(
positions[maxInDIDX].ticket,
comment //
);
if (isClosed)
{
//
string message = XEQMSupportToken + "Close " + ToString(positions[maxInDIDX].ticket) + " Due Max In Drawdown ...";
// //
// bool isClosed = mTrader.Close(
// positions[maxInDIDX].ticket,
// comment //
// );
// if (isClosed)
// {
// //
// string message = XEQMSupportToken + "Close " + ToString(positions[maxInDIDX].ticket) + " Due Max In Drawdown ...";
//
Alert(message);
}
// //
// Alert(message);
// }
//
return;
}
// //
// return;
// }
//
return;
}
// //
// return;
// }
//
return;
}
// //
// return;
// }
//
int longs = 0;
double longVolumes = 0;
double longProfits = 0;
// //
// int longs = 0;
// double longVolumes = 0;
// double longProfits = 0;
//
int shorts = 0;
double shortVolumes = 0;
double shortProfits = 0;
// //
// int shorts = 0;
// double shortVolumes = 0;
// double shortProfits = 0;
//
// Retrieve Required Informations of Positions ...
CountPositions(
positions,
longs,
longProfits,
longVolumes,
shorts,
shortProfits,
shortVolumes //
);
// //
// // Retrieve Required Informations of Positions ...
// CountPositions(
// positions,
// longs,
// longProfits,
// longVolumes,
// shorts,
// shortProfits,
// shortVolumes //
// );
//
// Retrieve Youngest Age ...
XPosition youngest;
int youngestAge = GetYoungest(
youngest,
positions //
);
// //
// // Retrieve Youngest Age ...
// XPosition youngest;
// int youngestAge = GetYoungest(
// youngest,
// positions //
// );
//
// Now Comparing items for enabling force State ...
bool isForceState =
//
youngestAge >= 20 &&
//
(longProfits + shortProfits < 0)
//
;
if (isForceState)
{
//
ForceState(true);
// //
// // Now Comparing items for enabling force State ...
// bool isForceState =
// //
// youngestAge >= 20 &&
// //
// (longProfits + shortProfits < 0)
// //
// ;
// if (isForceState)
// {
// //
// ForceState(true);
//
return;
}
// //
// return;
// }
//
XPosition supports[];
int supportsCount = ExtractSupports(
positions,
supports //
);
if (!IsValidSize(supportsCount))
{
return;
}
// //
// XPosition supports[];
// int supportsCount = ExtractSupports(
// positions,
// supports //
// );
// if (!IsValidSize(supportsCount))
// {
// return;
// }
//
int maxSupports = mTradeHandler.EnableSupport()
? MaxNumberOfSupports()
: 0;
int maxGrids = mTradeHandler.EnableGrid()
? MaxNumberOfGrids()
: 0;
int maxRecoveries = mTradeHandler.EnableRecovery()
? MaxNumberOfRecoveries()
: 0;
// //
// int maxSupports = mTradeHandler.EnableSupport()
// ? MaxNumberOfSupports()
// : 0;
// int maxGrids = mTradeHandler.EnableGrid()
// ? MaxNumberOfGrids()
// : 0;
// int maxRecoveries = mTradeHandler.EnableRecovery()
// ? MaxNumberOfRecoveries()
// : 0;
//
// Supporting Force States ...
bool isProtectionForce =
supportsCount >= 1;
if (isProtectionForce)
{
//
ForceState(true);
// //
// // Supporting Force States ...
// bool isProtectionForce =
// supportsCount >= 1;
// if (isProtectionForce)
// {
// //
// ForceState(true);
//
return;
}
// //
// return;
// }
//
}