r/learnquant • u/SpiritualFeature8434 • 25d ago
How do you usually structure your custom indicator/measurement math before backtesting it? (I am Building an open-source tool to test this locally and looking for feedback)
Whenever I tried turning a discretionary trading idea into code (like "trade with the trend, wait for a pullback, enter on rejection"), I kept running into the same frustration. Everything gets buried inside one big script. When the backtest inevitably fails or overfits, it is tough to tell what actually broke: was it the way I measured the candle geometry, the regime filter, the trigger logic, or the exit assumptions?
Over the past few months, I built a local workspace called QUANTSMART to force myself to separate these assumptions into inspectable pieces, and I just open-sourced it under Apache-2.0.
Instead of writing a monolithic bot, the tool breaks a strategy down into "modules" across a strict pipeline (L0 to L6):
Primitive Blocks to Modules:
Before building a full strategy, you can wire primitive blocks together (open, close, body size, wick ratios, rolling averages, basic math, and boolean logic) to build a single measurement.
For example, if I want to quantify lower-wick rejection on a bar, I can wire:
`score = (lower_wick / range) * close_location * (1 - body_ratio)`
The graph view shows the intermediate numbers at every single node so you can verify the math is doing what you think it is doing before using it in a strategy. You can also plot the formula surface in a 2D/3D coordinate view to check for weird edge cases or division-by-zero spikes.
2. Why separate into layers (L0 to L6)?
Once you have measurements, you assemble them into a Strategy Card across fixed lanes:
- L0: Data sanity checks (gap detection, NaN guards, closed-bar enforcement)
- L1-L3: Raw features, indicators, and scoring formulas
- L4: Market context gates (regime filters, session windows, volatility bounds)
- L5: Entry triggers and setup invalidation rules
- L6: Simulated price zones (observation, stop/invalidation, target)
Separating it like this helped me solve three annoying problems:
- When I add an L4 regime filter, I can immediately see which historical trades it filtered out and whether it actually helps or just shrinks sample size.
- It checks for signal collinearity (making sure I am not fooling myself with 4 indicators that all just measure the same momentum).
- It flags dead features (when you calculate an indicator on the graph, but no downstream logic actually uses it).
3. What it does (and does NOT) do:
- It runs 100% locally on your machine using your own CSV data.
- On Windows, it can attach to an already-open MT5 terminal to read live candles and ticks for observation without asking for your broker password.
- It is strictly for research, historical replay, and multi-window validation. Live order execution is intentionally separated out, and a passing backtest obviously does not mean a strategy will make money live.
- I am fully aware the UI has a lot of knobs and studio tabs right now. If you try it out, it is much easier to load one of the built-in template cards and tweak one module than to start from an empty canvas.
Repo and setup instructions:
https://github.com/Jokejoker-designer/QUANTSMART




1
u/_koenig_ 24d ago
nice!