PineScripter

PineScripter Blog

Insights on Pine Script development, trading automation, and developer productivity.

Looking for a quick calculation instead? Explore our free trading and Pine Script calculators.

Guide

How request.security Works in Pine Script (And Why Most Indicators Get It Wrong)

request.security is the most powerful and most misused function in Pine Script. Here is a precise account of what it fetches, when it evaluates, and the one pattern that prevents repainting.

13 min read
Tutorial

Building an Order Block Indicator in Pine Script

Order blocks are specific price bars where institutional orders caused a sharp move away. Here is a precise structural definition and a complete Pine Script v6 build using boxes and pivot detection.

14 min read
Guide

Pine Script Lookahead: The Setting That Makes Indicators Lie

barmerge.lookahead_on is a single parameter that can make a multi-timeframe indicator look perfect in backtests and fail immediately live. Here is exactly what it does and why it is almost always wrong.

10 min read
Guide

Why Your Pine Script Alert Fires on the Wrong Bar

alertcondition fires on every tick the condition is true, including mid-bar ticks on the live candle. Here is the confirmed-bar pattern that makes alerts fire exactly once, at the close.

9 min read
Guide

Pine Script v6 Lazy Evaluation: The and/or Trap That Breaks Indicators

In Pine Script v6, the and and or operators short-circuit. Any ta.* function on the skipped side stops updating its history. Here is what breaks, why, and the one-line fix.

9 min read
Guide

Expectancy: The Only Number That Predicts Long-Term Trading Results

Win rate and average profit tell you different halves of the story. Expectancy combines them into the single figure that determines whether a strategy makes money over time.

9 min read
Guide

barstate.isconfirmed in Pine Script: Signals That Stop Repainting

Signals that appear on unclosed bars and then disappear are one of the most common Pine Script frustrations. barstate.isconfirmed is the one-line fix — here is exactly how it works.

9 min read
Tutorial

How to Build a Divergence Detector in Pine Script (Non-Repainting)

RSI and MACD divergence detection requires confirmed pivot highs and lows, which means the signal always arrives a few bars late — and must. Here is the complete build in Pine Script v6.

13 min read
Tutorial

From Indicator to Backtestable Strategy in Pine Script

An indicator marks signals. A strategy acts on them and tracks the results. Converting one to the other is a small code change with a big payoff — here is the complete workflow.

11 min read
Guide

Profit Factor Explained: What It Reveals and When to Ignore It

Profit factor above 1.0 means more money came in than went out. But a profit factor of 3.0 on 8 trades and 1.4 on 300 trades are not the same thing. Here is how to read it correctly.

8 min read
Guide

Win Rate Is a Trap: What Your Strategy Statistics Actually Tell You

A 70% win rate can be a losing strategy. A 35% win rate can be highly profitable. Here is the math that explains why, and the numbers that actually predict long-term results.

10 min read
Tutorial

Building a Multi-Timeframe Indicator That Does Not Repaint

The most common way to add higher-timeframe context to a Pine Script indicator repaints. Here is the confirmed-bar pattern that fixes it, built step by step in Pine Script v6.

12 min read
Guide

Pine Script Strategy Tester: Every Metric Explained

Most traders glance at net profit and move on. Here is what each Strategy Tester metric actually measures, when each one misleads, and how to read the full picture honestly.

13 min read
Guide

Pine Script max_bars_back Error: Causes and Fixes

Why Pine cannot determine the referencing length of a series, how history buffers are sized from your code, and the three ways to fix it without guessing at numbers.

11 min read
Guide

Pine Script: End of Line Without Line Continuation

Pine uses indentation as part of its grammar. Learn exactly which whitespace rules produce this error, why pasted code triggers it, and how to fix it in one edit.

10 min read
Guide

Pine Script Label and Line Limits: Fixing the 500 Cap

Why your labels and lines silently disappear from the chart, how max_labels_count and max_lines_count actually work, and how to draw only what you need.

11 min read
Guide

Stop Loss and Take Profit in Pine Script: A Full Guide

How strategy.exit() actually works, the difference between stop, limit, loss and profit parameters, and why exits fire on the bar you did not expect.

13 min read
Guide

Trailing Stops in Pine Script: How to Code Them Right

trail_points and trail_offset are measured in ticks, not price, which is why most trailing stops behave nothing like intended. Here is the full mechanism.

12 min read
Guide

Pine Script Session and Time Filters Without Bugs

Session strings run in exchange time, not yours. How to build a trading-hours filter that holds up across symbols, timezones, and daylight saving changes.

