last ...
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
// }
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
@@ -3386,3 +3386,222 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//
|
||||
// Handle Creating a new Signal Info ...
|
||||
// XSignal signal;
|
||||
// X121SetupConditions otherConditions[];
|
||||
// if (hHasSignal)
|
||||
// {
|
||||
// //
|
||||
// signal = hSignal;
|
||||
|
||||
// //
|
||||
// AddRef(
|
||||
// cConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// sConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// }
|
||||
// else if (lHasSignal)
|
||||
// {
|
||||
// //
|
||||
// signal = lSignal;
|
||||
|
||||
// //
|
||||
// AddRef(
|
||||
// cConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// sConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// mConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// }
|
||||
// else if (mHasSignal)
|
||||
// {
|
||||
// //
|
||||
// signal = mSignal;
|
||||
|
||||
// //
|
||||
// AddRef(
|
||||
// cConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// sConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// }
|
||||
// else if (sHasSignal)
|
||||
// {
|
||||
// //
|
||||
// signal = sSignal;
|
||||
|
||||
// //
|
||||
// AddRef(
|
||||
// cConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// mConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// lConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// AddRef(
|
||||
// hConditions,
|
||||
// otherConditions //
|
||||
// );
|
||||
// }
|
||||
// else if (cHasSignal)
|
||||
// {
|
||||
// //
|
||||
// signal = cSignal;
|
||||
|
||||
// //
|
||||
// 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 //
|
||||
// );
|
||||
// }
|
||||
|
||||
@@ -42,14 +42,14 @@ input group "Signals";
|
||||
//,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb
|
||||
// EURUSDb,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb
|
||||
// EURUSDb,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb,XAUUSDb,NZDUSDb,AUDUSDb,USDCADb,BTCUSD,ETHUSD
|
||||
input string x121EASymbols = "EURUSDb"; // Symbols
|
||||
input bool x121EAUseAllSymbols = false; // Use All Available Symbols
|
||||
input bool x121EAUseAllWatchListSymbols = false; // Use All WatchList Symbols
|
||||
input bool x121EAAllowLong = true; // Allow Long Trades
|
||||
input bool x121EAAllowShort = true; // Allow Short Trades
|
||||
input int x121EADelayBetweenTwoSignal = 5; // Delay Between two Same Signals
|
||||
input int x121EAReuiredSignalVerifications = 1; // Required Verifications for Signals
|
||||
input bool x121EAGetVerificationFromOtherTimeFrames = false; // Get Verifications from Other Time Frames
|
||||
input string x121EASymbols = "EURUSDb"; // Symbols
|
||||
input bool x121EAUseAllSymbols = false; // Use All Available Symbols
|
||||
input bool x121EAUseAllWatchListSymbols = false; // Use All WatchList Symbols
|
||||
input bool x121EAAllowLong = true; // Allow Long Trades
|
||||
input bool x121EAAllowShort = true; // Allow Short Trades
|
||||
input int x121EADelayBetweenTwoSignal = 5; // Delay Between two Same Signals
|
||||
input int x121EAReuiredSignalVerifications = 4; // Required Verifications for Signals
|
||||
input bool x121EAGetVerificationFromOtherTimeFrames = true; // Get Verifications from Other Time Frames
|
||||
|
||||
//
|
||||
// Risk Management ...
|
||||
@@ -80,6 +80,7 @@ input double x121EANextTrailPoint = 25; // Next Trailling Step
|
||||
//
|
||||
input group "Supporting";
|
||||
input bool x121EAAllowSupport = false; // Allow Support Signals
|
||||
input bool x121EASupportOnlyForces = false; // Support Only Force Signals
|
||||
double x121EASupportDistance = 50; // Supporting Distance
|
||||
input int x121EAMaxNumberOfSupports = 1; // Max Number of Support Signals
|
||||
input double x121EASupportVolumeMultiplier = 2.0; // Support Signals Volume Multiplier
|
||||
@@ -88,6 +89,7 @@ input double x121EAMaxAllowedSupportVolume = 0.04; // Max Allowed Support Signal
|
||||
//
|
||||
input group "Grid";
|
||||
input bool x121EAAllowGrid = false; // Allow Grid Signals
|
||||
input bool x121EAGridOnlyForces = false; // Grid Only Force Signals
|
||||
input int x121EAMaxNumberOfGrids = 5; // Max Number of Grid Signals
|
||||
input double x121EAGridDistance = 100; // Grid Distance
|
||||
input double x121EAGridVolumeMultiplier = 2.0; // Grid Volume Multiplier
|
||||
@@ -96,6 +98,7 @@ input double x121EAMaxAllowedGridVolume = 0.04; // Max Allowed Grid Signals Volu
|
||||
//
|
||||
input group "Recovery";
|
||||
input bool x121EAAllowRecovery = false; // Allow Recovery Signals
|
||||
input bool x121EARecoverOnlyForces = false; // Recover Only Force Signals
|
||||
input int x121EAMaxNumberOfRecoveries = 2; // Max Number of Recovery Signals
|
||||
input double x121EARecoveryDistance = 100; // Recovery Distance
|
||||
input double x121EARecoveryVolumeMultiplier = 2; // Recovery Volume Multiplier
|
||||
@@ -302,6 +305,7 @@ bool InitialEA()
|
||||
//
|
||||
// Supporting ...
|
||||
x121EA.AllowSupport(x121EAAllowSupport);
|
||||
x121EA.SupportOnlyForces(x121EASupportOnlyForces);
|
||||
x121EA.SupportDistance(x121EASupportDistance);
|
||||
x121EA.MaxNumberOfSupports(x121EAMaxNumberOfSupports);
|
||||
x121EA.SupportVolumeMultiplier(x121EASupportVolumeMultiplier);
|
||||
@@ -310,6 +314,7 @@ bool InitialEA()
|
||||
//
|
||||
// Grid ...
|
||||
x121EA.AllowGrid(x121EAAllowGrid);
|
||||
x121EA.GridOnlyForces(x121EAGridOnlyForces);
|
||||
x121EA.GridDistance(x121EAGridDistance);
|
||||
x121EA.MaxNumberOfGrids(x121EAMaxNumberOfGrids);
|
||||
x121EA.GridVolumeMultiplier(x121EAGridVolumeMultiplier);
|
||||
@@ -318,6 +323,7 @@ bool InitialEA()
|
||||
//
|
||||
// Recovery ...
|
||||
x121EA.AllowRecovery(x121EAAllowRecovery);
|
||||
x121EA.RecoverOnlyForces(x121EARecoverOnlyForces);
|
||||
x121EA.RecoveryDistance(x121EARecoveryDistance);
|
||||
x121EA.MaxNumberOfRecoveries(x121EAMaxNumberOfRecoveries);
|
||||
x121EA.RecoveryVolumeMultiplier(x121EARecoveryVolumeMultiplier);
|
||||
@@ -386,24 +392,24 @@ void X121PreConfigureStyles(X121SetupInputs &inputs)
|
||||
{
|
||||
//
|
||||
// XHTD ...
|
||||
inputs.htdInputs.show = true;
|
||||
inputs.htdInputs.show = false;
|
||||
|
||||
//
|
||||
// XATSL ...
|
||||
inputs.atslInputs.show = true;
|
||||
inputs.atslInputs.show = false;
|
||||
|
||||
//
|
||||
// XSLN ...
|
||||
inputs.slnInputs.show = true;
|
||||
inputs.slnInputs.show = false;
|
||||
|
||||
//
|
||||
// XDMNT ...
|
||||
inputs.dmntInputs.showBull = true;
|
||||
inputs.dmntInputs.showBear = true;
|
||||
inputs.dmntInputs.showBull = false;
|
||||
inputs.dmntInputs.showBear = false;
|
||||
|
||||
//
|
||||
// XSTR ...
|
||||
inputs.strInputs.showTrends = true;
|
||||
inputs.strInputs.showTrends = false;
|
||||
inputs.strInputs.fillTrends = false;
|
||||
|
||||
//
|
||||
|
||||
@@ -38,7 +38,7 @@ input bool show = true; // Show
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 2
|
||||
#property indicator_buffers 3
|
||||
#property indicator_plots 2
|
||||
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user