last..
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user