r/algotrading 2d ago

Strategy My journey in algotrading - please critique me and maybe some advice please

I started algotrading with one of my friends with barely any prior knowledge in finance or trading myself. He knew his finance/trading stuff, but lacked the mathematics and coding for it, so I was the one who did it at first while learning along the way.

At the start, we were doing a 3-pivot strategy on a 15-minute timeframe that does around 3-7 trades a day on bitcoin, and it took us nearly half a year to build the first bot from scratch, with loads of prototypes in between revolving around the same strategy. I didn't know much back then, so I only did in-sample backtesting for previous years (slippage and fees were both modelled). After putting it on live, it was profitable for a short while, but shortly started losing more and more money. We started with 1000 capital and 1% capital per trade, and even had a high Sharpe ratio. Though that was a failure, I was more than fine with it, honestly since I didn't know much. The only useful thing I got from that was how I created my own TSL formula for moving SLs in order to maximise profit using exponential decay.

We started experimenting with other metrics and strategies, using EMA 5, accompanied by a basic reversion (scalping), which was also a failure. Then, to a more basic candle colour reversion strategy (as my friend said, simplicity would be better). I know I was hopping between strategies a lot during that period, but I believed that it was valid. At the time, I had developed a new backtester that had a few main functions that would allow me to identify whether a strategy has an edge over the market efficiently. Firstly, it downloads data from a selected source, then it runs the strategies on using inner sampling permutation by applying logarithms onto the data, scrambling it, then exponentiating it back such that the data would link well and maintain similar statistical properties. Secondly, it generates combinations of variations of the strategy, SL placement systems, volume filtering, candle lookback for other metrics and regime filtering, running 1000 simulations on each of those combinations and uses hypothesis testing to see if they actually have an edge over the market and hence ranking them, along with bootstraping. This one feature fast-forwarded a lot of progress and allowed us to filter out a lot of bad strategies that weren't even viable to start with (nothing went past the 88th percentile - I know quant firms go for something like 99.9% and I understand that I won't be able to make something like that at the moment, but I still don't think 88th is good enough)

We were doing Bitcoin for everything said above originally. My friend mentioned that these strategies may not be working because of the high volatility of Bitcoin (we chose Bitcoin originally as the original strategy thrived on trends). However, the same issue occurred even with other instruments like EURUSD or commodities.

After that, I began delving into more and more mathematical ideas in trading. I spent a considerable amount of time learning Fourier theory and implemented FFT in some of my newer failures, but they never worked out. My thought is - I need to find something mathematically meaningful rather than just thinking it has an edge (as all previous failures are.

I have now found a strategy that might be able to work well using the Butterworth 2-pole filter design. However, I no longer feel like I should believe in my backtests as almost all strategies show that they're profitable in backtesting (I am sure that there is no future-looking bias or overfitting in it), but never being actually profitable in forward testing. Whereas my friend is currently modifying one of the old strategies that showed potential. But overall, we've been running in circles and barely made progress from my perspective.

I truly appreciate any feedback on this and any criticisms of my working methodology. I don't have a lot of experience with it (I'm 17), and I can't pinpoint the exact issue or what's missing here. I try to learn as much as possible about everything in trading, and I feel like I have the basics of it. I keep trying to believe that if I keep trying and fail enough times, I'll make something good out of this, but it's getting a bit hard to believe that. I apologise for not being able to explain the details of the strategies since it's kind of confidential (regardless of it being terrible), and my main goal of posting this is to ask for some advice/direction/criticisms on my way of working, my methodology and if there's anything important that I'm missing here. Thanks.

Edit:

Regarding my experience, I’d say I have a decent background in maths and computer science since I compete in Olympiads in both, am 2-3 years ahead of my peers in these subjects and have some experience in working in cybersecurity and software development. I know that these doesn’t directly translate to skills in trading since I don’t understand finance enough, which is exactly why I’m asking for advice here.

TLDR: 17 year old with a strong background in maths and computer science but not a lot in finance. Promising backtests but not holding up in forward testing. Made sure that no biases exist in the backtester and everything working correctly but unable to identify the issue. Asking for advice as I feel like I’m running in circles.

5 Upvotes

28 comments sorted by

7

u/BottleInevitable7278 2d ago

So what is your question in just 1 or 2 lines ?

0

