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
+9 -36
View File
@@ -4479,7 +4479,7 @@ class XCPOIDrawer : public XCBase
* @return ( int ) * @return ( int )
*/ */
int DrawFVGOrderBlock( int DrawFVGOrderBlock(
XFVGOrderBlock &models[], XFVGOrderBlock &model,
XCBaseObject *&drawnObjects[] // XCBaseObject *&drawnObjects[] //
) )
{ {
@@ -4490,37 +4490,28 @@ class XCPOIDrawer : public XCBase
Clean(drawnObjects); Clean(drawnObjects);
// //
int count = ArraySize(models); if (!model.IsValid())
if (!IsValidSize(count))
{ {
return result; return result;
} }
//
for (int i = 0; i < count; i++)
{
//
XFVGOrderBlock iModel = models[i];
// //
ENUM_X_DIRECTION iDir; ENUM_X_DIRECTION iDir;
bool hasDirection = iModel.GetDirection(iDir); result = model.GetDirection(iDir);
if (!hasDirection) if (!result)
{ {
continue; return result;
} }
// //
bool isBullish = IsBullish(iDir); bool isBullish = IsBullish(iDir);
//
if (isBullish) if (isBullish)
{ {
// //
// Order Block ... // Order Block ...
XCBullishOrderBlockObject *iOBObj; XCBullishOrderBlockObject *iOBObj;
bool isCreated = CreateBullishOrderBlock( bool isCreated = CreateBullishOrderBlock(
iModel.orderBlock, model.orderBlock,
iOBObj // iOBObj //
); );
if (isCreated) if (isCreated)
@@ -4536,7 +4527,7 @@ class XCPOIDrawer : public XCBase
// FVG ... // FVG ...
XCBullishFairValueGapObject *iFVGObj; XCBullishFairValueGapObject *iFVGObj;
isCreated = CreateBullishFairValueGap( isCreated = CreateBullishFairValueGap(
iModel.fairValueGap, model.fairValueGap,
iFVGObj // iFVGObj //
); );
if (isCreated) if (isCreated)
@@ -4554,7 +4545,7 @@ class XCPOIDrawer : public XCBase
// Order Block ... // Order Block ...
XCBearishOrderBlockObject *iOBObj; XCBearishOrderBlockObject *iOBObj;
bool isCreated = CreateBearishOrderBlock( bool isCreated = CreateBearishOrderBlock(
iModel.orderBlock, model.orderBlock,
iOBObj // iOBObj //
); );
if (isCreated) if (isCreated)
@@ -4570,7 +4561,7 @@ class XCPOIDrawer : public XCBase
// FVG ... // FVG ...
XCBearishFairValueGapObject *iFVGObj; XCBearishFairValueGapObject *iFVGObj;
isCreated = CreateBearishFairValueGap( isCreated = CreateBearishFairValueGap(
iModel.fairValueGap, model.fairValueGap,
iFVGObj // iFVGObj //
); );
if (isCreated) if (isCreated)
@@ -4583,24 +4574,6 @@ class XCPOIDrawer : public XCBase
} }
} }
//
// Price Zone ...
// XCBaseObject *stateZoneObjects[];
// int stateZoneObjectsCount = DrawStateZones(
// iModel.stateZones,
// stateZoneObjects //
// );
// if (IsValidSize(stateZoneObjectsCount))
// {
// //
// Copy(
// stateZoneObjects,
// drawnObjects,
// false // Force Clean ...
// );
// }
}
// //
result = ArraySize(drawnObjects); result = ArraySize(drawnObjects);
File diff suppressed because it is too large Load Diff
+105 -29
View File
@@ -6425,6 +6425,110 @@ struct XFVGOrderBlock
// //
return result; 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;
}
//
}; };
// //
@@ -9055,15 +9159,9 @@ bool IsPriceAboveZone(
return result; return result;
} }
//
double ask = GetAsk(bar.symbol);
double bid = GetBid(bar.symbol);
// //
result = result =
// //
ask > zone.Upper() &&
bid > zone.Upper() &&
bar.low > zone.Upper() bar.low > zone.Upper()
// //
; ;
@@ -9131,16 +9229,10 @@ bool IsPriceBelowZone(
return result; return result;
} }
//
double ask = GetAsk(bar.symbol);
double bid = GetBid(bar.symbol);
// //
result = result =
// //
ask < zone.Lower() && bar.high < zone.Lower()
bid < zone.Lower() &&
bar.low < zone.Lower()
// //
; ;
@@ -9207,21 +9299,13 @@ bool IsPriceInsideZone(
return result; return result;
} }
//
double ask = GetAsk(bar.symbol);
double bid = GetBid(bar.symbol);
// //
result = result =
// //
ask <= zone.Upper() &&
bid <= zone.Upper() &&
bar.low <= zone.Upper() bar.low <= zone.Upper()
// //
&& &&
// //
ask >= zone.Lower() &&
bid >= zone.Lower() &&
bar.low >= zone.Lower() bar.low >= zone.Lower()
// //
; ;
@@ -9249,21 +9333,13 @@ bool IsPriceInsideZone(
return result; return result;
} }
//
double ask = GetAsk(bar.symbol);
double bid = GetBid(bar.symbol);
// //
result = result =
// //
ask <= upper &&
bid <= upper &&
bar.low <= upper bar.low <= upper
// //
&& &&
// //
ask >= lower &&
bid >= lower &&
bar.low >= lower bar.low >= lower
// //
; ;
@@ -1326,6 +1326,9 @@ class XC121SMCExpert : public XCBaseExpert
// //
// Check Force Close ... // Check Force Close ...
string forceCloseTimeStr = CloseAllTradesAt(); string forceCloseTimeStr = CloseAllTradesAt();
if (IsValid(forceCloseTimeStr))
{
//
datetime forceCloseTime = ParseDateTimeFromTimeString(forceCloseTimeStr); datetime forceCloseTime = ParseDateTimeFromTimeString(forceCloseTimeStr);
bool canForceClose = IsTimeInRange( bool canForceClose = IsTimeInRange(
TimeCurrent(), TimeCurrent(),
@@ -1336,6 +1339,7 @@ class XC121SMCExpert : public XCBaseExpert
{ {
mIsForceCloseAtTime = mTradeHandler.ForceClose(); mIsForceCloseAtTime = mTradeHandler.ForceClose();
} }
}
// //
// Update Positions Data ... // Update Positions Data ...
+136 -116
View File
@@ -49,8 +49,7 @@ struct X121SMCStrategyXTWPVSignalConditions
datetime triggerTime; datetime triggerTime;
// //
XFVGOrderBlock bullishOrderBlocks[]; XFVGOrderBlock fvgOB;
XFVGOrderBlock bearishOrderBlocks[];
// //
// Constructor ... // Constructor ...
@@ -166,40 +165,20 @@ struct X121SMCStrategyXTWPVSignalConditions
*/ */
void ExtensionClean() void ExtensionClean()
{ {
// fvgOB.Clean();
Clean(bullishOrderBlocks);
Clean(bearishOrderBlocks);
} }
/** /**
* Update Order Blocks Date ... * Update Order Blocks Date ...
*/ */
void UpdateOrderBlocks() { void UpdateOrderBlocks()
{
// //
int count = 0;
datetime cTime = TimeCurrent(); datetime cTime = TimeCurrent();
// //
count = ArraySize(bullishOrderBlocks); fvgOB.orderBlock.To(cTime);
if (IsValidSize(count)) { fvgOB.fairValueGap.To(cTime);
//
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);
}
}
} }
// //
@@ -447,14 +426,14 @@ bool DetectX121SMCXTWPVSiganlSetup(
// //
conditions.dir = forDir; conditions.dir = forDir;
Copy( if (isBullish)
bullishOrderBlocks, {
conditions.bullishOrderBlocks // conditions.fvgOB = bullishOrderBlocks[0];
); }
Copy( else
bearishOrderBlocks, {
conditions.bearishOrderBlocks // conditions.fvgOB = bearishOrderBlocks[0];
); }
// //
conditions.setupTime = cTime; conditions.setupTime = cTime;
@@ -483,7 +462,7 @@ bool DetectX121SMCXTWPVSiganlTrigger(
XC121SMCCycleHelper *consolidationCycleHelper, XC121SMCCycleHelper *consolidationCycleHelper,
XC121SMCCycleHelper *visionCycleHelper, XC121SMCCycleHelper *visionCycleHelper,
// //
int maxAllowedSetupAge = 0 // int maxAllowedSetupAge = 576 //
// //
) )
{ {
@@ -684,86 +663,44 @@ bool DetectX121SMCXTWPVSiganlTrigger(
// //
// Trigger Conditions ... // 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 ... // Waits For Price to Go Inside FVG ...
XFVGOrderBlock fvgOrderBlock; bool isPriceInsideOB = IsPriceInsideZone(
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];
//
isPriceInsideOB = IsPriceInsideZone(
cBar, cBar,
iModel.orderBlock // conditions.fvgOB.orderBlock //
); );
// //
isPriceInsideFVG = IsPriceInsideZone( bool isPriceInsideFVG = IsPriceInsideZone(
cBar, cBar,
iModel.fairValueGap // conditions.fvgOB.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;
}
}
// //
result = isPriceInsideOB && result = isPriceInsideOB &&
isPriceInsideFVG && 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) if (!result)
{ {
return result; return result;
@@ -773,13 +710,15 @@ bool DetectX121SMCXTWPVSiganlTrigger(
// Detect Bullish Conditions ... // Detect Bullish Conditions ...
isBullish = isBullish =
isBullish && isBullish &&
cBar.IsBullish(); cBar.IsBullish() &&
isNewDecisionVale;
// //
// Detect Bearish Conditions ... // Detect Bearish Conditions ...
isBearish = isBearish =
isBearish && isBearish &&
cBar.IsBearish(); cBar.IsBearish() &&
isNewDecisionPeak;
// //
result = isBullish || result = isBullish ||
@@ -788,13 +727,6 @@ bool DetectX121SMCXTWPVSiganlTrigger(
{ {
// //
// Cleanup Setup Conditions ... // Cleanup Setup Conditions ...
// int setupAge = conditions.GetSetupAge();
// if (IsValidSize(setupAge) &&
// IsValidSize(maxAllowedSetupAge) &&
// setupAge >= maxAllowedSetupAge)
// {
// conditions.Clean();
// }
// //
return result; return result;
@@ -844,6 +776,22 @@ bool DetectX121SMCXTWPVSiganlTrigger(
double peak = triggerConditions.x121Conditions.peaksBuffer[1]; double peak = triggerConditions.x121Conditions.peaksBuffer[1];
double vale = triggerConditions.x121Conditions.valesBuffer[1]; double vale = triggerConditions.x121Conditions.valesBuffer[1];
//
if (conditions.fvgOB.IsValid())
{
//
Add(
fvgOBUpper,
sls //
);
//
Add(
fvgOBLower,
sls //
);
}
// //
if (isBullish) if (isBullish)
{ {
@@ -857,6 +805,12 @@ bool DetectX121SMCXTWPVSiganlTrigger(
sls // sls //
); );
} }
//
Add(
vale,
sls //
);
} }
else if (isBearish) else if (isBearish)
{ {
@@ -870,11 +824,12 @@ bool DetectX121SMCXTWPVSiganlTrigger(
sls // sls //
); );
} }
}
// //
if (ArraySize(sls) == 0) Add(
{ peak,
sls //
);
} }
// //
@@ -927,6 +882,71 @@ bool DetectX121SMCXTWPVSiganlTrigger(
return result; 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 ... // Draw Signal ...
int DrawX121SMCXTWPVSiganl( int DrawX121SMCXTWPVSiganl(
+112 -55
View File
@@ -478,6 +478,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// //
// XTWPV Signal ... // XTWPV Signal ...
X121SMCStrategyXTWPVSignalConditions mXTWPVConditions; X121SMCStrategyXTWPVSignalConditions mXTWPVConditions;
X121SMCStrategyXTWPVSignalConditions mXTWPVConditionsCollection[];
bool DetectXTWPVSignal( bool DetectXTWPVSignal(
X121SMCStrategyConditions &conditions // X121SMCStrategyConditions &conditions //
) )
@@ -489,10 +490,52 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
bool isBullish = false; bool isBullish = false;
bool isBearish = false; bool isBearish = false;
//
int zIndex = 0;
int cIndex = zIndex + 1;
int pIndex = cIndex + 1;
int ppIndex = pIndex + 1;
// //
string symbol = GetSymbol(); string symbol = GetSymbol();
ENUM_TIMEFRAMES period = GetPeriod(); 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(); datetime cTime = TimeCurrent();
@@ -524,54 +567,60 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// //
setupDir = mXTWPVConditions.dir; setupDir = mXTWPVConditions.dir;
setupTime = mXTWPVConditions.setupTime; setupTime = mXTWPVConditions.setupTime;
}
// //
if (isSetuped) if (isSetuped)
{ {
// //
mXTWPVConditions.UpdateOrderBlocks(); AddRef(
mXTWPVConditions,
mXTWPVConditionsCollection);
// //
XCBaseObject *bullDrawnObjects[]; mXTWPVConditions.Clean();
int bullDrawnObjectsCount = mPOIDrawer.DrawFVGOrderBlock(
mXTWPVConditions.bullishOrderBlocks,
bullDrawnObjects //
);
if (IsValidSize(bullDrawnObjectsCount))
{
AddObjectsIfNotExists(bullDrawnObjects);
}
//
XCBaseObject *bearDrawnObjects[];
int bearDrwanObjectsCount = mPOIDrawer.DrawFVGOrderBlock(
mXTWPVConditions.bearishOrderBlocks,
bearDrawnObjects //
);
if (IsValidSize(bearDrwanObjectsCount))
{
AddObjectsIfNotExists(bearDrawnObjects);
} }
} }
// //
result = isSetuped; int conditionsCount = ArraySize(mXTWPVConditionsCollection);
result = IsValidSize(conditionsCount);
if (!result) if (!result)
{ {
return result; return result;
} }
// //
// Detect Trigger Conditions ... // Looking For Conditions ...
bool canTrigger = mXTWPVConditions.CanTrigger(); int selectedIndex = 0;
datetime triggerTime = mXTWPVConditions.triggerTime; X121SMCStrategyXTWPVSignalConditions mConditions;
for (int i = 0; i < conditionsCount; i++)
{
//
// Update Conditions ...
mXTWPVConditionsCollection[i].UpdateOrderBlocks();
//
// 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) if (!canTrigger)
{ {
// //
// Detect Signal Trigger ... // Detect Signal Trigger ...
canTrigger = DetectX121SMCXTWPVSiganlTrigger( canTrigger = DetectX121SMCXTWPVSiganlTrigger(
mXTWPVConditions, mXTWPVConditionsCollection[i],
symbol, symbol,
period, period,
mTriggerCycleHelper, mTriggerCycleHelper,
@@ -590,15 +639,39 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
} }
// //
triggerTime = mXTWPVConditions.triggerTime; triggerTime = mXTWPVConditionsCollection[i].triggerTime;
} }
// //
// Check Signal Direction ... if (canTrigger)
{
//
selectedIndex = i;
mConditions = mXTWPVConditionsCollection[i];
break;
}
}
// //
isBullish = IsBullish(setupDir); result = IsValid(mConditions.setupTime) &&
isBearish = IsBearish(setupDir); HasDirection(mConditions.dir);
if (!result)
{
return result;
}
//
// Remove Selected Index from Main Collection ...
ArrayRemove(
mXTWPVConditionsCollection,
selectedIndex,
1 //
);
//
// Check Signal Direction ...
isBullish = IsBullish(mConditions.dir);
isBearish = IsBearish(mConditions.dir);
result = isBullish || result = isBullish ||
isBearish; isBearish;
if (!result) if (!result)
@@ -608,26 +681,10 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// //
// Issues Signal on Conditions ... // Issues Signal on Conditions ...
conditions.signalDir = setupDir; conditions.sl = mConditions.sl;
conditions.provider = providerStr; conditions.provider = providerStr;
conditions.sl = mXTWPVConditions.sl; conditions.signalDir = mConditions.dir;
conditions.target = mXTWPVConditions.target; conditions.target = mConditions.target;
//
// TODO: Remove ...
// conditions.decisionZones = mXTWPVConditions.decisionZone;
// conditions.marketStructure = mXTWPVConditions.analyseMarketStructure;
// if (isBullish)
// {
// conditions.priceZones = mXTWPVConditions.valePriceZone;
// }
// else
// {
// conditions.priceZones = mXTWPVConditions.peakPriceZone;
// }
//
mXTWPVConditions.Clean();
// //
return result; return result;
@@ -685,7 +742,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
x121Inputs.Default(); x121Inputs.Default();
// //
x121Inputs.showRSI = false; x121Inputs.showRSI = true;
// //
bool isInited = false; bool isInited = false;
@@ -710,14 +767,14 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// //
// XATR ... // XATR ...
x121Inputs.xatrInputs.showATRUpper = true; x121Inputs.xatrInputs.showATRUpper = false;
x121Inputs.xatrInputs.showATRLower = true; x121Inputs.xatrInputs.showATRLower = false;
// //
// XSTR ... // XSTR ...
x121Inputs.xstrInputs.showStr = true; x121Inputs.xstrInputs.showStr = true;
x121Inputs.xstrInputs.showStrUpper = true; x121Inputs.xstrInputs.showStrUpper = false;
x121Inputs.xstrInputs.showStrLower = true; x121Inputs.xstrInputs.showStrLower = false;
// //
// XDON ... // XDON ...
@@ -729,7 +786,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
// //
// XVWAP ... // XVWAP ...
x121Inputs.xvwapInputs.showVWapFast = false; x121Inputs.xvwapInputs.showVWapFast = false;
x121Inputs.xvwapInputs.showVWapFast = false; x121Inputs.xvwapInputs.showVWapMedium = false;
x121Inputs.xvwapInputs.showVWapSlow = false; x121Inputs.xvwapInputs.showVWapSlow = false;
// //