SniperGold_ML/ml/parity/check_h1_gap.py

27 lines
1.3 KiB
Python
Raw Permalink Normal View History

# -*- coding: utf-8 -*-
import numpy as np
import datetime as dt
z = np.load(r"D:\TradingTerminal\HFM Metatrader 5\MQL5\Files\AlgoForge\Data\XAUUSD_H1.npz")
ht = z["time"].astype(np.int64)
t0 = int(dt.datetime(2026, 2, 15, tzinfo=dt.timezone.utc).timestamp())
t1 = int(dt.datetime(2026, 2, 18, tzinfo=dt.timezone.utc).timestamp())
m = (ht >= t0) & (ht <= t1)
sel = ht[m]
d = np.diff(sel)
print("H1 bars 02-15..02-18:", len(sel))
for i, g in enumerate(d):
if g != 3600:
print(" gap:", dt.datetime.fromtimestamp(int(sel[i]), dt.timezone.utc),
"->", dt.datetime.fromtimestamp(int(sel[i + 1]), dt.timezone.utc),
"delta(h)=", g / 3600)
t2026 = int(dt.datetime(2026, 1, 1, tzinfo=dt.timezone.utc).timestamp())
d2 = np.diff(ht[ht >= t2026])
print("unique non-hourly gaps 2026:", np.unique(d2[d2 != 3600]))
# cek juga: bar ke-51 terbaru dari e_ea (20:00 02-16) dalam indeks npz vs cache
e = int(np.searchsorted(ht, int(dt.datetime(2026, 2, 16, 20, tzinfo=dt.timezone.utc).timestamp())))
print("e_ea idx:", e, dt.datetime.fromtimestamp(int(ht[e]), dt.timezone.utc))
print("e_ea-50 idx:", e - 50, dt.datetime.fromtimestamp(int(ht[e - 50]), dt.timezone.utc))
# bar ke-51 terbaru secara KALENDER (51 bar terakhir sebelum e_ea inklusif? bars[50] = 51st newest)
# cache bars[0]=e_ea, bars[50] = 50 bar lebih tua dari e_ea = npz index e-50 (asumsi dens)