◆ New — Strategy Validator, Code Fixer & Prop Compliance Checker are live. Try one free →
Learn · free

Trade the truth, not the backtest.

Plain-English guides to the bugs that quietly wreck strategies — and the risk math and patterns nobody teaches properly.

Correctness

The bugs that make a backtest lie

Guides

Trading, explained

How to Convert a MetaTrader EA to TradingView Pine Script

A developer-facing guide to porting a working MQL4/MQL5 Expert Advisor into a clean, non-repainting Pine v6 strategy: what maps cleanly, what cannot be faithfully converted (hedging, multi-symbol trading, tick scalping, event callbacks, DLL imports), a worked EMA-cross example, and how to validate the result signal-for-signal. This is educational material only, not financial advice; automated trading carries a genuine risk of loss, and any converted strategy should be studied and backtested before it goes anywhere near live capital.
Read →

request.security() Repainting in Pine Script: Causes and the Fix

A precise walkthrough of why request.security() repaints on historical bars, the look-ahead trap that makes backtests look unrealistically good, and the exact patterns that pull a confirmed higher-timeframe value instead. Educational only — validate before trading; not financial advice, and trading carries risk of loss.
Read →

Why Your Pine Script Backtest Doesn't Match Live Trading

A backtest that looks clean in the Strategy Tester but behaves differently live almost always traces to a handful of well-understood causes: repainting signals, look-ahead bias, intrabar recalculation, and unrealistic fill assumptions. This guide walks through each mechanism and its fix, then gives a non-repainting baseline you can build on. Educational only — nothing here is financial advice, no strategy is implied to be profitable, and trading always carries the risk of loss.
Read →

How to Add a Trailing Stop in Pine Script v6

A practical, code-first guide to adding a trailing stop to a Pine Script v6 strategy using strategy.exit() with trail_points, trail_offset, and trail_price. Covers a fixed-distance trailing stop, an ATR-based version that breathes with volatility, and how to combine a hard stop-loss with a trailing stop in one call — with point units explained via syminfo.mintick. This is educational material only, not financial advice; trailing stops can lock in less on strong runs and get whipsawed in noise, and a backtest result is never a forecast of live performance.
Read →

MQL5 vs Pine Script: Key Differences and Which to Use

MQL5 and Pine Script solve the same problem — turning a trading idea into code — but they live on different platforms and model time, price, and orders in fundamentally different ways. Pine Script runs inside TradingView charts and is declarative and series-based; MQL5 runs inside MetaTrader 5 against a broker and is event-driven and imperative. This guide compares where each runs, how they execute, what they can and cannot automate, and how they backtest, then shows the same EMA-cross idea in both. It is educational only: nothing here is predictive, no strategy is implied to be profitable, and trading carries the risk of loss. You do not have to choose one forever — ForexCodes converts between Pine and MetaTrader in both directions.
Read →

MQL4 vs MQL5: Which Should You Code Your EA In?

A practical, balanced comparison of MQL4 and MQL5 for building an Expert Advisor: the trade APIs, hedging vs netting, backtesting, platform availability, and migration. This is educational material only, not financial advice; automated trading carries a real risk of loss, and any code here should be studied and tested on a demo account before it goes anywhere near a live one.
Read →

How to Add a Stop-Loss to a MetaTrader Expert Advisor

A practical, code-first walkthrough of attaching a real stop-loss to a MetaTrader Expert Advisor in both MQL4 and MQL5, covering fixed and ATR-based stops plus the broker stops-level / error 130 gotcha. This is educational content only, not financial advice; trading carries a real risk of loss, and every example should be tested on a demo account first before it ever touches a live one.
Read →

Why Expert Advisors Blow Accounts: The Bugs to Check Before You Run One

Most of the ways an expert advisor blows an account are not exotic market events — they are ordinary code bugs that compile fine, pass a clean backtest, and only bite once real money and real spread are involved. This guide walks through the six safety bugs to check before you run any bought, downloaded, or AI-generated EA, and shows how to spot each one in the code. It is educational only, not financial advice; trading carries a substantial risk of loss, and you should always test on a demo account first.
Read →

How to Convert a TradingView Strategy into a MetaTrader EA

This guide walks through what it actually takes to convert a TradingView Pine strategy into a MetaTrader Expert Advisor, focusing on the semantic gap between Pine's declarative bar-series model and MQL's event-driven OnTick loop. It is educational only and not financial advice; nothing here implies any strategy is profitable. Trading involves a real risk of loss, so always test any converted EA on a demo account first before considering live use.
Read →

What Is an Expert Advisor (EA)? A Plain-English Guide to MetaTrader Bots

A beginner-friendly explanation of what an Expert Advisor is, how MetaTrader runs it through OnInit and OnTick, how EAs differ from indicators and scripts, what the .mq4/.mq5 and .ex4/.ex5 file types mean, and how to install one. This article is educational only and is not financial advice; automated trading involves a real risk of loss, so always use a stop-loss and test on a demo account first.
Read →

How to Add Stop-Loss and Take-Profit in Pine Script

A practical, code-first guide to adding stop-loss and take-profit to a Pine Script v6 strategy using strategy.exit with stop= and limit=. Covers fixed-distance versus ATR-based levels, long and short handling, and the difference between a backtest result and a live trading outcome. This is educational material only, not financial advice; trading involves real risk of loss, and a tester result never guarantees future performance.
Read →

Pine Script for Beginners: Your First Indicator

A friendly, step-by-step walkthrough of Pine Script for beginners: opening the Pine Editor, writing your first //@version=6 script, declaring an indicator, adding inputs, and plotting a simple EMA on your chart. This article is educational only and not financial advice; nothing here describes a profitable system, and trading always involves the risk of loss. The goal is to make you comfortable reading and writing clean, correct Pine v6 code.
Read →

How to Backtest a Strategy in TradingView — and What It Cannot Tell You

A practical walkthrough of how TradingView's Strategy Tester runs your code, how to read the metrics it reports, and the structural reasons those numbers can mislead — look-ahead, repaint, overfitting, ignored costs, and tiny samples. This is educational material only, not financial advice; trading involves risk of loss, and a backtest describes the past, not the future.
Read →

How to Convert a TradingView Indicator into a Strategy

A practical guide to converting an indicator() into a strategy() in Pine Script v6: what each script type actually does, how to replace visual plotshape markers with strategy.entry and strategy.exit, and why any repaint hiding in your original indicator carries straight into the backtest. This is educational material about Pine Script mechanics, not financial advice, and nothing here implies any approach is profitable; trading carries a real risk of loss.
Read →

Pine Script v5 to v6: The Complete Migration Guide

A practical, code-first walkthrough of moving a script from Pine Script v5 to v6: the version declaration, what genuinely breaks, the namespace and behavioral changes, and a full before/after rewrite. This is educational material about the language itself, not trading or financial advice — and remember that all trading involves the risk of loss, regardless of how clean your code is.
Read →

How to Turn a Trading Idea Into Pine Script

A practical walkthrough for taking a plain-English trading idea and expressing it as correct, non-repainting Pine Script v6 — not just code that compiles, but code that means what you think it means. This is educational material only, not financial advice, and trading carries a real risk of loss. The goal is clarity of logic, not any claim about performance.
Read →

Why Your TradingView Alerts Fire Late or Repaint — and How to Fix Them

A practical, plain-English guide to why TradingView alerts fire on the wrong bar, repaint, or seem to arrive late — and how bar-close confirmation, barstate.isconfirmed, and the alert() vs alertcondition() distinction actually behave. This is educational material only, not financial advice; trading involves risk of loss, and a non-repainting alert is about correctness, not profitability.
Read →