12 min read
Tutorial

Order Blocks in Pine Script: What They Are and How to Code

What an order block actually is structurally, why marketed indicators disagree about it, and how to detect and draw one in Pine Script v6 without repainting.

14 min read
Tutorial

RSI Divergence in Pine Script: Detecting It Correctly

Divergence detection needs confirmed pivots, and confirmed pivots arrive late. How to code RSI divergence in Pine Script v6 and be honest about the lag.

13 min read
Guide

Why Backtest Results Differ From Live Trading

Fill assumptions, intrabar order, commission, slippage, and repainting each move the number. Here is what TradingView models, what it does not, and how to narrow the gap.

14 min read
Guide

TradingView Indicator Limits: How Many You Can Add

How many indicators each TradingView plan allows per chart, which Pine Script limits apply on top of that, and what to do when you hit either one.

11 min read
Tutorial

RSI Strategy in Pine Script: A Step-by-Step Guide

What the Relative Strength Index actually measures, why traders lean on it, and how to build an RSI indicator and a backtestable strategy in Pine Script v6, plus a trend filter and the honest pitfalls.

11 min read
Tutorial

MACD Strategy in Pine Script: A Step-by-Step Guide

What the MACD line, signal line, and histogram each tell you, why the indicator is so popular, and how to build a MACD indicator and strategy in Pine Script v6 with ta.macd().

11 min read
Tutorial

Bollinger Bands in Pine Script: A Complete Guide

What Bollinger Bands measure, why volatility bands adapt to each market, and how to build the indicator and two classic strategies, mean reversion and the squeeze breakout, in Pine Script v6.

11 min read
Tutorial

VWAP in Pine Script: The Volume-Weighted Guide

What VWAP measures, why intraday traders anchor to the volume-weighted average price, and how to build it with session anchoring and deviation bands in Pine Script v6 using ta.vwap().

11 min read
Tutorial

Supertrend in Pine Script: How to Build and Use It

What the Supertrend indicator does, why its ATR-based bands adapt to volatility, and how to build it and a strategy in Pine Script v6 with ta.supertrend() and line-break plotting.

10 min read
Tutorial

Stochastic Oscillator in Pine Script: A Complete Guide

What the stochastic oscillator measures, why %K and %D are read together, and how to build the indicator and a strategy in Pine Script v6, plus the fast, slow, and full variants explained.

10 min read
Tutorial

ATR in Pine Script: Measuring Volatility in Code

What the Average True Range measures, why it is the backbone of volatility-aware stops and position sizing, and how to build and use it in Pine Script v6 with ta.atr().

10 min read
Tutorial

ADX in Pine Script: Measuring Trend Strength

What the Average Directional Index measures, why it answers a different question than most indicators, and how to build it with +DI and -DI as a trend filter in Pine Script v6 using ta.dmi().

10 min read
Tutorial

On-Balance Volume in Pine Script: A Volume Guide

What On-Balance Volume measures, why volume-based confirmation and divergence matter, and how to build the OBV indicator and a volume-confirmed strategy in Pine Script v6 with ta.obv.

10 min read
Tutorial

Money Flow Index in Pine Script: Volume-Weighted Momentum

What the Money Flow Index measures, why it is called the volume-weighted RSI, and how to build the indicator and a strategy in Pine Script v6 with ta.mfi(), plus when to prefer it over the RSI.

10 min read
Comparison

PineScripter vs ChatGPT and Claude: Better Pine Script, Lower Cost

General assistants were not built for Pine Script and are expensive to run. Here is how a Pine-tuned model wrapped in a compile-checking agent produces code that compiles more often, for a fraction of the token cost.

13 min read
Guide

Pine Script Runtime Errors: Why It Fails on the Chart

A runtime error happens while a script executes on bars, after it compiled. Learn how to read the message and bar index, and fix historical buffer, memory, drawing-limit, and invalid-argument failures.

13 min read
Guide

Why Your Pine Script Strategy Isn't Taking Trades

The script compiles and the trade list is empty. Check the five causes in order: the condition never fires, order size versus capital, unreachable order calls, v6 margin defaults, and the removed when parameter.

13 min read
Guide

What the Pine Script v6 Converter Fixes and What It Misses

The Pine Editor converts v5 to v6 automatically, but only handles mechanical syntax. Learn what it cannot decide for you: boolean na states, strategy.exit parameter pairs, margin defaults, and dynamic requests.

13 min read
Guide

ThinkScript to Pine Script: A Practical Conversion Guide

