v2-LenhY-hotfix4 | 2026-05-24 | Branch: feat/alamo-hedge
Khi L3 close sớm (checkpoint profit), g_alamoPrevCache vẫn trỏ tới L3 (đã đóng). L4 fire check dùng stale data → qualCount=0 → không fire.
// HOTFIX7: when highest Ln closes, cascade cache to next-highest
bool wasHighestLn = (ticket == g_alamoPrevCache.ticket);
AlamoRemoveLnAt(i);
if(ArraySize(g_alamoTickets) == 0) {
g_alamoPrevCache.valid = false; // invalidate
}
else if(wasHighestLn) {
// Cascade to new highest Ln (last in array)
int newHighIdx = ArraySize(g_alamoTickets) - 1;
ulong newHighTicket = g_alamoTickets[newHighIdx];
if(PositionSelectByTicket(newHighTicket)) {
g_alamoPrevCache.ticket = newHighTicket;
g_alamoPrevCache.priceOpen = PositionGetDouble(POSITION_PRICE_OPEN);
g_alamoPrevCache.type = (ENUM_POSITION_TYPE)PositionGetInteger(POSITION_TYPE);
g_alamoPrevCache.fireTime = (datetime)PositionGetInteger(POSITION_TIME);
g_alamoPrevCache.valid = true;
Print("ALAMO: prevCache updated to L", (newHighIdx + 1));
}
}
ALAMO: S1 của L3 FIRE | DD=30.01% ≥ fireGate=30.00% | qualCount=7 | 2cond_lots=23.88 ALAMO: FIRE SKIP — margin 61594.76 > free 44892.36
Main grid đã dùng hết margin (20+ positions). Không còn margin để mở hedge 23.88 lots. Đây là expected behavior — không thể hedge nếu không có margin.
| ✓ | prevCache cascade khi Ln close |
| ✓ | L3 fire check passes (DD ≥ 30%) |
| ✓ | Margin check blocks correctly |
| ✓ | Stale MONITOR timeout = cosmetic only |