Common Pine Script Errors, Decoded

A plain-English walkthrough of the most common Pine Script errors beginners hit on TradingView — mutable-variable scope, na handling, type mismatches, "Cannot call with arguments", and series-vs-simple — with the cause and a tiny correct v6 fix for each. This is educational material about writing correct code, not trading or financial advice; trading involves real risk of loss, and a script that compiles cleanly tells you nothing about whether a strategy is sound.
Read →

Support & Resistance

Support and resistance are price levels where buying or selling pressure has tended to show up in the past. This guide explains what the terms mean, how traders commonly identify and interpret them, why levels break or hold, and how to plot a simple horizontal level in Pine Script v6. It is educational only — no indicator predicts the future, and all trading carries risk of loss.
Read →

Trend vs Range Markets

A plain-English guide to the difference between trending and ranging market conditions, how traders commonly describe each, and why the same tools can behave very differently depending on which condition is present. Educational only, with no trade recommendations.
Read →

Divergence (Price vs Indicator)

Divergence describes a disagreement between price movement and a momentum oscillator such as RSI, MACD, or the Stochastic. This educational guide explains what divergence is, the common regular and hidden types, how traders typically interpret it, its well-known weaknesses, and a short, valid Pine Script v6 example. It is for education only and is not buy or sell advice. No indicator predicts the future, and all trading carries risk of loss.
Read →

Risk Management Basics

A plain-English introduction to the core ideas behind trading risk management: position sizing, stop placement, risk-to-reward thinking, and protecting your overall account. This article is educational only and does not give buy or sell advice. No indicator, pattern, or method can predict markets, and all trading carries the risk of losing money.
Read →

Position Sizing

Position sizing is the process of deciding how much to put into a single trade. This educational guide explains the common fixed-percentage method, how stop distance and account size feed into the math, and why traders treat sizing as a risk-control tool rather than a profit lever. Includes a worked example and a short Pine Script v6 snippet for visualising risk-per-trade. Educational only — no advice, no signals, and a reminder that all trading carries risk of loss.
Read →

Drawdown & Recovery Math

An educational look at how drawdown is measured and why the math of recovering from a loss is not symmetrical. This article explains the percentages plainly, shows the simple formula, and offers a short Pine Script v6 example for visualising drawdown on a chart. It is for learning only and is not advice to act on. No indicator or formula predicts markets, and all trading carries the risk of loss.
Read →

What Is Backtesting (and Its Traps)

Backtesting means running a fixed set of trading rules against historical price data to see how they would have behaved in the past. It is a useful research and learning tool, but it is easy to fool yourself with it. This article explains what backtesting is, how it works, and the common traps that make past results look far better than anything you should expect going forward. Educational only. No indicator or method is predictive, and all trading carries the risk of loss.
Read →

Candlestick Basics

A plain-English introduction to candlestick charts: what each part of a candle shows, how traders read common single-candle and multi-candle shapes, and why candlesticks describe the past rather than predict the future. Educational only — no indicator is predictive, all trading carries the risk of loss, and nothing here is buy or sell advice.
Read →

Chart Patterns — an Overview

A plain-English introduction to chart patterns: what they are, how traders identify the common ones, and how people typically interpret them. Patterns describe price behavior — they do not predict it, and trading carries the risk of loss.
Read →

Head & Shoulders Pattern

The Head & Shoulders is a classic chart pattern that traders study as a possible sign of a shift in trend. This guide explains how the pattern is structured, how traders identify it, and how they typically interpret it — in plain English, with no claims about predicting price or guaranteeing outcomes. Nothing here is buy or sell advice, and trading carries a real risk of loss.
Read →

Double Top & Double Bottom

A plain-English, educational look at two of the most-discussed reversal chart patterns: the double top and the double bottom. Covers how traders identify them, the role of the "neckline," common confirmation habits, and the many ways these patterns can fail. Educational only — nothing here is a signal, recommendation, or prediction, and trading carries risk of loss.
Read →

Triangles & Wedges: How Traders Read These Chart Patterns

Triangles and wedges are consolidation patterns formed by converging trendlines. This guide explains how traders identify each type, what the shapes describe about price behaviour, and the common ways people interpret them — strictly as study material, not as signals to act on. Patterns are descriptive, not predictive, and trading carries a real risk of loss.
Read →

Flags & Pennants: How Traders Read These Consolidation Patterns

Flags and pennants are short consolidation patterns that some traders identify after a sharp price move. This guide explains how they are commonly described and interpreted, and why none of it is predictive. Educational only — nothing here is buy/sell advice or a signal to act on, and trading carries a real risk of loss.
Read →

The Doji Candlestick

A doji is a candlestick whose open and close are at or very near the same price, producing a tiny or non-existent body. It reflects a session where buyers and sellers ended in rough balance. This guide explains how traders identify dojis, the common variations, how they are typically interpreted in context, and why a doji on its own is not a signal to act. Educational content only; nothing here is trading advice and trading carries risk of loss.
Read →

Engulfing Candlesticks

An engulfing pattern is a two-candle formation where the real body of the second candle fully covers the real body of the first. This guide explains how traders identify bullish and bearish engulfing patterns, how they are commonly interpreted, and the limitations to keep in mind. It is educational only and not advice; nothing here is predictive, and trading carries risk of loss.
Read →

Hammer & Shooting Star

The hammer and shooting star are single-candle shapes defined by a small body and one long wick. This guide explains how traders identify each pattern, what the long wick is often read to suggest about a session, and why context and confirmation matter. Educational only — these shapes are not signals to act on and nothing here is predictive. Trading carries risk of loss.
Read →

Multi-Timeframe Analysis: How Traders Read One Market Across Several Charts

Multi-timeframe analysis (MTF) is the practice of studying the same instrument on more than one chart interval to put short-term price action in context. This guide explains how traders typically structure higher, intermediate, and lower timeframes, common pitfalls like repainting and conflicting reads, and a short, valid Pine v6 snippet for pulling higher-timeframe data. It is educational only: nothing here is a signal, recommendation, or prediction, and trading carries the risk of loss.
Read →

Expectancy & Trading Edge

Expectancy is a simple way to describe what a trading approach has done on average per trade over a sample of past results. This guide explains the formula, the difference between win rate and edge, why position sizing and costs change the picture, and how traders study expectancy in a strategy tester. It is educational only and makes no claims about future results. Nothing here is predictive, and trading carries risk of loss.
Read →

alertcondition() vs alert() in Pine Script: Which One Should You Use?

A precise comparison of Pine Script's two alert mechanisms: alertcondition(), which registers a named, fixed-message alert option in TradingView's Create Alert dialog, and alert(), which fires events from inside script logic with dynamically built messages. Covers the const-string limitation, the unconfirmed-bar trap that makes alerts fire on signals that later disappear, and what to use in strategies. Educational material only, not financial advice — an alert is a notification mechanism, and no alerting choice makes a signal profitable; trading carries a real risk of loss.
Read →

Strategy Order Alerts and Webhooks in Pine Script: alert_message and Placeholders

How TradingView strategy order-fill alerts reach a webhook: attaching alert_message payloads to strategy.entry()/exit()/close(), the {{strategy.*}} placeholder reference, building JSON that a bot can parse, and the delivery mechanics on TradingView's side. Written with the caveat the topic demands: webhook automation inherits every discrepancy between the broker emulator's simulated fills and real execution. Educational material only, not financial advice — wiring alerts to real money without validation is how backtest fictions become live losses, and trading always carries a real risk of loss.
Read →

Pine Script Arrays: A Practical Guide to push, get, Loops, and Pitfalls

