Prepare requirements, add DrwaState in X121SMCBaseStrategy class ...

This commit is contained in:
2024-11-15 13:44:05 +03:30
parent 069f899f8a
commit d5ead24335
6 changed files with 746 additions and 134 deletions
@@ -972,6 +972,452 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
mDrawnObjects.Add(iObj);
}
/**
* Draw Specified State on Chart ...
*
* @param state: XPOIState instance ...
*/
void DrawState(
XPOIState &state,
bool drawSwingHighs = true,
bool drawSwingLows = true,
bool drawSupportZones = true,
bool drawResistanceZones = true,
bool drawSupplyZones = true,
bool drawDemandZones = true,
bool drawBullishOrderBlocks = true,
bool drawBearishOrderBlocks = true,
bool drawBullishFairValueGaps = true,
bool drawBearishFairValueGaps = true,
bool drawBullishRejectionBars = true,
bool drawBearishRejectionBars = true,
bool drawBullishMomentumBars = true,
bool drawBearishMomentumBars = true //
)
{
//
int count = 0;
//
// Swings ...
//
// Swing Highs ...
if (drawSwingHighs)
{
//
count = ArraySize(state.swingHighs);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XCSwing item = state.swingHighs[i];
//
XCSwingHighObject *iObj;
bool isCreated = mPOIDrawer.CreateSwingHigh(
item,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
}
}
//
// Swing Lows ...
if (drawSwingLows)
{
//
count = ArraySize(state.swingLows);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XCSwing item = state.swingLows[i];
//
XCSwingLowObject *iObj;
bool isCreated = mPOIDrawer.CreateSwingLow(
item,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
}
}
//
// Support and Resistance Zones ...
//
// Support Zones ...
if (drawSupportZones)
{
//
count = ArraySize(state.supportZones);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XCSupportZone item = state.supportZones[i];
//
XCSupportZoneObject *iObj;
bool isCreated = mPOIDrawer.CreateSupportZone(
item,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
}
}
//
// Resistance Zones ...
if (drawResistanceZones)
{
//
count = ArraySize(state.resistanceZones);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XCResistanceZone item = state.resistanceZones[i];
//
XCResistanceZoneObject *iObj;
bool isCreated = mPOIDrawer.CreateResistanceZone(
item,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
}
}
//
// Supply and Demand Zones ...
//
// Supply Zones ...
if (drawSupplyZones)
{
//
count = ArraySize(state.supplyZones);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XCSupplyZone item = state.supplyZones[i];
//
XCSupplyZoneObject *iObj;
bool isCreated = mPOIDrawer.CreateSupplyZone(
item,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
}
}
//
// Demand Zones ...
if (drawDemandZones)
{
//
count = ArraySize(state.demandZones);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XCDemandZone item = state.demandZones[i];
//
XCDemandZoneObject *iObj;
bool isCreated = mPOIDrawer.CreateDemandZone(
item,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
}
}
//
// Order Blocks ...
//
// Bullish Order Blocks ...
if (drawBullishOrderBlocks)
{
//
count = ArraySize(state.bullishOrderBlocks);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XCOrderBlock item = state.bullishOrderBlocks[i];
//
XCBullishOrderBlockObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishOrderBlock(
item,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
}
}
//
// Bearish Order Blocks ...
if (drawBearishOrderBlocks)
{
//
count = ArraySize(state.bearishOrderBlocks);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XCOrderBlock item = state.bearishOrderBlocks[i];
//
XCBearishOrderBlockObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishOrderBlock(
item,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
}
}
//
// Fair Value Gaps ...
//
// Bullish Fair Value Gaps ...
if (drawBullishFairValueGaps)
{
//
count = ArraySize(state.bullishFairValueGaps);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XCFVG item = state.bullishFairValueGaps[i];
//
XCBullishFairValueGapObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishFairValueGap(
item,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
}
}
//
// Bearish Fair Value Gaps ...
if (drawBearishFairValueGaps)
{
//
count = ArraySize(state.bearishFairValueGaps);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XCFVG item = state.bearishFairValueGaps[i];
//
XCBearishFairValueGapObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishFairValueGap(
item,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
}
}
//
// Rejection Bars ...
//
// Bullish Rejection Bars ...
if (drawBullishRejectionBars)
{
//
count = ArraySize(state.bullishRejectionBars);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XCRejectionBar item = state.bullishRejectionBars[i];
//
XCBullishRejectionBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishRejectionBar(
item,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
}
}
//
// Bearish Rejection Bars ...
if (drawBearishRejectionBars)
{
//
count = ArraySize(state.bearishRejectionBars);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XCRejectionBar item = state.bearishRejectionBars[i];
//
XCBearishRejectionBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishRejectionBar(
item,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
}
}
//
// Momentum Bars ...
//
// Bullish Momentum Bars ...
if (drawBullishMomentumBars)
{
//
count = ArraySize(state.bullishMomentumBars);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XCMomentumBar item = state.bullishMomentumBars[i];
//
XCBullishMomentumBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBullishMomentumBar(
item,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
}
}
//
// Bearish Momentum Bars ...
if (drawBearishMomentumBars)
{
//
count = ArraySize(state.bearishMomentumBars);
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
XCMomentumBar item = state.bearishMomentumBars[i];
//
XCBearishMomentumBarObject *iObj;
bool isCreated = mPOIDrawer.CreateBearishMomentumBar(
item,
iObj //
);
if (isCreated)
{
AddObjectIfNotExists(iObj);
}
}
}
}
//
// Ticks Zone ...
if (state.ticksZone != NULL)
{
}
}
//
// Private ...
private:
@@ -1236,6 +1682,42 @@ class XCX121SMCBaseStrategy : public XCBaseAlert
}
}
/**
* Add Specified Object to Drawn Objects if not Exists ...
*/
void AddObjectIfNotExists(XCBaseObject *object)
{
//
string name = object.ObjName();
//
bool canAdd = true;
int count = mDrawnObjects.Total();
if (IsValidSize(count))
{
//
for (int i = 0; i < count; i++)
{
//
string iName = ((XCBaseObject *)mDrawnObjects.At(i)).ObjName();
//
if (name == iName)
{
//
canAdd = false;
break;
}
}
}
//
if (canAdd)
{
mDrawnObjects.Add(object);
}
}
//
};
@@ -835,6 +835,7 @@ class XC121SMCExpert : public XCBaseExpert
strategy.R2R(2);
strategy.AllowLong(AllowLong());
strategy.AllowShort(AllowShort());
strategy.MaxAllowedSpread(20);
//
if (Disabled())
@@ -176,6 +176,12 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
//
// Try to Implement SMC Based Conditions ...
ENUM_X_DIRECTION dir = X_DIRECTION_NONE;
result = DetectConditions(dir);
if (!result)
{
return result;
}
//
result = hasLong ||
@@ -307,6 +313,58 @@ class XCX121SMCTestStrategy : public XCX121SMCBaseStrategy
X3VWAPInputs x3vwapInputs;
XCX3VWAPHelper *x3vwapHelper;
//
// Actions ...
bool DetectConditions(ENUM_X_DIRECTION &dir)
{
//
bool result = false;
//
mConditions.Clean();
mConditions.symbol = GetSymbol();
mConditions.period = GetPeriod();
mConditions.time = TimeCurrent();
//
dir = X_DIRECTION_NONE;
//
// TODO: Implement ...
ENUM_X_DIRECTION marketStructureDir;
result = DetectMarketStructure(
marketStructureDir,
_5MState //
);
//
if (!result)
{
mConditions.Clean();
}
//
return result;
}
bool DetectMarketStructure(
ENUM_X_DIRECTION &dir,
XPOIState &state //
) {
//
bool result = false;
//
DrawState(state);
//
Print("Salam");
//
return result;
}
//
// Private ...
private: