TradingView indicator guide

200-day moving average: daily vs intraday charts

A 200-day moving average uses 200 daily observations. For a simple moving average of closing prices, add the latest 200 daily closes and divide by 200. A length of 200 on a 15-minute chart instead averages 200 fifteen-minute bars unless the indicator explicitly calculates on the daily timeframe. Choose the daily data source and whether to include the unfinished day before using the line as a trend filter.

Build the daily SMA filter

200 days and 200 bars are different windows

Length specifies how many observations enter the calculation; timeframe specifies what each observation represents. The same length can therefore describe very different histories. Keep the exchange-qualified symbol, price source, and adjustment settings consistent when comparing values.

  • For an equity feed with no weekend bars, weekends contribute no extra observations. A continuously traded crypto feed can have daily bars on weekends.
  • Multiplying 200 by the expected bars per session is not equivalent: averaging intraday closes includes prices other than each daily close.
  • Require at least 200 valid daily observations. A new listing may not have enough history to produce the requested average.
Calculation timeframeLength 200 meansA 200-day SMA?
1 day200 daily closing observationsYes, with close as the source.
15 minutes200 fifteen-minute closing observationsNo.
1 week200 weekly closing observationsNo.
1 day, displayed on a 15-minute chart200 daily closes mapped onto the intraday chartYes; the display timeframe does not change the daily calculation.

Set up the daily average in TradingView

Start on a standard 1D candlestick chart. Add the built-in Moving Average indicator, select the simple average, set Length to 200, Source to Close, and Offset to 0. Check a completed date in the Data Window before changing the display timeframe.

  • To keep daily calculations on an intraday chart, open the indicator settings and set Timeframe to 1 day instead of Chart. Then switch the chart to your intraday interval.
  • For the built-in indicator, enable Wait for timeframe closes if you want new values only when its daily bar closes. This controls availability; it does not produce a new daily observation at every intraday close.
  • With that option enabled, some intraday bars can display Ø in the indicator values. TradingView may connect the available points with a line. Line With Breaks exposes those gaps.
  • Do not use a visual plot offset to fix timing. Moving the line left or right changes where it is drawn, not when its value was known.

Choose developing or completed daily data

During an open daily bar, its close is the latest price rather than a final closing price. An average that includes it can change throughout the session. A five-minute bar closing does not confirm the daily bar. Waiting for daily confirmation gives a later but defined observation.

  • For a custom Pine indicator, calculate the SMA inside the daily request context. Averaging a daily-close series after mapping it onto intraday bars counts the repeated chart-bar values instead.
  • TradingView documents a confirmed higher-timeframe pattern that offsets the requested expression by one higher-timeframe bar and pairs it with lookahead_on. Both parts are needed; using lookahead_on with the current daily value can leak future information into historical bars.
  • A custom script can carry the prior completed value across intraday bars as a step line. This is a different display policy from the built-in indicator gaps described above.
  • This policy addresses unfinished daily values. It does not prevent data-feed revisions or changes caused by selecting a different symbol or adjustment setting.
PolicyValue used during TuesdayConsequence
Developing daily averageThe current Tuesday price plus the preceding 199 daily closesThe average and a price-above-average condition can change before Tuesday closes.
Prior completed daily averageThe 200-day SMA ending on MondayThe reference stays fixed during Tuesday; the next daily period receives Tuesday's completed value.

A daily trend filter with an explicit decision time

The following hypothetical rule permits long setups during the next trading day only when the prior completed daily close is above its 200-day SMA. At equality or below, the filter is off. Both inputs come from the same completed daily bar. The numbers illustrate the rule; they are not observed prices or backtest results.

  • If price falls below the line during Tuesday, this prior-day filter remains on until the next daily update. Comparing each intraday close with the fixed daily average would be a separate rule and can change during the day.
  • A filter can remain on through a sharp decline and can toggle repeatedly around a flat average. It also responds after price has moved. None of these properties gives it a measured advantage.
  • Before testing trades, define the entry trigger, fill timing, exit, costs, and position size separately. Do not assume a daily-close decision could have filled earlier in that same session.
Completed dayDaily close / 200-day SMANext-day filter
Monday102 / 100On throughout Tuesday.
Tuesday99 / 100.05Off throughout Wednesday.
Wednesday100.10 / 100.10Off throughout Thursday under the strict above rule.

Check the value and timing before using alerts

Record a completed daily SMA and daily close for one symbol. On an intraday chart, inspect the next daily period: a prior-day implementation should show those recorded values throughout that period. Repeat across a weekend or market holiday to check how the selected feed defines the next available daily bar.

  • Compare like with like: SMA versus EMA, Close versus another source, completed versus developing data, and the same ticker and price adjustments.
  • Record the intraday value while the market is open, then reload after the daily close. Investigate a change in earlier displayed values rather than treating the historical line as proof of live behavior.
  • If the filter is unavailable because history is insufficient, treat it as unavailable. Do not silently replace it with zero or a shorter average.

Turn the rule into an inspectable Pine script

Give Pineify the calculation and timing requirements together: use the selected symbol's daily closes, compute a 200-period SMA in the daily context, and display the prior completed value on a standard intraday chart. Request a filter that compares the prior daily close with that same daily SMA, plus a clear indication when history is insufficient.

  • Specify the alert event separately, such as the first intraday bar close of a new daily period when the filter changes from off to on. A state that remains true all day is not a new event on every bar.
  • Ask for a syntax check, inspect the generated source, then compare its values and event timestamps in TradingView. Syntax diagnostics do not validate the trading premise.
Where Pineify fits

Pine Script AI Coding Agent

Draft or revise a daily moving-average filter with Pineify. Specify the daily source, confirmation policy, and alert timing, then inspect the generated Pine Script and verify it on your TradingView chart.

Build the daily SMA filter

Frequently asked questions

Educational indicator guidance, not investment advice. Examples are hypothetical and are not backtest results. A moving-average filter does not guarantee returns or limit losses.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.