Get your API key

Lesson 4 of 5

A daily-trend filter on an intraday chart

Read the daily trend on a 15-minute chart with request.security, avoid the future-leak and repainting traps, and test it.

10 min Log in to open

Education only. This is not investment advice and nothing here is a buy or sell recommendation. Trading carries risk of loss, and past results do not predict the future. Practise with TradingView's Paper Trading (fake money) only, never connect broker API keys or place live orders from these lessons. For personal advice, talk to a SEBI-registered Investment Adviser.

One step at a time, like flipping pages.

By the end of this lesson you will show 15-minute crossover markers only when the daily trend agrees, read the daily data the safe way, and test that history and live behave the same.

You need: the crossover script from lesson 2, TradingView, an AI chat or agent · Time: 10 minutes

  1. On a 15-minute chart you saw many crossovers that reversed quickly. One common learning idea is a filter: only mark a 15-minute crossover when a bigger picture agrees. Here the bigger picture is the daily trend, defined exactly:

    • Daily up: yesterday's daily close is above yesterday's 20-day EMA.
    • Daily down: yesterday's daily close is below yesterday's 20-day EMA.
    • Marker up on the 15-minute chart: fast EMA crosses above slow EMA and daily up. Marker down: the mirror.

    Notice the word "yesterday". On Wednesday at 11:00, Wednesday's daily bar has not closed. Its close is just the latest price and keeps changing.

    Diagram of daily bars Monday, Tuesday (closed) and Wednesday (still forming) above a row of Wednesday's 15-minute bars, with three boxes explaining that Tuesday's close is safe, today's close repaints, and lookahead without the one-bar offset leaks the future
    On Wednesday's 15-minute bars, read only daily bars that have closed.
    Why?

    A filter is only as honest as the data it reads. If the 15-minute bars could see a daily value that wasn't known yet at that time, the filter would look brilliant in history and never work the same way live.

Log in free to read the rest of this lesson

Every lesson is free. A free account unlocks all of them and saves your progress.

Still to come in this lesson:

  1. Three ways to read daily data
  2. Prompt the filtered indicator
  3. Test it like a sceptic
  4. Recap