r/algorithmictrading

I open-sourced my entire SPY 0DTE options bot — code, strategy, the full manual, and a live dashboard so you don't have to take my word for anything
▲ 13 r/algorithmictrading+2 crossposts

I open-sourced my entire SPY 0DTE options bot — code, strategy, the full manual, and a live dashboard so you don't have to take my word for anything

Some background first: I've spent 3+ years building and running automated futures strategies on the IBKR API, and honestly, none of this would exist without that scar tissue. Alpaca's options API is a different beast (in some ways easier, in some ways much weirder), but knowing what a live bot does to you at 3:25 PM on a bad day is transferable knowledge.

So — the whole thing is on GitHub now. Not a framework with the good parts removed — the actual entry logic I run every morning, all the parameters, the risk management, and the 22-page strategy manual with every session post-mortem, losing days included.

Code + manual: github.com/milgar7969/alpaca-options-framework
Live results: milgar7969.github.io/spy-0dte-dashboard — updates itself daily after the close, green or red

It's paper trading, last 30 days are green, May was rough, and the dashboard will tell on me either way.

Half the value is honestly the README and the pdf manual, which document every Alpaca options landmine I stepped on: bracket orders rejected, null Greeks on 0DTE, and cancelled buy orders that fill anyway (ask me how I know).

Credit where it's due: this is a human + AI collaboration. I built and run this with Claude (Anthropic's model) as my pair programmer — it wrote a lot of the code, caught bugs in the logs I'd have missed, and talked me out of some bad ideas.

The strategy calls, the market experience, and the stubbornness are mine. I'd rather be upfront about that than have the haters leave negative comments.

Clone it, break it, tell me what I did right and what I got wrong.
p.s. there are a lot of knowledge, from my years of experience I am sharing for free, so please be nice ;-)

u/Tiny-Ad-7916 — 22 hours ago

I built a close-based momentum/quality strategy with next-open execution: backtest + paper trading results

Hey everyone,

I’ve been building and testing a systematic equity trading strategy for the last few weeks/months, and I wanted to share the current state of the project.

The idea is simple at a high level:

The strategy ranks a stock universe after the market close using a proprietary quality/momentum score. It then creates a plan for the next session and executes that plan at/near the next market open. I built it this way to avoid reacting to intraday noise and to keep the execution logic closer to what can actually be tested.

The system is not just a backtest script anymore. It is connected to an Alpaca paper account and runs as an operational bot. It sends Telegram updates for open positions, planned buys/sells, stop exits, cooldowns, daily status, and a visual journal/infographic so I can monitor what it is doing without digging through raw logs.

High-level rules:

- close-based signal generation

- next-open execution

- fractional position sizing

- managed position cap

- stop/cooldown risk layer

- daily Telegram reporting

- no discretionary intraday panic decisions

Backtest summary:

The research backtest used IEX data, 7.5 bps slippage, post-sell confirmed cash, a buying-power buffer, and a warmup period.

Main research period:

2022-01-03 to 2026-06-18

Result:

+557.79% total return

52.68% CAGR

18.21% max drawdown

1,226 trades

~9.5 average managed positions

Period breakdown:

2022 bear market: -13.74%

2023 recovery: +87.68%

2024 bull market: +122.98%

2025 choppy market: +14.86%

2026 YTD to June 18: +58.76%

Forward paper test:

2026-06-10 to 2026-07-03

Paper account:

$10,000.00 -> $10,362.78

+$362.78 / +3.63%

This is still early, and the forward sample is obviously small. I’m treating the paper result as a live operational test, not proof that the strategy works long term.

A few transparency notes:

- This is paper trading, not live capital yet.

- I am not sharing the exact score formula or thresholds publicly.

- The current production version has evolved after the backtest, including a broader stock universe, better reporting, scale-up/replacement logic, and cleaner execution checks.

- Some early paper logs had test/duplicate rows that need to be filtered from analysis.

- The system is still under active development.

One recent change: I expanded the stock universe because the system has a 12-position cap, and the previous universe occasionally did not provide enough high-quality candidates to fully utilize the allocation target. The goal was not to force more trades, but to give the model a wider pool while keeping the same risk controls.

I’m mainly looking for feedback on:

- backtest design

- operational risk

- paper-vs-live assumptions