A working guide to arrays in Pine Script v6: creating them with array.new<type>(), the core push/get/set/size API, safe looping with for...in, and the pitfalls that actually bite — above all the var-versus-rebuilt-each-bar mistake that silently corrupts historical calculations, plus out-of-bounds indexes and reference semantics. Every recommended example compiles under v6 and passes our deterministic validator. Educational material only, not financial advice; arrays are a data structure, and nothing built with them is implied to be profitable — trading carries a real risk of loss.
Read →

How to Draw Labels, Boxes, and Lines in Pine Script v6 (and Manage Object Limits)

A practical guide to Pine Script v6 drawing objects: creating labels with label.new(), boxes with box.new(), and lines with line.new(), plus the part most tutorials skip — max_labels_count, max_boxes_count, and max_lines_count, and the garbage-collection behaviour that silently deletes your oldest drawings. Covers deterministic FIFO management with arrays and the cheaper update-in-place pattern using var and setter functions. Educational material only, not financial advice: drawings are a visualization and inspection tool, and no chart annotation makes a strategy profitable — trading always carries a real risk of loss.
Read →

Sessions and Timezones in Pine Script: time(), Session Strings, and DST Traps

How to restrict a Pine Script v6 strategy to specific trading sessions using time() with session strings, and how to avoid the timezone bugs that quietly corrupt session-based backtests — especially the daylight-saving trap that makes a 'London open' strategy test on the wrong hour for weeks every year. Covers exchange time vs chart display time vs UTC, IANA timezone names, overnight sessions, and day-of-week filters. Educational only, not financial advice: a session filter shapes when a strategy trades, it does not make it profitable, and trading carries a real risk of loss.
Read →

How to Debug Pine Script: plotchar, Labels, log.info, and the Pine Logs Pane

Pine Script has no step-through debugger, so debugging means making values visible: plot() and plotchar() into the Data Window, label.new() and tables on the chart, and log.info() into the Pine Logs pane. This guide builds a systematic workflow from those tools — and shows how to recognise when the 'bug' is not your logic at all but repainting or series/simple type confusion. Educational material only, not financial advice: these techniques verify that code does what you intended, which is a separate question from whether any strategy makes money, and trading carries a real risk of loss.
Read →

strategy() vs indicator() in Pine Script: What Actually Changes

A precise look at what actually changes when a Pine Script v6 script declares strategy() instead of indicator(): the broker emulator, order fills on the next bar's open, intrabar price-path assumptions, and the extra recalculation modes (calc_on_every_tick, calc_on_order_fills) that only exist for strategies. The same logic can plot identically in both forms yet signal on different bars — this guide explains exactly why. Educational material only, not financial advice; nothing here makes a strategy profitable, and backtest results are never a forecast of live performance.
Read →

Handling na Values in Pine Script: nz(), na(), fixnan() and Silent Bugs

How na actually behaves in Pine Script v6 and how to handle it correctly with na(), nz(), and fixnan(). The core hazard: na propagates through arithmetic and comparisons, so a condition touching na is neither true nor false — it silently never fires, which is the mechanism behind a large share of 'my strategy never enters' bugs. Covers where na comes from, when nz() is the wrong fix, and a wrong-then-fixed worked example. Educational material only, not financial advice; correct na handling makes code honest, not profitable.
Read →

barstate in Pine Script: isconfirmed, islast, isrealtime and Why They Matter

A complete map of Pine Script v6's barstate.* flags — isconfirmed, isrealtime, ishistory, islast, isnew, isfirst, islastconfirmedhistory — and what each one implies for repainting. The barstate execution model (historical bars calculate once at close; the realtime bar recalculates on every tick with rollback) is the root cause of most 'works in backtest, fails live' complaints, and barstate.isconfirmed is the standard gate that closes the gap. Educational material only, not financial advice; correct bar-state handling removes an illusion, it does not create an edge.
Read →

Pine Script Strategy Properties Explained: Commission, Slippage, Initial Capital, and Fill Assumptions

A property-by-property guide to the strategy() declaration in Pine Script v6 — commission_type, commission_value, slippage, initial_capital, default_qty_type, margin, and the fill-timing switches — and how each one changes the numbers the Strategy Tester reports for the exact same entry logic. The defaults assume a zero-cost, frictionless market, so an untouched declaration almost always overstates results. This is educational material only, not financial advice; no property setting makes a strategy profitable, and trading carries a real risk of loss.
Read →

TradingView Strategy Tester Explained: Every Metric, Honestly

A metric-by-metric walkthrough of the TradingView Strategy Tester — net profit, profit factor, max drawdown, percent profitable, Sharpe, average trade and the rest — including which numbers are easy to game, which rest on unrealistic fill assumptions, and why almost none of them mean much on a small trade count. This is educational material only, not financial advice; every figure in the tester describes the past under simulation assumptions, and trading carries a real risk of loss.
Read →

Deep Backtesting in TradingView: What It Does and What It Doesn't Fix

Deep Backtesting runs your strategy server-side over far more history than the chart loads, with a selectable date range — but it keeps the exact same broker-emulator fill assumptions, and more data only helps if you don't re-optimise on it. This guide separates what the mode genuinely adds (a longer, regime-spanning sample) from what it cannot fix (fills, costs, repainting, and overfitting). Educational material only, not financial advice; no backtest mode turns a historical result into a forecast, and trading carries a real risk of loss.
Read →

How TradingView's Broker Emulator Fills Orders: the OHLC Assumption Explained

TradingView's Strategy Tester does not replay real ticks — its broker emulator reconstructs an assumed intrabar price path from each bar's open, high, low, and close, and that assumption silently decides whether your stop loss or take profit was hit first whenever both fall inside one bar. This article documents the exact path rules, explains the same-bar SL/TP ambiguity they create, and gives you a Pine v6 script to measure how much of your backtest depends on the assumption. Educational material only, not financial advice; a backtest is a historical simulation under stated assumptions, never a forecast, and trading carries a real risk of loss.
Read →

Why You Shouldn't Backtest on Heikin Ashi, Renko, or Range Charts

Strategy backtests on Heikin Ashi, Renko, range, kagi, and point-and-figure charts are wrong for a structural reason: by default the Strategy Tester fills orders at the chart's synthetic prices — averaged or brick-quantised values that never actually traded — so entries and exits happen at prices no broker could ever have given you. This article walks through the exact math of why, shows the inflated-win-rate failure mode, and gives the correct pattern: compute synthetic-candle signals in Pine on a standard chart so fills use real prices. Educational content only, not financial advice; no chart type or fill setting makes a strategy profitable, and trading carries a real risk of loss.
Read →

MT4 Strategy Tester Modeling Quality: What 90% Actually Means

The '90% modeling quality' figure in an MT4 Strategy Tester report does not mean your backtest is 90% accurate — it means the entire test ran on ticks that MT4 *invented* by interpolating inside 1-minute bars, and 90% is simply the ceiling label MetaQuotes assigns to that best-available mode. This article explains the modeling-quality formula, how the tick interpolation actually works, which strategies it silently breaks, and what real-tick alternatives exist. Educational content only, not financial advice; no modeling quality percentage makes a backtest a forecast, and trading carries a real risk of loss.
Read →

MT5 Strategy Tester Modes Compared: Every Tick, Real Ticks, 1-Minute OHLC, and Open Prices

The MT5 strategy tester offers four price-modeling modes, and the same EA can produce four visibly different equity curves depending on which one you pick. This guide explains exactly how 'Every tick', 'Every tick based on real ticks', '1 minute OHLC', and 'Open prices only' construct price inside each bar, why the differences concentrate in stop and limit fills and spread handling, and a workflow for choosing the right mode at each stage. Educational material only, not financial advice: no tester mode turns a backtest into a forecast, and trading carries a real risk of loss.
Read →