No official converter exists between thinkorswim and TradingView. Here is the concept mapping, the persistent-state pattern, and why thinkScript negative offsets cannot be translated to Pine at all.

14 min read
Guide

Position Size in Pine Script: How to Code Your Risk Rules

Pine Script offers fixed, cash, and percent-of-equity order sizing plus per-order quantity. Learn how each behaves and how to derive quantity from a stop distance without dividing by na.

13 min read
Comparison

Cursor and Copilot for Pine Script: Where They Fall Short

Cursor and Copilot can edit Pine Script but cannot compile it, because Pine only runs on TradingView. Here is why that breaks their feedback loop and how to work around it.

13 min read
Comparison

ChatGPT vs Claude vs Gemini for Pine Script Compared

Three general assistants priced within a dollar of each other, judged on one job: producing Pine Script that compiles and stays maintainable across several iterations.

14 min read
Guide

How to Check AI-Generated Pine Script Before You Use It

Compiling is the first test, not the last. A seven-pass review that catches version drift, conditions that never fire, repainting, strategy-default surprises, and runtime errors.

14 min read
Comparison

TrendSpider vs PineScripter: No-Code or Code You Own

These sit in different categories. One is an automation-first analysis platform, the other is a Pine Script coding workspace that leaves you with exportable source.

13 min read
Comparison

Buying TradingView Indicators vs Coding Your Own

TradingView protected and invite-only scripts hide their source from users by design. That documented fact decides more than price does when choosing between buying and building.

13 min read
Guide

"Undeclared Identifier" in Pine Script: Cause and Fix

The "undeclared identifier" error is usually a missing namespace, typo, scope issue, or declaration-order problem. Learn the exact debugging process and the smallest safe fix.

10 min read
Guide

"Could Not Find Function" in Pine Script: Fix It

Pine Script cannot find a function when its namespace, version, or signature does not match. Learn how to resolve the exact call without replacing your full script.

10 min read
Guide

"Mismatched Input" Error in Pine Script: Fix It

A mismatched input error often points after the real problem. Find the missing parenthesis, comma, quote, or indentation issue and make the smallest correct repair.

10 min read
Guide

"Cannot Use plot in Local Scope" in Pine Script

Pine Script plots must be declared in global scope. Learn the correct conditional-plot pattern with na values instead of placing plot calls inside if blocks.

10 min read
Guide

"Script Requesting Too Many Securities" in Pine Script

Your script has exceeded Pine Script data-request limits. Learn how unique request contexts are counted and how tuple requests reduce unnecessary duplication.

11 min read
Guide

Pine Script v6 Errors After Upgrading: How to Fix Them

Fix the common Pine Script v5-to-v6 migration failures, including strict booleans, removed strategy parameters, changed defaults, dynamic requests, and visual syntax.

13 min read
Comparison

Free AI Pine Script Generator: What You Actually Get

A free generator is useful only if it helps beyond the first draft. Compare compile-error recovery, surgical editing, code ownership, and workspace maintenance.

11 min read
Guide

Can AI Write Pine Script? An Honest Look at What Works

AI can accelerate Pine Script drafts and explanations. Learn where it helps, why compile feedback matters, and how a focused editing workflow avoids manual error handoffs.

11 min read
Guide

How to Prompt ChatGPT for Pine Script, and Why It Still Breaks

Use clearer Pine Script prompts and understand the limits of a general chat workflow: compiler handoffs, full-script regenerations, and difficult code review.

12 min read
Comparison

Best AI for TradingView: Tools for Writing Pine Script Faster

The best AI for TradingView coding depends on the task. Compare a dedicated Pine Script workspace with general AI assistants for writing, compiling, and maintaining code.

12 min read
Guide

How Pine Script's Execution Model Actually Works

Pine Script runs your code once per bar, not once total. Understand the series-of-values model, historical vs realtime bars, the [] history operator, and why your variables seem to reset every bar.

12 min read
Guide

The Pine Script Type System: Series vs Simple vs Const

The "cannot call with arguments of type series" error comes from Pine Script's type-qualifier hierarchy. Here is how const, input, simple, and series interact with function parameters, and how v6 tightened the rules.

11 min read
Guide

var, varip, and Persistent State in Pine Script

A complete guide to persistent state in Pine Script: how var initializes once, how varip behaves differently on realtime bars, and how to build counters and arrays that survive across bars.

10 min read
Guide

Arrays, Matrices, and Maps in Pine Script

