last works on create X121Setup ...
This commit is contained in:
@@ -284,6 +284,159 @@ struct XMRBInputs
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Define Conditions ...
|
||||
struct XMRBConditions
|
||||
{
|
||||
//
|
||||
// Common ...
|
||||
string symbol;
|
||||
ENUM_TIMEFRAMES period;
|
||||
datetime time;
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
double fast[];
|
||||
double slow[];
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
bool isFastOverSlow;
|
||||
bool isFastUnderSlow;
|
||||
bool isFastCrossedOverSlow;
|
||||
bool isFastCrossedUnderSlow;
|
||||
|
||||
//
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
Clean(fast);
|
||||
Clean(slow);
|
||||
|
||||
//
|
||||
ArraySetAsSeries(fast, true);
|
||||
ArraySetAsSeries(slow, true);
|
||||
|
||||
//
|
||||
isFastOverSlow = false;
|
||||
isFastUnderSlow = false;
|
||||
isFastCrossedOverSlow = false;
|
||||
isFastCrossedUnderSlow = false;
|
||||
}
|
||||
|
||||
//
|
||||
void GenerateScore(
|
||||
double &bullishScore,
|
||||
double &bearishScore //
|
||||
)
|
||||
{
|
||||
//
|
||||
bullishScore = 0;
|
||||
bearishScore = 0;
|
||||
|
||||
//
|
||||
if (isFastOverSlow)
|
||||
{
|
||||
bullishScore++;
|
||||
}
|
||||
if (isFastCrossedOverSlow)
|
||||
{
|
||||
bullishScore++;
|
||||
}
|
||||
|
||||
//
|
||||
if (isFastUnderSlow)
|
||||
{
|
||||
bearishScore++;
|
||||
}
|
||||
if (isFastCrossedUnderSlow)
|
||||
{
|
||||
bearishScore++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
string GenerateSummary(
|
||||
bool onlyCommons = false,
|
||||
bool onlyConditions = false,
|
||||
bool includeScores = true,
|
||||
bool ignoreFalseConditions = true,
|
||||
string separator = "\n" //
|
||||
)
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
double bullishScore = 0;
|
||||
double bearishScore = 0;
|
||||
GenerateScore(
|
||||
bullishScore,
|
||||
bearishScore //
|
||||
);
|
||||
|
||||
//
|
||||
string scoresStr =
|
||||
//
|
||||
"Scores: " + separator +
|
||||
"---------------" + separator +
|
||||
"Bullish: " + ToString(bullishScore) + separator +
|
||||
"Bearish: " + ToString(bearishScore) + separator +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
string commonStr = GenerateSpecifiedCommonSummary(
|
||||
this,
|
||||
separator,
|
||||
includeScores //
|
||||
);
|
||||
|
||||
//
|
||||
string conditionsStr =
|
||||
//
|
||||
ToString("isFastOverSlow", isFastOverSlow, ignoreFalseConditions, separator) +
|
||||
ToString("isFastUnderSlow", isFastUnderSlow, ignoreFalseConditions, separator) +
|
||||
ToString("isFastCrossedOverSlow", isFastCrossedOverSlow, ignoreFalseConditions, separator) +
|
||||
ToString("isFastCrossedUnderSlow", isFastCrossedUnderSlow, ignoreFalseConditions, separator) +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
"[" + GetTag() + "]" + separator +
|
||||
(onlyConditions
|
||||
? ""
|
||||
: commonStr) +
|
||||
(!includeScores
|
||||
? ""
|
||||
: scoresStr) +
|
||||
" " + separator +
|
||||
(onlyCommons
|
||||
? ""
|
||||
: conditionsStr) +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string GetTag()
|
||||
{
|
||||
return "XMRB";
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXMRBHelper : public XSCBaseHelper
|
||||
@@ -1196,6 +1349,74 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
bool GetConditions(
|
||||
XMRBConditions &conditions, //
|
||||
int barIndex = 0, //
|
||||
int loopback = 3 //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = true;
|
||||
|
||||
//
|
||||
if (loopback < 3)
|
||||
{
|
||||
loopback = 3;
|
||||
}
|
||||
|
||||
//
|
||||
conditions.Clean();
|
||||
|
||||
//
|
||||
conditions.symbol = mSymbol;
|
||||
conditions.period = mPeriod;
|
||||
conditions.time = TimeCurrent();
|
||||
|
||||
//
|
||||
int zIndex = barIndex;
|
||||
int cIndex = zIndex + 1;
|
||||
int pIndex = cIndex + 1;
|
||||
int ppIndex = pIndex + 1;
|
||||
|
||||
//
|
||||
CopyFast(
|
||||
zIndex,
|
||||
loopback,
|
||||
conditions.fast //
|
||||
);
|
||||
CopySlow(
|
||||
zIndex,
|
||||
loopback,
|
||||
conditions.slow //
|
||||
);
|
||||
|
||||
//
|
||||
// Calculate Conditions ...
|
||||
|
||||
//
|
||||
bool isFastOverSlow = conditions.fast[cIndex] > conditions.slow[cIndex];
|
||||
bool isFastUnderSlow = conditions.fast[cIndex] < conditions.slow[cIndex];
|
||||
|
||||
//
|
||||
bool isFastOverSlowPrev = conditions.fast[pIndex] > conditions.slow[pIndex];
|
||||
bool isFastUnderSlowPrev = conditions.fast[pIndex] < conditions.slow[pIndex];
|
||||
|
||||
//
|
||||
bool isFastCrossedOverSlow = isFastOverSlow &&
|
||||
!isFastOverSlowPrev;
|
||||
bool isFastCrossedUnderSlow = isFastUnderSlow &&
|
||||
!isFastUnderSlowPrev;
|
||||
|
||||
//
|
||||
conditions.isFastOverSlow = isFastOverSlow;
|
||||
conditions.isFastUnderSlow = isFastUnderSlow;
|
||||
conditions.isFastCrossedOverSlow = isFastCrossedOverSlow;
|
||||
conditions.isFastCrossedUnderSlow = isFastCrossedUnderSlow;
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user