MT5 Strategy Optimization: Genetic Algorithm, Forward Testing, and the Overfitting Trap

The MT5 strategy tester's optimizer will happily search thousands of parameter combinations and hand you the one that scored best on the past — which is precisely why it is an overfitting machine by design. This guide covers how the slow complete and fast genetic algorithms actually work, how to use the built-in Forward period as a walk-forward guardrail, and the research (Bailey, Lopez de Prado, White, Hansen) explaining why the best pass is almost always an overstatement. Educational material only, not financial advice: an optimized backtest is not a forecast, and trading carries a real risk of loss.
Read →

MetaTrader OrderSend Errors Explained: 130, 131, 134, 4109 and Friends

OrderSend error 130 (invalid stops) and its siblings — 131, 134, 4109, requotes and context-busy errors — all trace back to a small set of broker-side constraints: stop level distance, lot step and limits, margin, and trading permissions. This guide gives the error table with root causes and the defensive MQL4 patterns (with MQL5 retcode equivalents) that prevent each one before the order is ever sent. Educational material only, not financial advice: these patterns make order code robust, they do not make any strategy profitable, and trading carries a real risk of loss.
Read →

Why Your EA Isn't Taking Trades: A Diagnostic Checklist

A step-by-step diagnostic checklist for an Expert Advisor that is attached to a chart but never opens a trade — from the AutoTrading button and account-level permissions down to symbol suffixes, order-level rejections, and silent logic bugs, with MQL5 snippets that print exactly which layer is blocking you. This is educational material only, not financial advice: the goal here is an EA that executes what its code says, and an EA that trades is not the same thing as an EA that makes money — trading carries a real risk of loss.
Read →

Why MetaTrader Backtests Don't Match Live Results

Why an EA that looks strong in the MT4/MT5 Strategy Tester behaves differently on a live account: tick modeling and interpolated price paths, fixed versus floating spread, execution latency, slippage and requotes, swap and commission, and broker data differences — each explained mechanically rather than hand-waved, with concrete ways to make the comparison more honest. Educational material only, not financial advice: even a carefully modeled backtest is a description of the past, not a forecast, and live trading carries a real risk of loss.
Read →

Overfitting in Trading: Why Your Perfect Backtest Is Probably Curve-Fit

What overfitting (curve-fitting) means in a trading backtest, demonstrated the honest way: by showing that parameter optimization reliably discovers 'winning' strategies on pure random-walk data where no edge exists by construction. Covers the multiple-testing mathematics behind the illusion — White's Reality Check, Hansen's SPA test, and Bailey and López de Prado's work on the deflated Sharpe ratio and the probability of backtest overfitting — plus the warning signs and the mitigations that actually help. Educational material only, not financial advice: nothing here claims any strategy is profitable, and trading carries a real risk of loss.
Read →

Walk-Forward Analysis in Trading: How to Do It Step by Step

Walk-forward analysis repeatedly optimizes a strategy on a past window and then tests the frozen parameters on the unseen window that follows, rolling through history so the stitched out-of-sample record — not the optimized fit — becomes your performance estimate. This guide covers the window-size math, a worked example, a manual TradingView protocol in Pine v6, and MetaTrader 5's built-in forward period. It is educational material only, not financial advice: walk-forward reduces self-deception but guarantees nothing, and trading always carries a real risk of loss.
Read →

Monte Carlo Simulation for Trading Strategies: How to Stress-Test a Backtest

A Monte Carlo simulation takes the trade results from your backtest and generates thousands of alternative sequences — by reshuffling trade order or resampling with replacement — so you see a distribution of drawdowns and outcomes instead of the single path history happened to produce. This guide explains both methods from first principles, shows a minimal implementation, and covers how to read drawdown percentiles and risk of ruin. Educational material only, not financial advice: Monte Carlo stress-tests the path of a backtest, it cannot validate the edge behind it, and trading carries a real risk of loss.
Read →

The Deflated Sharpe Ratio Explained: Correcting Your Backtest for How Many Strategies You Tried

The deflated Sharpe ratio, introduced by David Bailey and Marcos López de Prado, is the probability that a strategy's true Sharpe ratio is positive after correcting the observed value for the number of strategy variants tried, the length of the track record, and non-normal returns. If you tested a hundred configurations and reported the best, most of that best Sharpe is selection bias — and the DSR quantifies exactly how much. This is educational material only, not financial advice: no statistic certifies profitability, and trading carries a real risk of loss.
Read →

In-Sample vs Out-of-Sample Testing: The One Habit That Separates Testing from Fooling Yourself

In-sample data is what you build and tune a strategy on; out-of-sample data is a held-out slice the strategy has never seen, used exactly once to check whether the edge survives outside its training ground. This guide covers why the split matters statistically, the subtle failure where repeated peeking turns your out-of-sample set back into in-sample, and how to implement a clean split in TradingView and MetaTrader. This is educational material only, not financial advice: a strategy that passes an out-of-sample test can still lose money live, and trading always carries a real risk of loss.
Read →

How Many Trades Does a Backtest Need to Be Statistically Meaningful?

There is no single magic number, but the math gives usable floors: around 30 trades is the bare minimum for any inference at all, roughly 100 trades narrows a win-rate estimate to about ±10 percentage points, and demonstrating positive expectancy typically demands several hundred trades because per-trade P&L is far noisier than win/loss outcomes. This article works through the actual confidence-interval arithmetic, provides a lookup table, and explains why a large trade count still isn't sufficient on its own. Educational content only, not financial advice — statistical significance is not profitability, and trading always carries a real risk of loss.
Read →

Look-Ahead Bias: The Backtest Bug That Uses Tomorrow's Data Today

Look-ahead bias is when a backtest makes decisions using information that would not yet have existed at the moment of the trade — tomorrow's close, this week's final high, a full-sample average computed through the future. It is the most flattering bug a backtest can have, and this guide traces it from concept to the two most common concrete instances: barmerge.lookahead_on in Pine Script and unclosed-bar reads in MQL. Educational content only, not financial advice — removing look-ahead bias makes a backtest honest, not profitable, and trading always carries a real risk of loss.
Read →

What Is Slippage in Trading — and How Much Should You Budget For?

A precise look at slippage: what it is, the market mechanics that produce it, how its size varies by instrument, session, and order type, and how to inject a slippage assumption into a Pine Script or MetaTrader backtest instead of pretending fills are perfect. This is educational material only, not financial advice; the ranges here are planning assumptions to verify against your own fill data, and trading always carries a real risk of loss.
Read →

Bid, Ask, and Spread Mechanics: Why Spreads Widen and What They Cost You

How bid/ask quotes are actually formed, why spreads widen around news and at rollover, and the detail most backtests miss: charts draw bid prices while long entries fill at the ask, so the spread is an invisible per-trade cost that flatters every bid-only backtest. Includes the arithmetic for pricing spread cost per trade and how to charge it inside a Pine Script strategy. Educational material only, not financial advice; trading carries a real risk of loss.
Read →

How Margin and Leverage Work in Forex: Margin Calls and Stop-Outs, Step by Step

The actual arithmetic brokers assume you know: how required margin, equity, free margin, and margin level are computed, and a worked example that follows a $1,000 account tick by tick from entry to margin call to the stop-out price. Also covers what leverage does and does not change, regional leverage caps, and why a stop-out is not a substitute for a stop-loss. Educational material only, not financial advice; leveraged trading carries a real risk of losing your deposit.
Read →

Why ChatGPT-Generated Pine Script Won't Compile (and How to Fix It)

