complete scoring and summary generating in x121 market cycle conditions class ...

This commit is contained in:
2024-06-01 03:51:48 +03:30
parent 4e4be34f1a
commit 753b99411f
4 changed files with 1182 additions and 121 deletions
+36 -116
View File
@@ -44,21 +44,6 @@
// //
// Definitions ... // Definitions ...
//
// Signallers ...
enum ENUM_X121_SIGNAL_PROVIDERS
{
//
PROVIDER_NONE,
XSP,
XTEST,
X786,
X121,
X110,
X92,
X128,
};
// //
// X121 Provider Inputs ... // X121 Provider Inputs ...
class X121ProviderInputs : public XSCBase class X121ProviderInputs : public XSCBase
@@ -1035,8 +1020,8 @@ public:
// //
// Set Signal Providers ... // Set Signal Providers ...
void SetSignalProviderState( void SetSignalProviderState(
ENUM_X121_SIGNAL_PROVIDERS provider, // Provider State ENUM_XSIGNAL_PROVIDERS provider, // Provider State
bool state // Which state is going to set ... bool state // Which state is going to set ...
) )
{ {
// //
@@ -1087,8 +1072,8 @@ public:
// //
void SetSignalProviderStates( void SetSignalProviderStates(
ENUM_X121_SIGNAL_PROVIDERS &providers[], // Collection of Providers ... ENUM_XSIGNAL_PROVIDERS &providers[], // Collection of Providers ...
bool state // Which state is going to set ... bool state // Which state is going to set ...
) )
{ {
// //
@@ -3706,12 +3691,14 @@ private:
bool condition1 = bool condition1 =
// //
((cHasX786 && ((cHasX786 &&
sHasX786) sHasX786 &&
mHasX786)
// //
|| ||
// //
(cHasX786 && (cHasX786 &&
mHasX786)) mHasX786 &&
lHasX786))
// //
; ;
@@ -3719,12 +3706,14 @@ private:
bool condition2 = bool condition2 =
// //
((sHasX786 && ((sHasX786 &&
mHasX786) mHasX786 &&
lHasX786)
// //
|| ||
// //
(sHasX786 && (sHasX786 &&
lHasX786)) lHasX786 &&
hHasX786))
// //
; ;
@@ -3732,12 +3721,14 @@ private:
bool condition3 = bool condition3 =
// //
((mHasX786 && ((mHasX786 &&
lHasX786) lHasX786 &&
hHasX786)
// //
|| ||
// //
(mHasX786 && (mHasX786 &&
hHasX786)) hHasX786 &&
sHasX786))
// //
; ;
@@ -3745,7 +3736,8 @@ private:
bool condition4 = bool condition4 =
// //
(lHasX786 && (lHasX786 &&
hHasX786) hHasX786 &&
mHasX786)
// //
; ;
@@ -4232,7 +4224,7 @@ private:
// //
return result; return result;
} }
// //
bool X128HasSpecifiedShortSignal( bool X128HasSpecifiedShortSignal(
X121MarketConditions &mConditions, // X121MarketConditions &mConditions, //
@@ -4259,12 +4251,12 @@ private:
struct X121ProviderDescriptor struct X121ProviderDescriptor
{ {
// //
string symbol; // Trading Symbol string symbol; // Trading Symbol
ENUM_TIMEFRAMES period; // Trading Timeframe ENUM_TIMEFRAMES period; // Trading Timeframe
double staticVolume; // Static Volume for Positions double staticVolume; // Static Volume for Positions
bool allowLong; // Allow Long Signals bool allowLong; // Allow Long Signals
bool allowShort; // Allow Short Signals bool allowShort; // Allow Short Signals
ENUM_X121_SIGNAL_PROVIDERS signallers[]; // Allowed Signal Providers ENUM_XSIGNAL_PROVIDERS signallers[]; // Allowed Signal Providers
// //
X121ProviderInputs inputs; X121ProviderInputs inputs;
@@ -4299,10 +4291,10 @@ struct X121ProviderDescriptor
// //
bool Init( bool Init(
ENUM_X121_SIGNAL_PROVIDERS &mSignallers[], // Allowed Signal Providers ENUM_XSIGNAL_PROVIDERS &mSignallers[], // Allowed Signal Providers
bool mAllowLong = true, // Allow Long Signals bool mAllowLong = true, // Allow Long Signals
bool mAllowShort = true, // Allow Short Signals bool mAllowShort = true, // Allow Short Signals
double mStaticVolume = 0.01 // Static Volume for Positions double mStaticVolume = 0.01 // Static Volume for Positions
) )
{ {
// //
@@ -4324,12 +4316,12 @@ struct X121ProviderDescriptor
// //
bool Init( bool Init(
string mSymbol, // Trading Symbol string mSymbol, // Trading Symbol
ENUM_TIMEFRAMES mPeriod, // Trading Timeframe ENUM_TIMEFRAMES mPeriod, // Trading Timeframe
ENUM_X121_SIGNAL_PROVIDERS &mSignallers[], // Allowed Signal Providers ENUM_XSIGNAL_PROVIDERS &mSignallers[], // Allowed Signal Providers
bool mAllowLong = true, // Allow Long Signals bool mAllowLong = true, // Allow Long Signals
bool mAllowShort = true, // Allow Short Signals bool mAllowShort = true, // Allow Short Signals
double mStaticVolume = 0.01 // Static Volume for Positions double mStaticVolume = 0.01 // Static Volume for Positions
) )
{ {
// //
@@ -4359,7 +4351,7 @@ struct X121ProviderDescriptor
this.staticVolume = mStaticVolume; this.staticVolume = mStaticVolume;
// //
ENUM_X121_SIGNAL_PROVIDERS tmp[]; ENUM_XSIGNAL_PROVIDERS tmp[];
Copy( Copy(
mSignallers, mSignallers,
tmp // tmp //
@@ -4476,76 +4468,4 @@ struct X121ProviderDescriptor
} }
}; };
//
void GetAllX121SignalProviders(ENUM_X121_SIGNAL_PROVIDERS &result[])
{
//
Clean(result);
//
Add(XSP, result);
Add(XTEST, result);
Add(X786, result);
Add(X121, result);
Add(X110, result);
Add(X92, result);
Add(X128, result);
}
//
string ToString(ENUM_X121_SIGNAL_PROVIDERS value)
{
return EnumToString(value);
}
//
ENUM_X121_SIGNAL_PROVIDERS ToX121SignalProvider(string content)
{
//
ENUM_X121_SIGNAL_PROVIDERS result = PROVIDER_NONE;
//
if (!IsValid(content))
{
return result;
}
//
if (content == ToString(PROVIDER_NONE))
{
result = PROVIDER_NONE;
}
else if (content == ToString(XSP))
{
result = XSP;
}
else if (content == ToString(XTEST))
{
result = XTEST;
}
else if (content == ToString(X786))
{
result = X786;
}
else if (content == ToString(X121))
{
result = X121;
}
else if (content == ToString(X110))
{
result = X110;
}
else if (content == ToString(X92))
{
result = X92;
}
else if (content == ToString(X128))
{
result = X128;
}
//
return result;
}
// //
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -193,7 +193,7 @@ bool InitialEA()
// //
// Define Signallers ... // Define Signallers ...
ENUM_X121_SIGNAL_PROVIDERS signallers[]; ENUM_XSIGNAL_PROVIDERS signallers[];
Add(X786, signallers); Add(X786, signallers);
// Add(X121, signallers); // Add(X121, signallers);
// Add(X121, signallers); // Add(X121, signallers);
+105 -2
View File
@@ -3711,6 +3711,109 @@ double GetAppliedPrice(
return (0); return (0);
} }
//
// Calculate TP/SL for Specified Type of Positions ...
void CalculateTPSL(
double &mSL, // Hold SL
double &mTP, // Hold TP
ENUM_POSITION_TYPE mType, // Position Type Long (Buy) / Short (Sell)
double mEntry, // Entry Price
double mR2R = 1, // Provided Risk To Reward Ratio
double slPrice = 0, // Provided SL Price
double tpPrice = 0 // Provided TP Price
)
{
//
// if Both TP and SL Provided, ignore R2R and Calculate direct ...
// if SL provided, Calculate TP based on Provided R2R ...
// if TP provided, Calculate SL based on Provided R2R ...
// default R2R is set to 1 ...
//
mSL = 0;
mTP = 0;
//
bool isLong = IsLong(mType);
//
// Set Default R2R ...
if (mR2R < 1)
{
mR2R = 1;
}
//
if (mEntry <= 0 ||
(tpPrice <= 0 && slPrice <= 0))
{
return;
}
//
double risk = 0;
double reward = 0;
//
bool canCalculateBasedOnSL = slPrice > 0 &&
(isLong
? slPrice < mEntry
: slPrice > mEntry);
//
bool canCalculateBasedOnTP = tpPrice > 0 &&
(isLong
? tpPrice > mEntry
: tpPrice < mEntry);
//
if (canCalculateBasedOnSL && !canCalculateBasedOnTP)
{
//
risk = MathAbs(mEntry - slPrice);
reward = risk * mR2R;
}
else if (!canCalculateBasedOnSL && canCalculateBasedOnTP)
{
//
reward = MathAbs(mEntry - tpPrice);
risk = reward / mR2R;
}
else if (!canCalculateBasedOnSL && !canCalculateBasedOnTP)
{
//
bool canSetTPPrice = isLong
? tpPrice > mEntry
: tpPrice < mEntry;
if (canSetTPPrice)
{
mTP = tpPrice;
}
//
bool canSetSLPrice = isLong
? slPrice < mEntry
: slPrice > mEntry;
if (canSetSLPrice)
{
mSL = slPrice;
}
//
return;
}
//
mTP = isLong
? mEntry + reward
: mEntry - reward;
//
mSL = isLong
? mEntry - reward
: mEntry + reward;
}
// //
// Symbols ... // Symbols ...
@@ -5792,8 +5895,8 @@ string ToString(
string prefix, // Title string prefix, // Title
bool value, // Value bool value, // Value
bool ignoreFalseConditions = true, // Ignore False Conditions bool ignoreFalseConditions = true, // Ignore False Conditions
string prefixSeparator = ":", // Title Separator string lineSeparator = "\n", // Line Separator
string lineSeparator = "\n" // Line Separator string prefixSeparator = ":" // Title Separator
) )
{ {
// //