Last ...
This commit is contained in:
@@ -68,3 +68,976 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////
|
||||||
|
// Conditions Parsing ...
|
||||||
|
///////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//
|
||||||
|
// Conditions Props ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// D1 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XPOIState d1State;
|
||||||
|
ENUM_X_DIRECTION d1MarketDirection;
|
||||||
|
XCSupportZone *d1SupportZones[];
|
||||||
|
XCResistanceZone *d1ResistanceZones[];
|
||||||
|
|
||||||
|
//
|
||||||
|
XCSwing *d1SwingHigh;
|
||||||
|
XCSwing *d1SwingLow;
|
||||||
|
|
||||||
|
//
|
||||||
|
// H4 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XPOIState h4State;
|
||||||
|
ENUM_X_DIRECTION h4MarketDirection;
|
||||||
|
XCSupportZone *h4SupportZones[];
|
||||||
|
XCResistanceZone *h4ResistanceZones[];
|
||||||
|
|
||||||
|
//
|
||||||
|
XCSwing *h4SwingHigh;
|
||||||
|
XCSwing *h4SwingLow;
|
||||||
|
|
||||||
|
//
|
||||||
|
// H2 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XPOIState h2State;
|
||||||
|
ENUM_X_DIRECTION h2MarketDirection;
|
||||||
|
XCSupportZone *h2SupportZones[];
|
||||||
|
XCResistanceZone *h2ResistanceZones[];
|
||||||
|
|
||||||
|
//
|
||||||
|
XCSwing *h2SwingHigh;
|
||||||
|
XCSwing *h2SwingLow;
|
||||||
|
|
||||||
|
//
|
||||||
|
// H1 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XPOIState h1State;
|
||||||
|
ENUM_X_DIRECTION h1MarketDirection;
|
||||||
|
XCSupportZone *h1SupportZones[];
|
||||||
|
XCResistanceZone *h1ResistanceZones[];
|
||||||
|
|
||||||
|
//
|
||||||
|
XCSwing *h1SwingHigh;
|
||||||
|
XCSwing *h1SwingLow;
|
||||||
|
|
||||||
|
//
|
||||||
|
// M15 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XPOIState m15State;
|
||||||
|
ENUM_X_DIRECTION m15MarketDirection;
|
||||||
|
XCSupportZone *m15SupportZones[];
|
||||||
|
XCResistanceZone *m15ResistanceZones[];
|
||||||
|
|
||||||
|
//
|
||||||
|
XCSwing *m15SwingHigh;
|
||||||
|
XCSwing *m15SwingLow;
|
||||||
|
|
||||||
|
//
|
||||||
|
// M5 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XPOIState m5State;
|
||||||
|
ENUM_X_DIRECTION m5MarketDirection;
|
||||||
|
XCSupportZone *m5SupportZones[];
|
||||||
|
XCResistanceZone *m5ResistanceZones[];
|
||||||
|
|
||||||
|
//
|
||||||
|
XCSwing *m5SwingHigh;
|
||||||
|
XCSwing *m5SwingLow;
|
||||||
|
|
||||||
|
//
|
||||||
|
// M1 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XPOIState m1State;
|
||||||
|
ENUM_X_DIRECTION m1MarketDirection;
|
||||||
|
XCSupportZone *m1SupportZones[];
|
||||||
|
XCResistanceZone *m1ResistanceZones[];
|
||||||
|
|
||||||
|
//
|
||||||
|
XCSwing *m1SwingHigh;
|
||||||
|
XCSwing *m1SwingLow;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Clean Method ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// D1 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
d1State.Clean();
|
||||||
|
d1MarketDirection = X_DIRECTION_NONE;
|
||||||
|
Clean(d1SupportZones);
|
||||||
|
Clean(d1ResistanceZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
d1SwingHigh = NULL;
|
||||||
|
d1SwingLow = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
// H4 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
h4State.Clean();
|
||||||
|
h4MarketDirection = X_DIRECTION_NONE;
|
||||||
|
Clean(h4SupportZones);
|
||||||
|
Clean(h4ResistanceZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
h4SwingHigh = NULL;
|
||||||
|
h4SwingLow = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
// H2 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
h2State.Clean();
|
||||||
|
h2MarketDirection = X_DIRECTION_NONE;
|
||||||
|
Clean(h2SupportZones);
|
||||||
|
Clean(h2ResistanceZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
h2SwingHigh = NULL;
|
||||||
|
h2SwingLow = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
// H1 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
h1State.Clean();
|
||||||
|
h1MarketDirection = X_DIRECTION_NONE;
|
||||||
|
Clean(h1SupportZones);
|
||||||
|
Clean(h1ResistanceZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
h1SwingHigh = NULL;
|
||||||
|
h1SwingLow = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
// M15 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
m15State.Clean();
|
||||||
|
m15MarketDirection = X_DIRECTION_NONE;
|
||||||
|
Clean(m15SupportZones);
|
||||||
|
Clean(m15ResistanceZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
m15SwingHigh = NULL;
|
||||||
|
m15SwingLow = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
// M5 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
m5State.Clean();
|
||||||
|
m5MarketDirection = X_DIRECTION_NONE;
|
||||||
|
Clean(m5SupportZones);
|
||||||
|
Clean(m5ResistanceZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
m5SwingHigh = NULL;
|
||||||
|
m5SwingLow = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
// M1 ...
|
||||||
|
|
||||||
|
//
|
||||||
|
m1State.Clean();
|
||||||
|
m1MarketDirection = X_DIRECTION_NONE;
|
||||||
|
Clean(m1SupportZones);
|
||||||
|
Clean(m1ResistanceZones);
|
||||||
|
|
||||||
|
//
|
||||||
|
m1SwingHigh = NULL;
|
||||||
|
m1SwingLow = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Tools Functions ...
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Strategy Class Calling on Conditions Detections ...
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Market Structures ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// 1D ...
|
||||||
|
conditions.d1State = _1DState;
|
||||||
|
result = DetectMarketStructure(
|
||||||
|
conditions.d1MarketDirection,
|
||||||
|
conditions.d1SupportZones,
|
||||||
|
conditions.d1ResistanceZones,
|
||||||
|
_1DState //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 4H ...
|
||||||
|
conditions.h4State = _4HState;
|
||||||
|
result = DetectMarketStructure(
|
||||||
|
conditions.h4MarketDirection,
|
||||||
|
conditions.h4SupportZones,
|
||||||
|
conditions.h4ResistanceZones,
|
||||||
|
_4HState //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 2H ...
|
||||||
|
conditions.h2State = _2HState;
|
||||||
|
result = DetectMarketStructure(
|
||||||
|
conditions.h2MarketDirection,
|
||||||
|
conditions.h2SupportZones,
|
||||||
|
conditions.h2ResistanceZones,
|
||||||
|
_2HState //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 1H ...
|
||||||
|
conditions.h1State = _1HState;
|
||||||
|
result = DetectMarketStructure(
|
||||||
|
conditions.h1MarketDirection,
|
||||||
|
conditions.h1SupportZones,
|
||||||
|
conditions.h1ResistanceZones,
|
||||||
|
_1HState //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 15M ...
|
||||||
|
conditions.m15State = _15MState;
|
||||||
|
result = DetectMarketStructure(
|
||||||
|
conditions.m15MarketDirection,
|
||||||
|
conditions.m15SupportZones,
|
||||||
|
conditions.m15ResistanceZones,
|
||||||
|
_15MState //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 5M ...
|
||||||
|
conditions.m5State = _5MState;
|
||||||
|
result = DetectMarketStructure(
|
||||||
|
conditions.m5MarketDirection,
|
||||||
|
conditions.m5SupportZones,
|
||||||
|
conditions.m5ResistanceZones,
|
||||||
|
_5MState //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 1M ...
|
||||||
|
conditions.m1State = _1MState;
|
||||||
|
result = DetectMarketStructure(
|
||||||
|
conditions.m1MarketDirection,
|
||||||
|
conditions.m1SupportZones,
|
||||||
|
conditions.m1ResistanceZones,
|
||||||
|
_1MState //
|
||||||
|
);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 1H-15M-5M ...
|
||||||
|
ENUM_X_DIRECTION marketStructure = X_DIRECTION_NONE;
|
||||||
|
result = conditions.HasMarketStructure(marketStructure);
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Detect Swing High and Swing Low ...
|
||||||
|
// 1H-15M-5M ...
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// 1H ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XCSwing *h1SwingLows[];
|
||||||
|
XCSwing *h1SwingHighs[];
|
||||||
|
XCSupportZone *h1SupportZone = NULL;
|
||||||
|
XCResistanceZone *h1ResistanceZone = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
count = ArraySize(conditions.h1SupportZones);
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCSupportZone *item = conditions.h1SupportZones[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canSelect =
|
||||||
|
h1SupportZone == NULL ||
|
||||||
|
h1SupportZone.Lower() < item.Lower();
|
||||||
|
if (canSelect)
|
||||||
|
{
|
||||||
|
h1SupportZone = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (h1SupportZone != NULL)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Detect Swings ...
|
||||||
|
count = ArraySize(conditions.h1State.swingLows);
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double upper = h1SupportZone.Upper();
|
||||||
|
double lower = h1SupportZone.Lower();
|
||||||
|
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCSwing *item = conditions.h1State.swingLows[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL iBar;
|
||||||
|
bool isFilled = item.FillBar(iBar);
|
||||||
|
if (!isFilled)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canSelect = (iBar.high <= upper &&
|
||||||
|
iBar.low >= lower) ||
|
||||||
|
(iBar.high >= upper &&
|
||||||
|
iBar.low <= lower);
|
||||||
|
if (canSelect)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
item,
|
||||||
|
h1SwingLows //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw ...
|
||||||
|
XCSwingLowObject *iObj;
|
||||||
|
bool isCreated = mPOIDrawer.CreateSwingLow(
|
||||||
|
item,
|
||||||
|
iObj //
|
||||||
|
);
|
||||||
|
if (isCreated)
|
||||||
|
{
|
||||||
|
AddObjectIfNotExists(iObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw ...
|
||||||
|
XCSupportZoneObject *iObj;
|
||||||
|
bool isCreated = mPOIDrawer.CreateSupportZone(
|
||||||
|
h1SupportZone,
|
||||||
|
iObj //
|
||||||
|
);
|
||||||
|
if (isCreated)
|
||||||
|
{
|
||||||
|
AddObjectIfNotExists(iObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
count = ArraySize(conditions.h1ResistanceZones);
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCResistanceZone *item = conditions.h1ResistanceZones[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canSelect =
|
||||||
|
h1ResistanceZone == NULL ||
|
||||||
|
h1ResistanceZone.Upper() > item.Upper();
|
||||||
|
if (canSelect)
|
||||||
|
{
|
||||||
|
h1ResistanceZone = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (h1ResistanceZone != NULL)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Detect Swings ...
|
||||||
|
count = ArraySize(conditions.h1State.swingHighs);
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double upper = h1ResistanceZone.Upper();
|
||||||
|
double lower = h1ResistanceZone.Lower();
|
||||||
|
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCSwing *item = conditions.h1State.swingHighs[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
XOHCL iBar;
|
||||||
|
bool isFilled = item.FillBar(iBar);
|
||||||
|
if (!isFilled)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canSelect = (iBar.high <= upper &&
|
||||||
|
iBar.low >= lower) ||
|
||||||
|
(iBar.high >= upper &&
|
||||||
|
iBar.low <= lower);
|
||||||
|
if (canSelect)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
item,
|
||||||
|
h1SwingHighs //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw ...
|
||||||
|
XCSwingHighObject *iObj;
|
||||||
|
bool isCreated = mPOIDrawer.CreateSwingHigh(
|
||||||
|
item,
|
||||||
|
iObj //
|
||||||
|
);
|
||||||
|
if (isCreated)
|
||||||
|
{
|
||||||
|
AddObjectIfNotExists(iObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw ...
|
||||||
|
XCResistanceZoneObject *iObj;
|
||||||
|
bool isCreated = mPOIDrawer.CreateResistanceZone(
|
||||||
|
h1ResistanceZone,
|
||||||
|
iObj //
|
||||||
|
);
|
||||||
|
if (isCreated)
|
||||||
|
{
|
||||||
|
AddObjectIfNotExists(iObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 15M ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XCSupportZone *m15SupportZone = NULL;
|
||||||
|
count = ArraySize(conditions.m15SupportZones);
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCSupportZone *item = conditions.m15SupportZones[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canSelect =
|
||||||
|
m15SupportZone == NULL ||
|
||||||
|
m15SupportZone.Lower() < item.Lower();
|
||||||
|
if (canSelect)
|
||||||
|
{
|
||||||
|
m15SupportZone = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m15SupportZone != NULL)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCSupportZoneObject *iObj;
|
||||||
|
bool isCreated = mPOIDrawer.CreateSupportZone(
|
||||||
|
m15SupportZone,
|
||||||
|
iObj //
|
||||||
|
);
|
||||||
|
if (isCreated)
|
||||||
|
{
|
||||||
|
AddObjectIfNotExists(iObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XCResistanceZone *m15ResistanceZone = NULL;
|
||||||
|
count = ArraySize(conditions.m15ResistanceZones);
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCResistanceZone *item = conditions.m15ResistanceZones[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canSelect =
|
||||||
|
m15ResistanceZone == NULL ||
|
||||||
|
m15ResistanceZone.Upper() > item.Upper();
|
||||||
|
if (canSelect)
|
||||||
|
{
|
||||||
|
m15ResistanceZone = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m15ResistanceZone != NULL)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCResistanceZoneObject *iObj;
|
||||||
|
bool isCreated = mPOIDrawer.CreateResistanceZone(
|
||||||
|
m15ResistanceZone,
|
||||||
|
iObj //
|
||||||
|
);
|
||||||
|
if (isCreated)
|
||||||
|
{
|
||||||
|
AddObjectIfNotExists(iObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 5M ...
|
||||||
|
|
||||||
|
//
|
||||||
|
XCSupportZone *m5SupportZone = NULL;
|
||||||
|
count = ArraySize(conditions.m5SupportZones);
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCSupportZone *item = conditions.m5SupportZones[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canSelect =
|
||||||
|
m5SupportZone == NULL ||
|
||||||
|
m5SupportZone.Lower() < item.Lower();
|
||||||
|
if (canSelect)
|
||||||
|
{
|
||||||
|
m5SupportZone = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m5SupportZone != NULL)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCSupportZoneObject *iObj;
|
||||||
|
bool isCreated = mPOIDrawer.CreateSupportZone(
|
||||||
|
m5SupportZone,
|
||||||
|
iObj //
|
||||||
|
);
|
||||||
|
if (isCreated)
|
||||||
|
{
|
||||||
|
AddObjectIfNotExists(iObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
XCResistanceZone *m5ResistanceZone = NULL;
|
||||||
|
count = ArraySize(conditions.m5ResistanceZones);
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCResistanceZone *item = conditions.m5ResistanceZones[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canSelect =
|
||||||
|
m5ResistanceZone == NULL ||
|
||||||
|
m5ResistanceZone.Upper() > item.Upper();
|
||||||
|
if (canSelect)
|
||||||
|
{
|
||||||
|
m5ResistanceZone = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m5ResistanceZone != NULL)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCResistanceZoneObject *iObj;
|
||||||
|
bool isCreated = mPOIDrawer.CreateResistanceZone(
|
||||||
|
m5ResistanceZone,
|
||||||
|
iObj //
|
||||||
|
);
|
||||||
|
if (isCreated)
|
||||||
|
{
|
||||||
|
AddObjectIfNotExists(iObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// DrawState(_5MState);
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Strategy Class Tools Functions ...
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect Specified States Market Structure ...
|
||||||
|
*
|
||||||
|
* @param dir: ENUM_X_DIRECTION member, Refrence ...
|
||||||
|
* @param state: XPOIState instance ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool DetectMarketStructure(
|
||||||
|
ENUM_X_DIRECTION &dir,
|
||||||
|
XCSupportZone *&supportZones[],
|
||||||
|
XCResistanceZone *&resistanceZones[],
|
||||||
|
XPOIState &state //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Filter Untouched Supports ...
|
||||||
|
Clean(supportZones);
|
||||||
|
int untouchedSupportsCount = 0;
|
||||||
|
count = ArraySize(state.supportZones);
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCSupportZone *item = state.supportZones[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Find Breakout Bar
|
||||||
|
XOHCL iBar;
|
||||||
|
bool isFilled = item.FillBar(iBar);
|
||||||
|
if (!isFilled)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int iBarIndex = iBar.Index();
|
||||||
|
int iBarUnTouchedCount = 0;
|
||||||
|
for (int j = 0; j < iBarIndex; j++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XOHCL jBar;
|
||||||
|
bool isInited = jBar.Init(
|
||||||
|
iBar.symbol,
|
||||||
|
iBar.period,
|
||||||
|
j //
|
||||||
|
);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isUntouched =
|
||||||
|
jBar.low > item.Upper();
|
||||||
|
if (isUntouched)
|
||||||
|
{
|
||||||
|
iBarUnTouchedCount++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iBarUnTouchedCount--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iBarUnTouchedCount > 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
item,
|
||||||
|
supportZones //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
untouchedSupportsCount = ArraySize(supportZones);
|
||||||
|
if (IsValidSize(untouchedSupportsCount))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Draw ...
|
||||||
|
// for (int i = 0; i < untouchedSupportsCount; i++)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// XCSupportZone *item = supportZones[i];
|
||||||
|
|
||||||
|
// //
|
||||||
|
// XCSupportZoneObject *iObj;
|
||||||
|
// bool isCreated = mPOIDrawer.CreateSupportZone(
|
||||||
|
// item,
|
||||||
|
// iObj //
|
||||||
|
// );
|
||||||
|
// if (isCreated)
|
||||||
|
// {
|
||||||
|
// AddObjectIfNotExists(iObj);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Filter Untouched Resistances ...
|
||||||
|
Clean(resistanceZones);
|
||||||
|
int untouchedResistancesCount = 0;
|
||||||
|
count = ArraySize(state.resistanceZones);
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XCResistanceZone *item = state.resistanceZones[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Find Breakout Bar
|
||||||
|
XOHCL iBar;
|
||||||
|
bool isFilled = item.FillBar(iBar);
|
||||||
|
if (!isFilled)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int iBarIndex = iBar.Index();
|
||||||
|
int iBarUnTouchedCount = 0;
|
||||||
|
for (int j = 0; j < iBarIndex; j++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XOHCL jBar;
|
||||||
|
bool isInited = jBar.Init(
|
||||||
|
iBar.symbol,
|
||||||
|
iBar.period,
|
||||||
|
j //
|
||||||
|
);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isUntouched =
|
||||||
|
jBar.high < item.Lower();
|
||||||
|
if (isUntouched)
|
||||||
|
{
|
||||||
|
iBarUnTouchedCount++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iBarUnTouchedCount--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (iBarUnTouchedCount > 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Add(
|
||||||
|
item,
|
||||||
|
resistanceZones //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
untouchedResistancesCount = ArraySize(resistanceZones);
|
||||||
|
if (IsValidSize(untouchedResistancesCount))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Draw ...
|
||||||
|
// for (int i = 0; i < untouchedResistancesCount; i++)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// XCResistanceZone *item = resistanceZones[i];
|
||||||
|
|
||||||
|
// //
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -376,105 +376,11 @@ struct X121SMCStrategyConditions
|
|||||||
ENUM_TIMEFRAMES period;
|
ENUM_TIMEFRAMES period;
|
||||||
datetime time;
|
datetime time;
|
||||||
|
|
||||||
//
|
|
||||||
XPVPivot orderFlow[];
|
|
||||||
|
|
||||||
//
|
//
|
||||||
XPVConditions xpvConditions;
|
XPVConditions xpvConditions;
|
||||||
X3MAConditions x3maConditions;
|
X3MAConditions x3maConditions;
|
||||||
X3VWAPConditions x3vwapConditions;
|
X3VWAPConditions x3vwapConditions;
|
||||||
|
|
||||||
//
|
|
||||||
// D1 ...
|
|
||||||
|
|
||||||
//
|
|
||||||
XPOIState d1State;
|
|
||||||
ENUM_X_DIRECTION d1MarketDirection;
|
|
||||||
XCSupportZone *d1SupportZones[];
|
|
||||||
XCResistanceZone *d1ResistanceZones[];
|
|
||||||
|
|
||||||
//
|
|
||||||
XCSwing *d1SwingHigh;
|
|
||||||
XCSwing *d1SwingLow;
|
|
||||||
|
|
||||||
//
|
|
||||||
// H4 ...
|
|
||||||
|
|
||||||
//
|
|
||||||
XPOIState h4State;
|
|
||||||
ENUM_X_DIRECTION h4MarketDirection;
|
|
||||||
XCSupportZone *h4SupportZones[];
|
|
||||||
XCResistanceZone *h4ResistanceZones[];
|
|
||||||
|
|
||||||
//
|
|
||||||
XCSwing *h4SwingHigh;
|
|
||||||
XCSwing *h4SwingLow;
|
|
||||||
|
|
||||||
//
|
|
||||||
// H2 ...
|
|
||||||
|
|
||||||
//
|
|
||||||
XPOIState h2State;
|
|
||||||
ENUM_X_DIRECTION h2MarketDirection;
|
|
||||||
XCSupportZone *h2SupportZones[];
|
|
||||||
XCResistanceZone *h2ResistanceZones[];
|
|
||||||
|
|
||||||
//
|
|
||||||
XCSwing *h2SwingHigh;
|
|
||||||
XCSwing *h2SwingLow;
|
|
||||||
|
|
||||||
//
|
|
||||||
// H1 ...
|
|
||||||
|
|
||||||
//
|
|
||||||
XPOIState h1State;
|
|
||||||
ENUM_X_DIRECTION h1MarketDirection;
|
|
||||||
XCSupportZone *h1SupportZones[];
|
|
||||||
XCResistanceZone *h1ResistanceZones[];
|
|
||||||
|
|
||||||
//
|
|
||||||
XCSwing *h1SwingHigh;
|
|
||||||
XCSwing *h1SwingLow;
|
|
||||||
|
|
||||||
//
|
|
||||||
// M15 ...
|
|
||||||
|
|
||||||
//
|
|
||||||
XPOIState m15State;
|
|
||||||
ENUM_X_DIRECTION m15MarketDirection;
|
|
||||||
XCSupportZone *m15SupportZones[];
|
|
||||||
XCResistanceZone *m15ResistanceZones[];
|
|
||||||
|
|
||||||
//
|
|
||||||
XCSwing *m15SwingHigh;
|
|
||||||
XCSwing *m15SwingLow;
|
|
||||||
|
|
||||||
//
|
|
||||||
// M5 ...
|
|
||||||
|
|
||||||
//
|
|
||||||
XPOIState m5State;
|
|
||||||
ENUM_X_DIRECTION m5MarketDirection;
|
|
||||||
XCSupportZone *m5SupportZones[];
|
|
||||||
XCResistanceZone *m5ResistanceZones[];
|
|
||||||
|
|
||||||
//
|
|
||||||
XCSwing *m5SwingHigh;
|
|
||||||
XCSwing *m5SwingLow;
|
|
||||||
|
|
||||||
//
|
|
||||||
// M1 ...
|
|
||||||
|
|
||||||
//
|
|
||||||
XPOIState m1State;
|
|
||||||
ENUM_X_DIRECTION m1MarketDirection;
|
|
||||||
XCSupportZone *m1SupportZones[];
|
|
||||||
XCResistanceZone *m1ResistanceZones[];
|
|
||||||
|
|
||||||
//
|
|
||||||
XCSwing *m1SwingHigh;
|
|
||||||
XCSwing *m1SwingLow;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
void X121SMCStrategyConditions()
|
void X121SMCStrategyConditions()
|
||||||
{
|
{
|
||||||
@@ -498,100 +404,6 @@ struct X121SMCStrategyConditions
|
|||||||
xpvConditions.Clean();
|
xpvConditions.Clean();
|
||||||
x3maConditions.Clean();
|
x3maConditions.Clean();
|
||||||
x3vwapConditions.Clean();
|
x3vwapConditions.Clean();
|
||||||
|
|
||||||
//
|
|
||||||
Clean(orderFlow);
|
|
||||||
|
|
||||||
//
|
|
||||||
// D1 ...
|
|
||||||
|
|
||||||
//
|
|
||||||
d1State.Clean();
|
|
||||||
d1MarketDirection = X_DIRECTION_NONE;
|
|
||||||
Clean(d1SupportZones);
|
|
||||||
Clean(d1ResistanceZones);
|
|
||||||
|
|
||||||
//
|
|
||||||
d1SwingHigh = NULL;
|
|
||||||
d1SwingLow = NULL;
|
|
||||||
|
|
||||||
//
|
|
||||||
// H4 ...
|
|
||||||
|
|
||||||
//
|
|
||||||
h4State.Clean();
|
|
||||||
h4MarketDirection = X_DIRECTION_NONE;
|
|
||||||
Clean(h4SupportZones);
|
|
||||||
Clean(h4ResistanceZones);
|
|
||||||
|
|
||||||
//
|
|
||||||
h4SwingHigh = NULL;
|
|
||||||
h4SwingLow = NULL;
|
|
||||||
|
|
||||||
//
|
|
||||||
// H2 ...
|
|
||||||
|
|
||||||
//
|
|
||||||
h2State.Clean();
|
|
||||||
h2MarketDirection = X_DIRECTION_NONE;
|
|
||||||
Clean(h2SupportZones);
|
|
||||||
Clean(h2ResistanceZones);
|
|
||||||
|
|
||||||
//
|
|
||||||
h2SwingHigh = NULL;
|
|
||||||
h2SwingLow = NULL;
|
|
||||||
|
|
||||||
//
|
|
||||||
// H1 ...
|
|
||||||
|
|
||||||
//
|
|
||||||
h1State.Clean();
|
|
||||||
h1MarketDirection = X_DIRECTION_NONE;
|
|
||||||
Clean(h1SupportZones);
|
|
||||||
Clean(h1ResistanceZones);
|
|
||||||
|
|
||||||
//
|
|
||||||
h1SwingHigh = NULL;
|
|
||||||
h1SwingLow = NULL;
|
|
||||||
|
|
||||||
//
|
|
||||||
// M15 ...
|
|
||||||
|
|
||||||
//
|
|
||||||
m15State.Clean();
|
|
||||||
m15MarketDirection = X_DIRECTION_NONE;
|
|
||||||
Clean(m15SupportZones);
|
|
||||||
Clean(m15ResistanceZones);
|
|
||||||
|
|
||||||
//
|
|
||||||
m15SwingHigh = NULL;
|
|
||||||
m15SwingLow = NULL;
|
|
||||||
|
|
||||||
//
|
|
||||||
// M5 ...
|
|
||||||
|
|
||||||
//
|
|
||||||
m5State.Clean();
|
|
||||||
m5MarketDirection = X_DIRECTION_NONE;
|
|
||||||
Clean(m5SupportZones);
|
|
||||||
Clean(m5ResistanceZones);
|
|
||||||
|
|
||||||
//
|
|
||||||
m5SwingHigh = NULL;
|
|
||||||
m5SwingLow = NULL;
|
|
||||||
|
|
||||||
//
|
|
||||||
// M1 ...
|
|
||||||
|
|
||||||
//
|
|
||||||
m1State.Clean();
|
|
||||||
m1MarketDirection = X_DIRECTION_NONE;
|
|
||||||
Clean(m1SupportZones);
|
|
||||||
Clean(m1ResistanceZones);
|
|
||||||
|
|
||||||
//
|
|
||||||
m1SwingHigh = NULL;
|
|
||||||
m1SwingLow = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -613,99 +425,6 @@ struct X121SMCStrategyConditions
|
|||||||
return result;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Reporter Functions ...
|
// Reporter Functions ...
|
||||||
|
|
||||||
|
|||||||
@@ -312,6 +312,10 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
X3VWAPInputs x3vwapInputs;
|
X3VWAPInputs x3vwapInputs;
|
||||||
XCX3VWAPHelper *x3vwapHelper;
|
XCX3VWAPHelper *x3vwapHelper;
|
||||||
|
|
||||||
|
//
|
||||||
|
XPVPivot mOrderFlow[];
|
||||||
|
ENUM_X_DIRECTION mOrderFlowDir;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Actions ...
|
// Actions ...
|
||||||
|
|
||||||
@@ -382,527 +386,85 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Detect Swing Highs and Lows Based On XPV ...
|
// Only Detect Order Flow when there isn't ...
|
||||||
|
if (ArraySize(mOrderFlow) == 0 ||
|
||||||
//
|
mOrderFlowDir == X_DIRECTION_NONE)
|
||||||
int samePivots = 40;
|
|
||||||
int requiredPivots = 10;
|
|
||||||
|
|
||||||
//
|
|
||||||
DetectPVPivots(
|
|
||||||
cIndex,
|
|
||||||
samePivots,
|
|
||||||
requiredPivots,
|
|
||||||
conditions.orderFlow //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
int orderFlowCount = ArraySize(conditions.orderFlow);
|
|
||||||
if (IsValidSize(orderFlowCount))
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
for (int i = 0; i < orderFlowCount; i++)
|
//
|
||||||
|
int samePivots = 40;
|
||||||
|
int requiredPivots = 10;
|
||||||
|
|
||||||
|
//
|
||||||
|
DetectPVPivots(
|
||||||
|
cIndex,
|
||||||
|
samePivots,
|
||||||
|
requiredPivots,
|
||||||
|
mOrderFlow,
|
||||||
|
mOrderFlowDir //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
int orderFlowCount = ArraySize(mOrderFlow);
|
||||||
|
if (IsValidSize(orderFlowCount))
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
XPVPivot iPivot = conditions.orderFlow[i];
|
for (int i = 0; i < orderFlowCount; i++)
|
||||||
|
|
||||||
//
|
|
||||||
XCXPVPivotObject *iObj;
|
|
||||||
iObj = new XCXPVPivotObject();
|
|
||||||
bool isCreated = iObj.Create(
|
|
||||||
mPOIDrawer.ChartIdentification(),
|
|
||||||
mPOIDrawer.SubWindowIdentification(),
|
|
||||||
iPivot //
|
|
||||||
);
|
|
||||||
if (isCreated)
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
if (iPivot.IsPeak())
|
XPVPivot iPivot = mOrderFlow[i];
|
||||||
{
|
|
||||||
//
|
|
||||||
iObj.PivotWidth(1);
|
|
||||||
iObj.PivotFill(false);
|
|
||||||
iObj.PivotColor(clrAqua);
|
|
||||||
iObj.PivotStyle(STYLE_SOLID);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
if (iPivot.IsVale())
|
XCXPVPivotObject *iObj;
|
||||||
|
iObj = new XCXPVPivotObject();
|
||||||
|
bool isCreated = iObj.Create(
|
||||||
|
mPOIDrawer.ChartIdentification(),
|
||||||
|
mPOIDrawer.SubWindowIdentification(),
|
||||||
|
iPivot //
|
||||||
|
);
|
||||||
|
if (isCreated)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
iObj.PivotWidth(1);
|
if (iPivot.IsPeak())
|
||||||
iObj.PivotFill(false);
|
{
|
||||||
iObj.PivotStyle(STYLE_SOLID);
|
//
|
||||||
iObj.PivotColor(clrMagenta);
|
iObj.PivotWidth(1);
|
||||||
}
|
iObj.PivotFill(false);
|
||||||
|
iObj.PivotColor(clrAqua);
|
||||||
|
iObj.PivotStyle(STYLE_SOLID);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
AddObjectIfNotExists(iObj);
|
if (iPivot.IsVale())
|
||||||
|
{
|
||||||
|
//
|
||||||
|
iObj.PivotWidth(1);
|
||||||
|
iObj.PivotFill(false);
|
||||||
|
iObj.PivotStyle(STYLE_SOLID);
|
||||||
|
iObj.PivotColor(clrMagenta);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
AddObjectIfNotExists(iObj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
result = IsValidSize(ArraySize(mOrderFlow));
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
result = IsValidSize(ArraySize(conditions.orderFlow));
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Filter Peaks and Vales ...
|
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
Print("Result: ", result);
|
Print("Result: ", result);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//
|
|
||||||
// Detect Market Structures ...
|
|
||||||
|
|
||||||
//
|
|
||||||
// 1D ...
|
|
||||||
conditions.d1State = _1DState;
|
|
||||||
result = DetectMarketStructure(
|
|
||||||
conditions.d1MarketDirection,
|
|
||||||
conditions.d1SupportZones,
|
|
||||||
conditions.d1ResistanceZones,
|
|
||||||
_1DState //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// 4H ...
|
|
||||||
conditions.h4State = _4HState;
|
|
||||||
result = DetectMarketStructure(
|
|
||||||
conditions.h4MarketDirection,
|
|
||||||
conditions.h4SupportZones,
|
|
||||||
conditions.h4ResistanceZones,
|
|
||||||
_4HState //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// 2H ...
|
|
||||||
conditions.h2State = _2HState;
|
|
||||||
result = DetectMarketStructure(
|
|
||||||
conditions.h2MarketDirection,
|
|
||||||
conditions.h2SupportZones,
|
|
||||||
conditions.h2ResistanceZones,
|
|
||||||
_2HState //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// 1H ...
|
|
||||||
conditions.h1State = _1HState;
|
|
||||||
result = DetectMarketStructure(
|
|
||||||
conditions.h1MarketDirection,
|
|
||||||
conditions.h1SupportZones,
|
|
||||||
conditions.h1ResistanceZones,
|
|
||||||
_1HState //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// 15M ...
|
|
||||||
conditions.m15State = _15MState;
|
|
||||||
result = DetectMarketStructure(
|
|
||||||
conditions.m15MarketDirection,
|
|
||||||
conditions.m15SupportZones,
|
|
||||||
conditions.m15ResistanceZones,
|
|
||||||
_15MState //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// 5M ...
|
|
||||||
conditions.m5State = _5MState;
|
|
||||||
result = DetectMarketStructure(
|
|
||||||
conditions.m5MarketDirection,
|
|
||||||
conditions.m5SupportZones,
|
|
||||||
conditions.m5ResistanceZones,
|
|
||||||
_5MState //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// 1M ...
|
|
||||||
conditions.m1State = _1MState;
|
|
||||||
result = DetectMarketStructure(
|
|
||||||
conditions.m1MarketDirection,
|
|
||||||
conditions.m1SupportZones,
|
|
||||||
conditions.m1ResistanceZones,
|
|
||||||
_1MState //
|
|
||||||
);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// 1H-15M-5M ...
|
|
||||||
ENUM_X_DIRECTION marketStructure = X_DIRECTION_NONE;
|
|
||||||
result = conditions.HasMarketStructure(marketStructure);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Detect Swing High and Swing Low ...
|
|
||||||
// 1H-15M-5M ...
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
// 1H ...
|
|
||||||
|
|
||||||
//
|
|
||||||
XCSwing *h1SwingLows[];
|
|
||||||
XCSwing *h1SwingHighs[];
|
|
||||||
XCSupportZone *h1SupportZone = NULL;
|
|
||||||
XCResistanceZone *h1ResistanceZone = NULL;
|
|
||||||
|
|
||||||
//
|
|
||||||
count = ArraySize(conditions.h1SupportZones);
|
|
||||||
if (IsValidSize(count))
|
|
||||||
{
|
|
||||||
//
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCSupportZone *item = conditions.h1SupportZones[i];
|
|
||||||
|
|
||||||
//
|
|
||||||
bool canSelect =
|
|
||||||
h1SupportZone == NULL ||
|
|
||||||
h1SupportZone.Lower() < item.Lower();
|
|
||||||
if (canSelect)
|
|
||||||
{
|
|
||||||
h1SupportZone = item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (h1SupportZone != NULL)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Detect Swings ...
|
|
||||||
count = ArraySize(conditions.h1State.swingLows);
|
|
||||||
if (IsValidSize(count))
|
|
||||||
{
|
|
||||||
//
|
|
||||||
double upper = h1SupportZone.Upper();
|
|
||||||
double lower = h1SupportZone.Lower();
|
|
||||||
|
|
||||||
//
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCSwing *item = conditions.h1State.swingLows[i];
|
|
||||||
|
|
||||||
//
|
|
||||||
XOHCL iBar;
|
|
||||||
bool isFilled = item.FillBar(iBar);
|
|
||||||
if (!isFilled)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
bool canSelect = (iBar.high <= upper &&
|
|
||||||
iBar.low >= lower) ||
|
|
||||||
(iBar.high >= upper &&
|
|
||||||
iBar.low <= lower);
|
|
||||||
if (canSelect)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
Add(
|
|
||||||
item,
|
|
||||||
h1SwingLows //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw ...
|
|
||||||
XCSwingLowObject *iObj;
|
|
||||||
bool isCreated = mPOIDrawer.CreateSwingLow(
|
|
||||||
item,
|
|
||||||
iObj //
|
|
||||||
);
|
|
||||||
if (isCreated)
|
|
||||||
{
|
|
||||||
AddObjectIfNotExists(iObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw ...
|
|
||||||
XCSupportZoneObject *iObj;
|
|
||||||
bool isCreated = mPOIDrawer.CreateSupportZone(
|
|
||||||
h1SupportZone,
|
|
||||||
iObj //
|
|
||||||
);
|
|
||||||
if (isCreated)
|
|
||||||
{
|
|
||||||
AddObjectIfNotExists(iObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
count = ArraySize(conditions.h1ResistanceZones);
|
|
||||||
if (IsValidSize(count))
|
|
||||||
{
|
|
||||||
//
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCResistanceZone *item = conditions.h1ResistanceZones[i];
|
|
||||||
|
|
||||||
//
|
|
||||||
bool canSelect =
|
|
||||||
h1ResistanceZone == NULL ||
|
|
||||||
h1ResistanceZone.Upper() > item.Upper();
|
|
||||||
if (canSelect)
|
|
||||||
{
|
|
||||||
h1ResistanceZone = item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (h1ResistanceZone != NULL)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Detect Swings ...
|
|
||||||
count = ArraySize(conditions.h1State.swingHighs);
|
|
||||||
if (IsValidSize(count))
|
|
||||||
{
|
|
||||||
//
|
|
||||||
double upper = h1ResistanceZone.Upper();
|
|
||||||
double lower = h1ResistanceZone.Lower();
|
|
||||||
|
|
||||||
//
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCSwing *item = conditions.h1State.swingHighs[i];
|
|
||||||
|
|
||||||
//
|
|
||||||
XOHCL iBar;
|
|
||||||
bool isFilled = item.FillBar(iBar);
|
|
||||||
if (!isFilled)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
bool canSelect = (iBar.high <= upper &&
|
|
||||||
iBar.low >= lower) ||
|
|
||||||
(iBar.high >= upper &&
|
|
||||||
iBar.low <= lower);
|
|
||||||
if (canSelect)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
Add(
|
|
||||||
item,
|
|
||||||
h1SwingHighs //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw ...
|
|
||||||
XCSwingHighObject *iObj;
|
|
||||||
bool isCreated = mPOIDrawer.CreateSwingHigh(
|
|
||||||
item,
|
|
||||||
iObj //
|
|
||||||
);
|
|
||||||
if (isCreated)
|
|
||||||
{
|
|
||||||
AddObjectIfNotExists(iObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw ...
|
|
||||||
XCResistanceZoneObject *iObj;
|
|
||||||
bool isCreated = mPOIDrawer.CreateResistanceZone(
|
|
||||||
h1ResistanceZone,
|
|
||||||
iObj //
|
|
||||||
);
|
|
||||||
if (isCreated)
|
|
||||||
{
|
|
||||||
AddObjectIfNotExists(iObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// 15M ...
|
|
||||||
|
|
||||||
//
|
|
||||||
XCSupportZone *m15SupportZone = NULL;
|
|
||||||
count = ArraySize(conditions.m15SupportZones);
|
|
||||||
if (IsValidSize(count))
|
|
||||||
{
|
|
||||||
//
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCSupportZone *item = conditions.m15SupportZones[i];
|
|
||||||
|
|
||||||
//
|
|
||||||
bool canSelect =
|
|
||||||
m15SupportZone == NULL ||
|
|
||||||
m15SupportZone.Lower() < item.Lower();
|
|
||||||
if (canSelect)
|
|
||||||
{
|
|
||||||
m15SupportZone = item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (m15SupportZone != NULL)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCSupportZoneObject *iObj;
|
|
||||||
bool isCreated = mPOIDrawer.CreateSupportZone(
|
|
||||||
m15SupportZone,
|
|
||||||
iObj //
|
|
||||||
);
|
|
||||||
if (isCreated)
|
|
||||||
{
|
|
||||||
AddObjectIfNotExists(iObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
XCResistanceZone *m15ResistanceZone = NULL;
|
|
||||||
count = ArraySize(conditions.m15ResistanceZones);
|
|
||||||
if (IsValidSize(count))
|
|
||||||
{
|
|
||||||
//
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCResistanceZone *item = conditions.m15ResistanceZones[i];
|
|
||||||
|
|
||||||
//
|
|
||||||
bool canSelect =
|
|
||||||
m15ResistanceZone == NULL ||
|
|
||||||
m15ResistanceZone.Upper() > item.Upper();
|
|
||||||
if (canSelect)
|
|
||||||
{
|
|
||||||
m15ResistanceZone = item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (m15ResistanceZone != NULL)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCResistanceZoneObject *iObj;
|
|
||||||
bool isCreated = mPOIDrawer.CreateResistanceZone(
|
|
||||||
m15ResistanceZone,
|
|
||||||
iObj //
|
|
||||||
);
|
|
||||||
if (isCreated)
|
|
||||||
{
|
|
||||||
AddObjectIfNotExists(iObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// 5M ...
|
|
||||||
|
|
||||||
//
|
|
||||||
XCSupportZone *m5SupportZone = NULL;
|
|
||||||
count = ArraySize(conditions.m5SupportZones);
|
|
||||||
if (IsValidSize(count))
|
|
||||||
{
|
|
||||||
//
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCSupportZone *item = conditions.m5SupportZones[i];
|
|
||||||
|
|
||||||
//
|
|
||||||
bool canSelect =
|
|
||||||
m5SupportZone == NULL ||
|
|
||||||
m5SupportZone.Lower() < item.Lower();
|
|
||||||
if (canSelect)
|
|
||||||
{
|
|
||||||
m5SupportZone = item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (m5SupportZone != NULL)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCSupportZoneObject *iObj;
|
|
||||||
bool isCreated = mPOIDrawer.CreateSupportZone(
|
|
||||||
m5SupportZone,
|
|
||||||
iObj //
|
|
||||||
);
|
|
||||||
if (isCreated)
|
|
||||||
{
|
|
||||||
AddObjectIfNotExists(iObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
XCResistanceZone *m5ResistanceZone = NULL;
|
|
||||||
count = ArraySize(conditions.m5ResistanceZones);
|
|
||||||
if (IsValidSize(count))
|
|
||||||
{
|
|
||||||
//
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCResistanceZone *item = conditions.m5ResistanceZones[i];
|
|
||||||
|
|
||||||
//
|
|
||||||
bool canSelect =
|
|
||||||
m5ResistanceZone == NULL ||
|
|
||||||
m5ResistanceZone.Upper() > item.Upper();
|
|
||||||
if (canSelect)
|
|
||||||
{
|
|
||||||
m5ResistanceZone = item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (m5ResistanceZone != NULL)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCResistanceZoneObject *iObj;
|
|
||||||
bool isCreated = mPOIDrawer.CreateResistanceZone(
|
|
||||||
m5ResistanceZone,
|
|
||||||
iObj //
|
|
||||||
);
|
|
||||||
if (isCreated)
|
|
||||||
{
|
|
||||||
AddObjectIfNotExists(iObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// DrawState(_5MState);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -913,8 +475,8 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
* @param barIndex: Start Bar Index ...
|
* @param barIndex: Start Bar Index ...
|
||||||
* @param minRepetition: minimum Repeate of POI for Validation ...
|
* @param minRepetition: minimum Repeate of POI for Validation ...
|
||||||
* @param requiredPivots: Number of Min Requirement POI(s) ...
|
* @param requiredPivots: Number of Min Requirement POI(s) ...
|
||||||
* @param peaks: XPVPivot instance Array Reference ...
|
* @param orderFlow: XPVPivot instance Array Reference ...
|
||||||
* @param vales: XPVPivot instance Array Reference ...
|
* @param orderFlowDirection: ENUM_X_DIRECTION member Reference which represents OrderFlow Direction ...
|
||||||
* @param maxAllowedLoopbackBars: Integer, Max Allowed Loopback Bars ...
|
* @param maxAllowedLoopbackBars: Integer, Max Allowed Loopback Bars ...
|
||||||
*
|
*
|
||||||
* @return ( bool )
|
* @return ( bool )
|
||||||
@@ -923,13 +485,17 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
int barIndex,
|
int barIndex,
|
||||||
int minRepetition,
|
int minRepetition,
|
||||||
int requiredPivots,
|
int requiredPivots,
|
||||||
XPVPivot &orderFlow[], // OrderFlows ...
|
XPVPivot &orderFlow[], // OrderFlows ...
|
||||||
int maxAllowedLoopbackBars = 576 //
|
ENUM_X_DIRECTION &orderFlowDirection, // Order Flow Direction ...
|
||||||
|
int maxAllowedLoopbackBars = 576 //
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
orderFlowDirection = X_DIRECTION_NONE;
|
||||||
|
|
||||||
//
|
//
|
||||||
if (maxAllowedLoopbackBars <= 0)
|
if (maxAllowedLoopbackBars <= 0)
|
||||||
{
|
{
|
||||||
@@ -1185,7 +751,7 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
FilterBrokenPivots(orderFlow);
|
FilterBrokenPivots(orderFlow);
|
||||||
|
|
||||||
//
|
//
|
||||||
ENUM_X_DIRECTION orderFlowDirection;
|
// Detect Order Flow Direction ...
|
||||||
result = DetectPivotDirection(
|
result = DetectPivotDirection(
|
||||||
orderFlow,
|
orderFlow,
|
||||||
orderFlowDirection //
|
orderFlowDirection //
|
||||||
@@ -1199,231 +765,6 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Detect Specified States Market Structure ...
|
|
||||||
*
|
|
||||||
* @param dir: ENUM_X_DIRECTION member, Refrence ...
|
|
||||||
* @param state: XPOIState instance ...
|
|
||||||
*
|
|
||||||
* @return ( bool )
|
|
||||||
*/
|
|
||||||
bool DetectMarketStructure(
|
|
||||||
ENUM_X_DIRECTION &dir,
|
|
||||||
XCSupportZone *&supportZones[],
|
|
||||||
XCResistanceZone *&resistanceZones[],
|
|
||||||
XPOIState &state //
|
|
||||||
)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
bool result = false;
|
|
||||||
|
|
||||||
//
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Filter Untouched Supports ...
|
|
||||||
Clean(supportZones);
|
|
||||||
int untouchedSupportsCount = 0;
|
|
||||||
count = ArraySize(state.supportZones);
|
|
||||||
if (IsValidSize(count))
|
|
||||||
{
|
|
||||||
//
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCSupportZone *item = state.supportZones[i];
|
|
||||||
|
|
||||||
//
|
|
||||||
// Find Breakout Bar
|
|
||||||
XOHCL iBar;
|
|
||||||
bool isFilled = item.FillBar(iBar);
|
|
||||||
if (!isFilled)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
int iBarIndex = iBar.Index();
|
|
||||||
int iBarUnTouchedCount = 0;
|
|
||||||
for (int j = 0; j < iBarIndex; j++)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XOHCL jBar;
|
|
||||||
bool isInited = jBar.Init(
|
|
||||||
iBar.symbol,
|
|
||||||
iBar.period,
|
|
||||||
j //
|
|
||||||
);
|
|
||||||
if (!isInited)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isUntouched =
|
|
||||||
jBar.low > item.Upper();
|
|
||||||
if (isUntouched)
|
|
||||||
{
|
|
||||||
iBarUnTouchedCount++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iBarUnTouchedCount--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (iBarUnTouchedCount > 0)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
Add(
|
|
||||||
item,
|
|
||||||
supportZones //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
untouchedSupportsCount = ArraySize(supportZones);
|
|
||||||
if (IsValidSize(untouchedSupportsCount))
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Draw ...
|
|
||||||
// for (int i = 0; i < untouchedSupportsCount; i++)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// XCSupportZone *item = supportZones[i];
|
|
||||||
|
|
||||||
// //
|
|
||||||
// XCSupportZoneObject *iObj;
|
|
||||||
// bool isCreated = mPOIDrawer.CreateSupportZone(
|
|
||||||
// item,
|
|
||||||
// iObj //
|
|
||||||
// );
|
|
||||||
// if (isCreated)
|
|
||||||
// {
|
|
||||||
// AddObjectIfNotExists(iObj);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Filter Untouched Resistances ...
|
|
||||||
Clean(resistanceZones);
|
|
||||||
int untouchedResistancesCount = 0;
|
|
||||||
count = ArraySize(state.resistanceZones);
|
|
||||||
if (IsValidSize(count))
|
|
||||||
{
|
|
||||||
//
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XCResistanceZone *item = state.resistanceZones[i];
|
|
||||||
|
|
||||||
//
|
|
||||||
// Find Breakout Bar
|
|
||||||
XOHCL iBar;
|
|
||||||
bool isFilled = item.FillBar(iBar);
|
|
||||||
if (!isFilled)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
int iBarIndex = iBar.Index();
|
|
||||||
int iBarUnTouchedCount = 0;
|
|
||||||
for (int j = 0; j < iBarIndex; j++)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
XOHCL jBar;
|
|
||||||
bool isInited = jBar.Init(
|
|
||||||
iBar.symbol,
|
|
||||||
iBar.period,
|
|
||||||
j //
|
|
||||||
);
|
|
||||||
if (!isInited)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isUntouched =
|
|
||||||
jBar.high < item.Lower();
|
|
||||||
if (isUntouched)
|
|
||||||
{
|
|
||||||
iBarUnTouchedCount++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iBarUnTouchedCount--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (iBarUnTouchedCount > 0)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
Add(
|
|
||||||
item,
|
|
||||||
resistanceZones //
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
untouchedResistancesCount = ArraySize(resistanceZones);
|
|
||||||
if (IsValidSize(untouchedResistancesCount))
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Draw ...
|
|
||||||
// for (int i = 0; i < untouchedResistancesCount; i++)
|
|
||||||
// {
|
|
||||||
// //
|
|
||||||
// XCResistanceZone *item = resistanceZones[i];
|
|
||||||
|
|
||||||
// //
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Private ...
|
// Private ...
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user