- avoiding overfitting

- whether this reporting style is useful

- what additional validation you would want before considering live deployment

u/DoganDGL — 1 day ago

Algo trading signals or is execution a must?

Does anyone here use algos more as a decision-support tool rather than for full automation? I know the point of algorithmic trading is usually to automate execution, but I actually trust myself more with the execution side (at least for now). I’ve been using pine script to build something with the help of AI - is this common here or are there better tools?

What I’m working on is having an algo identify levels, conditions and potential setups, then I decide whether to take the trade manually after confirming the trade with some execution criteria (liquidity sweeps, CVD, acceptance/rejection).

My thinking is it removes a lot of the repetitive analysis and keeps things objective, but still lets me control the actual entries and exits. I’m completely new to this side of trading, so I’m curious if anyone else uses algos this way or if there’s something I’m overlooking.

I’m very open to feedback and guidance on this one.

reddit.com
u/Impressive-Ad7917 — 22 hours ago

My MT5 EA "Gold Raider" hit a 100% win rate on M1 Gold. Here are the backend stats.

https://preview.redd.it/1cn4jscquwah1.png?width=1241&format=png&auto=webp&s=803a18288d674c52cb44d81710d3204b95d60612

GoldRaider testing from 9/1/2025 to 7/2/2026 on M1 chart.

Hey everyone,