ChatGPT and other AI assistants routinely produce Pine Script that fails to compile because they blend Pine v4, v5, and v6 syntax, call built-ins without their namespaces, invent functions and parameters that don't exist, and ignore Pine's series/simple type system. This guide maps each common compiler error to its cause and shows the validated Pine v6 fix, then covers the more dangerous case: AI code that compiles but silently does the wrong thing. Educational material only, not financial advice — fixing a compile error makes a script run, not profitable, and trading always carries a real risk of loss.
Read →

Supertrend vs Parabolic SAR: What's the Difference and Which Should You Use?

Supertrend and Parabolic SAR are both stop-and-reverse trend followers, but they move for completely different reasons: Supertrend holds an ATR-scaled band that ratchets with volatility, while Parabolic SAR accelerates toward price on every bar via its EP × AF formula. This guide gives both formulas, validated Pine v6 for each, a comparison script that highlights the exact bars where their signals diverge, and an honest verdict: they are different tools, not a better/worse pair. Educational content only, not financial advice — neither indicator confers an edge, and trading carries a real risk of loss.
Read →

RSI vs Stochastic Oscillator: What's the Difference?

RSI and the Stochastic oscillator both print 0–100 momentum readings, but they measure different things: RSI compares the average size of up-closes to down-closes, while the Stochastic measures where the latest close sits inside the recent high–low range. Because the denominators differ, there are market conditions where the two must mathematically disagree — this guide shows the formulas, validated Pine v6 for each, and a script that highlights those disagreement bars. Educational material only, not financial advice; no oscillator reading is a prediction, and trading carries a real risk of loss.
Read →

Keltner Channels vs Bollinger Bands: Which Should You Use?

A deterministic comparison of Keltner Channels and Bollinger Bands: how ATR-based width and standard-deviation-based width actually behave differently on the same data, complete Pine Script v6 code for plotting both, and how the two combine into the squeeze (Bollinger Bands closing inside Keltner Channels). This is educational material only, not financial advice — neither channel predicts price, a band touch is not a signal by itself, and trading carries a real risk of loss.
Read →

Which Indicators Repaint? The Complete List

A definitive, testable list of which TradingView indicators repaint and which don't: ZigZag, Williams Fractals, pivot points, Ichimoku's Chikou Span, and mis-written request.security calls on one side; moving averages, RSI, MACD, ATR, Bollinger Bands and Supertrend (on confirmed bars) on the other. Includes the three distinct mechanisms of repainting and the correct non-repainting higher-timeframe pattern in Pine v6. Educational material only, not financial advice — a non-repainting indicator is not thereby a profitable one, and trading carries a real risk of loss.
Read →

Does Supertrend Repaint? A Deterministic Answer

Supertrend does not repaint on confirmed bars — once a bar closes, the line and its flips are fixed forever — but it does fluctuate on the live bar, and it becomes a genuine repainter when pulled from a higher timeframe through a bare request.security call. This article proves each claim from the indicator's mathematics and shows the correct Pine Script v6 patterns for confirmed-bar signals and non-repainting HTF Supertrend. Educational material only, not financial advice — a non-repainting Supertrend is not a profitable one, and trading carries a real risk of loss.
Read →

Why Heikin Ashi Backtests Show Unrealistic Results (and How to Fix Them)

Heikin Ashi backtests look spectacular because the broker emulator fills orders at synthetic Heikin Ashi prices that never traded — a one-sided bias that always flatters the strategy. This guide walks through the exact fill mechanics, TradingView's 'Fill orders using standard OHLC' fix, and a cleaner pattern that computes Heikin Ashi signals on a standard chart. Educational material only, not financial advice: a backtest — even a corrected one — is a historical description, not a forecast, and trading carries a real risk of loss.
Read →

Are Renko Backtests Reliable? An Honest Look at Brick Mechanics

No — a backtest run on a Renko chart is not a reliable estimate of live performance, and this article explains exactly why: bricks are synthetic, time-agnostic constructs whose historical and real-time versions are built from different data, whose fill prices sit on a grid the market never respected, and whose ATR-sized variants redraw their own history. It closes with the honest alternative: porting brick logic to a standard chart. Educational material only, not financial advice — no backtest of any kind is a forecast, and trading carries a real risk of loss.
Read →

Best RSI Settings for Day Trading and Scalping: An Honest Answer

There is no evidence-backed 'best' RSI setting — changing the length or the overbought/oversold bands changes signal frequency and smoothness, not the underlying edge, and the magic numbers promoted in broker content are in-sample optimization artifacts. This article explains what each setting mathematically does, why 'RSI 7 with 80/20' claims collapse under the multiple-testing lens of Bailey, López de Prado, White, and Hansen, and provides a validated Pine Script v6 testbed so you can evaluate any setting yourself. Educational material only, not financial advice: no setting turns RSI into a profit engine, backtests are not forecasts, and trading carries a real risk of loss.
Read →

How to Fix OrderSend Error 130 (Invalid Stops) in MQL4

A practical guide to diagnosing and fixing MetaTrader 4's OrderSend error 130 (ERR_INVALID_STOPS): stops placed inside the broker's MODE_STOPLEVEL distance, prices measured from the wrong side of the spread, unnormalized doubles, and ECN accounts that reject stops attached to a market order. Includes a copy-paste validation helper and the two-step OrderSend-then-OrderModify pattern. This is educational material only, not financial advice — correct order mechanics make an EA's risk explicit, they do not make it profitable, and trading carries a real risk of loss.
Read →

Pine Script 'Syntax Error at Input' — What It Means and How to Fix It

Pine Script's 'syntax error at input' is the compiler telling you it stopped being able to parse your code at a specific token — and the real mistake is often on an earlier line. This guide covers the four causes behind almost every instance: a missing //@version directive, broken indentation or line-wrapping, unbalanced brackets, and invisible characters pasted in from the web or AI chat windows, each with the wrong version and the corrected Pine v6 shown side by side. Educational material only, not financial advice; a script that compiles is merely a script that compiles — it says nothing about whether the logic is sound or the strategy has an edge, and trading carries a real risk of loss.
Read →

Kelly Criterion Calculator: How Much Should You Risk Per Trade?

The Kelly criterion gives the bet size that maximizes long-run logarithmic growth of a bankroll — f* = W − (1−W)/R, from your win rate and payoff ratio. This guide derives the number, shows a Pine Script v6 calculator, and then spends equal time on the part most calculators omit: your win rate is an estimate from a finite sample, not a fact, and estimation error makes full Kelly systematically too aggressive — which is why practitioners from Thorp onward use fractional Kelly. Educational material only, not financial advice: no position-sizing formula creates an edge where none exists, and trading carries a real risk of loss.
Read →

Prop Firm Trailing Drawdown: How It Works and How Close You Are to Breaching It

Trailing drawdown is the prop-firm rule that moves your failure threshold up as your account makes new highs — and it comes in at least three distinct flavours (end-of-day, intraday, and locked) that behave very differently for identical trading. This guide defines each mode precisely, works the breach-distance math by hand, and shows how to track a trailing floor against a strategy equity curve in Pine Script v6. It is educational material only, not financial advice: passing or failing a drawdown rule says nothing about whether a strategy has an edge, and trading always carries a real risk of loss.
Read →

Forex Swap Rates Explained: How Much Holding a Position Overnight Really Costs

Holding a forex position past your broker's rollover time incurs a swap — a daily credit or debit derived from the interest-rate differential between the two currencies, plus broker markup. This guide explains where swap rates come from, how to read the three MT4/MT5 swap quoting modes, why Wednesday usually charges three days at once, and how to convert a quoted swap into actual money for your position. It is educational material only, not financial advice; swap values change with central-bank rates and broker policy, and trading carries a real risk of loss.
Read →

