Overview
Spike Detector is an automated trading bot for Deriv's synthetic indices — Boom 1000/500, Crash 1000/500, the Volatility 10/25/50/75/100 series, and Step Index — instruments that are algorithmically generated rather than derived from real market feeds, and whose price behavior (occasional sharp "spikes" against an otherwise steady drift, or continuous randomized volatility) calls for very different indicator thresholds than conventional forex pairs. The EA watches for RSI and MACD to reach simultaneous statistical extremes on the M1 timeframe and opens a mean-reversion trade against the exhausted move, on the premise that a spike or extreme swing on a synthetic index is more likely to revert than a real market's momentum breakout.
The project went through a long, visible iteration history (Idea → Ideaa → V2 → V3, plus a separate dashboard variant), reflecting an unusually data-driven build process — for an instrument class this synthetic and fast-moving, the "right" thresholds and stop-loss scaling only reveal themselves through repeated live/demo testing rather than being derivable from first principles.
Architecture
- Indicator handles (
OnInit) — ATR, Bollinger Bands, and a customSpike Detectorindicator loaded viaiCustom(), alongside on-the-fly RSI/MACD handles created per tick inOnTick(). - Confluence entry logic (
OnTick) — computes the RSI and MACD values for the current and prior bar, checks both against extreme thresholds (RSI ≥ 80 combined with MACD in the top 20% of its visible chart range for a sell; the mirrored condition for a buy) and requires a flat book (PositionsTotal()==0) before firing. - Per-instrument risk table (
OpenBuy/OpenSell) — a string-matched lookup (StringFind(_Symbol, "Boom 1000", ...)etc.) that scales the stop-loss distance differently per synthetic index, since Boom/Crash and each Volatility index use wildly different point-to-price ratios. - Time-boxed license gate (
OnInit) — anallowed_untilhard-coded datetime check that fails EA initialization outright once the demo/license period expires, functioning as a lightweight standalone version of the account/expiry pattern formalized separately in the license-generator suite.
Implementation
OnTick() pulls the last three bars of RSI(14) and MACD(12,26,5) via CopyBuffer(), then derives the MACD's "percentage of visible chart range" using ChartGetDouble(CHART_PRICE_MAX/MIN) rather than a fixed numeric threshold — meaning the extreme-detection band adapts to each symbol's actual volatility scale on screen rather than assuming a fixed MACD magnitude that would only be correct for one instrument. A sell fires when RSI is at or above 80 and MACD is in the top 20% of that range with no open position; a buy is the mirror condition at RSI ≤ 20. This is deliberately simple as a signal — the engineering weight is in the per-symbol risk normalization, not the entry logic.
That risk normalization matters because Deriv's synthetic indices don't share a common point scale the way forex pairs roughly do: OpenBuy()/OpenSell() string-match the active symbol against each known instrument family (Boom/Crash 1000 vs 500, each Volatility index, Step Index) and multiply the configured InpStopLossPoints by a different scaling factor per family (10,000x for some, 1,000x or 100x or 10x for others) before converting to a price distance — without that table, a stop-loss setting tuned for Volatility 75 would be either meaningless or catastrophically wide on Boom 1000. Trailing-stop logic (closeBuyTrades/closeSellTrades) additionally time-boxes exits: a position without a take-profit set is closed once it's been open longer than a configurable number of M1 bars, giving the EA a fallback exit even when the mean-reversion thesis doesn't play out cleanly.
Reliability
The EA hard-fails on two conditions before it ever risks capital: an expired allowed_until license date, and a non-M1 chart timeframe (since every threshold was tuned specifically for M1 bar dynamics on synthetic indices). Trade counting (GetTodayTradesTotal()) is logged on every initialization to give the operator immediate visibility into daily activity, and InpMaxTradesPerDay/InpMaxNumOfOpenOrders inputs cap exposure independently of the signal logic, so a run of rapid-fire spikes can't compound position count unboundedly.