A bit ago, I posted about a strategy test for my custom expert advisor, Gold Raider (specifically running setfile #23). The backtest scored a 100% win rate over 96 trades on a €1,000 account, with a max equity drawdown of just 3.67%.

I’ve attached the full report image GR4_Set23_Demo.png for reference.

Naturally, a 100% win rate screams "hidden martingale or grid system that will eventually blow the account." However, I wanted to share a look at the architecture of the EA to show why it performs this way. This is a pure single-order scalper with strict safety nets.

📊 The Backtest Conditions (From GR4_Set23_Demo.png)

  • Broker / Leverage: Fusion Markets Pty Ltd | 1:500
  • Data Quality: 100% Real Ticks
  • Timeframe: M1 (XAUUSD)
  • Total Net Profit: 1,226.20 EUR (~122% gain)
  • Profit Factor: 128.73

🛠️ The Safety Architecture (Why it hasn't lost)

Instead of relying on dangerous money management, Gold Raider uses a multi-layered gatekeeper system to filter out bad entries, combined with aggressive exit management.

1. Multi-Timeframe Confirmation Gates

The entry engine doesn't just look at the M1 chart. To take a trade, it passes through three distinct validation filters:

  • Filter A (RSI Confirmation): Dynamically tracks M5 momentum zones to ensure we aren’t buying the absolute top or selling the absolute bottom of a macro swing.
  • Filter B (Trend Strength Confirmation): An optional higher-timeframe Efficiency Ratio filter that blocks trades if the market is moving too violently in the opposite direction.
  • Filter C (Range Validation): Uses a structural lookback algorithm to calculate key volatility boundaries. It ensures the EA only fires when price is within safe execution zones.

2. Strict Protection & Safety Nets

The EA has hardcoded protective logic to shield the account from catastrophic black swan events:

  • No Grid / No Martingale: It executes fixed lot sizes or automated equity-proportionate lot sizing. One trade at a time per side.
  • Hard Stop Loss & Emergency SL: Every single trade is launched with an initial stop loss protection mechanism.
  • Aggressive Break-Even (BE) Logic: The moment a scalp moves into a set amount of profit points, the EA aggressively moves the SL to lock in the trade at Entry + 1 point. This is exactly why the backtest shows a 100% win rate—trades that don't hit the primary target are choked out at break-even before they can turn into losses.
  • Built-in News Guard: It integrates directly with the internal MT5 calendar to completely halt new entries during high-impact macroeconomic events (like NFP or FOMC).

🚀 Next Steps: Live Testing

The equity curve in GR4_Set23_Demo.png shows a very smooth, linear ascent because the break-even and trailing mechanics are highly optimized for MT5's historical real ticks.

Of course, the real enemy of an M1 gold scalper is live execution: slippage, commissions, and spread widening. The code does include a strict max-spread filter to prevent trading during toxic market hours, but forward testing is the only way to know for sure. I am moving this to a live demo/forward test to see how the execution holds up.

Would love to get your thoughts on the filter mechanics, or what further stress-tests you'd put an M1 scalper through!

reddit.com
u/onelittledragon — 2 days ago

A strategy that makes +66% on BTC and -60% on SOL is a curve fit, not a strategy.

Building my bot and doing a lot of backtesting these days.

I had a breakout system that looked bulletproof on BTC: +66%, profit factor 3.2, 13% max drawdown, profitable in 6 of 9 walk-forward windows. So far, so great.

But, it only fired about 8 trades a year. At that frequency a single-asset walk-forward can't tell a real edge from getting lucky. The sample is just too small, no matter how you slice the windows.

So I froze the exact config, no re-tuning, and ran it on ETH and SOL.

  • BTC: +66%
  • ETH: -11%
  • SOL: -60%, with a 0% win rate.

Also tried different parameters, but no parameter set rescued the other two. It was fit to BTC.

Might still be something "real" that only happens on BTC. But more likely just overfitting.

In contrast, my market-neutral funding carry pays +6.7 / +6.6 / +5.6% on BTC, ETH, SOL. Neatly aligned, what a real structural edge should looks like, boring and the same everywhere.

If your edge is low frequency and only tested on one asset, you don't know it's real yet. You know it fit one history. Might still make you money.

Do you cross-validate across instruments, or is single-asset walk-forward enough for you?

reddit.com
u/espressodoppioo — 2 days ago
▲ 8 r/algorithmictrading+7 crossposts

One of my favorite features isn’t AI… it’s the Start/Stop button.

That might sound strange, but I built IMALI so users stay in control.
When you press Start, the platform begins scanning markets based on your selected strategy. It looks for opportunities that meet the strategy’s rules and risk parameters before considering a trade.
When you press Stop, the bot stops opening new positions. You stay in control instead of wondering what the software is doing.
A few other controls I built because I wanted them myself:
• Switch between Paper and Live Trading in seconds.
• Choose your own trading strategy based on your risk tolerance.
• Set your preferred market (Crypto, Stocks, Futures, or DEX where supported).
• View every trade from one dashboard.
• Connect or disconnect your exchange whenever you want.
My goal wasn’t to create a “black box” bot.
It was to build software that helps people understand what their automation is doing while giving them the ability to take over at any time.
If you’re curious, you can try the one-click demo here:
👉 https://imali-defi.com/trade-demo
I’d love your feedback.

u/Agile_Strategy_223 — 4 days ago

Is there hope for me

I've just started algo trading more than a years ago . For options buying .. my heart is broken.. I've tried 100s of strategies.. but I'm not able to find one profitable.. is there hope for me?

I don't know where to get the data for back testing with LTP.. so I just back test with pts and paper trade and trade and a year has passed testing . Nothing is consistent or profitable.. is there actually a strategy that works.. and how much profit% can I expect if I'm successful.. am I expecting too much?

reddit.com
u/Chemical_Anything602 — 5 days ago

Your estimate of retail traders running algo trading?

No official data out there. Not to include institutional traders or organisations.

What is your estimate that retail traders out there deploying algorithm? 1%? 10%

Curious how much the data might have jumped since the beginning of FREE LLM to code strategies.

reddit.com
u/LatterRain5 — 5 days ago

The hiden alfa of the strategyes with low win ratio

I listened about breakout, men reversion and sational strategies that tend to have a 50-70% of win ratio.

But lately i am been reading some autors that talk about low win ratios but with a lot of net profit with a ver very good chart of net profit in a lot of years, the example is on the turtles book, that are called as trend following strategies (5-30% of win ratio)

So i will like to know if someone here has found edge of this kind of strategies and how has been your performance or some tip to find those, i can share also my experiencie so is not the one side alfa divulgation.

In my own thinks i believe that this are like 'narnia' strategies in the correct markets of shure.

reddit.com
u/Anonimo1sdfg — 5 days ago

beginner to statistical modeling

Right now I am thinking of starting a project regarding MCMC or Bayesian networks, for I am not sure what I should look into. My goal is to create a very rigorous model that will provide risk analysis as accurately as possible. Im willing to spend around 10k for compute power, is this possible?

Also, I am an undergrad pursuing a math of comp and statistics data science major, but I would not say I am a master at probability, and I do not have much experience in ML. I am willing to learn, but do you think its feasible for me?

reddit.com
u/DaisyBearBriar — 6 days ago

Just started with a algo trading idea.

I just have the strategy created. And I'm serious about building it. Im a java developer. Not very proficient, but I can get the job done.

What are the common pitfalls i will face, and what the basics I should understand, while making the system.

It's a simple swing trade management system. So I won't need a high level of optimizations. If the system is good. I might incorporate more strategy.

Right know I'm just making the llm create the documents on each segments.

Signal generation, entry placement, trade management and book keeping.

What issues could I face when I code the system?

reddit.com
u/Longjumping_Dot1117 — 7 days ago

Built a systematic momentum strategy for US tech stocks - sharing the backtest

Wanted to share a project I've been working on: a fully rules-based momentum strategy for US tech equities. No discretionary stock picking - everything is ranked and selected by a defined funnel (momentum filters, 52-week high proximity, MA stack), rebalanced monthly.

Backtest results since 2016:

  • CAGR: 42.1% (trailing 10Y)
  • 1Y return: +145.4%
  • 3Y return: +403.8%
  • Max drawdown: -40.8%

Happy to go into the funnel logic or backtest construction if anyone's curious - especially interested in feedback on drawdown management since -40.8% is still rough.

reddit.com
u/IndexEdge — 6 days ago

my best algo bot has a 1.52 Sharpe Ratio

my best algorithm has a 1.52 sharpe ratio and it's a daytrader.

daily-rebalanced FAST residual momentum. Beta-residualize each S&P-100 mega-cap vs SPY over 40d.

I tested several hundred different algorithms, 99% barely beat the SPY. I have an LLM researching more that get sent to a quant engine that are backtested to see if they pass the SPY gate. They are all duds.

What's your best performance?

you can now bring your API key and test our stock database for free and make any models that you want. You can also test your own models.

reddit.com
u/Must_Dragonfruit — 8 days ago

Anyone here looked into trading bots and bounced off how complicated it is?

Tried getting a trading bot running this week and almost gave up like 3 times — half the battle was just the setup, WSL, servers, my card kept getting declined by VPS providers lol. Strategy was the easy part honestly. Anyone else bounce off how technical it is just to run one? Or did you push through? Genuinely curious where people landed.

reddit.com
u/achillhi — 9 days ago

Connecting Tradingview and Claude Via MCP

Hey all,

I've been seeing some things on line saying its possible to connect claude and trading view via MCP. Is this true? Is it actually beneficial? I've recently had my second child and am finding it hard to continue trading whilist being a father, I've heard you can set it up to scan for your setups and get it to notify you when they appear. Can any one confirm this? Also alot of the stuff I am seeing is mac based, is it capable on windows. If anyone could point me in the right direction it would be appreciated!

Thank you in advance!

reddit.com
u/tusikone — 7 days ago
▲ 9 r/algorithmictrading+8 crossposts

Data ingestion and avoiding lookahead bias is a massive headache, so I built an open-source CLI agent to automate my backtesting setup.

It takes a plain-English strategy idea, generates validated Python using your own LLM key, and runs a historical backtest.

I just added Binance support today.

My biggest challenge right now is the automated safety checks—it currently scans the AST for lookahead flaws before executing.

The tool is free and open source locally at finnyai.tech, with an optional $10/mo tier for managed hosting.

If anyone here builds automated validation for strategy code, how do you handle edge cases and LLM data hallucinations?

u/Awkward_Weather5721 — 9 days ago

Option strategy backtesting and multi-leg strategy creation

What tool do you use to backtest your option trading strategies?
Streak doesn't let you do this, I believe it did at some point in time, but not anymore.

Have you deployed a very long multi-legged strategy to be able to generate consistent returns from option trading?

I am trying to create a tool for my personal use, but would want to check if there are any good tools out there.

reddit.com
u/Expensive_Fee92 — 8 days ago

Deepstops assist advise

Hello enthusiasts ,

I'm running an automated live system of about ~70–75% win rate, lots of small wins, positive in aggregate, the entries themselves aren't the problem, Im pretty satisfied with the build over all , besides the low end.

So... the losers can run deep before they resolve, and a small number of them never come back and do the most damage. The edge depends on sitting through drawdown, but the occasional non-recovery is brutal.

What I've already tested (so "just use a stop" won't help):

  • Hard stop at −20% ROI (on a 10x position): net negative. It cut a huge number of trades that would have recovered — bled more than it saved.
  • Drawdown distribution: even among trades that breach −40% ROI, about 53% still return to a small loss or a profit. So any flat "cut at −X%" throws away more eventual winners than catastrophes it prevents.

So a fixed price-based stop is a trap that ive discovered over multiple sesions. The deep drawdowns are mostly noise the rest killers, and by the rest I've narrowed it down to about 4-5%.

The big question how can i mittigate the deep loses? The methodology used:

  • Time-based exit (cut if not recovered within N bars) instead of a price stop
  • Vol-expansion / regime filter — only bail when the regime that breaks the recovery assumption shows up
  • Portfolio-level heat cap instead of per-trade stops
  • Size for the drawdown + fractional Kelly, just accept the DD
  • A cheap tail hedge / trend overlay

To sum up, I've tried lots of options for the bot itself, and the current conclusion is just not run it 24/7 but in specific times of the day and for a short while.

Any and all suggestions would be greatly appreciated.

reddit.com
u/humannm48 — 7 days ago

5 year backtest TSLA strategy

I’ve been developing an intraday breakout strategy on Tesla for months. What started as a simple range breakout system gradually evolved through lots of iterations — adding filters, refining exits, and eventually running a proper walk-forward validation. It’s been running live on my real account since March 11, 2026.
Sharing the full results and methodology here because I think the validation process is worth discussing. Most backtest posts skip this part entirely.

The strategy in plain terms:
The system identifies a price range using the high and low of the previous 4 candles on the 5-minute chart. When price breaks out of that range with enough momentum, an entry is triggered — but only if four filters all agree:
• ADX: confirms the breakout is happening in a trending environment
• Minimum range size (ATR-based): rejects setups where the range is too compressed
• Candle strength: evaluates the size and close position of the breakout candle
• RSI on higher timeframe: avoids entries in overbought/oversold conditions on the higher timeframe
This combination addresses the main failure modes of breakout trading: false breaks, low-momentum moves, and counter-trend entries. The result is a win rate significantly above the 45–55% typical of unfiltered breakout systems.
Exits use a layered approach: fixed TP at 2.75%, EMA trailing stop, no-progress exit, and a no follow-through exit if price returns into the range. In the last hour of the session, the trailing tightens aggressively to protect intraday gains.
~150 trades per year, both long and short, NYSE RTH only.

Backtest results:
(Jan 2021 – Jun 2026, $100k fixed capital, $1/order commission + 5 ticks slippage, no compounding)
• Net profit: +$378,906 (+378.91%)
• CAGR: 33.37%
• Max drawdown: 6.45% — TSLA itself drew down -56% in this period
• Calmar Ratio: 5.17
• Profit Factor: 2.181
• Sortino Ratio: 2.954
• Sharpe Ratio: 0.693
• Win Rate: 71.15% across 825 trades
• 57 of 66 months profitable (86%)
• Zero losing years

Capital is fixed throughout — no compounding.
With 70% equity reinvestment the numbers look very different:
• Net profit: +$1,242,892 (+1,242.89%)
• CAGR: 61.33%
• Max drawdown: 9.52%
• Calmar Ratio: 6.43
• Profit Factor: 2.168
• Sortino Ratio: 2.853
• Sharpe Ratio: 0.887

Walk-forward validation — the part I want to focus on
I ran three WFA iterations to test whether the edge holds on unseen data:

|Iteration| In-Sample | OOS | Profit factor |
|1 |2021–2023 | 2024 | 1.714 |
|2 |2021–2024 | 2025 | 2.878 |
|3 |2021–2025 | 2026 | 2.106 |

All three OOS periods made money. Two of three had a PF above 2.0 out-of-sample.
Iteration 1 is the weakest — H1 2024 was the most directionless period TSLA had in the entire dataset. A breakout system underperforming in a low-momentum regime is expected behavior, not a strategy failure. It recovered as soon as volatility returned.

Happy to discuss the methodology, the exit logic, the walk-forward process, or anything else in the comments.

u/ferri_2126 — 11 days ago