XAUUSD Lot Size and Pip Value: How to Calculate Position Size for Gold

Position sizing on gold trips up traders who arrive from forex, because the contract is 100 troy ounces rather than 100,000 currency units and because brokers disagree on whether a gold pip is a $0.10 or $0.01 price move. This guide states the contract math plainly, resolves the pip-convention confusion, works a full risk-based lot-size example, and shows how to read the true tick value programmatically in MQL5 so your EA sizes correctly on any broker. Educational material only, not financial advice — gold is a volatile, gapping instrument and trading it carries a real risk of loss.
Read →

Curve Fitting: How to Tell If Your Trading Strategy Is Overfit

A research-grounded guide to detecting curve fitting in a backtested strategy: parameter-sensitivity plateaus, degrees of freedom versus trade count, out-of-sample degradation, and the multiple-testing corrections of Bailey, López de Prado, White, and Hansen. The honest headline: you can never prove a strategy is not overfit — you can only fail to reject it under increasingly hostile tests. Educational material only, not financial advice; a backtest describes the past, not the future, and trading carries a real risk of loss.
Read →

Can ChatGPT Write a Profitable Trading Strategy?

An honest, technical answer to whether ChatGPT or any AI can write a profitable trading strategy: it can write strategy code — often subtly broken — and the correctness of that code is checkable, but profitability is not something any AI, backtest, or human can guarantee. Covers the typical failure modes of LLM-generated Pine Script and MQL, why 'looks profitable in a backtest' is a weak claim, and a sane workflow for using AI assistance. Educational only, not financial advice; trading carries a real risk of loss.
Read →

Pine Script Tables: How to Display Data on the Chart

A code-first guide to Pine Script v6 tables: creating a table once with var table.new(), updating cells only on barstate.islast, building a live stats panel, and adding a performance panel to a strategy. Covers the classic mistake — recreating the table on every bar — and why it slows scripts down. Educational material only, not financial advice; a stats panel describes historical data and a backtest, never future performance, and trading carries a real risk of loss.
Read →

request.security_lower_tf(): How to Use Intrabar Data in Pine Script v6

A practical guide to request.security_lower_tf() in Pine Script v6 — the rarely-explained sibling of request.security() that returns arrays of intrabar values from a lower timeframe. Covers a complete intrabar volume-delta example, why older bars come back with empty arrays, how the realtime bar behaves, and why intrabar precision is still an approximation rather than ground truth. Educational material only, not financial advice; intrabar data does not make a strategy profitable, and trading carries a real risk of loss.
Read →

Pine Script Libraries: How to Create, Publish, and Import Reusable Code

How Pine Script v6 libraries work end to end: declaring a library, the export rules and type constraints for exported functions, publishing and the auto-incrementing version number, and importing with the import User/Name/Version syntax. Includes why exact-version pinning is quietly one of the best reproducibility features in Pine — and the gotchas that bite first-time library authors. Educational material only, not financial advice; shared code does not make a strategy profitable, and trading carries a real risk of loss.
Read →

var vs varip in Pine Script: Persistent Variables Explained

What var and varip actually do in Pine Script v6: var persists across bars but rolls back on every intrabar update, while varip survives those rollbacks and keeps state between ticks. That difference makes varip powerful for live monitoring and dangerous inside strategy logic, because varip-driven behaviour cannot be reproduced by a backtest. Educational material only, not financial advice; no persistence keyword makes a strategy profitable, and trading carries a real risk of loss.
Read →

Pyramiding in Pine Script Strategies: How It Works and How It Distorts Backtests

A precise guide to the pyramiding parameter in Pine Script v6 strategies: what it actually limits, how strategy.entry() and strategy.order() treat it differently, how adds interact with position sizing, average price, and exits, and why pyramided backtests systematically look better than the live trading they claim to describe. This is educational material only, not financial advice; pyramiding concentrates risk into your open position, and a backtest result is never a forecast of live performance.
Read →

The Martingale Math: Why Doubling-Down EAs Always Blow Up Eventually

A first-principles look at why martingale and grid Expert Advisors that double lot size after each loss produce beautiful equity curves for months and then delete an account in an afternoon. We derive the exponential exposure growth, the probability of a losing streak long enough to exhaust any finite account, and the gambler's-ruin arithmetic behind it. This is educational material only, not financial advice, and not a claim that any strategy is or isn't profitable — the point is that a smooth curve and a survivable strategy are not the same thing.
Read →

Order Types Explained: Market, Limit, Stop, and Stop-Limit (and How Each Gets Filled)

A precise guide to the four core order types — market, limit, stop, and stop-limit — organised around the one distinction that actually matters: whether an order guarantees execution or guarantees price, because no order guarantees both. We map each type to its fill behaviour and to how Pine Script's Strategy Tester and MetaTrader simulate it, so your backtest assumptions match reality. Educational only, not financial advice; understanding order mechanics is about correctness, not returns.
Read →

Why Most Backtests Fail: The Seven Failure Modes, Ranked

A backtest that looks great and a strategy that works live are two different claims. This hub article ranks the seven reasons backtested strategies fall apart in real trading — costs and fills, overfitting, look-ahead bias, regime change, survivorship bias, small samples, and unrealistic fills — with the code and data smells that give each one away.
Read →

Why Python Backtests Fail Live: The Common Culprits

A backtest that prints a smooth equity curve and dies in live trading is almost never unlucky. It is usually one of five specific, detectable Python mistakes: look-ahead bias, same-bar fills, data leakage, missing costs, or overfitting. This hub names each culprit, shows the code smell that gives it away, and links to the deep dive that fixes it.
Read →

Look-Ahead Bias in Python Backtests: How to Find and Fix It

Look-ahead bias is when a backtest uses information that would not have been available at decision time, inflating results in ways that never survive live trading. This guide defines it, then walks the four traps that produce it most often in Python: negative .shift(), centered rolling windows, whole-series normalization, and same-bar execution. Every fix shown here is written to pass a look-ahead check. This is an educational engineering guide, not financial or trading advice, and nothing here implies any strategy is or will be profitable.
Read →

Look-Ahead Bias in backtrader: the [1]-is-the-Future Trap

In backtrader, line objects are indexed relative to “now”: [0] is the current bar, [-1] is the previous bar, and a positive index like [1] reaches into the FUTURE. That inversion of normal Python list semantics is the most common source of look-ahead bias in backtrader strategies. This guide shows the bug, the fix, and why next-bar-open fills matter. It is an educational engineering guide, not financial or trading advice, and implies nothing about profitability.
Read →

Look-Ahead Bias in freqtrade: Informative Pairs and populate_indicators

freqtrade’s two most common look-ahead leaks come from higher-timeframe data: merging an informative pair that references a still-forming HTF candle, and populate_indicators computing values that quietly depend on future rows. This guide shows the correct merge_informative_pair usage, why the merge lags the HTF candle by design, and how startup_candle_count keeps indicators consistent between backtest and live. It is an educational engineering guide, not financial or trading advice, and implies nothing about profitability.
Read →

Look-Ahead Bias in vectorbt: Same-Bar Execution in from_signals

vectorbt's Portfolio.from_signals fills orders at the close of the bar that produced the signal by default, which silently leaks information you could not have acted on in real time. This article shows exactly where the leak enters, how to fix it with entries.shift(1) and explicit price/lag settings, and how to sanity-check the result. It is educational material about backtest correctness only, not trading or financial advice, and makes no claims about profitability or returns.
Read →