Pine Script has three collection types: arrays, matrices, and maps. Here is when to reach for each, the object-count limits that trip people up, and the performance tradeoffs to keep in mind.

11 min read
Guide

Everything New in Pine Script v6, Ranked by What Matters

Pine Script v6 launched in November 2024 with dynamic requests, strict booleans, enums, runtime logging, and unlimited backtesting. Here is what actually changes how you write code, ranked by impact.

13 min read
Guide

Dynamic Requests in Pine Script v6: Multi-Symbol Scanners

Pine Script v6 lets you pass series arguments to request.security, so you can scan a watchlist inside a loop. Here is how to build scanners that were impossible in v5, plus the memory limits behind the RE10139 error.

11 min read
Guide

Runtime Logging in Pine Script: Debugging with log.info

Before v6, debugging Pine Script meant plotting values and squinting. Now log.info, log.warning, and log.error send timestamped messages to the Pine Logs pane. Here is how to actually debug with them.

9 min read
Guide

Enums in Pine Script v6: Cleaner State Machines and Inputs

Enums arrived in Pine Script v6. They make state machines readable, give you type-safe dropdown inputs, and eliminate the magic strings that used to break silently. Here is how and when to use them.

8 min read
Guide

What Pine Script Can and Cannot Do: An Honest Map

Before you commit to Pine Script, know its edges: the 500ms loop limit, drawing-object caps, no outbound HTTP, no file I/O, and the sandbox. An honest map of what the language can and cannot do.

12 min read
Guide

Can Pine Script Connect to an API, Broker, or Webhook?

Pine Script cannot make outbound API calls, but it can fire alerts that hit a webhook, which an external service can turn into broker orders. Here is exactly what is possible and where the line is.

10 min read
Guide

Why Your Pine Script Is Slow and How to Fix It

Loop timeouts and laggy charts usually trace to a few culprits: redundant request.security calls, expensive loops, and drawing-object churn. Here is how to profile Pine Script and fix the slow parts.

10 min read
Guide

Multi-Timeframe Analysis in Pine Script Without Repainting

Higher-timeframe data is one of the most misused features in Pine Script. Here is the definitive guide to request.security with lookahead, the confirmed-bar pattern, and code that does not repaint.

12 min read
Guide

Repainting Explained: The Five Kinds and How to Prevent Each

Repainting is not one bug, it is five. Higher-timeframe leak, realtime fluctuation, future leak via lookahead, security misuse, and drawing repaint. Here is how to spot and prevent each kind.

13 min read
Comparison

Pine Script vs Python for Algorithmic Trading

An honest, technical comparison of Pine Script and Python for algorithmic trading. Where Pine wins (chart-native, zero setup, alerts) and where Python wins (data access, machine learning, live execution).

12 min read
Comparison

Pine Script vs Backtrader: Chart-Native or Python Control?

Backtrader gives you event-driven realism and live-trading hooks in Python. Pine Script gives you speed and chart-native visualization. An honest comparison of the tradeoffs.

10 min read
Comparison

Pine Script vs VectorBT: Vectorized Speed vs Simplicity

VectorBT runs thousands of vectorized backtests in seconds using NumPy and Numba. Pine Script runs one strategy, live, on your chart. An honest comparison of speed, accuracy, and the learning curve.

10 min read
Comparison

Pine Script vs Backtesting.py: The Simplest Way to Test

Backtesting.py is the friendliest Python backtesting framework. Pine Script is the friendliest chart-native one. An honest comparison for traders deciding where to test their first strategy.

9 min read
Comparison

Pine Script vs MQL5 (MetaTrader): Two Worlds of Algo Trading

MQL5 powers MetaTrader with full automation and a marketplace. Pine Script powers TradingView with fast, visual scripting. An honest comparison of language design, execution, and ecosystem.

11 min read
Comparison

Pine Script vs ThinkScript vs EasyLanguage

Three charting-platform scripting languages compared: Pine Script on TradingView, ThinkScript on thinkorswim, and EasyLanguage on TradeStation. Language design, capabilities, and who each suits.

10 min read
Guide

Why TradingView Built Its Own Language

TradingView could have used Python or JavaScript. Instead it built Pine Script. Here is why: the sandbox, determinism, safety at scale, and the series-of-values model that makes chart scripting natural.

9 min read
Tutorial

Building a Repaint-Free Alert System in Pine Script

alertcondition, alert(), and strategy alerts do different things. Here is how each works, how to fire alerts only on confirmed bars, and how to format webhook JSON for external execution.

11 min read
Guide

