This commit is contained in:
2025-01-30 03:12:21 +03:30
parent 5b58753ab1
commit ea90e5f6c0
3 changed files with 267 additions and 23 deletions
+198
View File
@@ -801,6 +801,204 @@ struct X121SMCCycleState
return IsValidSize(CountBearishFVGs());
}
//
bool GetOldestOB(
XCOrderBlock *&orderBlock //
)
{
//
bool result = false;
//
orderBlock = NULL;
//
bool hasBullishOB = HasBullishOBs();
bool hasBearishOB = HasBearishOBs();
result = hasBullishOB ||
hasBearishOB;
if (!result)
{
return result;
}
//
int iBullOBIDX = -1;
bool iHasBullOB = false;
XCOrderBlock *iBullOB = NULL;
if (hasBullishOB)
{
//
XCZone* iZones[];
ToZone(
bullishOBs,
iZones //
);
//
iBullOBIDX = GetOldest(
iZones //
);
//
iHasBullOB = IsValidIndex(iBullOBIDX);
if (iHasBullOB)
{
iBullOB = bullishOBs[iBullOBIDX];
}
}
//
int iBearOBIDX = -1;
bool iHasBearOB = false;
XCOrderBlock *iBearOB = NULL;
if (hasBearishOB)
{
//
XCZone* iZones[];
ToZone(
bearishOBs,
iZones //
);
//
iBearOBIDX = GetOldest(
iZones //
);
//
iHasBearOB = IsValidIndex(iBearOBIDX);
if (iHasBearOB)
{
iBearOB = bearishOBs[iBearOBIDX];
}
}
//
if (iHasBullOB)
{
orderBlock = iBullOB;
}
//
if (iHasBearOB)
{
//
bool canSet = orderBlock == NULL ||
orderBlock.From() > iBearOB.From();
if (canSet)
{
orderBlock = iBearOB;
}
}
//
result = orderBlock != NULL &&
orderBlock.IsValid();
//
return result;
}
//
bool GetYoungestOB(
XCOrderBlock *&orderBlock //
)
{
//
bool result = false;
//
orderBlock = NULL;
//
bool hasBullishOB = HasBullishOBs();
bool hasBearishOB = HasBearishOBs();
result = hasBullishOB ||
hasBearishOB;
if (!result)
{
return result;
}
//
int iBullOBIDX = -1;
bool iHasBullOB = false;
XCOrderBlock *iBullOB = NULL;
if (hasBullishOB)
{
//
XCZone* iZones[];
ToZone(
bullishOBs,
iZones //
);
//
iBullOBIDX = GetYoungest(
iZones //
);
//
iHasBullOB = IsValidIndex(iBullOBIDX);
if (iHasBullOB)
{
iBullOB = bullishOBs[iBullOBIDX];
}
}
//
int iBearOBIDX = -1;
bool iHasBearOB = false;
XCOrderBlock *iBearOB = NULL;
if (hasBearishOB)
{
//
XCZone* iZones[];
ToZone(
bearishOBs,
iZones //
);
//
iBearOBIDX = GetYoungest(
iZones //
);
//
iHasBearOB = IsValidIndex(iBearOBIDX);
if (iHasBearOB)
{
iBearOB = bearishOBs[iBearOBIDX];
}
}
//
if (iHasBullOB)
{
orderBlock = iBullOB;
}
//
if (iHasBearOB)
{
//
bool canSet = orderBlock == NULL ||
orderBlock.From() < iBearOB.From();
if (canSet)
{
orderBlock = iBearOB;
}
}
//
result = orderBlock != NULL &&
orderBlock.IsValid();
//
return result;
}
//
};