Machine learning (ML):
software that learns patterns from historical examples instead of being explicitly programmed with rules.
Educational content only — not financial advice. Trading involves substantial risk of loss.
Learn, in plain English, how everyday traders in the US build an AI-assisted trading system — a machine-learning "trade filter," a market-storm detector, and math-based position sizing — then automate every order through PickMyTrade, with Claude Fable (Anthropic's AI model) writing the code as your copilot.
AI trading (machine-learning trading) means using a computer model, trained on years of market history, to help make trading decisions — most usefully, deciding which trade ideas are worth taking and how much risk conditions allow. It is not a robot that magically knows the future.
Here's the analogy that makes everything below click. Imagine you run a small shop and you're deciding which products to stock. You could guess. Or you could hire an experienced assistant who has watched thousands of product launches and says: "Based on everything I've seen, this one looks like a 68-out-of-100. That one is a 31 — skip it." The assistant isn't psychic. They've just seen so many past examples that they recognize the conditions under which things tend to work.
A machine-learning model plays exactly that assistant role in a trading system. You show it thousands of historical trade setups, each labeled with what actually happened (win, loss, or fizzle). It learns which market conditions — recent volatility, trend strength, momentum — tended to accompany the winners. Then, for every new trade your strategy proposes, it produces a score: the estimated probability this trade works out. You take the high scores and skip the rest.
Three terms you'll see constantly (each also lives in the glossary):
software that learns patterns from historical examples instead of being explicitly programmed with rules.
replaying your strategy over past market data to see how it would have behaved — a rehearsal, not a guarantee.
letting software place the orders your rules generate, so execution is fast, consistent, and emotion-free.
Professionals don't use AI to predict prices. They use it to filter trades, read market conditions, and manage risk. That's the honest, durable use of machine learning in markets — and it's exactly the system this page teaches you to build.
Professional trading desks don't chase the biggest possible gains. They aim for steady, risk-managed growth with much smaller drawdowns than buy-and-hold investing. That is the goal this entire plan is designed around.
A drawdown is the drop from your account's peak to its lowest point before it recovers — the "how much did it hurt on the way down" number. Buy-and-hold stock investing has historically delivered solid long-run growth, but with occasional gut-wrenching plunges along the way. The professional-style alternative accepts a calmer ride: it is designed to give up some of the excitement in exchange for shallower dips, which are easier to survive financially and emotionally.
Two numbers professionals use to keep score, each in one sentence:
how much return you earned per unit of bumpiness (volatility) along the way; higher means a smoother, more efficient ride.
your yearly growth rate divided by your worst drawdown; it directly rewards "grew steadily without a crater."
Historically, this class of technique — trade filtering, regime detection, volatility-based sizing — has been used by professional managers precisely to improve those two ratios rather than to chase headline returns. Every design choice in the rest of this guide serves that goal.
Nothing on this page promises any particular return, and no honest teacher can. What the plan can give you is a professional-style process: measured risk on every trade, an automated execution chain with no emotional overrides, and testing habits that keep you honest before a single real dollar is at stake.
The whole system is a pipeline of five blocks. Your strategy proposes trades; AI grades them and checks the market weather; fixed math decides position size; and PickMyTrade executes at your broker. Each block has one job, and no block is allowed to do another block's job.
Everything starts with a simple, understandable strategy — for example, a TradingView strategy that says "buy when the market is in an uptrend and pulls back to its average." This block's only job is to propose candidate trades. It doesn't need to be brilliant; it needs to be consistent, because the next block will do the quality control.
This is the machine-learning heart of the system. A LightGBM model — trained on your strategy's own historical trades — scores each new proposal: what's the probability this trade hits its profit target before its stop? Think of it as an experienced desk manager approving or rejecting trade tickets. The AI never invents trades; it grades them. Quants call this meta-labeling, and it's how professionals turn a mediocre signal into a selective one.
Markets have moods: long calm stretches and sudden storms. A small statistical model (a hidden Markov model, via the hmmlearn library) watches volatility and returns to classify today as calm or stormy — like a weather service for your account. In stormy regimes the system reduces exposure or stands aside entirely. Standing aside during storms is one of the oldest, most reliable ideas in professional risk management.
Fixed, transparent arithmetic — never AI guesswork — decides how much to trade. Volatility targeting means trading smaller when the market is wild and normal size when it's calm, so every trade risks a similar, controlled amount. Fractional Kelly is a deliberately conservative version of a classic bet-sizing formula: higher-confidence trades may size modestly larger, but always within a hard cap (commonly risking well under 1–2% of the account per trade). Stops and targets are set as ATR multiples — a standard measure of recent price movement — so they adapt to conditions automatically.
When a trade passes every gate, your TradingView alert fires a webhook (an instant machine-to-machine message) to PickMyTrade, which places the order at your connected broker — with the take-profit and stop-loss bracket attached from the first second. No hesitation, no second-guessing, no fat-finger errors.
AI answers two questions only: "Which trades are worth taking?" and "Is the market safe right now?" Fixed math answers "How much?" and "Where are the stop and target?" (always ATR-based rules, never an AI guess). And once the system is running, you don't override individual trades — discipline is the feature. This separation is exactly how professional systematic desks keep machine learning powerful but contained.
Eight steps take you from zero to a live, automated, risk-managed system. With an AI copilot writing the code, the first working version is typically a few weekends of effort; the honest testing that follows is what turns it into something you can trust.
Start with daily bars and swing trades (holding for days to weeks) on very liquid US instruments: the SPY or QQQ ETFs, or Micro E-mini futures — MES (S&P 500) and MNQ (Nasdaq-100). Micro futures are one-tenth the size of the standard E-mini contracts, need only a small margin deposit, and — unlike frequent stock day-trading in a margin account — are not subject to the FINRA Pattern Day Trader $25,000 rule. Slower timeframes also give machine learning a better signal-to-noise ratio and keep trading costs from eating your results.
Your model is only as good as its history. Download 10+ years of daily data for your chosen instrument. For learning, the free yfinance Python library is perfectly fine. When you later expand to baskets of individual stocks, professional, survivorship-bias-free data (e.g., Norgate Data) becomes the upgrade — it includes companies that were delisted, so your backtest isn't secretly built only on survivors.
Features are the facts you show the model about each day: returns over the last 5/20/60 days, realized volatility, ATR, distance from a long-term moving average, a momentum reading. Resist the urge to pile on dozens of exotic indicators — in practice, a small set of simple, distinct features generalizes far better than kitchen-sink complexity.
To learn, the model needs an answer key. The triple-barrier method creates one: for each historical signal, place three "barriers" — a profit target above, a stop-loss below (both set as ATR/volatility multiples so they breathe with the market), and a time limit. Whichever barrier gets hit first is the label: win, loss, or timeout. It mirrors exactly how a disciplined trade is managed in real life, which is what makes the labels trustworthy.
Now train a LightGBM classifier — the workhorse model for tabular market data — to predict, from the features on signal day, whether the trade ends at the profit barrier or the stop barrier. The output is a probability score for every future signal. You'll set a threshold (say, only act above a certain confidence) during validation. This trains in seconds to minutes on a normal laptop — no GPU required.
A model tested on data it already saw is like a student grading their own exam with the answer sheet open. Honest validation means: walk-forward testing (train on the past, test on the never-seen future, roll forward, repeat) and purged cross-validation (carefully removing overlapping samples so no information leaks between training and testing). Then subtract realistic commissions and slippage — and re-run everything at double your cost estimate. A system worth trading still makes sense under those harsher assumptions.
Run everything end-to-end on live market data with simulated money for one to three months — TradingView alerts, the AI filter, sizing, and demo-account execution. You're verifying that real-time behavior matches the backtest: same signals, sensible fills, no bugs at 9:30 a.m. Paper trading is free and it's where the "gotchas" surface harmlessly.
When paper results track the backtest, connect the chain for real: your TradingView strategy fires alerts, each alert sends a JSON webhook to PickMyTrade, and PickMyTrade routes the order — with its take-profit/stop-loss bracket — to your broker account. Start at the smallest possible size (one micro contract or a few ETF shares), watch the system's live statistics for weeks, and only scale gradually if reality keeps matching the test.
Claude Fable is Anthropic's frontier AI model (model id claude-fable-5), available through the Claude app and Claude Code. For this project it acts as your personal quant developer, tutor, and code reviewer — writing the Python, explaining every concept, and catching the classic mistakes before they cost you.
Concretely, Claude Fable can:
the data pipeline, feature engineering, triple-barrier labeling, LightGBM training, and backtests, from plain-English requests.
ask it to re-explain purged cross-validation with a cooking analogy until it clicks.
e.g., translate a TradingView Pine Script strategy into Python so it can be backtested and meta-labeled properly.
look-ahead bias and data leakage, the subtle bugs that make backtests look great and live trading disappoint.
TradingView alert messages and the JSON payloads PickMyTrade consumes via webhook.
Here are ready-to-copy prompts for each stage. Paste them into Claude and adapt the details to your setup.
Write Python code using yfinance and pandas that downloads 15 years of daily OHLCV data for SPY, cleans it (missing days, splits/dividends via adjusted prices), and computes these features: log returns over 5/20/60 days, 20-day realized volatility, 14-day ATR, and distance from the 200-day moving average as a percentage. Save the result to a Parquet file. Explain each step in comments as if I'm new to Python.
Write Python code using pandas and LightGBM to train a model that predicts whether my strategy's next trade will hit its profit target before its stop, using triple-barrier labels. Set the profit barrier at 2x the 14-day ATR above entry, the stop barrier at 1.5x ATR below, and a vertical barrier of 10 trading days. Label each historical signal by whichever barrier is touched first. Train a LightGBM classifier on my feature DataFrame and output the predicted win probability for each signal. Make sure every feature only uses information available BEFORE the signal bar closes.
Take my LightGBM trade-filter model and evaluate it with walk-forward validation: train on 2010-2017, test on 2018, then roll the window forward year by year through last year. Also implement purged K-fold cross-validation with an embargo so overlapping triple-barrier labels never leak between train and test folds. Report precision, the net-of-cost expectancy per trade assuming $2.50 commission and 1 tick of slippage per side on MES, and re-run everything at double those costs. Explain the results to me in plain English.
Here is my TradingView Pine Script strategy [paste script]. Convert it to Python using pandas so that it produces the exact same entry signals on the same historical bars. Then show me how to verify the two versions match by comparing signal dates. Flag anything in my Pine Script that could cause look-ahead bias, like using the current bar's close before it has closed or security() calls with lookahead on.
Review this backtesting code [paste code] specifically for look-ahead bias and data leakage. Check: (1) do any features use future information, (2) are scalers or feature selection fitted on the full dataset instead of only the training window, (3) do my triple-barrier labels overlap between train and test splits, (4) am I trading at prices I couldn't actually have gotten. List every issue found, rate its severity, and show the corrected code.
I use PickMyTrade to route TradingView alerts to my broker. Here is the alert JSON payload that PickMyTrade generated for my account [paste JSON]. Explain what every field does in plain English, then show me how to adapt it so my strategy's alerts pass the correct order quantity and attach a take-profit and stop-loss bracket. Also write the TradingView alert message using placeholders like {{close}} correctly. Claude Fable writes and reviews the code; you read it, run it, question it, and make every decision about money. Treat the AI as a brilliant junior developer: enormously productive, but everything ships only after the human signs off. Never deploy code you haven't at least walked through and paper traded.
Because in trading, execution bugs don't cost you time — they cost you money, instantly. With Claude Fable writing code for you, it's tempting to build your own order-routing script too. Here's why professionals — and this plan — keep strategy and execution separate, and rent the execution layer.
A homemade execution script with one flaw — a dropped webhook, a duplicate order, a missed stop-loss, a crashed process that leaves a futures position open overnight, an API disconnect during a fast market — can wipe out weeks of carefully earned edge in minutes. A bug in your research code wastes an evening; a bug in your execution code is a direct, immediate financial loss. Execution failures are not "learning experiences."
A battle-tested execution bridge like PickMyTrade already handles the hard reliability engineering: retry logic, each broker's API quirks, session re-authentication, take-profit/stop-loss bracket placement, partial fills, and order-state tracking — hardened across thousands of users' live orders every day. A solo builder cannot realistically out-engineer that, and there is zero alpha (trading edge) in re-inventing it. Nobody ever beat the market because their webhook parser was homemade.
Everything that can actually make your results better lives in the layers you own: signal quality, the AI trade filter (meta-labeling), the regime gate, position sizing, and honest validation. That is where 100% of your research hours should go. Every hour spent debugging homemade order-routing code is an hour stolen from the only layer that can actually produce an edge.
Keeping strategy (your code) and execution (PickMyTrade) separate means a strategy bug can't corrupt order handling, and an execution hiccup can't silently poison your research results. Professional trading firms are structured exactly this way: quants build the signals; a dedicated, hardened execution layer routes the orders. You're borrowing an institutional design pattern, for the price of a subscription.
Rent the plumbing. Own the brains.
Your intelligence — the strategy, the AI filter, the risk rules — is yours and irreplaceable. The pipes that carry orders to the broker are a commodity. Buy the commodity; invest in the intelligence.
PickMyTrade is a trade-automation platform that connects TradingView alerts to real broker accounts. It's the bridge that turns your system's signals into actual, bracket-protected orders — automatically, around the clock, without you touching a mouse.
A webhook is simply an instant message one piece of software sends to another over the internet. The execution chain looks like this:
(your strategy's conditions are met)
(a small structured text payload describing the trade)
and applies your settings (quantity, symbol mapping, risk rules)
with take-profit and stop-loss bracket orders attached.
Setup requires no coding: in the PickMyTrade dashboard you connect your broker account, and the platform auto-generates the alert JSON payload — you paste it into your TradingView alert's message box along with PickMyTrade's webhook URL, and the pipeline is live. The company advertises sub-second, cloud-based routing that runs 24/7, so signals execute even when your computer is off.
This is where the whole plan comes together. The research behind systematic trading is unambiguous on one point: the most common way a good system fails is the human overriding it — skipping the entry that felt scary (often the winner), moving a stop "just this once," or revenge-trading after a loss. Automated execution through PickMyTrade enforces the discipline your backtest assumed:
PickMyTrade is an execution-automation tool — it places the orders your strategy generates. It does not provide trading advice, signals, or strategies, and using it does not change the risk of the strategy you feed it. The strategy quality is on you (and your validation process).
Every software component of this system is free and open source. You don't need to understand them all today — this table is your map, with a plain-English "what it does for you" for each. Claude Fable knows every one of these libraries and can write working code for them on request.
| Tool | Category | What it does for you, in plain English |
|---|---|---|
| LightGBM | ML model | The workhorse "trade filter" brain — learns from history and scores each new trade's odds. Fast on any laptop. |
| scikit-learn | ML toolkit | The Swiss-army knife for machine learning: data splitting, metrics, and model evaluation utilities. |
| pandas | Data handling | The spreadsheet of Python — loads, cleans, and transforms your price history and features. |
| mlfinpy | Quant methods | Ready-made implementations of the professional techniques in this guide: triple-barrier labeling and meta-labeling. |
| skfolio | Validation & portfolio | Provides purged/combinatorial cross-validation out of the box — the honest testing machinery — plus portfolio construction tools. |
| hmmlearn | Regime detection | The "storm detector": fits hidden Markov models that classify the market as calm or turbulent. |
| vectorbt | Fast backtesting | Lightning-fast first-pass backtests to triage ideas in seconds (use a stricter tool before going live). |
| NautilusTrader | Realistic backtesting / live | Professional-grade engine that simulates realistic order fills — your final pre-live re-check and a bridge to production. |
| MLflow | Experiment tracking | A lab notebook that automatically records every model version and test you run, so you always know what you tried. |
| FinBERT | News sentiment | Reads financial headlines and scores their tone — useful as a "storm warning" veto filter, not as a crystal ball. |
| Chronos / TimesFM | AI forecasting | Modern AI time-series models used here for one job only: forecasting volatility to feed position sizing. |
| yfinance | Data (free) | Free historical price downloads — perfect for learning and prototyping the pipeline. |
| Norgate Data | Data (paid upgrade) | Survivorship-bias-free historical data, including delisted stocks — the professional upgrade when you expand to stock baskets. |
Almost every beginner setback in ML trading comes from a short list of known, avoidable mistakes. Learn them once here, and you're ahead of the curve.
If the model was trained on 2020 and you "test" it on 2020, of course it looks brilliant. Always evaluate on genuinely unseen periods — that's what walk-forward and purged cross-validation (Step 6) exist for.
Tweak parameters long enough and you'll "discover" a system that perfectly fits the past — and only the past. Prefer settings that work across a broad range of values, and count how many variations you tried.
Stops and targets belong to fixed ATR-based rules, not model predictions. Asking ML to pick exact exit prices is a known way to overfit; keeping exits mechanical is how professionals contain the AI's job.
On one-minute charts, commissions and slippage devour small edges, and the data is mostly noise — the worst possible diet for an ML model. Daily/swing timeframes keep costs small relative to each trade's potential.
The backtest can't catch a mis-configured alert, a symbol mapping typo, or a data feed hiccup. One to three months of simulated trading catches these for free. Going straight to live money skips the system's dress rehearsal.
Skipping the scary signal, nudging a stop, doubling up after a loss — every override invalidates the statistics you validated. Automating execution with PickMyTrade exists precisely to protect the system from its owner's moods.
No. AI assistants like Claude Fable (Anthropic's frontier model) can write the Python code for the entire pipeline — data download, feature engineering, model training, and backtesting — from plain-English instructions. Your job is to understand what each piece does, review the outputs, and stay in control of the decisions. Reading code is a much lower bar than writing it, and the example prompts above get you started.
You can build and test everything for close to zero dollars: free data sources, free open-source software, and free paper-trading (simulated) accounts. When you eventually go live, Micro E-mini futures were designed for small accounts and carry much lower margin requirements than full-size contracts. This guide makes no recommendation about how much to deposit or risk — never trade money you cannot afford to lose.
Yes. Retail traders in the US may legally use automated and algorithmic trading through regulated brokers, and tools like TradingView alerts and PickMyTrade operate within that framework. Two rules to know: the FINRA Pattern Day Trader rule requires $25,000 minimum equity if you place more than three stock day-trades in five business days in a margin account (futures are not subject to this rule), and every broker has its own automation policies you agree to. This is general information, not legal advice.
PickMyTrade is a trade-automation platform that connects TradingView alerts to real broker accounts. When your TradingView strategy fires an alert, it sends a JSON message via webhook to PickMyTrade's cloud, which immediately places the order at your connected broker — including take-profit and stop-loss bracket orders, trailing stops, and position sizing rules you configure. It requires no coding: PickMyTrade generates the alert payload for you to paste into TradingView.
As published on its official sites, PickMyTrade supports Tradovate, Rithmic, Interactive Brokers, TradeStation, TradeLocker, ProjectX, Tradier, Match Trader, and the Binance crypto exchange, plus a long list of futures prop firms such as Apex Trader Funding and Topstep. The lineup evolves, so check pickmytrade.com for the current list before choosing a broker.
For almost everyone, use a proven execution service. Execution bugs — a duplicate order, a missed stop-loss, a script that crashes while holding a futures position overnight — cost real money instantly, and reliable order routing (retry logic, broker API quirks, session re-authentication, bracket placement, partial fills) is hard engineering that platforms like PickMyTrade have already battle-tested across thousands of users' live orders. Your trading edge lives entirely in your strategy, AI filter, and risk rules — there is no edge in re-inventing order plumbing. Rent the plumbing, own the brains.
Not in the crystal-ball sense — and professionals do not use it that way. In professional practice, machine learning is used to filter trade ideas (estimating which setups have better odds), detect market regimes (calm versus stormy conditions), and inform position sizing. The edge comes from taking fewer, better trades and managing risk consistently, not from forecasting tomorrow's price.
Meta-labeling is a professional technique, popularized by quant researcher Marcos López de Prado, where a machine-learning model does not generate trades — it grades them. Your existing strategy proposes each trade, and a second model (often LightGBM) predicts the probability that this specific trade will hit its profit target before its stop, based on current market conditions. Low-confidence trades are skipped; high-confidence trades can be sized slightly larger within fixed risk limits.
Daily bars with swing holding periods (days to weeks) are widely considered the best fit for individual traders. Slower timeframes have a better signal-to-noise ratio for machine learning, dramatically lower commission and slippage drag, no need for split-second execution, and they keep stock traders clear of the Pattern Day Trader rule. Very fast intraday trading is where fees and latency work hardest against individuals.
No. The recommended model family for this kind of tabular market data is gradient-boosted trees (LightGBM), which trains in seconds to minutes on an ordinary laptop CPU. Even the optional extras — FinBERT news sentiment and AI volatility forecasters like Chronos or TimesFM — run fine on CPU for daily-timeframe workloads.
Plan for a few months of evenings-and-weekends work: roughly two to four weeks for a first working pipeline with an AI copilot writing the code, then one to three months of validation and paper trading before any real money. The paper-trading stage is not optional padding — it is where you confirm the live system behaves like the backtest.
The triple-barrier method is a way of labeling historical trades so a machine-learning model can learn from them. For each past signal you place three barriers: a profit target above, a stop-loss below (both set as multiples of recent volatility), and a time limit. Whichever barrier is hit first determines the label — win, loss, or timeout — mirroring how a disciplined trade is actually managed.
Yes. The FINRA Pattern Day Trader rule — $25,000 minimum equity for frequent day-trading — applies to stocks and ETFs in margin accounts, not to futures. Micro E-mini futures such as MES (S&P 500) and MNQ (Nasdaq-100) were created specifically for smaller accounts, with much smaller contract sizes and margins than the full-size versions. Futures remain leveraged instruments with substantial risk, so position sizing rules still matter most.
Educational purposes only. All content on this page is provided for general educational and informational purposes and does not constitute investment, financial, legal, or tax advice, nor a recommendation or solicitation to buy or sell any security, futures contract, or other financial instrument.
Substantial risk of loss. Trading futures, derivatives, and other leveraged products involves substantial risk of loss and is not suitable for all investors. You can lose more than your initial investment. Only risk capital — money you can afford to lose without affecting your lifestyle — should ever be used for trading.
Past performance is not indicative of future results. Hypothetical and backtested performance results have inherent limitations: they are prepared with the benefit of hindsight, do not involve financial risk, and cannot account for all factors — including the ability to withstand losses — that affect actual trading. No representation is made that any account will or is likely to achieve results similar to any examples or concepts discussed.
No guarantees. Nothing on this page guarantees profit or protection from loss. Machine-learning models can be wrong, market conditions change, and automated systems can malfunction.
Not a registered advisor. The author and publisher of this page are not a registered investment advisor, broker-dealer, commodity trading advisor (CTA), or financial planner. Before making any financial decision, consult a licensed financial advisor who can evaluate your individual circumstances.
About the tools mentioned. PickMyTrade is a third-party execution-automation tool that routes alerts to brokers; it does not provide trading advice, signals, or strategies. Claude Fable is an AI model that assists with code and explanations; its output should always be reviewed by a human. TradingView, PickMyTrade, Anthropic, and all brokers named are independent companies; all trademarks belong to their respective owners. This page is independent educational content and is not endorsed by or affiliated with any of them. Factual product details (supported brokers, pricing) were taken from the vendors' public websites and may change — always verify on the official sites.
This page keeps things plain-English on purpose. If you already know Python and ML and want the practitioner-level version — Hugging Face time-series foundation models, López de Prado's CPCV/triple-barrier toolkit, NautilusTrader, Qlib, and a full reference pipeline with real code — read the Advanced AI Trading Guide: ML Library & Model Reference for Quants →
Build the brains, rent the plumbing. Connect your TradingView alerts to your broker through PickMyTrade and let every validated signal execute automatically.