Don't let a new signal engine write fake trades: a warm-up flag for trading alert bots
I run a small trading-alerts project, and this week I added eight new signal engines to a bot that was already running. The code was the easy part. The hard part was making sure the statistics stayed honest. The bug you only see once A signal engine reads recent candles and says "there is a setup". When you deploy a new engine on a live bot, its very first cycle looks at the last few hours of…
A small trading-alerts project expanded to include eight new signal engines for a live bot. The challenge lay in maintaining accurate statistics amidst the introduction of these new engines. The code was straightforward, but ensuring the statistics remained honest proved difficult. Upon deploying the new engine, its initial cycle examined recent candlestick data, identifying past setups that should not have been recorded as trades.
These fabricated trades appeared in the journal, inflated win rates, and skewed comparisons moving forward. The solution involved versioning engines and skipping the first cycle of newly deployed ones. A persistent marker file stored the engine's version, allowing the bot to recognize when a warm-up cycle had concluded. Within the loop, any signal generated by a new engine was disregarded until the warm-up period was complete.
If a signal was deemed stale, it was also ignored. A few seconds after the bot's deployment, it was confirmed that no trades originated from the freshly added engines, despite them being operational. This test proved invaluable and should be automated. Engines reliant on the clock are challenging to test offline. Some engines depend on session openings, making them unsuitable for playback through historical data.
For optimal testing, a fake feed in the correct format is recommended. It is crucial to isolate each engine within its own try/except block. A bug in one detector should only impact that specific detector, not the entire cycle. Additionally, avoid sharing strategy code between bots, as this can lead to unintended consequences. Each bot should possess its own copy of the code.
During engine validation, refrain from enabling alerts until comparisons are thoroughly measured. The presence of fabricated trades in the journal renders comparisons meaningless, regardless of the strategies employed. Measurement hygiene is paramount in this domain. Trading inherently involves risk, and this technical discussion does not constitute financial advice.
This account originates from ICT Edge, a trading-alerts tool, and was drafted with AI assistance, subsequently reviewed and edited by the author.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.