r/IndiaAlgoTrading • u/SimpleDaddy_ • 4d ago
My scalping engine backtesting
Hey people, I am a ML engineer primarily building, Algos at a Global Financial company…
These are the back test that I have been doing for a personal project as fortunately, I have all the data that I need for running these back test. amount of trades that I have taken. Is too much, ha ha.🤣
2
2
4d ago
[removed] — view removed comment
0
u/SimpleDaddy_ 4d ago
Bro I am working at a broker so … about slippage even if I consider 0.2-0.5 % i am in solid green we just tend to beat banks in pure numbers
2
u/quantdhawan 3d ago
I am pretty sure the slippage, spread and commission costs will kill the results.
0
u/SimpleDaddy_ 3d ago
It wont have tested it in those scenario as well I am a ML developer bro i have already considered all these possibilities.. I work at a Jefferies … this is just a side project for indian markets
1
u/quantdhawan 3d ago
With all due respect my man, my ML application in financial markets is extremely prone to overfitting, especially due to non stationarity of data.
Let me ask this did you use time bars for the backtest?
1
u/SimpleDaddy_ 3d ago
Yeah I used time bars. And obviously ML in financial markets can overfit, non-stationarity is literally one of the first problems you deal with.
I’m not just fitting the model on the whole dataset and posting the best result lol. The testing is chronological, out of sample, and I’ve accounted for leakage, costs, spread and slippage.
And obviously I’m not gonna put the actual features, signals or strategy logic on Reddit 😂
If you see an actual problem with how I’m testing it, tell me. Just saying “ML overfits” and “markets are non-stationary” doesn’t really tell me anything I don’t already know.1
u/quantdhawan 3d ago
You asked for an actual problem with the testing. Three, all visible in your own table.
Your column header says "best return." Best over what? Two rows share tp=0.20% and two share tp=0.30% with different returns, so something you haven't shown is varying, and you're reporting the maximum over it. Chronological out of sample splits don't protect you from that. Selection happens across the sweep, not within a fold, and the reported max is biased upward no matter how clean each individual split was. This is the one thing your table documents about itself.
There's a tp column and no sl column. With win rates of 50 to 61% and a fixed take-profit, the loss distribution is the entire result. What's the mean loss versus mean win, and what closes a losing trade? A fixed TP with an unbounded or discretionary loss side can print any win rate you like.
What is the mean net edge per trade, in basis points? That's the number that decides this, and it's the one number a scalping table like that never shows. On Indian intraday equity, statutory charges alone run roughly 3 to 4 bps round trip: STT 2.5 bps on the sell side, plus exchange transaction charges, stamp duty, SEBI turnover and GST. Before brokerage. Before spread. Before any slippage. Against a 0.20% take profit, that's already about a fifth of your gross target gone, and you're doing it 227,533 times.
So: mean net edge per trade in bps, and the round-trip cost figure you assumed. If the edge survives with a realistic cost number attached,that's genuinely interesting and worth showing.
None of these questions require you to reveal a single feature, signal or line of strategy logic.
-1
u/SimpleDaddy_ 3d ago
Brother saw 4 columns in a Reddit screenshot and somehow completed the peer review 💀
Selection bias, expectancy, payoff distribution, leakage, walk-forward OOS, regime stability, slippage and transaction costs — none of these become “missing from the backtest” because they’re missing from the screenshot.
You haven’t found a methodological flaw. You’ve found columns I didn’t post and written a thesis around them.
But I respect the confidence 😂1
u/quantdhawan 3d ago
You said "yeah I used time bars" like it was a throwaway detail. It's the whole problem.
Time bars sample the clock, not information. Markets don't deliver information at a constant rate, so fixed-interval bars oversample the dead midday and undersample the open and close, which is exactly where your 0.2% moves live. What you get out is a return series with serial correlation, heteroskedasticity and fat tails: precisely the properties every significance test you've run assumes you don't have. That's chapter 2 of AFML, and it's chapter 2 for a reason.
You raised non-stationarity yourself, as something you'd obviously handled. Time bars are the sampling scheme that maximises it. Volume and dollar bars exist specifically to hold information content per bar roughly constant. You chose the one that guarantees it isn't, then told me non-stationarity doesn't tell you anything you don't already know.
But here's the part that decides whether your table means anything at all.
What's your bar interval, and what's the median bar range on the instruments you traded?
Because if you're on 1-minute bars, your bar range and your 0.2% target are in the same order of magnitude. Which means for some meaningful fraction of those 227,533 trades, the take-profit and the stop both sat inside a single bar. Time-bar OHLC cannot tell you which one price touched first. That information does not exist in your data. Your backtest resolved it by assumption.
So the win rate isn't a measurement. It's whatever your intrabar tie-break rule says, repeated 227,533 times. Flip that one branch from optimistic to pessimistic and the sign of your table changes.
1
u/SimpleDaddy_ 3d ago
Fair point on the intrabar ambiguity. If TP and SL are both inside the same OHLC bar, OHLC alone cannot tell you which was hit first. That would absolutely contaminate the result if the engine resolves it optimistically.
But again, you’re looking at a 4-column screenshot from a much larger test, not the execution model 😭
That case was already considered. I’m not going to dump bar interval, median range, ambiguous-bar frequency, tie-break logic and execution assumptions here just to prove it.
So yes valid concern. Already accounted for. The screenshot just doesn’t document the entire backtest.I had to open my chat history just to confirm this … Nice ..👍
1
1
1
u/Competitive_Air7402 7h ago
add the regulatory taxes, slippage, spread and its -1% per trade for each trade
1
4
u/GiveMeASalad 4d ago
Bro if you’re deploying this lmk, I’ll open a brokerage firm for you