Files
xMQL5/BKPS/14030823/BKPs/121.smc.draw.conditions.mq5
T
2024-11-15 10:50:11 +03:30

837 lines
23 KiB
Plaintext

//
// Draw Functions ...
/**
* Draw Specific Condition ...
*
* @param conditions: X121SMCStrategyConditions instance ...
*/
void DrawConditions(X121SMCStrategyConditions &conditions)
{
//
// Draw Configurations ...
//
bool drawMainDemand = true;
bool drawMainSupply = true;
//
bool drawMainBullishOrderBlock = true;
bool drawMainBearishOrderBlock = true;
//
bool drawMainBullishFVG = true;
bool drawMainBearishFVG = true;
//
bool drawOrderBlocks = false;
bool drawFVGs = false;
bool drawSupportResistances = false;
bool drawSwings = false;
bool drawMomentumBars = false;
bool drawRejectionBars = false;
//
if (!conditions.IsValid())
{
return;
}
//
datetime time = TimeCurrent();
bool hasValidDemand = conditions.ValidateDemand();
bool hasValidSupply = conditions.ValidateSupply();
if (!hasValidDemand && !hasValidSupply)
{
return;
}
//
// Demand Zone ...
if (hasValidDemand)
{
//
// Demand ...
if (drawMainDemand)
{
//
XCDemandZoneObject *iObj;
bool isCreated = mPOIDrawer.CreateDemandZone(
conditions.demandZone,
iObj //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
//
if (drawMainBullishOrderBlock)
{
//
XCBullishOrderBlockObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishOrderBlock(
conditions.bullishOrderBlock,
iObj //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
//
if (drawMainBullishFVG)
{
//
XCBullishFVGObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishFVG(
conditions.bullishFVG,
iObj //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
//
// Order Blocks ...
int obsCount = ArraySize(conditions.bullishOrderBlocks);
if (drawOrderBlocks &&
IsValidSize(obsCount))
{
//
for (int i = 0; i < obsCount; i++)
{
//
XZone iZone = conditions.bullishOrderBlocks[i];
//
XCBullishOrderBlockObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishOrderBlock(
iZone,
iObj //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
}
//
// Fair Value Gaps ...
int fvgsCount = ArraySize(conditions.bullishFVGs);
if (drawFVGs &&
IsValidSize(fvgsCount))
{
//
for (int i = 0; i < fvgsCount; i++)
{
//
XZone iZone = conditions.bullishFVGs[i];
//
XCBullishFVGObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishFVG(
iZone,
iObj //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
}
//
// Supports ...
int supportsCount = ArraySize(conditions.supports);
if (drawSupportResistances &&
IsValidSize(supportsCount))
{
//
for (int i = 0; i < supportsCount; i++)
{
//
XOHCL iBar = conditions.supports[i];
//
XCSupportZoneObject *iObj;
bool isCreated = mPOIDrawer.CreateSupportZone(
iBar,
iObj,
time //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
}
//
// Swings ...
int swingsCount = ArraySize(conditions.swingLows);
if (drawSwings &&
IsValidSize(swingsCount))
{
//
for (int i = 0; i < swingsCount; i++)
{
//
XOHCL iBar = conditions.swingLows[i];
//
XCSwingLowObject *iObj;
bool isCreated = mPOIDrawer.CreateSwingLow(
iBar,
iObj //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
}
//
// Momentum Bars ...
int momentumBarsCount = ArraySize(conditions.bullishMomentumBars);
if (drawMomentumBars &&
IsValidSize(momentumBarsCount))
{
//
for (int i = 0; i < momentumBarsCount; i++)
{
//
XOHCL iBar = conditions.bullishMomentumBars[i];
//
XCBullishMomentumBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishMomentumBar(
iBar,
iObj //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
}
//
// Rejection Bars ...
int rejectionBarsCount = ArraySize(conditions.bullishRejectionBars);
if (drawRejectionBars &&
IsValidSize(rejectionBarsCount))
{
//
for (int i = 0; i < rejectionBarsCount; i++)
{
//
XOHCL iBar = conditions.bullishRejectionBars[i];
//
XCBullishRejectionBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishRejectionBar(
iBar,
iObj //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
}
}
//
// Supply Zone ...
if (hasValidSupply)
{
//
// Supply ...
if (drawMainSupply)
{
//
XCSupplyZoneObject *iObj;
bool isCreated = mPOIDrawer.CreateSupplyZone(
conditions.supplyZone,
iObj //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
//
if (drawMainBearishOrderBlock)
{
//
XCBearishOrderBlockObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishOrderBlock(
conditions.bearishOrderBlock,
iObj //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
//
if (drawMainBearishFVG)
{
//
XCBearishFVGObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishFVG(
conditions.bearishFVG,
iObj //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
//
// Order Blocks ...
int obsCount = ArraySize(conditions.bearishOrderBlocks);
if (drawOrderBlocks &&
IsValidSize(obsCount))
{
//
for (int i = 0; i < obsCount; i++)
{
//
XZone iZone = conditions.bearishOrderBlocks[i];
//
XCBearishOrderBlockObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishOrderBlock(
iZone,
iObj //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
}
//
// Fair Value Gaps ...
int fvgsCount = ArraySize(conditions.bearishFVGs);
if (drawFVGs &&
IsValidSize(fvgsCount))
{
//
for (int i = 0; i < fvgsCount; i++)
{
//
XZone iZone = conditions.bearishFVGs[i];
//
XCBearishFVGObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishFVG(
iZone,
iObj //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
}
//
// Resistances ...
int resistancesCount = ArraySize(conditions.resistances);
if (drawSupportResistances &&
IsValidSize(resistancesCount))
{
//
for (int i = 0; i < resistancesCount; i++)
{
//
XOHCL iBar = conditions.resistances[i];
//
XCResistanceZoneObject *iObj;
bool isCreated = mPOIDrawer.CreateResistanceZone(
iBar,
iObj,
time //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
}
//
// Swings ...
int swingsCount = ArraySize(conditions.swingHighs);
if (drawSwings &&
IsValidSize(swingsCount))
{
//
for (int i = 0; i < swingsCount; i++)
{
//
XOHCL iBar = conditions.swingHighs[i];
//
XCSwingHighObject *iObj;
bool isCreated = mPOIDrawer.CreateSwingHigh(
iBar,
iObj //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
}
//
// Momentum Bars ...
int momentumBarsCount = ArraySize(conditions.bearishMomentumBars);
if (drawMomentumBars &&
IsValidSize(momentumBarsCount))
{
//
for (int i = 0; i < momentumBarsCount; i++)
{
//
XOHCL iBar = conditions.bearishMomentumBars[i];
//
XCBearishMomentumBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishMomentumBar(
iBar,
iObj //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
}
//
// Rejection Bars ...
int rejectionBarsCount = ArraySize(conditions.bearishRejectionBars);
if (drawRejectionBars &&
IsValidSize(rejectionBarsCount))
{
//
for (int i = 0; i < rejectionBarsCount; i++)
{
//
XOHCL iBar = conditions.bearishRejectionBars[i];
//
XCBearishRejectionBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishRejectionBar(
iBar,
iObj //
);
if (isCreated)
{
mDrawnObjects.Add(iObj);
}
}
}
}
}
/**
* Draw Specified Market Struture ...
*
* @param structure: X121SMCMarketStructure instance ...
*/
void DrawMarketStructure(
X121SMCMarketStructure &structure,
ENUM_X_POSITION_TYPES type = X_POSITION_TYPE_ALL //
)
{
//
datetime cTime = TimeCurrent();
//
bool canAll = type == X_POSITION_TYPE_ALL;
bool canLong = type == X_POSITION_TYPE_LONG;
bool canShort = type == X_POSITION_TYPE_SHORT;
//
// Supply Zones ...
int supplysCount = ArraySize(structure.supplyZones);
if ((canAll || canLong) && IsValidSize(supplysCount))
{
//
for (int i = 0; i < supplysCount; i++)
{
//
XZone iZone = structure.supplyZones[i];
//
XCSupplyZoneObject *iObj;
bool isCreated = mPOIDrawer.CreateSupplyZone(
iZone,
iObj //
);
if (isCreated)
{
//
mDrawnObjects.Add(iObj);
}
}
}
//
// Demand Zones ...
int demandsCount = ArraySize(structure.demandZones);
if ((canAll || canShort) && IsValidSize(demandsCount))
{
//
for (int i = 0; i < demandsCount; i++)
{
//
XZone iZone = structure.demandZones[i];
//
XCDemandZoneObject *iObj;
bool isCreated = mPOIDrawer.CreateDemandZone(
iZone,
iObj //
);
if (isCreated)
{
//
mDrawnObjects.Add(iObj);
}
}
}
//
// Order Blocks ...
//
// Bullish OBs ...
int bullishOBsCount = ArraySize(structure.bullishOrderBlocks);
if ((canAll || canShort) && IsValidSize(bullishOBsCount))
{
//
for (int i = 0; i < bullishOBsCount; i++)
{
//
XZone iZone = structure.bullishOrderBlocks[i];
//
XCBullishOrderBlockObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishOrderBlock(
iZone,
iObj //
);
if (isCreated)
{
//
mDrawnObjects.Add(iObj);
}
}
}
//
// Bearish OBs ...
int bearishOBsCount = ArraySize(structure.bearishOrderBlocks);
if ((canAll || canLong) && IsValidSize(bearishOBsCount))
{
//
for (int i = 0; i < bearishOBsCount; i++)
{
//
XZone iZone = structure.bearishOrderBlocks[i];
//
XCBearishOrderBlockObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishOrderBlock(
iZone,
iObj //
);
if (isCreated)
{
//
mDrawnObjects.Add(iObj);
}
}
}
//
// Fair Value Gaps ...
//
// Bullish FVGs ...
int bullishFVGsCount = ArraySize(structure.bullishFVGs);
if ((canAll || canShort) && IsValidSize(bullishFVGsCount))
{
//
for (int i = 0; i < bullishFVGsCount; i++)
{
//
XZone iZone = structure.bullishFVGs[i];
//
XCBullishFVGObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishFVG(
iZone,
iObj //
);
if (isCreated)
{
//
mDrawnObjects.Add(iObj);
}
}
}
//
// Bearish FVGs ...
int bearishFVGsCount = ArraySize(structure.bearishFVGs);
if ((canAll || canLong) && IsValidSize(bearishFVGsCount))
{
//
for (int i = 0; i < bearishFVGsCount; i++)
{
//
XZone iZone = structure.bearishFVGs[i];
//
XCBearishFVGObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishFVG(
iZone,
iObj //
);
if (isCreated)
{
//
mDrawnObjects.Add(iObj);
}
}
}
//
// Swing Highs ...
int swingHighsCount = ArraySize(structure.swingHighs);
if ((canAll || canLong) && IsValidSize(swingHighsCount))
{
//
for (int i = 0; i < swingHighsCount; i++)
{
//
XOHCL iBar = structure.swingHighs[i];
//
XCSwingHighObject *iObj;
bool isCreated = mPOIDrawer.CreateSwingHigh(
iBar,
iObj //
);
if (isCreated)
{
//
mDrawnObjects.Add(iObj);
}
}
}
//
// Swing Lows ...
int swingLowsCount = ArraySize(structure.swingLows);
if ((canAll || canShort) && IsValidSize(swingLowsCount))
{
//
for (int i = 0; i < swingLowsCount; i++)
{
//
XOHCL iBar = structure.swingLows[i];
//
XCSwingLowObject *iObj;
bool isCreated = mPOIDrawer.CreateSwingLow(
iBar,
iObj //
);
if (isCreated)
{
//
mDrawnObjects.Add(iObj);
}
}
}
//
// Support Zones ...
int supportsCount = ArraySize(structure.supports);
if ((canAll || canShort) && IsValidSize(supportsCount))
{
//
for (int i = 0; i < supportsCount; i++)
{
//
XOHCL iBar = structure.supports[i];
//
XCSupportZoneObject *iObj;
bool isCreated = mPOIDrawer.CreateSupportZone(
iBar,
iObj,
cTime //
);
if (isCreated)
{
//
mDrawnObjects.Add(iObj);
}
}
}
//
// Resistance Zones ...
int resistancesCount = ArraySize(structure.resistances);
if ((canAll || canLong) && IsValidSize(resistancesCount))
{
//
for (int i = 0; i < resistancesCount; i++)
{
//
XOHCL iBar = structure.resistances[i];
//
XCResistanceZoneObject *iObj;
bool isCreated = mPOIDrawer.CreateResistanceZone(
iBar,
iObj,
cTime //
);
if (isCreated)
{
//
mDrawnObjects.Add(iObj);
}
}
}
//
// Momentum Bars ...
//
// Bullish Momentum Bars ...
int momentumBarCount = ArraySize(structure.bullishMomentumBars);
if ((canAll || canShort) && IsValidSize(momentumBarCount))
{
//
for (int i = 0; i < momentumBarCount; i++)
{
//
XOHCL iBar = structure.bullishMomentumBars[i];
//
XCBullishMomentumBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishMomentumBar(
iBar,
iObj //
);
if (isCreated)
{
//
mDrawnObjects.Add(iObj);
}
}
}
//
// Bearish Momentum Bars ...
momentumBarCount = ArraySize(structure.bearishMomentumBars);
if ((canAll || canLong) && IsValidSize(momentumBarCount))
{
//
for (int i = 0; i < momentumBarCount; i++)
{
//
XOHCL iBar = structure.bearishMomentumBars[i];
//
XCBearishMomentumBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishMomentumBar(
iBar,
iObj //
);
if (isCreated)
{
//
mDrawnObjects.Add(iObj);
}
}
}
//
// Rejection Bars ...
//
// Bullish Rejection Bars ...
int rejectionBarCount = ArraySize(structure.bullishRejectionBars);
if ((canAll || canShort) && IsValidSize(rejectionBarCount))
{
//
for (int i = 0; i < rejectionBarCount; i++)
{
//
XOHCL iBar = structure.bullishRejectionBars[i];
//
XCBullishRejectionBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishRejectionBar(
iBar,
iObj //
);
if (isCreated)
{
//
mDrawnObjects.Add(iObj);
}
}
}
//
// Bearish Rejection Bars ...
rejectionBarCount = ArraySize(structure.bearishRejectionBars);
if ((canAll || canLong) && IsValidSize(rejectionBarCount))
{
//
for (int i = 0; i < rejectionBarCount; i++)
{
//
XOHCL iBar = structure.bearishRejectionBars[i];
//
XCBearishRejectionBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishRejectionBar(
iBar,
iObj //
);
if (isCreated)
{
//
mDrawnObjects.Add(iObj);
}
}
}
}