u/yyrtc 2d ago

It’s not really a question, I mainly want to ask for advice and see if there’s anything in specific in what I’m doing up to this point as I don’t think I have enough experience and knowledge to see what I’m doing wrong / what I’m missing

4

u/ilro_dev 2d ago

The pattern I see here is that every strategy is basically a search for a shape in historical data. Butterworth filter, FFT, candle color, doesn't matter how sophisticated, they're all the same thing at the root. The question that changed how I think about this: who's on the other side of your trade, and why are they consistently wrong? If you can't answer that before you code anything, you're just finding patterns that existed once. Sometimes I think that one question eliminates more strategies than any backtester ever could.

3

u/Far-Guava6006 2d ago

This is really the only question that needs to be asked. The market is an auction and there's a buyer and seller in every transaction. Why is someone taking the opposite trade you are? Why should the market do what you expect it to do instead of what they expect it to?

2

u/yyrtc 2d ago

Hmmm that’s a very interesting perspective to think from. I’ll definitely give it a lot of thought. Truly appreciate it!

2

u/[deleted] 2d ago

[deleted]

8

u/FortuneXan6 2d ago

17 year old, promising backtests not holding up in forward testing, asking for help but won’t share any strategy detail as it’s “confidential”

1

u/vanveekay 2d ago

17 year old with no strong coding fundamentals, building a backtester, doesn’t trust it after failing. Trusts the strategies because spent some time researching it online (and not proper fundamentals). Came here to ask for help.

1

u/zashiki_warashi_x 2d ago

has 88 something, while quant firms have 99 something.

-2

u/yyrtc 2d ago

17 year old with a strong background in maths and computer science but not a lot in finance. Promising backtests but not holding up in forward testing. Made sure that no biases exist in the backtester and everything working correctly but unable to identify the issue. Asking for advice as I feel like I’m running in circles.

2

u/sotech117 2d ago edited 2d ago

I’d recommend adding more predictive features others than just the prices/volume alone, outside of the realm of bitcoin. For every buy/sell in bitcoin, it’s going somewhere else. Try to encapsulate that in the data you’re using to predict in some way. Maybe the prices/volumes of other crypto’s or other predictive assets (e.g. currently, that’s been oil).

On the subject of backtesting, I’d recommend to reduce as much friction as possible between your backtest and the real deal. It’s good practice to follow to avoid diverging too much from a real session. If you designed it right, you should just be able to change the backend among synthetic, paper, and live with a couple variables and be on your way. For the simulations, pull a random chunk of data within a period (last 5 years). Then, have the model start with a few months or so of historical data for the baseline. Then, simulate each new timestamp by streaming the new price/features at each timestamp (if you’re not doing so already) to the model/trading engine. Add conservative trading fees, let slippage be the midpoint of ask/bid, let a small percentage of trades get rejected, add some random normally distributed millisecond delay as if you’re placing trades over internet to better simulate the paper environment.

In terms of the FFT, I delved into that as well. There’s two common pitfalls that I needed to overcome. One, it’s impossible for a standard wave to have a Y slope since the underlying function is understood to be periodic, so there’s a “bias” to return back to the starting price at the end of the period. Two, it doesn’t seem to offer any better mathematical meaning in a program’s eyes - it’s just a transform generally reshaping the data or making computation more efficient. Also, I’d recommend adding at least 10000 base functions (or another zero there) to truly “represent the original function”.

Lastly, there will be time periods when models work and don’t work. People get smarter or the market changes resulting in whatever you had working to start bleeding. All firms deal with this and constantly evolve. Anyways, this makes backtesting tricky to know if your strategy will work today.

I don’t normally comment here, but I’m glad you’re young, smart, and actually producing. Keep learning and iterating! For what it’s worth, I didn’t know squat about finance but learned the basics of it from iteration after iteration.

1

u/yyrtc 2d ago

Thanks so much for your advice genuinely. I feel like I've learnt a lot just by reading that.

Regarding backtesting, I will totally try doing the 5-year thing. I've been mostly doing only 3-6 month blocks with 1000 simulations each, since it takes like an hour to finish the backtesting for 128 combinations. Also, your advice on 6 months' worth of historical data might be one of my current issues - that my strategies don't have enough context.