pandas .shift() for Trading Signals: +1 vs -1 (and Why It Matters)

In pandas, .shift(1) moves values from the past forward in time (safe for signals) while .shift(-1) pulls values from the future backward (a look-ahead bug). Getting the sign wrong is the single most common way a Python backtest silently cheats. This article walks through the mechanics, worked examples, and a mental model that keeps you on the safe side. It is educational content about backtest correctness only, not trading or financial advice, and makes no claim about returns.
Read →

backtrader vs vectorbt vs freqtrade: Which Python Backtester?

backtrader is an event-driven engine, vectorbt is a vectorized array engine, and freqtrade is a full crypto bot framework with a backtester attached; each trades off speed, realism, and how easy it is to leak look-ahead. This honest comparison lays out where each fits and the specific footguns of each, with no notion of a single best tool. It is educational content about tooling and backtest correctness only, not trading or financial advice, and makes no claim about profitability.
Read →

Data Leakage in Machine-Learning Trading Strategies

Data leakage is when information that would not have been available at prediction time bleeds into a model's training or preprocessing, inflating backtest metrics that then collapse live. This article shows the three most common leaks in Python ML trading pipelines — whole-series scaler fitting, global normalization, and fitting and evaluating on the same data — and how chronological splitting and TimeSeriesSplit fix them. It is educational only and is not financial advice; no method here implies profitability, and all trading carries risk of loss.
Read →

Same-Bar Execution: The Silent Python Backtest Bug

Same-bar execution is when a backtest computes a signal from a bar's close and then fills an order at that same close — a trade you could not have placed, because the close was not known until the bar had already finished. This article shows how the bug appears across pandas, vectorbt, and backtrader, and the two standard fixes: shift the signal by one bar, or fill at the next bar's open. It is educational only and not financial advice; the fixes make results honest, not profitable, and all trading carries risk of loss.
Read →

Walk-Forward Analysis in Python: a Practical Guide

Walk-forward analysis repeatedly fits a strategy on a training window and evaluates it on the immediately following, unseen window, then rolls forward — so every reported result is out-of-sample. This guide explains rolling versus anchored windows, why walk-forward beats a single in-sample fit, and gives a clean, look-ahead-free implementation sketch in Python. It is educational only and not financial advice; walk-forward exposes fragility but does not create edge, and all trading carries risk of loss.
Read →

Modeling Commission and Slippage in Python Backtests

A backtest run with zero trading costs almost always overstates its results, because commissions and slippage quietly eat into every fill. This article shows exactly how to set commission and slippage in backtrader (setcommission, set_slippage_perc) and vectorbt (fees, slippage), and why getting the units right matters. It is educational material about backtest realism, not financial advice or any claim about profitability.
Read →

backtrader Line Indexing Explained: [0], [-1], and the [1] Bug

In backtrader, a line object indexes time relative to the bar currently being processed: [0] is now, [-1] is the previous bar, and a positive index like [1] reaches into the future — the classic look-ahead footgun. This article explains the line/series model precisely, gives a reference table, and shows the correct patterns for referencing past values. It is educational material about backtest correctness, not financial advice.
Read →

freqtrade startup_candle_count Explained

In freqtrade, startup_candle_count tells the engine how many extra candles of history to load before your strategy starts acting, so indicators have warmed up and are not producing NaN or partial values. This article explains why warmup is needed, how to size the value from your longest lookback, and the bugs that appear when it is missing or too small. It is educational material about backtest correctness, not financial advice.
Read →

Is My Python Trading Strategy Overfit? How to Tell

Your Python strategy is probably overfit if it has many tunable parameters, was selected by its in-sample results, and produces a suspiciously smooth equity curve. This article lists the warning signs and walks through the three honest tests — out-of-sample, walk-forward, and probability of backtest overfitting (PBO) — with runnable, leak-free Python. It is educational content about model validation, not financial advice, and it makes no claim about whether any strategy is profitable.
Read →

Common vectorbt Mistakes That Inflate Your Backtest

vectorbt is fast, which means it computes wrong answers just as quickly as right ones. The four mistakes that most often inflate a vectorbt backtest are same-bar signals, zero fees and slippage, computing indicators on the full series across a split, and misreading the Portfolio stats. This article shows each one and its fix with real vectorbt API. It is educational material about backtest correctness, not financial advice, and implies nothing about profitability.
Read →

How to Verify a Backtest Report You Didn't Run

You can check a backtest's headline claims without re-running the strategy: recompute net profit, profit factor, win rate, and max drawdown straight from the trade list and confirm they reconcile with the summary. This article walks through each recomputation and what a mismatch tells you. It is educational only, not financial advice, and it is about verifying the arithmetic and internal consistency of a report — never about predicting whether a strategy will make money.
Read →

Backtest Integrity Checks: Catching a Report That Contradicts Itself

Integrity checks look for internal contradictions in a backtest — places where the report disagrees with itself — rather than judging whether the strategy is good. This article catalogs the main self-consistency red flags: recompute-versus-claimed mismatches, impossible chronology, zero-loss samples, single-trade-dominated edges, and near-perfectly-straight equity curves, and explains what each one means. It is educational only, not financial advice, and it is about robustness and honesty, never about predicting profitability.
Read →

The Drop-the-Best-Trades Test: Is Your Edge One Lucky Trade?

The drop-the-best-trades test removes a strategy's top few winning trades and checks whether the edge survives; if the result flips negative after dropping one to three trades, the backtest was a lucky streak rather than a system. This article shows how to run it, how to read it, and where it fits among robustness checks. It is educational only, not financial advice, and it measures fragility and concentration — never future profitability.
Read →

The Backtest Metrics That Flatter a Strategy (and What to Read Instead)

Net profit and win rate are the two numbers most likely to mislead you about a backtest. This article shows which metrics flatter a strategy, which ones expose it, and why every reading depends on how many trades produced it. Educational only. Nothing here is financial advice, and none of it speaks to whether a strategy will make money.
Read →

Before You Buy a Trading Strategy: A Backtest Verification Checklist

A practical checklist for vetting a strategy, EA, or signal service before you pay for it. It walks through reconciling the seller's numbers, checking the sample, stress-testing the best trades, spotting look-ahead and repaint tells, and demanding out-of-sample proof. Educational only — this is a due-diligence guide, not financial advice, and passing every check does not mean a strategy is profitable.
Read →

Monte Carlo Trade Shuffling: How Lucky Was Your Backtest's Ordering?

Monte Carlo trade shuffling reorders and resamples the trades a strategy actually produced to reveal the range of drawdowns and outcomes that same set of trades could have delivered in a different sequence. It shows where your realized result sits in that range — its luck percentile. This is educational only, is not financial advice, and is a resampling of observed trades, not a prediction of future performance.
Read →

Risk of Ruin: What Monte Carlo Reveals That a Single Backtest Hides

A single backtest shows one equity path out of millions that the same trades could have produced. Risk of ruin is the probability that some plausible ordering breaches a threshold you cannot recover from, and Monte Carlo is how you estimate it. This article is educational only and not financial advice — nothing here measures or predicts profitability, only the fragility of a result you already have.
Read →

Is Your Equity Curve Skill or Luck? The Reshuffle Test

A smooth equity curve can be a real edge, or it can be lucky sequencing of ordinary trades. The reshuffle test holds your trades fixed, shuffles their order thousands of times, and shows where your actual curve sits in the resulting distribution of drawdowns. This is educational only and not financial advice — it speaks to robustness and path-dependence, never to profitability.
Read →

Why Your Backtest's Max Drawdown Is Probably an Underestimate

