last ...
This commit is contained in:
@@ -572,7 +572,7 @@ class XC121SMCCycleHelper : public XCBase
|
||||
/**
|
||||
* Detect Order Blocks ...
|
||||
*
|
||||
* @return ( int )
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool DetectOrderBlocks(
|
||||
XCOrderBlock *&bullishOrderBlocks[],
|
||||
@@ -597,14 +597,14 @@ class XC121SMCCycleHelper : public XCBase
|
||||
}
|
||||
|
||||
//
|
||||
int bullOBsCount = DetectDirectionOrderBlocks(
|
||||
int bullOBsCount = DetectValidOrderBlocks(
|
||||
X_DIRECTION_BULLISH,
|
||||
state,
|
||||
bullishOrderBlocks //
|
||||
);
|
||||
|
||||
//
|
||||
int bearOBsCount = DetectDirectionOrderBlocks(
|
||||
int bearOBsCount = DetectValidOrderBlocks(
|
||||
X_DIRECTION_BEARISH,
|
||||
state,
|
||||
bearishOrderBlocks //
|
||||
@@ -618,6 +618,611 @@ class XC121SMCCycleHelper : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Fair Value Gaps ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool DetectFairValueGaps(
|
||||
XCFVG *&bullishFairValueGaps[],
|
||||
XCFVG *&bearishFairValueGaps[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
Clean(bullishFairValueGaps);
|
||||
Clean(bearishFairValueGaps);
|
||||
|
||||
//
|
||||
XPOIState state;
|
||||
mPOIDetector.GetState(state);
|
||||
bool isValid = state.IsValid() &&
|
||||
state.HasChild();
|
||||
if (!isValid)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int bullFVGsCount = DetectValidFairValueGaps(
|
||||
X_DIRECTION_BULLISH,
|
||||
state,
|
||||
bullishFairValueGaps //
|
||||
);
|
||||
|
||||
//
|
||||
int bearFVGsCount = DetectValidFairValueGaps(
|
||||
X_DIRECTION_BEARISH,
|
||||
state,
|
||||
bearishFairValueGaps //
|
||||
);
|
||||
|
||||
//
|
||||
result = IsValidSize(bullFVGsCount +
|
||||
bearFVGsCount);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Support Zones ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool DetectSupportZones(
|
||||
XCOrderBlock *&bullishOrderBlocks[],
|
||||
XCFVG *&bullishFairValueGaps[],
|
||||
XCSupportZone *&supportZones[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
Clean(supportZones);
|
||||
|
||||
//
|
||||
int obsCount = ArraySize(bullishOrderBlocks);
|
||||
int fvgsCount = ArraySize(bullishFairValueGaps);
|
||||
|
||||
//
|
||||
XPOIState state;
|
||||
mPOIDetector.GetState(state);
|
||||
bool isValid = state.IsValid() &&
|
||||
state.HasChild() &&
|
||||
IsValidSize(obsCount + fvgsCount);
|
||||
if (!isValid)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int supportZonesCount = DetectValidSupportZones(
|
||||
state,
|
||||
bullishOrderBlocks,
|
||||
bullishFairValueGaps,
|
||||
supportZones //
|
||||
);
|
||||
|
||||
//
|
||||
result = IsValidSize(supportZonesCount);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Resistance Zones ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool DetectResistanceZones(
|
||||
XCOrderBlock *&bearishOrderBlocks[],
|
||||
XCFVG *&bearishFairValueGaps[],
|
||||
XCResistanceZone *&resistanceZones[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
Clean(resistanceZones);
|
||||
|
||||
//
|
||||
int obsCount = ArraySize(bearishOrderBlocks);
|
||||
int fvgsCount = ArraySize(bearishFairValueGaps);
|
||||
|
||||
//
|
||||
XPOIState state;
|
||||
mPOIDetector.GetState(state);
|
||||
bool isValid = state.IsValid() &&
|
||||
state.HasChild() &&
|
||||
IsValidSize(obsCount + fvgsCount);
|
||||
if (!isValid)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int resistanceZonesCount = DetectValidResistanceZones(
|
||||
state,
|
||||
bearishOrderBlocks,
|
||||
bearishFairValueGaps,
|
||||
resistanceZones //
|
||||
);
|
||||
|
||||
//
|
||||
result = IsValidSize(resistanceZonesCount);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Demand Zones ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool DetectDemandZones(
|
||||
XCOrderBlock *&bullishOrderBlocks[],
|
||||
XCFVG *&bullishFairValueGaps[],
|
||||
XCDemandZone *&demandZones[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
Clean(demandZones);
|
||||
|
||||
//
|
||||
int obsCount = ArraySize(bullishOrderBlocks);
|
||||
int fvgsCount = ArraySize(bullishFairValueGaps);
|
||||
|
||||
//
|
||||
XPOIState state;
|
||||
mPOIDetector.GetState(state);
|
||||
bool isValid = state.IsValid() &&
|
||||
state.HasChild() &&
|
||||
IsValidSize(obsCount + fvgsCount);
|
||||
if (!isValid)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int demandZonesCount = DetectValidDemandZones(
|
||||
state,
|
||||
bullishOrderBlocks,
|
||||
bullishFairValueGaps,
|
||||
demandZones //
|
||||
);
|
||||
|
||||
//
|
||||
result = IsValidSize(demandZonesCount);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Supply Zones ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool DetectSupplyZones(
|
||||
XCOrderBlock *&bearishOrderBlocks[],
|
||||
XCFVG *&bearishFairValueGaps[],
|
||||
XCSupplyZone *&supplyZones[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
Clean(supplyZones);
|
||||
|
||||
//
|
||||
int obsCount = ArraySize(bearishOrderBlocks);
|
||||
int fvgsCount = ArraySize(bearishFairValueGaps);
|
||||
|
||||
//
|
||||
XPOIState state;
|
||||
mPOIDetector.GetState(state);
|
||||
bool isValid = state.IsValid() &&
|
||||
state.HasChild() &&
|
||||
IsValidSize(obsCount + fvgsCount);
|
||||
if (!isValid)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int supplyZonesCount = DetectValidSupplyZones(
|
||||
state,
|
||||
bearishOrderBlocks,
|
||||
bearishFairValueGaps,
|
||||
supplyZones //
|
||||
);
|
||||
|
||||
//
|
||||
result = IsValidSize(supplyZonesCount);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Cycle State and Update it ...
|
||||
*
|
||||
* @param state: X121SMCCycleState instance Reference ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool GetCycleState(X121SMCCycleState &state)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
string symbol = GetSymbol();
|
||||
ENUM_TIMEFRAMES period = GetPeriod();
|
||||
|
||||
//
|
||||
state.symbol = symbol;
|
||||
state.period = period;
|
||||
|
||||
//
|
||||
datetime cTime = TimeCurrent();
|
||||
|
||||
//
|
||||
// Detect Order Block ...
|
||||
|
||||
//
|
||||
bool hasBullishOBs = state.HasBullishOBs();
|
||||
int bullishOBsCount = state.CountBullishOBs();
|
||||
|
||||
//
|
||||
bool hasBearishOBs = state.HasBearishOBs();
|
||||
int bearishOBsCount = state.CountBearishOBs();
|
||||
|
||||
//
|
||||
bool hasOBs = hasBullishOBs &&
|
||||
hasBearishOBs;
|
||||
if (!hasOBs)
|
||||
{
|
||||
//
|
||||
XCOrderBlock *bullishOBs[];
|
||||
XCOrderBlock *bearishOBs[];
|
||||
hasOBs = DetectOrderBlocks(
|
||||
bullishOBs,
|
||||
bearishOBs //
|
||||
);
|
||||
|
||||
//
|
||||
if (hasOBs &&
|
||||
!hasBullishOBs)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
bullishOBs,
|
||||
state.bullishOBs //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (hasOBs &&
|
||||
!hasBearishOBs)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
bearishOBs,
|
||||
state.bearishOBs //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
hasBullishOBs = state.HasBullishOBs();
|
||||
bullishOBsCount = state.CountBullishOBs();
|
||||
|
||||
//
|
||||
hasBearishOBs = state.HasBearishOBs();
|
||||
bearishOBsCount = state.CountBearishOBs();
|
||||
}
|
||||
|
||||
//
|
||||
// Update Order Blocks Time ...
|
||||
if (hasOBs)
|
||||
{
|
||||
//
|
||||
if (hasBullishOBs)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < bullishOBsCount; i++)
|
||||
{
|
||||
state.bullishOBs[i].To(cTime);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (hasBearishOBs)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < bearishOBsCount; i++)
|
||||
{
|
||||
state.bearishOBs[i].To(cTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Fair Value Gap ...
|
||||
|
||||
//
|
||||
bool hasBullishFVGs = state.HasBullishFVGs();
|
||||
int bullishFVGsCount = state.CountBullishFVGs();
|
||||
|
||||
//
|
||||
bool hasBearishFVGs = state.HasBearishFVGs();
|
||||
int bearishFVGsCount = state.CountBearishFVGs();
|
||||
|
||||
//
|
||||
bool hasFVGs = hasBullishFVGs &&
|
||||
hasBearishFVGs;
|
||||
if (!hasFVGs)
|
||||
{
|
||||
//
|
||||
XCFVG *bullishFVGs[];
|
||||
XCFVG *bearishFVGs[];
|
||||
hasFVGs = DetectFairValueGaps(
|
||||
bullishFVGs,
|
||||
bearishFVGs //
|
||||
);
|
||||
|
||||
//
|
||||
if (hasFVGs &&
|
||||
!hasBullishFVGs)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
bullishFVGs,
|
||||
state.bullishFVGs //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (hasFVGs &&
|
||||
!hasBearishFVGs)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
bearishFVGs,
|
||||
state.bearishFVGs //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
hasBullishFVGs = state.HasBullishFVGs();
|
||||
bullishFVGsCount = state.CountBullishFVGs();
|
||||
|
||||
//
|
||||
hasBearishFVGs = state.HasBearishFVGs();
|
||||
bearishFVGsCount = state.CountBearishFVGs();
|
||||
}
|
||||
|
||||
//
|
||||
// Update Fair Value Gaps Time ...
|
||||
if (hasFVGs)
|
||||
{
|
||||
//
|
||||
if (hasBullishFVGs)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < bullishFVGsCount; i++)
|
||||
{
|
||||
state.bullishFVGs[i].To(cTime);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (hasBearishFVGs)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < bearishFVGsCount; i++)
|
||||
{
|
||||
state.bearishFVGs[i].To(cTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Support Zones ...
|
||||
|
||||
//
|
||||
bool hasSupportZones = state.HasSupportZones();
|
||||
int supportZonesCount = state.CountSupportZones();
|
||||
|
||||
//
|
||||
if (!hasSupportZones)
|
||||
{
|
||||
//
|
||||
XCSupportZone *supportZones[];
|
||||
hasSupportZones = DetectSupportZones(
|
||||
state.bullishOBs,
|
||||
state.bullishFVGs,
|
||||
supportZones //
|
||||
);
|
||||
|
||||
//
|
||||
if (hasSupportZones)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
supportZones,
|
||||
state.supportZones //
|
||||
);
|
||||
|
||||
//
|
||||
supportZonesCount = state.CountSupportZones();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Update Support Zones Time ...
|
||||
if (hasSupportZones)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < supportZonesCount; i++)
|
||||
{
|
||||
state.supportZones[i].To(cTime);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Demand Zones ...
|
||||
|
||||
//
|
||||
bool hasDemandZones = state.HasDemandZones();
|
||||
int demandZonesCount = state.CountDemandZones();
|
||||
|
||||
//
|
||||
if (!hasDemandZones)
|
||||
{
|
||||
//
|
||||
XCDemandZone *demandZones[];
|
||||
hasDemandZones = DetectDemandZones(
|
||||
state.bullishOBs,
|
||||
state.bullishFVGs,
|
||||
demandZones //
|
||||
);
|
||||
|
||||
//
|
||||
if (hasDemandZones)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
demandZones,
|
||||
state.demandZones //
|
||||
);
|
||||
|
||||
//
|
||||
demandZonesCount = state.CountDemandZones();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Update Support Zones Time ...
|
||||
if (hasDemandZones)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < demandZonesCount; i++)
|
||||
{
|
||||
state.demandZones[i].To(cTime);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Resistance Zones ...
|
||||
|
||||
//
|
||||
bool hasResistanceZones = state.HasResistanceZones();
|
||||
int resistanceZonesCount = state.CountResistanceZones();
|
||||
|
||||
//
|
||||
if (!hasResistanceZones)
|
||||
{
|
||||
//
|
||||
XCResistanceZone *resistanceZones[];
|
||||
hasResistanceZones = DetectResistanceZones(
|
||||
state.bearishOBs,
|
||||
state.bearishFVGs,
|
||||
resistanceZones //
|
||||
);
|
||||
|
||||
//
|
||||
if (hasResistanceZones)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < ArraySize(resistanceZones); i++)
|
||||
{
|
||||
resistanceZones[i].To(cTime);
|
||||
}
|
||||
|
||||
//
|
||||
Copy(
|
||||
resistanceZones,
|
||||
state.resistanceZones //
|
||||
);
|
||||
|
||||
//
|
||||
resistanceZonesCount = state.CountResistanceZones();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Update Resistance Zones Time ...
|
||||
if (hasResistanceZones)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < resistanceZonesCount; i++)
|
||||
{
|
||||
state.resistanceZones[i].To(cTime);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Supply Zones ...
|
||||
|
||||
//
|
||||
bool hasSupplyZones = state.HasSupplyZones();
|
||||
int supplyZonesCount = state.CountSupplyZones();
|
||||
|
||||
//
|
||||
if (!hasSupplyZones)
|
||||
{
|
||||
//
|
||||
XCSupplyZone *supplyZones[];
|
||||
hasSupplyZones = DetectSupplyZones(
|
||||
state.bearishOBs,
|
||||
state.bearishFVGs,
|
||||
supplyZones //
|
||||
);
|
||||
|
||||
//
|
||||
if (hasSupplyZones)
|
||||
{
|
||||
//
|
||||
Copy(
|
||||
supplyZones,
|
||||
state.supplyZones //
|
||||
);
|
||||
|
||||
//
|
||||
supplyZonesCount = state.CountSupplyZones();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Update Resistance Zones Time ...
|
||||
if (hasSupplyZones)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < supplyZonesCount; i++)
|
||||
{
|
||||
state.supplyZones[i].To(cTime);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = state.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve Cycle Conditions ...
|
||||
*
|
||||
@@ -688,6 +1293,288 @@ class XC121SMCCycleHelper : public XCBase
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Draw Cycle State ...
|
||||
*
|
||||
* @param state: X121SMCCyleState instance Reference ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int DrawCycleState(
|
||||
X121SMCCycleState &state,
|
||||
XCBaseObject *&drawnObjects[] //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
// Order Blocks ...
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
bool hasBullishOBs = state.HasBullishOBs();
|
||||
int bullishOBsCount = state.CountBullishOBs();
|
||||
if (hasBullishOBs)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < bullishOBsCount; i++)
|
||||
{
|
||||
//
|
||||
XCOrderBlock *iOb = state.bullishOBs[i];
|
||||
|
||||
//
|
||||
XCBullishOrderBlockObject *iObObj;
|
||||
bool isCreated = mPOIDrawer
|
||||
.CreateBullishOrderBlock(
|
||||
iOb,
|
||||
iObObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iObObj,
|
||||
drawnObjects //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
bool hasBearishOBs = state.HasBearishOBs();
|
||||
int bearishOBsCount = state.CountBearishOBs();
|
||||
if (hasBearishOBs)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < bearishOBsCount; i++)
|
||||
{
|
||||
//
|
||||
XCOrderBlock *iOb = state.bearishOBs[i];
|
||||
|
||||
//
|
||||
XCBearishOrderBlockObject *iObObj;
|
||||
bool isCreated = mPOIDrawer
|
||||
.CreateBearishOrderBlock(
|
||||
iOb,
|
||||
iObObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iObObj,
|
||||
drawnObjects //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Fair Value Gaps ...
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
bool hasBullishFVGs = state.HasBullishFVGs();
|
||||
int bullishFVGsCount = state.CountBullishFVGs();
|
||||
if (hasBullishFVGs)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < bullishFVGsCount; i++)
|
||||
{
|
||||
//
|
||||
XCFVG *iFVG = state.bullishFVGs[i];
|
||||
|
||||
//
|
||||
XCBullishFairValueGapObject *iFVGObj;
|
||||
bool isCreated = mPOIDrawer
|
||||
.CreateBullishFairValueGap(
|
||||
iFVG,
|
||||
iFVGObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
iFVGObj.ZoneColor(clrLime);
|
||||
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iFVGObj,
|
||||
drawnObjects //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
bool hasBearishFVGs = state.HasBearishFVGs();
|
||||
int bearishFVGsCount = state.CountBearishFVGs();
|
||||
if (hasBearishFVGs)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < bearishFVGsCount; i++)
|
||||
{
|
||||
//
|
||||
XCFVG *iFVG = state.bearishFVGs[i];
|
||||
|
||||
//
|
||||
XCBearishFairValueGapObject *iFVGObj;
|
||||
bool isCreated = mPOIDrawer
|
||||
.CreateBearishFairValueGap(
|
||||
iFVG,
|
||||
iFVGObj //
|
||||
);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
iFVGObj.ZoneColor(clrRed);
|
||||
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iFVGObj,
|
||||
drawnObjects //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Support Zones ...
|
||||
bool hasSupportZones = state.HasSupportZones();
|
||||
int supportZonesCount = state.CountSupportZones();
|
||||
if (hasSupportZones)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < supportZonesCount; i++)
|
||||
{
|
||||
//
|
||||
XCSupportZoneObject *iObj;
|
||||
bool isCreated = mPOIDrawer
|
||||
.CreateSupportZone(
|
||||
state.supportZones[i],
|
||||
iObj //
|
||||
);
|
||||
|
||||
//
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
iObj.ZoneColor(clrDarkSeaGreen);
|
||||
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iObj,
|
||||
drawnObjects //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Resistance Zones ...
|
||||
bool hasResistanceZones = state.HasResistanceZones();
|
||||
int resistanceZonesCount = state.CountResistanceZones();
|
||||
if (hasResistanceZones)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < resistanceZonesCount; i++)
|
||||
{
|
||||
//
|
||||
XCResistanceZoneObject *iObj;
|
||||
bool isCreated = mPOIDrawer
|
||||
.CreateResistanceZone(
|
||||
state.resistanceZones[i],
|
||||
iObj //
|
||||
);
|
||||
|
||||
//
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
iObj.ZoneColor(clrSaddleBrown);
|
||||
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iObj,
|
||||
drawnObjects //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Demand Zones ...
|
||||
bool hasDemandZones = state.HasDemandZones();
|
||||
int demandZonesCount = state.CountDemandZones();
|
||||
if (hasDemandZones)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < demandZonesCount; i++)
|
||||
{
|
||||
//
|
||||
XCDemandZoneObject *iObj;
|
||||
bool isCreated = mPOIDrawer
|
||||
.CreateDemandZone(
|
||||
state.demandZones[i],
|
||||
iObj //
|
||||
);
|
||||
|
||||
//
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
iObj.ZoneColor(clrDarkTurquoise);
|
||||
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iObj,
|
||||
drawnObjects //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Supply Zones ...
|
||||
bool hasSupplyZones = state.HasSupplyZones();
|
||||
int supplyZonesCount = state.CountSupplyZones();
|
||||
if (hasSupplyZones)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < supplyZonesCount; i++)
|
||||
{
|
||||
//
|
||||
XCSupplyZoneObject *iObj;
|
||||
bool isCreated = mPOIDrawer
|
||||
.CreateSupplyZone(
|
||||
state.supplyZones[i],
|
||||
iObj //
|
||||
);
|
||||
|
||||
//
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
iObj.ZoneColor(clrChocolate);
|
||||
|
||||
//
|
||||
Add(
|
||||
(XCBaseObject *)iObj,
|
||||
drawnObjects //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(drawnObjects);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Virtuals ...
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ const string X121SMCStrategyToken = "X121SMC";
|
||||
|
||||
//
|
||||
const string X121SMCXToken = "X121X";
|
||||
const string X121SMCXHKPVToken = "X121XHKPV";
|
||||
const string X121SMCXOBPVToken = "X121XOBPV";
|
||||
|
||||
//
|
||||
@@ -45,6 +46,7 @@ enum ENUM_X_121_SMC_PROVIDERS
|
||||
//
|
||||
X_121_SMC_PROVIDER_NONE,
|
||||
X_121_SMC_PROVIDER_X,
|
||||
X_121_SMC_PROVIDER_XHKPV,
|
||||
X_121_SMC_PROVIDER_XOBPV,
|
||||
};
|
||||
|
||||
@@ -612,6 +614,365 @@ struct X121SMCGuard
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Model Cycle State ...
|
||||
struct X121SMCCycleState
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
string symbol;
|
||||
ENUM_TIMEFRAMES period;
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
XCFVG *bullishFVGs[];
|
||||
XCOrderBlock *bullishOBs[];
|
||||
XCDemandZone *demandZones[];
|
||||
XCSupportZone *supportZones[];
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
XCFVG *bearishFVGs[];
|
||||
XCOrderBlock *bearishOBs[];
|
||||
XCSupplyZone *supplyZones[];
|
||||
XCResistanceZone *resistanceZones[];
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
X121SMCCycleState()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
/**
|
||||
* Cleanup Model ...
|
||||
*/
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
symbol = NULL;
|
||||
period = NULL;
|
||||
|
||||
//
|
||||
Clean(bullishFVGs);
|
||||
Clean(bullishOBs);
|
||||
Clean(demandZones);
|
||||
Clean(supportZones);
|
||||
|
||||
//
|
||||
Clean(bearishFVGs);
|
||||
Clean(bearishOBs);
|
||||
Clean(supplyZones);
|
||||
Clean(resistanceZones);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Model ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
IsValid(symbol) &&
|
||||
IsValid(period) &&
|
||||
(
|
||||
//
|
||||
(HasBullishOBs() &&
|
||||
(HasBullishFVGs() ||
|
||||
HasSupportZones() ||
|
||||
HasDemandZones()))
|
||||
//
|
||||
||
|
||||
(HasBearishOBs() &&
|
||||
(HasSupplyZones() ||
|
||||
HasBearishFVGs() ||
|
||||
HasResistanceZones()))
|
||||
//
|
||||
)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int CountBullishOBs()
|
||||
{
|
||||
return ArraySize(bullishOBs);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasBullishOBs()
|
||||
{
|
||||
return IsValidSize(CountBullishOBs());
|
||||
}
|
||||
|
||||
//
|
||||
int CountBearishOBs()
|
||||
{
|
||||
return ArraySize(bearishOBs);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasBearishOBs()
|
||||
{
|
||||
return IsValidSize(CountBearishOBs());
|
||||
}
|
||||
|
||||
//
|
||||
int CountSupportZones()
|
||||
{
|
||||
return ArraySize(supportZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasSupportZones()
|
||||
{
|
||||
return IsValidSize(CountSupportZones());
|
||||
}
|
||||
|
||||
//
|
||||
int CountResistanceZones()
|
||||
{
|
||||
return ArraySize(resistanceZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasResistanceZones()
|
||||
{
|
||||
return IsValidSize(CountResistanceZones());
|
||||
}
|
||||
|
||||
//
|
||||
int CountDemandZones()
|
||||
{
|
||||
return ArraySize(demandZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasDemandZones()
|
||||
{
|
||||
return IsValidSize(CountDemandZones());
|
||||
}
|
||||
|
||||
//
|
||||
int CountSupplyZones()
|
||||
{
|
||||
return ArraySize(supplyZones);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasSupplyZones()
|
||||
{
|
||||
return IsValidSize(CountSupplyZones());
|
||||
}
|
||||
|
||||
//
|
||||
int CountBullishFVGs()
|
||||
{
|
||||
return ArraySize(bullishFVGs);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasBullishFVGs()
|
||||
{
|
||||
return IsValidSize(CountBullishFVGs());
|
||||
}
|
||||
|
||||
//
|
||||
int CountBearishFVGs()
|
||||
{
|
||||
return ArraySize(bearishFVGs);
|
||||
}
|
||||
|
||||
//
|
||||
bool HasBearishFVGs()
|
||||
{
|
||||
return IsValidSize(CountBearishFVGs());
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
bool DetectPriceInsideBox(
|
||||
XBoxZone &box,
|
||||
X121Conditions &xConditions,
|
||||
X121SMCCycleState &state //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
box.Clean();
|
||||
|
||||
//
|
||||
string symbol = state.symbol;
|
||||
ENUM_TIMEFRAMES period = state.period;
|
||||
|
||||
//
|
||||
box.symbol = symbol;
|
||||
box.period = period;
|
||||
|
||||
//
|
||||
result = state.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Price Inside Order Block ...
|
||||
|
||||
//
|
||||
bool hasBullishOBs = state.HasBullishOBs();
|
||||
int bullishOBsCount = state.CountBullishOBs();
|
||||
|
||||
//
|
||||
bool hasBearishOBs = state.HasBearishOBs();
|
||||
int bearishOBsCount = state.CountBearishOBs();
|
||||
|
||||
//
|
||||
bool hasOBs =
|
||||
//
|
||||
hasBullishOBs ||
|
||||
hasBearishOBs
|
||||
//
|
||||
;
|
||||
result = hasOBs;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool hasPriceInsideOB = false;
|
||||
XCOrderBlock *priceInsideOB = NULL;
|
||||
ENUM_X_DIRECTION boxDir = X_DIRECTION_NONE;
|
||||
|
||||
//
|
||||
if (hasBullishOBs &&
|
||||
!hasPriceInsideOB)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < bullishOBsCount; i++)
|
||||
{
|
||||
//
|
||||
XCOrderBlock *iOb = state.bullishOBs[i];
|
||||
|
||||
//
|
||||
bool isInside = IsPriceInsideZone(
|
||||
xConditions.valesBuffer[1],
|
||||
(XCZone *)iOb //
|
||||
);
|
||||
if (isInside)
|
||||
{
|
||||
//
|
||||
priceInsideOB = iOb;
|
||||
hasPriceInsideOB = true;
|
||||
boxDir = X_DIRECTION_BULLISH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
if (hasBearishOBs &&
|
||||
!hasPriceInsideOB)
|
||||
{
|
||||
//
|
||||
for (int i = 0; i < bearishOBsCount; i++)
|
||||
{
|
||||
//
|
||||
XCOrderBlock *iOb = state.bearishOBs[i];
|
||||
|
||||
//
|
||||
bool isInside = IsPriceInsideZone(
|
||||
xConditions.peaksBuffer[1],
|
||||
(XCZone *)iOb //
|
||||
);
|
||||
if (isInside)
|
||||
{
|
||||
//
|
||||
priceInsideOB = iOb;
|
||||
hasPriceInsideOB = true;
|
||||
boxDir = X_DIRECTION_BEARISH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
bool hasBullishFVG = state.HasBullishFVGs();
|
||||
bool hasBearishFVG = state.HasBearishFVGs();
|
||||
bool hasDemandZones = state.HasDemandZones();
|
||||
bool hasSupplyZones = state.HasSupplyZones();
|
||||
bool hasSupportZones = state.HasSupportZones();
|
||||
bool hasResistanceZones = state.HasResistanceZones();
|
||||
|
||||
//
|
||||
bool hasBullishZones =
|
||||
//
|
||||
hasBullishFVG ||
|
||||
hasDemandZones ||
|
||||
hasSupportZones
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool hasBearishZones =
|
||||
//
|
||||
hasBearishFVG ||
|
||||
hasSupplyZones ||
|
||||
hasResistanceZones
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool hasPropperZones =
|
||||
//
|
||||
IsBullish(boxDir)
|
||||
? hasBullishZones
|
||||
: IsBearish(boxDir)
|
||||
? hasBearishZones
|
||||
: false
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (!hasPropperZones &&
|
||||
hasPriceInsideOB)
|
||||
{
|
||||
//
|
||||
box.to = priceInsideOB.To();
|
||||
box.from = priceInsideOB.From();
|
||||
box.upper = priceInsideOB.Upper();
|
||||
box.lower = priceInsideOB.Lower();
|
||||
}
|
||||
else if (hasPropperZones &&
|
||||
hasPriceInsideOB)
|
||||
{
|
||||
//
|
||||
// Detect Validate Zones ...
|
||||
}
|
||||
|
||||
//
|
||||
result = box.IsValid();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Guard to Collection ...
|
||||
*
|
||||
@@ -704,6 +1065,11 @@ string ToString(ENUM_X_121_SMC_PROVIDERS value)
|
||||
result = X121SMCXToken;
|
||||
break;
|
||||
|
||||
//
|
||||
case X_121_SMC_PROVIDER_XHKPV:
|
||||
result = X121SMCXHKPVToken;
|
||||
break;
|
||||
|
||||
//
|
||||
case X_121_SMC_PROVIDER_XOBPV:
|
||||
result = X121SMCXOBPVToken;
|
||||
@@ -737,6 +1103,10 @@ ENUM_X_121_SMC_PROVIDERS ParseProvider(string value)
|
||||
{
|
||||
result = X_121_SMC_PROVIDER_X;
|
||||
}
|
||||
else if (Contains(X121SMCXHKPVToken, value))
|
||||
{
|
||||
result = X_121_SMC_PROVIDER_XHKPV;
|
||||
}
|
||||
else if (Contains(X121SMCXOBPVToken, value))
|
||||
{
|
||||
result = X_121_SMC_PROVIDER_XOBPV;
|
||||
|
||||
@@ -900,7 +900,10 @@ bool DetectX121SMCXSignalSetup(
|
||||
forDir,
|
||||
priceInsideOB.GetSymbol(),
|
||||
priceInsideOB.GetPeriod(),
|
||||
(XCZone *)priceInsideOB //
|
||||
priceInsideOB.Upper(),
|
||||
priceInsideOB.Lower(),
|
||||
priceInsideOB.From(),
|
||||
priceInsideOB.To() //
|
||||
);
|
||||
if (hasBreakerBar)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,8 +23,8 @@
|
||||
// Imports ...
|
||||
// #include "../../Libraries/x-trade.lib"
|
||||
#include "../Classes/x-121.smc.market.cycle.helper.class.mq5"
|
||||
#include "../Libraries/x-121.smc.lib.mq5"
|
||||
#include "../Libraries/x-121.smc.guard.lib.mq5"
|
||||
#include "../Libraries/x-121.smc.lib.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
@@ -900,7 +900,10 @@ bool DetectX121SMCXOBPVSignalSetup(
|
||||
forDir,
|
||||
priceInsideOB.GetSymbol(),
|
||||
priceInsideOB.GetPeriod(),
|
||||
(XCZone *)priceInsideOB //
|
||||
priceInsideOB.Upper(),
|
||||
priceInsideOB.Lower(),
|
||||
priceInsideOB.From(),
|
||||
priceInsideOB.To() //
|
||||
);
|
||||
if (hasBreakerBar)
|
||||
{
|
||||
@@ -918,13 +921,204 @@ bool DetectX121SMCXOBPVSignalSetup(
|
||||
hasOBState = obState.IsValid();
|
||||
}
|
||||
|
||||
//
|
||||
// DRAW ...
|
||||
//
|
||||
|
||||
// //
|
||||
// XCBaseObject *drawnObjects[];
|
||||
|
||||
// //
|
||||
// if (hasBullishOrderBlocks)
|
||||
// {
|
||||
// //
|
||||
// for (int i = 0; i < bullishOrderBlocksCount; i++)
|
||||
// {
|
||||
// //
|
||||
// XCOrderBlock *iOb = conditions.bullishOBs[i];
|
||||
|
||||
// //
|
||||
// XCBullishOrderBlockObject *iObObj;
|
||||
// bool isCreated = visionCycleHelper
|
||||
// .mPOIDrawer
|
||||
// .CreateBullishOrderBlock(
|
||||
// iOb,
|
||||
// iObObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// //
|
||||
// Add(
|
||||
// (XCBaseObject *)iObObj,
|
||||
// drawnObjects //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// //
|
||||
// if (hasBearishOrderBlocks)
|
||||
// {
|
||||
// //
|
||||
// for (int i = 0; i < bearishOrderBlocksCount; i++)
|
||||
// {
|
||||
// //
|
||||
// XCOrderBlock *iOb = conditions.bearishOBs[i];
|
||||
|
||||
// //
|
||||
// XCBearishOrderBlockObject *iObObj;
|
||||
// bool isCreated = visionCycleHelper
|
||||
// .mPOIDrawer
|
||||
// .CreateBearishOrderBlock(
|
||||
// iOb,
|
||||
// iObObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// //
|
||||
// Add(
|
||||
// (XCBaseObject *)iObObj,
|
||||
// drawnObjects //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// //
|
||||
// if (hasPriceInsideOB)
|
||||
// {
|
||||
// //
|
||||
// bool isBullish = priceInsideOB.IsBullish();
|
||||
|
||||
// //
|
||||
// bool isCreated = false;
|
||||
// XCBaseObject *priceInsideOBObj = NULL;
|
||||
// if (isBullish)
|
||||
// {
|
||||
// //
|
||||
// XCBullishOrderBlockObject *iObj;
|
||||
// isCreated = visionCycleHelper
|
||||
// .mPOIDrawer
|
||||
// .CreateBullishOrderBlock(
|
||||
// priceInsideOB,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// //
|
||||
// iObj.ZoneColor(clrYellow);
|
||||
|
||||
// //
|
||||
// priceInsideOBObj = (XCBaseObject *)iObj;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //
|
||||
// XCBearishOrderBlockObject *iObj;
|
||||
// isCreated = visionCycleHelper
|
||||
// .mPOIDrawer
|
||||
// .CreateBearishOrderBlock(
|
||||
// priceInsideOB,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// //
|
||||
// iObj.ZoneColor(clrOrange);
|
||||
|
||||
// //
|
||||
// priceInsideOBObj = (XCBaseObject *)iObj;
|
||||
// }
|
||||
// }
|
||||
|
||||
// //
|
||||
// if (isCreated)
|
||||
// {
|
||||
// //
|
||||
// Add(
|
||||
// priceInsideOBObj,
|
||||
// drawnObjects //
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
// if (hasOldestBullishOB)
|
||||
// {
|
||||
// //
|
||||
// XCBullishOrderBlockObject *iObj;
|
||||
// bool isCreated = visionCycleHelper
|
||||
// .mPOIDrawer
|
||||
// .CreateBullishOrderBlock(
|
||||
// oldestBullishOB,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
|
||||
// //
|
||||
// if (hasYoungestBullishOB)
|
||||
// {
|
||||
// //
|
||||
// XCBullishOrderBlockObject *iObj;
|
||||
// bool isCreated = visionCycleHelper
|
||||
// .mPOIDrawer
|
||||
// .CreateBullishOrderBlock(
|
||||
// youngestBullishOB,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
|
||||
// //
|
||||
// if (hasOldestBearishOB)
|
||||
// {
|
||||
// //
|
||||
// XCBearishOrderBlockObject *iObj;
|
||||
// bool isCreated = visionCycleHelper
|
||||
// .mPOIDrawer
|
||||
// .CreateBearishOrderBlock(
|
||||
// oldestBearishOB,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
|
||||
// //
|
||||
// if (hasYoungestBearishOB)
|
||||
// {
|
||||
// //
|
||||
// XCBearishOrderBlockObject *iObj;
|
||||
// bool isCreated = visionCycleHelper
|
||||
// .mPOIDrawer
|
||||
// .CreateBearishOrderBlock(
|
||||
// youngestBearishOB,
|
||||
// iObj //
|
||||
// );
|
||||
// if (isCreated)
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
bool isSameCyclesPeak =
|
||||
//
|
||||
triggerXOBPVConditions.peaksBuffer[1] == decisionXOBPVConditions.peaksBuffer[1] &&
|
||||
decisionXOBPVConditions.peaksBuffer[1] == analyseXOBPVConditions.peaksBuffer[1] &&
|
||||
analyseXOBPVConditions.peaksBuffer[1] == verificationXOBPVConditions.peaksBuffer[1] &&
|
||||
verificationXOBPVConditions.peaksBuffer[1] == consolidationXOBPVConditions.peaksBuffer[1]
|
||||
analyseXOBPVConditions.peaksBuffer[1] == verificationXOBPVConditions.peaksBuffer[1]
|
||||
// &&
|
||||
// verificationXOBPVConditions.peaksBuffer[1] == consolidationXOBPVConditions.peaksBuffer[1]
|
||||
//
|
||||
;
|
||||
|
||||
@@ -933,14 +1127,15 @@ bool DetectX121SMCXOBPVSignalSetup(
|
||||
//
|
||||
triggerXOBPVConditions.valesBuffer[1] == decisionXOBPVConditions.valesBuffer[1] &&
|
||||
decisionXOBPVConditions.valesBuffer[1] == analyseXOBPVConditions.valesBuffer[1] &&
|
||||
analyseXOBPVConditions.valesBuffer[1] == verificationXOBPVConditions.valesBuffer[1] &&
|
||||
verificationXOBPVConditions.valesBuffer[1] == consolidationXOBPVConditions.valesBuffer[1]
|
||||
analyseXOBPVConditions.valesBuffer[1] == verificationXOBPVConditions.valesBuffer[1]
|
||||
// &&
|
||||
// verificationXOBPVConditions.valesBuffer[1] == consolidationXOBPVConditions.valesBuffer[1]
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
bool hasSameCyclesPV =
|
||||
hasOBState &&
|
||||
// hasOBState &&
|
||||
hasPriceInsideOB &&
|
||||
(isSameCyclesPeak ||
|
||||
isSameCyclesVale);
|
||||
@@ -1404,7 +1599,7 @@ bool DetectX121SMCXOBPVGuards(
|
||||
true, // TrailStop Guard ...
|
||||
true, // TrailTarget Guard ...
|
||||
true // Hedge Guard ...
|
||||
//
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
@@ -1491,34 +1686,3 @@ int AddX121SMCXOBPVConditionsIfNotExists(
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Conditions ...
|
||||
int DrawX121SMCXOBPVConditions(
|
||||
X121SMCStrategyXOBPVSignalConditions &conditions,
|
||||
XCBaseObject *&drawnObjects[],
|
||||
XCPOIDrawer *drawer //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
Clean(drawnObjects);
|
||||
|
||||
//
|
||||
if (drawer == NULL)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool isSetuped = conditions.IsSetuped();
|
||||
if (!isSetuped)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
//
|
||||
#include "../Signals/x-121.smc.x.signal.lib.mq5"
|
||||
#include "../Signals/x-121.smc.xhkpv.signal.lib.mq5"
|
||||
#include "../Signals/x-121.smc.xobpv.signal.lib.mq5"
|
||||
|
||||
//
|
||||
@@ -43,6 +44,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
//
|
||||
// Props ...
|
||||
bool useXSignal;
|
||||
bool useXHKPVSignal;
|
||||
bool useXOBPVSignal;
|
||||
|
||||
//
|
||||
@@ -67,6 +69,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
|
||||
//
|
||||
ArrayFree(mXConditionsCollection);
|
||||
ArrayFree(mXHKPVConditionsCollection);
|
||||
ArrayFree(mXOBPVConditionsCollection);
|
||||
}
|
||||
|
||||
@@ -194,6 +197,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
|
||||
//
|
||||
bool hasXSignal = false;
|
||||
bool hasXHKPVSignal = false;
|
||||
bool hasXOBPVSignal = false;
|
||||
|
||||
//
|
||||
@@ -205,6 +209,15 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
hasSignal = hasXSignal;
|
||||
}
|
||||
|
||||
//
|
||||
// XHKPV Signal ...
|
||||
if (useXHKPVSignal && !hasSignal)
|
||||
{
|
||||
//
|
||||
hasXHKPVSignal = DetectXHKPVSignal(conditions);
|
||||
hasSignal = hasXHKPVSignal;
|
||||
}
|
||||
|
||||
//
|
||||
// XOBPV Signal ...
|
||||
if (useXOBPVSignal && !hasSignal)
|
||||
@@ -386,6 +399,23 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// XHKPV Guard Detection ...
|
||||
if (useXHKPVSignal)
|
||||
{
|
||||
//
|
||||
bool hasGuard = DetectX121SMCXHKPVGuards(
|
||||
guards,
|
||||
positions,
|
||||
mTriggerCycleHelper,
|
||||
mDecisionCycleHelper,
|
||||
mAnalyseCycleHelper,
|
||||
mVerificationCycleHelper,
|
||||
mConsolidationCycleHelper,
|
||||
mVisionCycleHelper //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// XPZ Guard Detection ...
|
||||
if (useXOBPVSignal)
|
||||
@@ -676,6 +706,224 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XHKPV Signal ...
|
||||
bool DetectXHKPVSignal(
|
||||
X121SMCStrategyConditions &conditions //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
bool isBullish = false;
|
||||
bool isBearish = false;
|
||||
|
||||
//
|
||||
int zIndex = 0;
|
||||
int cIndex = zIndex + 1;
|
||||
int pIndex = cIndex + 1;
|
||||
int ppIndex = pIndex + 1;
|
||||
|
||||
//
|
||||
string symbol = GetSymbol();
|
||||
ENUM_TIMEFRAMES period = GetPeriod();
|
||||
|
||||
//
|
||||
XOHCL zBar;
|
||||
result = zBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
zIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL cBar;
|
||||
result = cBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
cIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL pBar;
|
||||
result = pBar.Init(
|
||||
symbol,
|
||||
period,
|
||||
pIndex //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double cLL = cBar.FindLowest(7, MODE_LOW);
|
||||
double cHH = cBar.FindHighest(7, MODE_HIGH);
|
||||
|
||||
//
|
||||
datetime cTime = TimeCurrent();
|
||||
|
||||
//
|
||||
ENUM_X_121_SMC_PROVIDERS provider = X_121_SMC_PROVIDER_XHKPV;
|
||||
string providerStr = ToString(provider);
|
||||
|
||||
//
|
||||
// Detect Setup Conditions ...
|
||||
datetime setupTime = mXHKPVConditions.setupTime;
|
||||
bool isSetuped = mXHKPVConditions.IsSetuped();
|
||||
ENUM_X_DIRECTION setupDir = mXHKPVConditions.dir;
|
||||
if (!isSetuped)
|
||||
{
|
||||
//
|
||||
// Detect Signal Setup ...
|
||||
isSetuped = DetectX121SMCXHKPVSignalSetup(
|
||||
symbol,
|
||||
period,
|
||||
mXHKPVConditions,
|
||||
mTriggerCycleHelper,
|
||||
mDecisionCycleHelper,
|
||||
mAnalyseCycleHelper,
|
||||
mVerificationCycleHelper,
|
||||
mConsolidationCycleHelper,
|
||||
mVisionCycleHelper //
|
||||
);
|
||||
|
||||
//
|
||||
setupDir = mXHKPVConditions.dir;
|
||||
setupTime = mXHKPVConditions.setupTime;
|
||||
|
||||
//
|
||||
if (isSetuped)
|
||||
{
|
||||
//
|
||||
int items = AddX121SMCXHKPVConditionsIfNotExists(
|
||||
mXHKPVConditions,
|
||||
mXHKPVConditionsCollection //
|
||||
);
|
||||
|
||||
//
|
||||
mXHKPVConditions.Clean();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
int conditionsCount = ArraySize(mXHKPVConditionsCollection);
|
||||
result = IsValidSize(conditionsCount);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Looking For Conditions ...
|
||||
int selectedIndex = 0;
|
||||
X121SMCStrategyXHKPVSignalConditions mTmpConditions[];
|
||||
Copy(
|
||||
mXHKPVConditionsCollection,
|
||||
mTmpConditions //
|
||||
);
|
||||
X121SMCStrategyXHKPVSignalConditions mConditions;
|
||||
for (int i = 0; i < conditionsCount; i++)
|
||||
{
|
||||
//
|
||||
// Check Triggers ...
|
||||
bool canTrigger = mTmpConditions[i].CanTrigger();
|
||||
datetime triggerTime = mTmpConditions[i].triggerTime;
|
||||
if (!canTrigger)
|
||||
{
|
||||
//
|
||||
// Detect Signal Trigger ...
|
||||
canTrigger = DetectX121SMCXHKPVSignalTrigger(
|
||||
mTmpConditions[i],
|
||||
symbol,
|
||||
period,
|
||||
mTriggerCycleHelper,
|
||||
mDecisionCycleHelper,
|
||||
mAnalyseCycleHelper,
|
||||
mVerificationCycleHelper,
|
||||
mConsolidationCycleHelper,
|
||||
mVisionCycleHelper //
|
||||
);
|
||||
|
||||
//
|
||||
result = canTrigger;
|
||||
if (!result)
|
||||
{
|
||||
//
|
||||
bool isISetuped = mTmpConditions[i].IsSetuped();
|
||||
if (!isISetuped)
|
||||
{
|
||||
//
|
||||
ArrayRemove(
|
||||
mXHKPVConditionsCollection,
|
||||
i,
|
||||
1 //
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
triggerTime = mTmpConditions[i].triggerTime;
|
||||
}
|
||||
|
||||
//
|
||||
if (canTrigger)
|
||||
{
|
||||
//
|
||||
selectedIndex = i;
|
||||
mConditions = mTmpConditions[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = IsValid(mConditions.setupTime) &&
|
||||
HasDirection(mConditions.dir);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Remove Selected Index from Main Collection ...
|
||||
ArrayRemove(
|
||||
mXHKPVConditionsCollection,
|
||||
selectedIndex,
|
||||
1 //
|
||||
);
|
||||
|
||||
//
|
||||
// Check Signal Direction ...
|
||||
isBullish = IsBullish(mConditions.dir);
|
||||
isBearish = IsBearish(mConditions.dir);
|
||||
result = isBullish ||
|
||||
isBearish;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Issues Signal on Conditions ...
|
||||
conditions.sl = mConditions.sl;
|
||||
conditions.provider = providerStr;
|
||||
conditions.signalDir = mConditions.dir;
|
||||
conditions.target = mConditions.target;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// XOBPV Signal ...
|
||||
bool DetectXOBPVSignal(
|
||||
@@ -910,7 +1158,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
{
|
||||
//
|
||||
useXSignal = false;
|
||||
useXOBPVSignal = true;
|
||||
useXHKPVSignal = true;
|
||||
useXOBPVSignal = false;
|
||||
|
||||
//
|
||||
string symbol = GetSymbol();
|
||||
|
||||
Reference in New Issue
Block a user