How TradingView Backtesting Actually Works

The Strategy Tester is easy to trust too much. Here is how bar-close fills, intrabar assumptions, calc_on_every_tick, slippage, commission, and lookahead really work, and where the numbers mislead you.

12 min read
Tutorial

Writing Reusable Pine Script Libraries

Pine Script libraries let you export functions once and import them across scripts. Here is how library(), export, and versioning work, and how to structure code you can reuse.

9 min read
Tutorial

Custom Types and Objects in Pine Script (UDTs)

User-defined types let you model data cleanly in Pine Script instead of juggling parallel arrays. Here is how to define types, build arrays of objects, and pair them with maps for readable code.

10 min read
Guide

How to Turn a Trading Idea into Testable Pine Script

A trading idea becomes testable Pine Script only after you turn it into concrete rules for entry, exit, filters, and sizing. Here is the process, from vague idea to a hypothesis to working v6 code.

9 min read
Tutorial

Moving Average Crossover in Pine Script: A Complete Guide

Build a moving average crossover in Pine Script v6 from scratch: first as an indicator, then a backtestable strategy, with a trend filter, SMA vs EMA, and the lag and whipsaw pitfalls explained.

9 min read
Guide

How PineScripter Keeps Your Pine Script Strategy Private

Your strategy logic is your edge. An honest look at where your Pine Script gets exposed across freelancers, indicator suites, and public libraries, and what a private coding tool can and cannot promise.

8 min read
Comparison

What It Costs to Get a Pine Script Indicator Built

The real Pine Script indicator cost by route: freelancer, hourly developer, doing it yourself, or an AI tool. Honest price ranges plus the hidden costs of waiting, revisions, and privacy.

9 min read
Guide

Is PineScripter Worth It? An Honest Review for 2026

An honest look at whether PineScripter is worth it: who should not pay for it, who gets the most value, the simple time-and-cost math, and how to decide in five minutes with the free tier.

9 min read
Comparison

Pineify vs PineScripter: No-Code Builder or Custom Code?

Pineify is a capable no-code Pine Script builder that exports real v6 code. PineScripter writes custom code from a description. An honest Pineify alternative comparison for when your idea outgrows the blocks.

8 min read
Comparison

Pinegen vs PineScripter: Generator or Full Workspace?

Pinegen is a capable Pine Script generator. PineScripter is a full coding workspace with a self-fixing error loop and surgical edits. An honest comparison for when you need more than a first draft.

7 min read
Guide

Pine Script v5 to v6: What Changed and How to Migrate

Migrating from Pine Script v5 to v6 is mostly a handful of predictable changes. Here's what actually changed, grouped by category, with the exact fix for each and the silent behavior changes to watch.

11 min read
Comparison

Best AI Pine Script Generators in 2026: An Honest Guide

Searching for an AI Pine Script generator? An honest 2026 roundup of ChatGPT, Pinegen, Pineify, LuxAlgo Quant, and PineScripter, judged on what compiles, what you can edit, and what you actually own.

11 min read
Guide

Pine Script Won't Compile? Common Errors and How to Fix Them

Your Pine Script won't compile? Most TradingView compile errors trace to a few root causes: type mismatches, scope rules, missing namespaces, indentation, and version drift. Here's how to read and fix each one.

9 min read
Comparison

LuxAlgo Quant vs PineScripter: An Honest Comparison

LuxAlgo Quant generates Pine Script and comes bundled with an indicator platform. PineScripter is a standalone workspace for code you own and edit. Here's an honest comparison.

8 min read
Guide

How PineScripter Works: From Idea to Working Pine Script in Seconds

You have a strategy idea. You want to see if it works. Here's how PineScripter eliminates the painful debugging cycle and gets you to a working script faster than any other tool.

10 min read
Comparison

5 Best AI Tools for Pine Script (2026 Comparison)

You want to write Pine Script faster. Should you use ChatGPT, Cursor, or a specialized tool? Here's an honest comparison of what actually works for TradingView development.

9 min read
Comparison

PineScripter vs Hiring a Fiverr Developer (Cost & Time Comparison)

You need a Pine Script indicator built. Do you hire a Fiverr developer for $150 and wait a week, or generate it yourself in 30 seconds? Here's the real cost comparison.

7 min read
Comparison

Why ChatGPT Fails at Pine Script (And What Actually Works)

You have a great trading idea at 11pm on Sunday. You ask ChatGPT to write the Pine Script. You paste it into TradingView... and it breaks. Here's why generic AI fails at Pine Script.

8 min read