4.1 Ghost Candles Pattern Matching Engine
computeGhostPredictions() // r ≥ 0.70
This non-parametric forecasting module extracts the trailing W = min(35, ⌊N/3⌋) closing prices and normalizes them into scale-invariant relative return vectors: x[k] = (close[k] - close[0]) / close[0]. It then performs an exhaustive sliding-window scan across historical data up to N - W - 30, evaluating structural similarity via the Pearson Product-Moment Correlation Coefficient mapped onto [0, 1] via (r + 1) / 2.
Matches scoring below 70% are discarded. Valid matches extract the subsequent 30 historical candles, rescale all OHLC coordinates by scaleRatio, and project them forward onto future timestamps (lastRealTime + (idx + 1) * avgInterval).
Financial markets often repeat historical patterns. Ghost Candles takes the shape of the last 35 price bars and searches backward through history to find a past moment that moved the exact same way (requiring at least a 70% match). When it finds a match, it takes the 30 candles that happened right after that past event, resizes them to today's price, and draws translucent "ghost" bars into the future so you can see how the market played out last time.