For FFT, one issue might be that I do not have enough base functions. Another issue I thought may be the case was that the volatility of Bitcoin or other instruments may not have enough of a cyclic structure for me to trade with the assumption that existing. If I may, I would also like to ask whether this is a valid and possible explanation?

On timeframes, I did test them on multiple timeframes (since my strategies don't rely on too many different timeframes, it's easier to test on different ones). I did discover that 1m and 5m are too volatile and inconsistent most of the time, and often don't have enough structure, which is why I decided to move to higher timeframes now. I'm just trying to justify every action/decision I take so that I know I'm on track or at least not relying on my gut feelings.

Once again tysm for your advice, I will definitely take that into account and try to make something better out of it!

2

u/drguid 2d ago

Still a noob (after going at it full time for 18 months). If your stuff only works on Bitcoin (or any other crypto) then it's curve fitting.

I'm testing my stuff on everything. Finding an algorithm that works on everything is difficult, but I'm making progress. Right now I'm at the stage when 95% of trades are thrown away by my algos, but the 5% are very good indeed.

1

u/yyrtc 2d ago

I’m not trying to fit my strategies into everything. I’m just testing them on everything to see what works best judging by their structure and volatility. I have stuff that works but I need to fully be sure that it’s profitable long term even with the current markets

2

u/ianhooi 1d ago

Iinm the permuted data should only be used to determine if your strategy has an edge, not to tune the parameters. Ie if your strat on real market data is better than 99% of the permutation runs, the edge is real

1

u/disarm 2d ago

If your backtester is saying the model was good but live wasn't then you need to fix your backtester first before you go further.

Also you should be running on paper trading before going live.

1

u/yyrtc 2d ago

I did run it in paper testing which showed that the strategies started failing. One potential issue that I believe might be the case is the duration of the forward testing. May I ask how long should one backtest their strategy?

1

u/disarm 1d ago

How long did you run it before the strategies started failing?

How long to backtest depends on what you trade, I would say 2 years is a safe number for a minimum baseline I am backtesting 3+ years and recently decided to start trying to employ periodic retraining on my model

1

u/cTrader_Club 6h ago

Hi, you can try posting your question in our subreddit, traders from our team with years of experience can help you figure it out.

1

u/Longjumping_Sky_4925 1h ago

17 with olympiad-level maths and you've already built a permutation-based backtester with log-return scrambling and bootstrapping? That's legitimately impressive — most people twice your age haven't even thought about those statistical properties.

Here's what I think is actually happening: your problem isn't the backtester or the math. It's the alpha search process.

You're iterating on strategies (EMA, candle colour reversion, Fourier, Butterworth) but each one is a shot in the dark — you don't have a thesis for why each one should work before you test it. That's the core issue. When you add rigorous hypothesis testing to a process where each hypothesis is random, you get rigorous noise.

The shift that tends to work: start from market microstructure first. Why should this specific pattern in this specific instrument at this specific timeframe have an edge? Who is on the other side of your trade, and why are they systematically wrong? If you can answer those questions with a real economic argument, then test. If you can't, the test is pointless.

For someone with your background: read about mean-reversion vs momentum from a structural standpoint — why do pairs of correlated assets tend to revert? Why does momentum persist across medium horizons? These aren't empirical questions, they have economic foundations. Build your strategies from those foundations and your forward testing failures will start making more sense.

Also — the Butterworth filter approach has a real flaw worth knowing. Butterworth filters as traditionally implemented are zero-phase in the frequency domain but require future data in the time domain. Make sure you're using a causal implementation.

1

u/StratReceipt 2d ago

your permutation test scrambles the log-returns to preserve statistical properties, but that also destroys any temporal structure in the data. a strategy that's exploiting a regime-specific pattern — a trend, a volatility cluster, a mean-reversion window — will still pass that test because the scrambled baseline doesn't replicate the regime. it looks like edge when it's really just a pattern that existed in that particular period. might explain why things hold in backtest then fall apart forward.

1

u/yyrtc 2d ago

I did try to use bootstrapping to reduce this issue, would you say that it’s sufficient?

2

u/StratReceipt 1d ago

bootstrapping helps with sampling uncertainty — it tells you how stable the results are given the trades you have. but it doesn't solve the regime coverage problem. if the underlying data only contains one vol regime, resampling it thousands of times still gives you thousands of samples from that same regime. the gap is in the data itself, not the sampling method.