Last Works ...
This commit is contained in:
@@ -38,6 +38,55 @@ struct X121SMCStrategyConditions
|
||||
ENUM_TIMEFRAMES period;
|
||||
datetime time;
|
||||
|
||||
//
|
||||
// D1 ...
|
||||
XPOIState d1State;
|
||||
ENUM_X_DIRECTION d1MarketDirection;
|
||||
XCSupportZone *d1SupportZones[];
|
||||
XCResistanceZone *d1ResistanceZones[];
|
||||
|
||||
//
|
||||
// H4 ...
|
||||
XPOIState h4State;
|
||||
ENUM_X_DIRECTION h4MarketDirection;
|
||||
XCSupportZone *h4SupportZones[];
|
||||
XCResistanceZone *h4ResistanceZones[];
|
||||
|
||||
//
|
||||
// H2 ...
|
||||
XPOIState h2State;
|
||||
ENUM_X_DIRECTION h2MarketDirection;
|
||||
XCSupportZone *h2SupportZones[];
|
||||
XCResistanceZone *h2ResistanceZones[];
|
||||
|
||||
//
|
||||
// H1 ...
|
||||
XPOIState h1State;
|
||||
ENUM_X_DIRECTION h1MarketDirection;
|
||||
XCSupportZone *h1SupportZones[];
|
||||
XCResistanceZone *h1ResistanceZones[];
|
||||
|
||||
//
|
||||
// M15 ...
|
||||
XPOIState m15State;
|
||||
ENUM_X_DIRECTION m15MarketDirection;
|
||||
XCSupportZone *m15SupportZones[];
|
||||
XCResistanceZone *m15ResistanceZones[];
|
||||
|
||||
//
|
||||
// M5 ...
|
||||
XPOIState m5State;
|
||||
ENUM_X_DIRECTION m5MarketDirection;
|
||||
XCSupportZone *m5SupportZones[];
|
||||
XCResistanceZone *m5ResistanceZones[];
|
||||
|
||||
//
|
||||
// M1 ...
|
||||
XPOIState m1State;
|
||||
ENUM_X_DIRECTION m1MarketDirection;
|
||||
XCSupportZone *m1SupportZones[];
|
||||
XCResistanceZone *m1ResistanceZones[];
|
||||
|
||||
//
|
||||
void X121SMCStrategyConditions()
|
||||
{
|
||||
@@ -56,6 +105,55 @@ struct X121SMCStrategyConditions
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
time = NULL;
|
||||
|
||||
//
|
||||
// D1 ...
|
||||
d1State.Clean();
|
||||
d1MarketDirection = X_DIRECTION_NONE;
|
||||
Clean(d1SupportZones);
|
||||
Clean(d1ResistanceZones);
|
||||
|
||||
//
|
||||
// H4 ...
|
||||
h4State.Clean();
|
||||
h4MarketDirection = X_DIRECTION_NONE;
|
||||
Clean(h4SupportZones);
|
||||
Clean(h4ResistanceZones);
|
||||
|
||||
//
|
||||
// H2 ...
|
||||
h2State.Clean();
|
||||
h2MarketDirection = X_DIRECTION_NONE;
|
||||
Clean(h2SupportZones);
|
||||
Clean(h2ResistanceZones);
|
||||
|
||||
//
|
||||
// H1 ...
|
||||
h1State.Clean();
|
||||
h1MarketDirection = X_DIRECTION_NONE;
|
||||
Clean(h1SupportZones);
|
||||
Clean(h1ResistanceZones);
|
||||
|
||||
//
|
||||
// M15 ...
|
||||
m15State.Clean();
|
||||
m15MarketDirection = X_DIRECTION_NONE;
|
||||
Clean(m15SupportZones);
|
||||
Clean(m15ResistanceZones);
|
||||
|
||||
//
|
||||
// M5 ...
|
||||
m5State.Clean();
|
||||
m5MarketDirection = X_DIRECTION_NONE;
|
||||
Clean(m5SupportZones);
|
||||
Clean(m5ResistanceZones);
|
||||
|
||||
//
|
||||
// M1 ...
|
||||
m1State.Clean();
|
||||
m1MarketDirection = X_DIRECTION_NONE;
|
||||
Clean(m1SupportZones);
|
||||
Clean(m1ResistanceZones);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,6 +175,99 @@ struct X121SMCStrategyConditions
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Custom Tools ...
|
||||
|
||||
/**
|
||||
* Check Conditions for Detect Market Structure ...
|
||||
*
|
||||
* @param structure: ENUM_X_DIRECTION member, Market Structure Direction reference ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasMarketStructure(
|
||||
ENUM_X_DIRECTION &structure //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
structure = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
result = IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool is1DBullish = IsBullish(d1MarketDirection);
|
||||
bool is1DBearish = IsBearish(d1MarketDirection);
|
||||
|
||||
//
|
||||
bool is4HBullish = IsBullish(h4MarketDirection);
|
||||
bool is4HBearish = IsBearish(h4MarketDirection);
|
||||
|
||||
//
|
||||
bool is2HBullish = IsBullish(h2MarketDirection);
|
||||
bool is2HBearish = IsBearish(h2MarketDirection);
|
||||
|
||||
//
|
||||
bool is1HBullish = IsBullish(h1MarketDirection);
|
||||
bool is1HBearish = IsBearish(h1MarketDirection);
|
||||
|
||||
//
|
||||
bool is15MBullish = IsBullish(m15MarketDirection);
|
||||
bool is15MBearish = IsBearish(m15MarketDirection);
|
||||
|
||||
//
|
||||
bool is5MBullish = IsBullish(m5MarketDirection);
|
||||
bool is5MBearish = IsBearish(m5MarketDirection);
|
||||
|
||||
//
|
||||
bool is1MBullish = IsBullish(m1MarketDirection);
|
||||
bool is1MBearish = IsBearish(m1MarketDirection);
|
||||
|
||||
//
|
||||
bool isStructuresBullish =
|
||||
//
|
||||
is1HBullish &&
|
||||
is15MBullish &&
|
||||
is5MBullish
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool isStructuresBearish =
|
||||
//
|
||||
is1HBearish &&
|
||||
is15MBearish &&
|
||||
is5MBearish
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool hasMarketStructure =
|
||||
isStructuresBullish ||
|
||||
isStructuresBearish;
|
||||
result = hasMarketStructure;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
structure =
|
||||
isStructuresBullish
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Provided Scores ...
|
||||
*
|
||||
|
||||
@@ -331,18 +331,132 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
dir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
// TODO: Implement ...
|
||||
ENUM_X_DIRECTION marketStructureDir;
|
||||
result = DetectMarketStructure(
|
||||
marketStructureDir,
|
||||
_5MState //
|
||||
);
|
||||
// Detect Market Structures ...
|
||||
|
||||
//
|
||||
// 1D ...
|
||||
mConditions.d1State = _1DState;
|
||||
result = DetectMarketStructure(
|
||||
mConditions.d1MarketDirection,
|
||||
_1DState //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mConditions.Clean();
|
||||
return result;
|
||||
}
|
||||
bool is1DBullish = IsBullish(mConditions.d1MarketDirection);
|
||||
bool is1DBearish = IsBearish(mConditions.d1MarketDirection);
|
||||
|
||||
//
|
||||
// 4H ...
|
||||
mConditions.h4State = _4HState;
|
||||
result = DetectMarketStructure(
|
||||
mConditions.h4MarketDirection,
|
||||
_4HState //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mConditions.Clean();
|
||||
return result;
|
||||
}
|
||||
bool is4HBullish = IsBullish(mConditions.h4MarketDirection);
|
||||
bool is4HBearish = IsBearish(mConditions.h4MarketDirection);
|
||||
|
||||
//
|
||||
// 2H ...
|
||||
mConditions.h2State = _2HState;
|
||||
result = DetectMarketStructure(
|
||||
mConditions.h2MarketDirection,
|
||||
_2HState //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mConditions.Clean();
|
||||
return result;
|
||||
}
|
||||
bool is2HBullish = IsBullish(mConditions.h2MarketDirection);
|
||||
bool is2HBearish = IsBearish(mConditions.h2MarketDirection);
|
||||
|
||||
//
|
||||
// 1H ...
|
||||
mConditions.h1State = _1HState;
|
||||
result = DetectMarketStructure(
|
||||
mConditions.h1MarketDirection,
|
||||
_1HState //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mConditions.Clean();
|
||||
return result;
|
||||
}
|
||||
bool is1HBullish = IsBullish(mConditions.h1MarketDirection);
|
||||
bool is1HBearish = IsBearish(mConditions.h1MarketDirection);
|
||||
|
||||
//
|
||||
// 15M ...
|
||||
mConditions.m15State = _15MState;
|
||||
result = DetectMarketStructure(
|
||||
mConditions.m15MarketDirection,
|
||||
_15MState //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mConditions.Clean();
|
||||
return result;
|
||||
}
|
||||
bool is15MBullish = IsBullish(mConditions.m15MarketDirection);
|
||||
bool is15MBearish = IsBearish(mConditions.m15MarketDirection);
|
||||
|
||||
//
|
||||
// 5M ...
|
||||
mConditions.m5State = _5MState;
|
||||
result = DetectMarketStructure(
|
||||
mConditions.m5MarketDirection,
|
||||
_5MState //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mConditions.Clean();
|
||||
return result;
|
||||
}
|
||||
bool is5MBullish = IsBullish(mConditions.m5MarketDirection);
|
||||
bool is5MBearish = IsBearish(mConditions.m5MarketDirection);
|
||||
|
||||
//
|
||||
// 1M ...
|
||||
mConditions.m1State = _1MState;
|
||||
result = DetectMarketStructure(
|
||||
mConditions.m1MarketDirection,
|
||||
_1MState //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mConditions.Clean();
|
||||
return result;
|
||||
}
|
||||
bool is1MBullish = IsBullish(mConditions.m1MarketDirection);
|
||||
bool is1MBearish = IsBearish(mConditions.m1MarketDirection);
|
||||
|
||||
//
|
||||
ENUM_X_DIRECTION marketStructure = X_DIRECTION_NONE;
|
||||
result = mConditions.HasMarketStructure(marketStructure);
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
mConditions.Clean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
DrawState(_5MState);
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -364,17 +478,12 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// DrawState(state);
|
||||
|
||||
//
|
||||
// Print("Salam");
|
||||
|
||||
//
|
||||
int count = 0;
|
||||
|
||||
//
|
||||
// Filter Untouched Supports ...
|
||||
int untouchedSupportsCount = 0;
|
||||
XCSupportZone *untouchedSupportZones[];
|
||||
count = ArraySize(state.supportZones);
|
||||
if (IsValidSize(count))
|
||||
@@ -436,31 +545,33 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
}
|
||||
|
||||
//
|
||||
int untouchedSupportsCount = ArraySize(untouchedSupportZones);
|
||||
untouchedSupportsCount = ArraySize(untouchedSupportZones);
|
||||
if (IsValidSize(untouchedSupportsCount))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < untouchedSupportsCount; i++)
|
||||
{
|
||||
//
|
||||
XCSupportZone *item = untouchedSupportZones[i];
|
||||
// Draw ...
|
||||
// for (int i = 0; i < untouchedSupportsCount; i++)
|
||||
// {
|
||||
// //
|
||||
// XCSupportZone *item = untouchedSupportZones[i];
|
||||
|
||||
//
|
||||
XCSupportZoneObject *iObj;
|
||||
bool isCreated = mPOIDrawer.CreateSupportZone(
|
||||
item,
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
AddObjectIfNotExists(iObj);
|
||||
}
|
||||
}
|
||||
// //
|
||||
// XCSupportZoneObject *iObj;
|
||||
// bool isCreated = mPOIDrawer.CreateSupportZone(
|
||||
// item,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// AddObjectIfNotExists(iObj);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Filter Untouched Resistances ...
|
||||
int untouchedResistancesCount = 0;
|
||||
XCResistanceZone *untouchedResistanceZones[];
|
||||
count = ArraySize(state.resistanceZones);
|
||||
if (IsValidSize(count))
|
||||
@@ -522,29 +633,54 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
||||
}
|
||||
|
||||
//
|
||||
int untouchedResistancesCount = ArraySize(untouchedResistanceZones);
|
||||
untouchedResistancesCount = ArraySize(untouchedResistanceZones);
|
||||
if (IsValidSize(untouchedResistancesCount))
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < untouchedResistancesCount; i++)
|
||||
{
|
||||
//
|
||||
XCResistanceZone *item = untouchedResistanceZones[i];
|
||||
// Draw ...
|
||||
// for (int i = 0; i < untouchedResistancesCount; i++)
|
||||
// {
|
||||
// //
|
||||
// XCResistanceZone *item = untouchedResistanceZones[i];
|
||||
|
||||
//
|
||||
XCResistanceZoneObject *iObj;
|
||||
bool isCreated = mPOIDrawer.CreateResistanceZone(
|
||||
item,
|
||||
iObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
AddObjectIfNotExists(iObj);
|
||||
}
|
||||
}
|
||||
// //
|
||||
// XCResistanceZoneObject *iObj;
|
||||
// bool isCreated = mPOIDrawer.CreateResistanceZone(
|
||||
// item,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// AddObjectIfNotExists(iObj);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
bool hasBullishStructure =
|
||||
IsValidSize(untouchedSupportsCount) &&
|
||||
untouchedSupportsCount > untouchedResistancesCount;
|
||||
bool hasBearishStructure =
|
||||
IsValidSize(untouchedResistancesCount) &&
|
||||
untouchedResistancesCount > untouchedSupportsCount;
|
||||
|
||||
//
|
||||
result = (hasBullishStructure &&
|
||||
!hasBearishStructure) ||
|
||||
(hasBearishStructure &&
|
||||
!hasBullishStructure);
|
||||
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
dir =
|
||||
hasBullishStructure
|
||||
? X_DIRECTION_BULLISH
|
||||
: X_DIRECTION_BEARISH;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user