This commit is contained in:
2025-01-08 17:32:36 +03:30
parent 73f39629fb
commit 9158a6cc6d
6 changed files with 1535 additions and 322 deletions
+62 -89
View File
@@ -4479,7 +4479,7 @@ class XCPOIDrawer : public XCBase
* @return ( int )
*/
int DrawFVGOrderBlock(
XFVGOrderBlock &models[],
XFVGOrderBlock &model,
XCBaseObject *&drawnObjects[] //
)
{
@@ -4490,115 +4490,88 @@ class XCPOIDrawer : public XCBase
Clean(drawnObjects);
//
int count = ArraySize(models);
if (!IsValidSize(count))
if (!model.IsValid())
{
return result;
}
//
for (int i = 0; i < count; i++)
ENUM_X_DIRECTION iDir;
result = model.GetDirection(iDir);
if (!result)
{
return result;
}
//
bool isBullish = IsBullish(iDir);
if (isBullish)
{
//
XFVGOrderBlock iModel = models[i];
//
ENUM_X_DIRECTION iDir;
bool hasDirection = iModel.GetDirection(iDir);
if (!hasDirection)
// Order Block ...
XCBullishOrderBlockObject *iOBObj;
bool isCreated = CreateBullishOrderBlock(
model.orderBlock,
iOBObj //
);
if (isCreated)
{
continue;
//
Add(
(XCBaseObject *)iOBObj,
drawnObjects //
);
}
//
bool isBullish = IsBullish(iDir);
//
if (isBullish)
// FVG ...
XCBullishFairValueGapObject *iFVGObj;
isCreated = CreateBullishFairValueGap(
model.fairValueGap,
iFVGObj //
);
if (isCreated)
{
//
// Order Block ...
XCBullishOrderBlockObject *iOBObj;
bool isCreated = CreateBullishOrderBlock(
iModel.orderBlock,
iOBObj //
Add(
(XCBaseObject *)iOBObj,
drawnObjects //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iOBObj,
drawnObjects //
);
}
//
// FVG ...
XCBullishFairValueGapObject *iFVGObj;
isCreated = CreateBullishFairValueGap(
iModel.fairValueGap,
iFVGObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iOBObj,
drawnObjects //
);
}
}
else
}
else
{
//
// Order Block ...
XCBearishOrderBlockObject *iOBObj;
bool isCreated = CreateBearishOrderBlock(
model.orderBlock,
iOBObj //
);
if (isCreated)
{
//
// Order Block ...
XCBearishOrderBlockObject *iOBObj;
bool isCreated = CreateBearishOrderBlock(
iModel.orderBlock,
iOBObj //
Add(
(XCBaseObject *)iOBObj,
drawnObjects //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iOBObj,
drawnObjects //
);
}
//
// FVG ...
XCBearishFairValueGapObject *iFVGObj;
isCreated = CreateBearishFairValueGap(
iModel.fairValueGap,
iFVGObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iFVGObj,
drawnObjects //
);
}
}
//
// Price Zone ...
// XCBaseObject *stateZoneObjects[];
// int stateZoneObjectsCount = DrawStateZones(
// iModel.stateZones,
// stateZoneObjects //
// );
// if (IsValidSize(stateZoneObjectsCount))
// {
// //
// Copy(
// stateZoneObjects,
// drawnObjects,
// false // Force Clean ...
// );
// }
// FVG ...
XCBearishFairValueGapObject *iFVGObj;
isCreated = CreateBearishFairValueGap(
model.fairValueGap,
iFVGObj //
);
if (isCreated)
{
//
Add(
(XCBaseObject *)iFVGObj,
drawnObjects //
);
}
}
//
File diff suppressed because it is too large Load Diff
+106 -30
View File
@@ -6425,6 +6425,110 @@ struct XFVGOrderBlock
//
return result;
}
/**
* Retrieve Boundary of Zone ...
*
* @param upper: Upper Boundary ...ّ
* @param lower: Lower Bondary ...
* @return ( bool )
*/
bool GetBoundary(
double &upper,
double &lower //
)
{
//
bool result = false;
//
upper = 0;
lower = 0;
//
result = IsValid();
if (!result)
{
return result;
}
//
upper = orderBlock.Upper();
upper = MathMax(upper, fairValueGap.Upper());
//
lower = orderBlock.Lower();
lower = MathMax(lower, fairValueGap.Lower());
//
result = lower > 0 &&
upper > 0 &&
upper > lower;
//
return result;
}
/**
* Check Model is same as another Istance ...
*
* @param value: XFVGOrderBlock instance Reference ...
*
* @return ( bool )
*/
bool IsSameAs(XFVGOrderBlock &value)
{
//
bool result = false;
//
result =
IsValid() &&
value.IsValid();
if (!result)
{
return result;
}
//
ENUM_X_DIRECTION dir;
result = GetDirection(dir);
if (!result)
{
return result;
}
//
ENUM_X_DIRECTION valueDir;
result = value.GetDirection(valueDir);
if (!result)
{
return result;
}
//
result =
//
dir = valueDir
//
&&
//
orderBlock.From() == value.orderBlock.From() &&
orderBlock.Upper() == value.orderBlock.Upper() &&
orderBlock.Lower() == value.orderBlock.Lower()
//
&&
//
fairValueGap.From() == value.fairValueGap.From() &&
fairValueGap.Upper() == value.fairValueGap.Upper() &&
fairValueGap.Lower() == value.fairValueGap.Lower()
//
;
//
return result;
}
//
};
//
@@ -8819,7 +8923,7 @@ bool CalculateStateZones(
}
}
}
//
result = zones.IsValid();
@@ -9055,15 +9159,9 @@ bool IsPriceAboveZone(
return result;
}
//
double ask = GetAsk(bar.symbol);
double bid = GetBid(bar.symbol);
//
result =
//
ask > zone.Upper() &&
bid > zone.Upper() &&
bar.low > zone.Upper()
//
;
@@ -9131,16 +9229,10 @@ bool IsPriceBelowZone(
return result;
}
//
double ask = GetAsk(bar.symbol);
double bid = GetBid(bar.symbol);
//
result =
//
ask < zone.Lower() &&
bid < zone.Lower() &&
bar.low < zone.Lower()
bar.high < zone.Lower()
//
;
@@ -9207,21 +9299,13 @@ bool IsPriceInsideZone(
return result;
}
//
double ask = GetAsk(bar.symbol);
double bid = GetBid(bar.symbol);
//
result =
//
ask <= zone.Upper() &&
bid <= zone.Upper() &&
bar.low <= zone.Upper()
//
&&
//
ask >= zone.Lower() &&
bid >= zone.Lower() &&
bar.low >= zone.Lower()
//
;
@@ -9249,21 +9333,13 @@ bool IsPriceInsideZone(
return result;
}
//
double ask = GetAsk(bar.symbol);
double bid = GetBid(bar.symbol);
//
result =
//
ask <= upper &&
bid <= upper &&
bar.low <= upper
//
&&
//
ask >= lower &&
bid >= lower &&
bar.low >= lower
//
;
+12 -8
View File
@@ -1326,15 +1326,19 @@ class XC121SMCExpert : public XCBaseExpert
//
// Check Force Close ...
string forceCloseTimeStr = CloseAllTradesAt();
datetime forceCloseTime = ParseDateTimeFromTimeString(forceCloseTimeStr);
bool canForceClose = IsTimeInRange(
TimeCurrent(),
forceCloseTime //
) &&
!mIsForceCloseAtTime;
if (canForceClose)
if (IsValid(forceCloseTimeStr))
{
mIsForceCloseAtTime = mTradeHandler.ForceClose();
//
datetime forceCloseTime = ParseDateTimeFromTimeString(forceCloseTimeStr);
bool canForceClose = IsTimeInRange(
TimeCurrent(),
forceCloseTime //
) &&
!mIsForceCloseAtTime;
if (canForceClose)
{
mIsForceCloseAtTime = mTradeHandler.ForceClose();
}
}
//
+142 -122
View File
@@ -49,8 +49,7 @@ struct X121SMCStrategyXTWPVSignalConditions
datetime triggerTime;
//
XFVGOrderBlock bullishOrderBlocks[];
XFVGOrderBlock bearishOrderBlocks[];
XFVGOrderBlock fvgOB;
//
// Constructor ...
@@ -166,40 +165,20 @@ struct X121SMCStrategyXTWPVSignalConditions
*/
void ExtensionClean()
{
//
Clean(bullishOrderBlocks);
Clean(bearishOrderBlocks);
fvgOB.Clean();
}
/**
* Update Order Blocks Date ...
*/
void UpdateOrderBlocks() {
void UpdateOrderBlocks()
{
//
int count = 0;
datetime cTime = TimeCurrent();
//
count = ArraySize(bullishOrderBlocks);
if (IsValidSize(count)) {
//
for (int i = 0; i < count; i++) {
//
bullishOrderBlocks[i].orderBlock.To(cTime);
bullishOrderBlocks[i].fairValueGap.To(cTime);
}
}
//
count = ArraySize(bearishOrderBlocks);
if (IsValidSize(count)) {
//
for (int i = 0; i < count; i++) {
//
bearishOrderBlocks[i].orderBlock.To(cTime);
bearishOrderBlocks[i].fairValueGap.To(cTime);
}
}
fvgOB.orderBlock.To(cTime);
fvgOB.fairValueGap.To(cTime);
}
//
@@ -447,14 +426,14 @@ bool DetectX121SMCXTWPVSiganlSetup(
//
conditions.dir = forDir;
Copy(
bullishOrderBlocks,
conditions.bullishOrderBlocks //
);
Copy(
bearishOrderBlocks,
conditions.bearishOrderBlocks //
);
if (isBullish)
{
conditions.fvgOB = bullishOrderBlocks[0];
}
else
{
conditions.fvgOB = bearishOrderBlocks[0];
}
//
conditions.setupTime = cTime;
@@ -483,7 +462,7 @@ bool DetectX121SMCXTWPVSiganlTrigger(
XC121SMCCycleHelper *consolidationCycleHelper,
XC121SMCCycleHelper *visionCycleHelper,
//
int maxAllowedSetupAge = 0 //
int maxAllowedSetupAge = 576 //
//
)
{
@@ -684,86 +663,44 @@ bool DetectX121SMCXTWPVSiganlTrigger(
//
// Trigger Conditions ...
//
double decisionPeak = decisionConditions.x121Conditions.peaksBuffer[1];
double isNewDecisionPeak = decisionConditions.x121Conditions.isNewPeak;
//
double decisionVale = decisionConditions.x121Conditions.valesBuffer[1];
double isNewDecisionVale = decisionConditions.x121Conditions.isNewVale;
//
// Waits For Price to Go Inside FVG ...
XFVGOrderBlock fvgOrderBlock;
bool isPriceInsideOB = false;
bool isPriceInsideFVG = false;
if (isBullish)
{
//
int count = ArraySize(conditions.bullishOrderBlocks);
for (int i = 0; i < count; i++)
{
//
XFVGOrderBlock iModel = conditions.bullishOrderBlocks[i];
bool isPriceInsideOB = IsPriceInsideZone(
cBar,
conditions.fvgOB.orderBlock //
);
//
isPriceInsideOB = IsPriceInsideZone(
cBar,
iModel.orderBlock //
);
//
isPriceInsideFVG = IsPriceInsideZone(
cBar,
iModel.fairValueGap //
);
//
if (isPriceInsideOB &&
isPriceInsideFVG)
{
//
fvgOrderBlock = iModel;
break;
}
//
isPriceInsideOB = false;
isPriceInsideFVG = false;
}
}
else
{
//
int count = ArraySize(conditions.bearishOrderBlocks);
for (int i = 0; i < count; i++)
{
//
XFVGOrderBlock iModel = conditions.bearishOrderBlocks[i];
//
isPriceInsideOB = IsPriceInsideZone(
cBar,
iModel.orderBlock //
);
//
isPriceInsideFVG = IsPriceInsideZone(
cBar,
iModel.fairValueGap //
);
//
if (isPriceInsideOB &&
isPriceInsideFVG)
{
//
fvgOrderBlock = iModel;
break;
}
//
isPriceInsideOB = false;
isPriceInsideFVG = false;
}
}
//
bool isPriceInsideFVG = IsPriceInsideZone(
cBar,
conditions.fvgOB.fairValueGap //
);
//
result = isPriceInsideOB &&
isPriceInsideFVG &&
fvgOrderBlock.IsValid();
conditions.fvgOB.IsValid();
if (!result)
{
return result;
}
//
double fvgOBUpper = 0;
double fvgOBLower = 0;
bool hasBoundary = conditions.fvgOB.GetBoundary(
fvgOBUpper,
fvgOBLower //
);
result = hasBoundary;
if (!result)
{
return result;
@@ -773,13 +710,15 @@ bool DetectX121SMCXTWPVSiganlTrigger(
// Detect Bullish Conditions ...
isBullish =
isBullish &&
cBar.IsBullish();
cBar.IsBullish() &&
isNewDecisionVale;
//
// Detect Bearish Conditions ...
isBearish =
isBearish &&
cBar.IsBearish();
cBar.IsBearish() &&
isNewDecisionPeak;
//
result = isBullish ||
@@ -788,13 +727,6 @@ bool DetectX121SMCXTWPVSiganlTrigger(
{
//
// Cleanup Setup Conditions ...
// int setupAge = conditions.GetSetupAge();
// if (IsValidSize(setupAge) &&
// IsValidSize(maxAllowedSetupAge) &&
// setupAge >= maxAllowedSetupAge)
// {
// conditions.Clean();
// }
//
return result;
@@ -844,6 +776,22 @@ bool DetectX121SMCXTWPVSiganlTrigger(
double peak = triggerConditions.x121Conditions.peaksBuffer[1];
double vale = triggerConditions.x121Conditions.valesBuffer[1];
//
if (conditions.fvgOB.IsValid())
{
//
Add(
fvgOBUpper,
sls //
);
//
Add(
fvgOBLower,
sls //
);
}
//
if (isBullish)
{
@@ -857,6 +805,12 @@ bool DetectX121SMCXTWPVSiganlTrigger(
sls //
);
}
//
Add(
vale,
sls //
);
}
else if (isBearish)
{
@@ -870,11 +824,12 @@ bool DetectX121SMCXTWPVSiganlTrigger(
sls //
);
}
}
//
if (ArraySize(sls) == 0)
{
//
Add(
peak,
sls //
);
}
//
@@ -927,6 +882,71 @@ bool DetectX121SMCXTWPVSiganlTrigger(
return result;
}
//
int AddX121SMCXTWPVConditionsIfNotExists(
X121SMCStrategyXTWPVSignalConditions &item,
X121SMCStrategyXTWPVSignalConditions &items[] //
)
{
//
int result = 0;
//
bool isSetuped = IsValid(item.setupTime) &&
HasDirection(item.dir);
if (!isSetuped)
{
return result;
}
//
int count = ArraySize(items);
bool canAdd = !IsValidSize(count);
if (!canAdd)
{
//
// Prese Item Data ...
bool isBullish = IsBullish(item.dir);
//
bool hasSame = false;
for (int i = 0; i < count; i++)
{
//
X121SMCStrategyXTWPVSignalConditions iItem = items[i];
//
hasSame = iItem.fvgOB.IsSameAs(item.fvgOB);
if (hasSame)
{
break;
}
}
//
canAdd = !hasSame;
}
//
if (canAdd)
{
//
AddRef(
item,
items //
);
//
// Remove Olds ...
//
result = ArraySize(items);
}
//
return result;
}
//
// Draw Signal ...
int DrawX121SMCXTWPVSiganl(
+130 -73
View File
@@ -478,6 +478,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// XTWPV Signal ...
X121SMCStrategyXTWPVSignalConditions mXTWPVConditions;
X121SMCStrategyXTWPVSignalConditions mXTWPVConditionsCollection[];
bool DetectXTWPVSignal(
X121SMCStrategyConditions &conditions //
)
@@ -489,10 +490,52 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
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;
}
//
datetime cTime = TimeCurrent();
@@ -524,81 +567,111 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
setupDir = mXTWPVConditions.dir;
setupTime = mXTWPVConditions.setupTime;
}
//
if (isSetuped)
{
//
mXTWPVConditions.UpdateOrderBlocks();
//
XCBaseObject *bullDrawnObjects[];
int bullDrawnObjectsCount = mPOIDrawer.DrawFVGOrderBlock(
mXTWPVConditions.bullishOrderBlocks,
bullDrawnObjects //
);
if (IsValidSize(bullDrawnObjectsCount))
if (isSetuped)
{
AddObjectsIfNotExists(bullDrawnObjects);
}
//
AddRef(
mXTWPVConditions,
mXTWPVConditionsCollection);
//
XCBaseObject *bearDrawnObjects[];
int bearDrwanObjectsCount = mPOIDrawer.DrawFVGOrderBlock(
mXTWPVConditions.bearishOrderBlocks,
bearDrawnObjects //
);
if (IsValidSize(bearDrwanObjectsCount))
{
AddObjectsIfNotExists(bearDrawnObjects);
//
mXTWPVConditions.Clean();
}
}
//
result = isSetuped;
int conditionsCount = ArraySize(mXTWPVConditionsCollection);
result = IsValidSize(conditionsCount);
if (!result)
{
return result;
}
//
// Detect Trigger Conditions ...
bool canTrigger = mXTWPVConditions.CanTrigger();
datetime triggerTime = mXTWPVConditions.triggerTime;
if (!canTrigger)
// Looking For Conditions ...
int selectedIndex = 0;
X121SMCStrategyXTWPVSignalConditions mConditions;
for (int i = 0; i < conditionsCount; i++)
{
//
// Detect Signal Trigger ...
canTrigger = DetectX121SMCXTWPVSiganlTrigger(
mXTWPVConditions,
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
// Update Conditions ...
mXTWPVConditionsCollection[i].UpdateOrderBlocks();
//
result = canTrigger;
if (!result)
// Draw Conditions ...
//
XFVGOrderBlock iFVGOB = mXTWPVConditionsCollection[i].fvgOB;
XCBaseObject *drawnObjects[];
mPOIDrawer.DrawFVGOrderBlock(
iFVGOB,
drawnObjects //
);
AddObjectsIfNotExists(drawnObjects);
//
// Check Triggers ...
bool canTrigger = mXTWPVConditionsCollection[i].CanTrigger();
datetime triggerTime = mXTWPVConditionsCollection[i].triggerTime;
if (!canTrigger)
{
return result;
//
// Detect Signal Trigger ...
canTrigger = DetectX121SMCXTWPVSiganlTrigger(
mXTWPVConditionsCollection[i],
symbol,
period,
mTriggerCycleHelper,
mDecisionCycleHelper,
mAnalyseCycleHelper,
mVerificationCycleHelper,
mConsolidationCycleHelper,
mVisionCycleHelper //
);
//
result = canTrigger;
if (!result)
{
return result;
}
//
triggerTime = mXTWPVConditionsCollection[i].triggerTime;
}
//
triggerTime = mXTWPVConditions.triggerTime;
if (canTrigger)
{
//
selectedIndex = i;
mConditions = mXTWPVConditionsCollection[i];
break;
}
}
//
// Check Signal Direction ...
result = IsValid(mConditions.setupTime) &&
HasDirection(mConditions.dir);
if (!result)
{
return result;
}
//
isBullish = IsBullish(setupDir);
isBearish = IsBearish(setupDir);
// Remove Selected Index from Main Collection ...
ArrayRemove(
mXTWPVConditionsCollection,
selectedIndex,
1 //
);
//
// Check Signal Direction ...
isBullish = IsBullish(mConditions.dir);
isBearish = IsBearish(mConditions.dir);
result = isBullish ||
isBearish;
if (!result)
@@ -608,26 +681,10 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// Issues Signal on Conditions ...
conditions.signalDir = setupDir;
conditions.sl = mConditions.sl;
conditions.provider = providerStr;
conditions.sl = mXTWPVConditions.sl;
conditions.target = mXTWPVConditions.target;
//
// TODO: Remove ...
// conditions.decisionZones = mXTWPVConditions.decisionZone;
// conditions.marketStructure = mXTWPVConditions.analyseMarketStructure;
// if (isBullish)
// {
// conditions.priceZones = mXTWPVConditions.valePriceZone;
// }
// else
// {
// conditions.priceZones = mXTWPVConditions.peakPriceZone;
// }
//
mXTWPVConditions.Clean();
conditions.signalDir = mConditions.dir;
conditions.target = mConditions.target;
//
return result;
@@ -685,7 +742,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
x121Inputs.Default();
//
x121Inputs.showRSI = false;
x121Inputs.showRSI = true;
//
bool isInited = false;
@@ -710,14 +767,14 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// XATR ...
x121Inputs.xatrInputs.showATRUpper = true;
x121Inputs.xatrInputs.showATRLower = true;
x121Inputs.xatrInputs.showATRUpper = false;
x121Inputs.xatrInputs.showATRLower = false;
//
// XSTR ...
x121Inputs.xstrInputs.showStr = true;
x121Inputs.xstrInputs.showStrUpper = true;
x121Inputs.xstrInputs.showStrLower = true;
x121Inputs.xstrInputs.showStrUpper = false;
x121Inputs.xstrInputs.showStrLower = false;
//
// XDON ...
@@ -729,7 +786,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
//
// XVWAP ...
x121Inputs.xvwapInputs.showVWapFast = false;
x121Inputs.xvwapInputs.showVWapFast = false;
x121Inputs.xvwapInputs.showVWapMedium = false;
x121Inputs.xvwapInputs.showVWapSlow = false;
//