The maximum drawdown your backtest reports is the drawdown of one historical ordering — rarely the worst plausible drawdown the same trades could produce. Monte Carlo resampling of the trade list surfaces the deeper draws you should actually plan around. This is educational only and not financial advice; it concerns risk and robustness, never profitability.
Read →

Block Bootstrap for Trading: Respecting Streaks When You Resample

Plain bootstrap resampling scrambles the order of your returns, which destroys the autocorrelation and streaks that make drawdowns painful. Block bootstrap samples contiguous chunks instead, preserving that structure and producing a more honest drawdown distribution. This article is educational only and is not financial advice; nothing here concerns or predicts profitability.
Read →

Probability of Backtest Overfitting (PBO): The Number Every Optimizer Should Report

Probability of Backtest Overfitting (PBO) estimates how often the configuration that looks best in-sample fails to stay above median out-of-sample, across many symmetric splits of your data. A high PBO means your selection process is fitting noise, not signal. This article is educational only, not financial advice, and concerns strategy robustness rather than profitability.
Read →

How to Detect Overfitting in an MT5 or TradingView Optimization

If you optimized across hundreds of parameter combinations in MT5 or TradingView, your best result is probably part-luck, and there are two honest ways to measure how much. Apply a multiple-testing haircut to your headline statistic, and run PBO or a Reality Check on the full returns matrix of every variant you tested. This article is educational only, not financial advice, and is about robustness rather than profitability.
Read →

The Multiple-Testing Haircut: Why Trying 500 Variants Inflates Your Best Sharpe

The more strategy variants you test, the higher the best Sharpe you will find by luck alone -- so the top result needs a haircut before you trust it. This article explains the Harvey & Liu multiple-testing adjustment and gives you the intuition to deflate a best-of-many Sharpe. It is educational only, not financial advice, and nothing here concerns or predicts profitability.
Read →

White's Reality Check & Hansen SPA: Did Your Best Strategy Actually Beat Luck?

White's Reality Check and Hansen's SPA test bootstrap the best performance statistic across all your strategy variants to ask whether the winner is genuinely superior or merely the luckiest of many. This article explains what their p-value means, what it does not, and how to run these data-snooping tests honestly. It is educational only, not financial advice, and concerns statistical robustness -- never profitability.
Read →

The Optimization Overfitting Trap: When Curve-Fitting Looks Like Alpha

A beautiful optimized equity curve is the default outcome of searching enough parameter combinations -- not evidence of an edge. This article explains why optimization manufactures the illusion of alpha, introduces the plateau-versus-peak test, and argues that robustness beats the single best parameter set. It is educational only, not financial advice, and is about integrity and robustness -- never profitability.
Read →

NinjaScript Repainting: Why OnEachTick Strategies Lie in Backtests

Repainting is when a NinjaScript signal appears, disappears, or moves as new ticks arrive inside a still-forming bar. Under Calculate.OnEachTick a live strategy can fire and un-fire an entry mid-bar, yet the Strategy Analyzer replays only closed-bar data and never reproduces it. This article is educational only and is not trading advice; nothing here implies any signal is profitable.
Read →

Calculate.OnEachTick vs OnBarClose in NinjaScript

Calculate controls how often OnBarUpdate() runs: OnBarClose fires once when a bar closes, OnEachTick fires on every tick, and OnPriceChange fires once per price change. OnBarClose is stable and reproducible in backtests; OnEachTick is responsive but can repaint. This article is educational only and is not trading advice; it makes no claim about profitability.
Read →

IsFirstTickOfBar in NinjaScript: The Repaint Fix

IsFirstTickOfBar is a NinjaScript property that is true only on the first tick of each new bar under Calculate.OnEachTick. Gating entries with it makes an OnEachTick strategy decide once per closed bar — using the settled Close[1] — which removes intrabar repaint while keeping tick-level updates for everything else. This article is educational only and is not trading advice; it implies nothing about profitability.
Read →

Look-Ahead Bias in NinjaScript (CurrentBar + N and Beyond)

Look-ahead bias in NinjaScript happens when your strategy reads data from bars that had not yet closed at the historical moment it claims to trade. This guide shows the exact API patterns that leak future data — future indexing, negative barsAgo, intrabar peeking — and how to detect and remove them. It is educational material about code correctness, not trading advice, and nothing here implies any strategy will be profitable.
Read →

Multi-Series Look-Ahead in NinjaScript: AddDataSeries Done Right

When you add a higher-timeframe series with AddDataSeries and read it on your primary series, it is easy to consume a higher-timeframe bar before it has actually closed — NinjaScript's equivalent of the TradingView request.security repaint. This guide shows correct BarsInProgress routing and how to reference secondary series without leaking future data. It is educational material about code correctness and implies nothing about profitability.
Read →

Why Your NinjaTrader Backtest Doesn't Match Live

A NinjaTrader backtest and live trading diverge for a short list of concrete reasons: intrabar repaint, running with or without Tick Replay, optimistic fill assumptions, and code that behaves differently in the Historical versus Realtime state. This guide is a diagnostic checklist for finding which one is biting you. It is educational material about code and testing correctness, and makes no claim about profitability or expected results.
Read →

NinjaScript Bar Indexing: barsAgo, CurrentBar, and the Gotchas

How NinjaScript's barsAgo indexing works (0 = current forming bar, 1 = previous bar), how CurrentBar gives the absolute position, and the off-by-one and future-index traps that quietly corrupt backtests. This article is educational and describes API behavior only; it makes no claim about profitability and is not trading advice.
Read →

Setting Stop-Loss and Profit Target in NinjaScript

How to attach protective exits in NinjaScript using SetStopLoss and SetProfitTarget in State.Configure, when to switch to per-entry ExitLongStopMarket/ExitShortStopMarket, and how the managed and unmanaged approaches differ. This article is educational and describes API behavior only; it makes no claim about profitability and is not trading advice.
Read →

Market Replay vs Strategy Analyzer: Which NinjaTrader Backtest to Trust

How NinjaTrader's Strategy Analyzer (bar-based backtest) differs from Market Replay (tick-by-tick playback), what each can and cannot reveal about intrabar fills and behavior, and why a discrepancy between them is often the fingerprint of repainting. This article is educational and describes tool behavior only; it makes no claim about profitability and is not trading advice.
Read →

NinjaScript OnStateChange Explained: SetDefaults, Configure, Historical, Realtime

OnStateChange is the lifecycle hook NinjaTrader calls as your indicator or strategy moves through defined states. Put the wrong work in the wrong state and you get silent misbehavior — most dangerously, a strategy that trades differently on historical bars than on live bars, so your backtest describes a system you will never actually run. This article is educational only and is not trading advice; nothing here implies any result or profitability.
Read →

Common NinjaScript Mistakes That Break Your Backtest

Most NinjaScript backtests fail quietly. The code compiles, the strategy runs, an equity curve appears — and none of it describes what would have happened in the market. This article walks through five concrete mistakes that corrupt backtest results: intrabar repaint, missing stops, empty catch blocks, unsynced multi-series access, and missing CurrentBar guards. Each comes with the fix. It is educational only and is not trading advice; nothing here implies any profitability or result.
Read →

Tick Replay in NinjaTrader: When You Need It and When It Repaints

Tick Replay reconstructs the historical tick sequence inside each bar so that OnEachTick logic runs on historical data the same way it runs live. Some indicators and strategies genuinely need it for accurate historical intrabar calculation; others do not, and enabling it can encourage exactly the intrabar patterns that repaint. This article explains what Tick Replay does, when it is required, and how it interacts with OnEachTick repaint. It is educational only and is not trading advice; nothing here implies any result or profitability.
Read →
Catch the bug that compiles.Run auditGet Pro