Last Works ...
This commit is contained in:
@@ -426,8 +426,9 @@ struct XPVPivot
|
||||
};
|
||||
|
||||
//
|
||||
// Model Signalling Conditions ...
|
||||
struct X121SMCStrategyConditions
|
||||
// Each Market Cycle (Time Frame) Conditions
|
||||
// Model as this Structure ...
|
||||
struct X121SMCCycleConditions
|
||||
{
|
||||
//
|
||||
string symbol;
|
||||
@@ -440,6 +441,9 @@ struct X121SMCStrategyConditions
|
||||
X3VWAPConditions x3vwapConditions;
|
||||
XCHSARConditions xchsarConditions;
|
||||
|
||||
//
|
||||
XPOIState state;
|
||||
|
||||
//
|
||||
void X121SMCStrategyConditions()
|
||||
{
|
||||
@@ -460,9 +464,11 @@ struct X121SMCStrategyConditions
|
||||
time = NULL;
|
||||
|
||||
//
|
||||
state.Clean();
|
||||
xpvConditions.Clean();
|
||||
x3maConditions.Clean();
|
||||
x3vwapConditions.Clean();
|
||||
xchsarConditions.Clean();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -479,6 +485,96 @@ struct X121SMCStrategyConditions
|
||||
result = IsSpecifiedValid(symbol) &&
|
||||
IsSpecifiedValid(period) &&
|
||||
IsSpecifiedValid(time);
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Cycle Conditions Has Bullish State ...
|
||||
*
|
||||
* @param bar: XOHCL instance ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsBullish(
|
||||
XOHCL &bar //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int index = bar.Index();
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
// Check Conditions Validation ...
|
||||
IsValid() &&
|
||||
//
|
||||
// Check Bar Validation ...
|
||||
bar.IsValid() &&
|
||||
//
|
||||
// Check XCHSar Current is Bullish ...
|
||||
xchsarConditions.isCBullish &&
|
||||
//
|
||||
// Check X3VWAP is Bullish State ...
|
||||
x3vwapConditions.isBullishState &&
|
||||
//
|
||||
// Check X3VWAP is Bullish Ordered ...
|
||||
x3vwapConditions.isBullishOrdered &&
|
||||
//
|
||||
// Check Close Over X3MA Fast ...
|
||||
bar.close > x3maConditions.fasts[index]
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Cycle Conditions Has Bearish State ...
|
||||
*
|
||||
* @param bar: XOHCL instance ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsBearish(
|
||||
XOHCL &bar //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
int index = bar.Index();
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
// Check Conditions Validation ...
|
||||
IsValid() &&
|
||||
//
|
||||
// Check Bar Validation ...
|
||||
bar.IsValid() &&
|
||||
//
|
||||
// Check XCHSar Current is Bearish ...
|
||||
xchsarConditions.isCBearish &&
|
||||
//
|
||||
// Check X3VWAP is Bearish State ...
|
||||
x3vwapConditions.isBearishState &&
|
||||
//
|
||||
// Check X3VWAP is Bearish Ordered ...
|
||||
x3vwapConditions.isBearishOrdered &&
|
||||
//
|
||||
// Check Close Under X3MA Fast ...
|
||||
bar.close < x3maConditions.fasts[index]
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -611,15 +707,18 @@ struct X121SMCStrategyConditions
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
string typeName = GetTypeName(this);
|
||||
|
||||
//
|
||||
if (!forObject)
|
||||
{
|
||||
result = X121SMCStrategyToken;
|
||||
result = typeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
result = X121SMCStrategyToken + "_" +
|
||||
result = typeName + "_" +
|
||||
symbol + "_" + ToString(period) + "_" +
|
||||
ToMD5(time);
|
||||
}
|
||||
@@ -631,160 +730,398 @@ struct X121SMCStrategyConditions
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Model Signalling Conditions ...
|
||||
struct X121SMCStrategyConditions
|
||||
{
|
||||
//
|
||||
string symbol;
|
||||
ENUM_TIMEFRAMES period;
|
||||
datetime time;
|
||||
|
||||
//
|
||||
// Cycles Conditions here ...
|
||||
X121SMCCycleConditions triggerConditions;
|
||||
X121SMCCycleConditions decisionConditions;
|
||||
X121SMCCycleConditions analyseConditions;
|
||||
X121SMCCycleConditions verificationConditions;
|
||||
X121SMCCycleConditions consolidationConditions;
|
||||
X121SMCCycleConditions visionConditions;
|
||||
|
||||
//
|
||||
void X121SMCStrategyConditions()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Cleanup ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
time = NULL;
|
||||
|
||||
//
|
||||
triggerConditions.Clean();
|
||||
decisionConditions.Clean();
|
||||
analyseConditions.Clean();
|
||||
verificationConditions.Clean();
|
||||
consolidationConditions.Clean();
|
||||
visionConditions.Clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsSpecifiedValid(symbol) &&
|
||||
IsSpecifiedValid(period) &&
|
||||
IsSpecifiedValid(time);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
bool HasDirection(
|
||||
ENUM_X_DIRECTION &dir,
|
||||
XOHCL &bar //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
result = IsValid() &&
|
||||
bar.IsValid() &&
|
||||
bar.Index() > 0;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int index = bar.Index();
|
||||
|
||||
//
|
||||
// Parse Cycles Conditions ...
|
||||
|
||||
//
|
||||
// Vision ...
|
||||
|
||||
//
|
||||
bool isVisionBullish =
|
||||
//
|
||||
// XCHSar Current is Bullish ...
|
||||
visionConditions.xchsarConditions.isCBullish &&
|
||||
//
|
||||
// Close Over X3MA Fast ...
|
||||
bar.close > visionConditions.x3maConditions.fasts[index] &&
|
||||
//
|
||||
// X3VWap Fast is Bullish ...
|
||||
visionConditions.x3vwapConditions.fastStates[index] ==
|
||||
X3VWAP_STATE_BULLISH
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isVisionBearish =
|
||||
//
|
||||
// XCHSar Current is Bearish ...
|
||||
visionConditions.xchsarConditions.isCBearish &&
|
||||
//
|
||||
// Close Under X3MA Fast ...
|
||||
bar.close < visionConditions.x3maConditions.fasts[index] &&
|
||||
//
|
||||
// X3VWap Fast is Bearish ...
|
||||
visionConditions.x3vwapConditions.fastStates[index] ==
|
||||
X3VWAP_STATE_BEARISH
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
// Check Vision Has Conditions or not ...
|
||||
bool hasVisionConditions =
|
||||
isVisionBullish ||
|
||||
isVisionBearish;
|
||||
result = hasVisionConditions;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Consolidation ...
|
||||
|
||||
//
|
||||
bool isConsolidationBullish = consolidationConditions.IsBullish(bar);
|
||||
bool isConsolidationBearish = consolidationConditions.IsBearish(bar);
|
||||
bool hasConsolidationConditions =
|
||||
isConsolidationBullish ||
|
||||
isConsolidationBearish;
|
||||
result = hasConsolidationConditions;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Verification ...
|
||||
|
||||
//
|
||||
bool isVerificationBullish = verificationConditions.IsBullish(bar);
|
||||
bool isVerificationBearish = verificationConditions.IsBearish(bar);
|
||||
bool hasVerificationConditions =
|
||||
isVerificationBullish ||
|
||||
isVerificationBearish;
|
||||
result = hasVerificationConditions;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Analyse ...
|
||||
|
||||
//
|
||||
bool isAnalyseBullish = analyseConditions.IsBullish(bar);
|
||||
bool isAnalyseBearish = analyseConditions.IsBearish(bar);
|
||||
bool hasAnalyseConditions =
|
||||
isAnalyseBullish ||
|
||||
isAnalyseBearish;
|
||||
result = hasAnalyseConditions;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Decision ...
|
||||
|
||||
//
|
||||
bool isDecisionBullish = decisionConditions.IsBullish(bar);
|
||||
bool isDecisionBearish = decisionConditions.IsBearish(bar);
|
||||
bool hasDecisionConditions =
|
||||
isDecisionBullish ||
|
||||
isDecisionBearish;
|
||||
result = hasDecisionConditions;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Analyse Conditions ...
|
||||
bool hasBullishConditions =
|
||||
//
|
||||
isVisionBullish &&
|
||||
isConsolidationBullish &&
|
||||
isVerificationBullish &&
|
||||
isAnalyseBullish &&
|
||||
isDecisionBullish
|
||||
//
|
||||
;
|
||||
bool hasBearishConditions =
|
||||
//
|
||||
isVisionBearish &&
|
||||
isConsolidationBearish &&
|
||||
isVerificationBearish &&
|
||||
isAnalyseBearish &&
|
||||
isDecisionBearish
|
||||
//
|
||||
;
|
||||
result = hasBullishConditions ||
|
||||
hasBearishConditions;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Specified Conditions Direction ...
|
||||
dir =
|
||||
hasBullishConditions
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Reporter Functions ...
|
||||
|
||||
/**
|
||||
* Generate Provided Scores ...
|
||||
*
|
||||
* @param bullishScore: Integer, reference ...
|
||||
* @param bearishScore: Integer, referenceF ...
|
||||
*/
|
||||
void GenerateScore(
|
||||
double &bullishScore,
|
||||
double &bearishScore //
|
||||
)
|
||||
{
|
||||
//
|
||||
bullishScore = 0;
|
||||
bearishScore = 0;
|
||||
|
||||
//
|
||||
if (!IsValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
double bullScore = 0;
|
||||
double bearScore = 0;
|
||||
|
||||
// //
|
||||
// // XPV ...
|
||||
// pvConditions.GenerateScore(
|
||||
// bullScore,
|
||||
// bearScore //
|
||||
// );
|
||||
// bullishScore += bullScore;
|
||||
// bearishScore += bearScore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Summary ...
|
||||
*
|
||||
* @param onlyCommons: Boolean ...
|
||||
* @param onlyConditions: Boolean ...
|
||||
* @param includeScores: Boolean ...
|
||||
* @param ignoreFalseConditions: Boolean ...
|
||||
* @param separator: String ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
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 commonStr = GenerateSpecifiedCommonSummary(
|
||||
this,
|
||||
separator,
|
||||
includeScores,
|
||||
true //
|
||||
);
|
||||
|
||||
// //
|
||||
// // XPV ...
|
||||
// string pvStr = pvConditions.GenerateSummary(
|
||||
// false,
|
||||
// true,
|
||||
// false,
|
||||
// ignoreFalseConditions //
|
||||
// );
|
||||
|
||||
//
|
||||
string conditionsStr =
|
||||
//
|
||||
// pvStr + separator +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
"[" + GetTag() + "]" + separator +
|
||||
"----------" + separator +
|
||||
(onlyConditions
|
||||
? ""
|
||||
: commonStr) +
|
||||
" " + separator +
|
||||
(onlyCommons
|
||||
? ""
|
||||
: conditionsStr) +
|
||||
""
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Unique Identifier ...
|
||||
*
|
||||
* @param forObject: Boolean ...
|
||||
*
|
||||
* @return ( string )
|
||||
*/
|
||||
string GetTag(
|
||||
bool forObject = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
string typeName = GetTypeName(this);
|
||||
|
||||
//
|
||||
if (!forObject)
|
||||
{
|
||||
result = typeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
result = typeName + "_" +
|
||||
symbol + "_" + ToString(period) + "_" +
|
||||
ToMD5(time);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
typedef void (*TOnX121SMCSignal)(
|
||||
XSignal &signal,
|
||||
X121SMCStrategyConditions &conditions //
|
||||
);
|
||||
|
||||
//
|
||||
// Time Frames Tools ...
|
||||
|
||||
/**
|
||||
* Calculate Analyse Period ...
|
||||
*
|
||||
* @param value: ENUM_TIMEFRAMES member, Specified Trigger Period ...
|
||||
*
|
||||
* @return ( ENUM_TIMEFRAMES )
|
||||
*/
|
||||
ENUM_TIMEFRAMES GetAnalysePeriod(ENUM_TIMEFRAMES value)
|
||||
{
|
||||
//
|
||||
ENUM_TIMEFRAMES result = NULL;
|
||||
|
||||
//
|
||||
value = NormalizePeriod(value);
|
||||
|
||||
//
|
||||
switch (value)
|
||||
{
|
||||
//
|
||||
case PERIOD_M1:
|
||||
case PERIOD_M2:
|
||||
case PERIOD_M3:
|
||||
case PERIOD_M4:
|
||||
case PERIOD_M5:
|
||||
case PERIOD_M6:
|
||||
case PERIOD_M10:
|
||||
case PERIOD_M12:
|
||||
result = PERIOD_M15;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_M15:
|
||||
case PERIOD_M20:
|
||||
result = PERIOD_M30;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H1:
|
||||
case PERIOD_H2:
|
||||
case PERIOD_H3:
|
||||
result = PERIOD_H4;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H4:
|
||||
case PERIOD_H6:
|
||||
case PERIOD_H8:
|
||||
result = PERIOD_H12;
|
||||
break;
|
||||
|
||||
//
|
||||
default:
|
||||
result = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
bool HasValidAnalysePeriod(
|
||||
ENUM_TIMEFRAMES value,
|
||||
ENUM_TIMEFRAMES &period //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
period = GetAnalysePeriod(value);
|
||||
result = IsValid(period);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate Vision Period ...
|
||||
*
|
||||
* @param value: ENUM_TIMEFRAMES member, Specified Trigger Period ...
|
||||
*
|
||||
* @return ( ENUM_TIMEFRAMES )
|
||||
*/
|
||||
ENUM_TIMEFRAMES GetVisionPeriod(ENUM_TIMEFRAMES value)
|
||||
{
|
||||
//
|
||||
ENUM_TIMEFRAMES result = NULL;
|
||||
|
||||
//
|
||||
value = NormalizePeriod(value);
|
||||
|
||||
//
|
||||
switch (value)
|
||||
{
|
||||
//
|
||||
case PERIOD_M1:
|
||||
case PERIOD_M2:
|
||||
case PERIOD_M3:
|
||||
case PERIOD_M4:
|
||||
case PERIOD_M5:
|
||||
case PERIOD_M6:
|
||||
case PERIOD_M10:
|
||||
case PERIOD_M12:
|
||||
result = PERIOD_H1;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_M15:
|
||||
case PERIOD_M20:
|
||||
result = PERIOD_H2;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H1:
|
||||
case PERIOD_H2:
|
||||
case PERIOD_H3:
|
||||
result = PERIOD_H6;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H4:
|
||||
case PERIOD_H6:
|
||||
case PERIOD_H8:
|
||||
result = PERIOD_D1;
|
||||
break;
|
||||
|
||||
//
|
||||
default:
|
||||
result = NULL;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
bool HasValidVisionPeriod(
|
||||
ENUM_TIMEFRAMES value,
|
||||
ENUM_TIMEFRAMES &period //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
period = GetVisionPeriod(value);
|
||||
result = IsValid(period);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Extentions ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user