TradingView pine editor
Find the TradingView Pine Editor and learn how to prepare, inspect, and test your own Pine script.
On this page
- Where do I find the Pine Editor?
- Should I start with an indicator or a strategy?
- What should I check before changing a script?
- How do I use inputs without losing track of the rules?
- How do I put a script on the chart?
- What does a successful script run tell me?
- How can I investigate unexpected behavior?
- How should I save and name my work?
- What belongs in a repeatable test record?
- What should I check before comparing test results?
- Sources
Key takeaways
- Open the Pine Editor from the tab at the bottom of a TradingView chart.
- Check whether your script is an indicator or a strategy before interpreting its output.
- Record the script, chart, inputs, and test assumptions so you can repeat a review.
- A script that runs without errors still needs checks against the rules you intended.
Where do I find the Pine Editor?
TradingView’s Pine Editor is where you work on Pine scripts, and its documentation says to open it from the Pine Editor tab at the bottom of the chart (checked 2026-11-14). Pine Script is the language used to express the calculations and rules in those scripts, while a script is the set of instructions you write and review.
Start with a chart and open the editor before deciding what you want the script to show. If you already have code, read its title and declaration before making a change, so you know which script you are working on and what kind of work it is meant to do.
Keep the editor and chart in view while you review a small change, using the code to check your intended calculation and the chart to inspect the visible behavior. If you are new to Pine, begin with a short script you can explain in plain words, because interacting conditions in a longer script can make an unexpected observation harder to trace.
Before changing anything, note the original script name and the purpose of your test, so you have a reference if you later need to retrace your edits or explain a different chart display. That record is especially useful when you return to a project after working on other scripts.
Should I start with an indicator or a strategy?
TradingView’s script structure documentation says a declaration statement identifies the script type and lists indicator(), strategy(), and library() as the available declarations (checked 2026-11-14). A declaration is the part of the script that identifies what kind of script it is, so read it before deciding how to inspect the output.
For a chart calculation, think about the output you want to inspect, such as a line representing a moving average over the prices you have chosen. A moving average summarizes prices over a chosen span of chart bars, where each bar represents a period of market data.
For a strategy test, write down the intended entry and exit conditions before looking for a report, including the circumstances under which each condition is meant to apply. An entry condition describes when a hypothetical position begins, while an exit condition describes when it ends.
Do not assume that a line on a chart is itself a complete test of those rules, because the calculation, the conditions that refer to it, and the simulation assumptions are separate things to inspect. When reviewing existing code, trace those parts from the declaration and resolve any mismatch with your intended purpose before interpreting the output.
What should I check before changing a script?
Read the script as a description of an idea rather than as a collection of settings to adjust, and note the data, calculations, and conditions that make up the idea. Write a short explanation of the intended behavior without copying the code, so you have an independent description to compare against it.
For example, describe what must be true before a hypothetical entry can occur and what event is meant to end that position, including any calculation either condition depends on. Then look for a mismatch, such as a condition using a different price than you expected or an exit rule depending on a calculation you had overlooked.
Keep a copy of your original work before making substantive edits, and give each saved version a name you can recognize when you return to it. Record the purpose of the change alongside the name, rather than relying on memory after several tests or assuming that a familiar title captures the full history.
If you do not understand a section, isolate the question before changing it, such as where a calculation gets its value or whether an exit condition can be reached. This review does not prove the script is correct, but it gives you a way to compare its written rules with the idea you meant to express before further edits make that comparison harder.
How do I use inputs without losing track of the rules?
An input is a value exposed for the person using a script to change, such as the length used in a calculation that appears elsewhere in the code. TradingView’s first indicator example uses inputs so the moving average lengths can be changed from the script’s settings (checked 2026-11-14).
Before exposing a value, describe what it controls and how a change would affect the calculation, using a label that distinguishes it from values with different roles. For example, a calculation length and a threshold used in a condition deserve distinct descriptions in your notes.
Keep a written record of the input values used for a test, along with the chart symbol and timeframe, meaning the duration represented by each chart bar. Those details give context to your review and help you reconstruct the setup when you return to the same question.
Changing an input is different from changing the code that uses it, so avoid changing both at once when you are trying to explain a different observation. Otherwise, you may not know whether the difference came from the value, the rewritten rule, or an interaction between them.
Use your notes to return to the earlier setup before comparing another value, and keep the reason for each comparison clear. For the separate question of how to define a search range, use the parameter range guide rather than treating every possible value as meaningful.
TradingTune for Chrome
Stop tuning your strategy's inputs by hand.
Free tier, no API keys. A free account is required to run. Not affiliated with TradingView, Inc.
How do I put a script on the chart?
TradingView’s strategy documentation says you can write a custom strategy in the Pine Editor and select Add to chart to test it (checked 2026-11-14). Before doing that, read through the script and confirm that the name and intended rules match the work you want to examine, particularly if you have saved several versions.
After adding it, inspect the chart context before judging the output, and record the symbol, timeframe, visible history, script name, and inputs. Add any assumptions you know affect the test, so you can distinguish a change in the script from a change in the surrounding setup.
Look for an example on the chart where you can explain what the script was meant to do, then trace the relevant calculation and condition back to the source. Compare your expectation with the visible behavior and write down any difference before deciding which part of the code to investigate.
If the observation is surprising, avoid changing several parts of the script at once, because that makes it harder to connect the next observation to a particular edit. Record the bar you are inspecting, the expected behavior, and the actual behavior, then follow the code that connects them.
A chart can help you find a mismatch, but agreement at a selected point is not a full validation of the script across other conditions. Other periods, different inputs, or an overlooked rule may reveal a separate issue that your chosen example did not show.
What does a successful script run tell me?
A successful run is a useful checkpoint, but it is not evidence that the code expresses the intended idea or that the test assumptions fit your research question. A script can be valid as written while using a condition, value, or assumption that you did not mean to include in the rules.
Separate the question of whether the code runs from the question of whether its behavior makes sense, and pick a chart location where you can inspect that behavior. Describe the expected calculation before looking at the visible output, so your expectation is not shaped entirely by what you happen to see.
For a strategy, compare the intended entry and exit rules with the hypothetical activity you observe, including the conditions that were meant to lead to each event. If you cannot explain an event, trace the relevant conditions and inputs before drawing a conclusion from the report.
TradingView describes Pine strategies as scripts that simulate trades across historical and realtime bars, as explained in its strategy documentation (checked 2026-11-14). A simulation is a representation of activity under specified rules and assumptions, not a record of actual execution.
Make a note of what you checked and what remains uncertain, including any behavior you could not explain from the code. The guide to common backtesting mistakes is a useful next reference when you move from inspecting the script to reviewing the conditions that shape a test.
How can I investigate unexpected behavior?
Debugging means inspecting a script to find why its behavior differs from what you intended, using a specific question to guide the search. For example, investigate why a condition appears true on a particular bar rather than trying to review every calculation at once.
TradingView’s debugging documentation says the log functions write interactive messages in the Pine Logs pane (checked 2026-11-14). A log is a text record that can help you inspect a value or condition during a script’s execution, giving you another way to investigate an unexpected observation.
Write down what you expect the relevant value to be before inspecting it, then compare that expectation with the observed value and trace any difference through the inputs and calculations that produced it. If your expectation was wrong, update your explanation and check whether the intended rule itself needs clarification.
A useful investigation keeps the chart context fixed while you examine the question, because changing the symbol, timeframe, input, and code together makes the next observation harder to connect to a cause. When you find a mismatch, make a focused edit and repeat the same check under the same conditions.
Keep the original and new observations in your notes, including any uncertainty about whether the edit addressed the underlying rule rather than just the example. A debug output can help explain that local example, but it does not establish that every part of the script is correct, so review other relevant conditions before a wider test.
How should I save and name my work?
TradingView’s first indicator instructions say that a saved script is stored on TradingView’s cloud servers and is local to the author’s account (checked 2026-11-14). Choose a name that describes the script and its purpose, rather than a name that assumes the test has succeeded or implies a conclusion you have not established.
Keep a separate research note that connects the name to the change you made, including the date of your edit, a plain description of the rule, and any question you still need to check. The note can also explain whether you changed the calculation itself or only a value used by the calculation.
When making a substantial revision, preserve a way to identify the earlier code, so you can compare an unintended change with the previous version. That record also helps you explain which script was used for a particular test when you revisit the work.
Do not rely on a script name alone to capture the full setup, since inputs and chart context matter to the interpretation of what you observed. Record those details with the test rather than assuming that a familiar title means the same conditions were used each time.
A compact note can distinguish a calculation change from an input change and a chart change, giving you a practical place to start if a later review produces a different observation. Keep the distinction clear even when the edit seems small at the time.
What belongs in a repeatable test record?
A repeatable record connects the code you reviewed to the chart and assumptions used for that review, making your reasoning visible rather than turning a past observation into a forecast. It also gives you a basis for finding differences between tests that were meant to answer the same question.
Record the script name and the specific revision, then list the inputs and chart symbol alongside the timeframe and period you inspected. Add a description of the question the test was meant to answer, so the record explains why those details were relevant.
Include assumptions about simulated activity and costs where they matter to your strategy, and mark an assumption as unknown if you have not yet checked it. Investigate that uncertainty before treating the test as comparable with another run that may use different assumptions.
Describe the checks you performed on the code, including any chart examples used to trace a condition and any questions that remained open. Note changes made during debugging, since a test of the revised script is not the same record as a test of the earlier version.
A useful record separates observation from interpretation, so write what you saw on a particular bar and then explain why you think it occurred. Leave room to revise that explanation if another check contradicts it or reveals a condition you had not considered.
For a broader workflow around script inputs and research notes, see turning Pine Script strategy inputs into a repeatable backtesting workflow, which explores how to keep the work organized.
What should I check before comparing test results?
Make sure the scripts being compared express the same intended rules, or clearly record the rule change you are investigating before drawing conclusions. A comparison is difficult to interpret when the code, chart context, and inputs have all changed without a record of those changes.
Review the period used for the test and keep it distinct from any later period reserved for a separate check, so you can describe what each review was intended to examine. The in-sample and out-of-sample guide covers that separation and its limits.
Read the test assumptions alongside the reported measures, rather than treating a single measure as a complete account of the simulation. The metrics guide explains what common measures can and cannot describe, including why their meaning depends on the test context.
If you investigate several input values, keep the script version and other test conditions consistent while you examine them, and record the reason for each comparison. When a code revision is necessary, treat it as a new question rather than silently mixing it with the earlier input review.
Finish by writing down what the comparison does not answer, including any assumptions or behaviors you have not yet checked. A historical test describes a simulation under its chosen data and assumptions, so it cannot establish how the same rules will behave under every future condition.
Sources
TradingTune for Chrome
Stop tuning your strategy's inputs by hand.
TradingTune runs systematic parameter searches on your own TradingView strategy, right inside the chart page. You keep the strategy, you read the results.
Free tier, no API keys. A free account is required to run. Not affiliated with TradingView, Inc.
TradingTune for Chrome
Stop tuning your strategy's inputs by hand.
TradingTune runs systematic parameter searches on your own TradingView strategy, right inside the chart page. You keep the strategy, you read the results.
Free tier, no API keys. A free account is required to run. Not affiliated with TradingView, Inc.
TradingTune for Chrome
Stop tuning your strategy's inputs by hand.
TradingTune runs systematic parameter searches on your own TradingView strategy, right inside the chart page. You keep the strategy, you read the results.
Free tier, no API keys. A free account is required to run. Not affiliated with TradingView, Inc.
TradingTune for Chrome
Stop tuning your strategy's inputs by hand.
TradingTune runs systematic parameter searches on your own TradingView strategy, right inside the chart page. You keep the strategy, you read the results.
Free tier, no API keys. A free account is required to run. Not affiliated with TradingView, Inc.
TradingTune for Chrome
Stop tuning your strategy's inputs by hand.
TradingTune runs systematic parameter searches on your own TradingView strategy, right inside the chart page. You keep the strategy, you read the results.
Free tier, no API keys. A free account is required to run. Not affiliated with TradingView, Inc.