FlowScript: Code Your Own Indicators · Lesson 8 of 10 · 10 min

Sessions, delta and other timeframes

Prior-day and overnight levels, buy-minus-sell volume, and the daily trend on an intraday chart.

Session values are built in and use New York time: pdh, pdl, pdc (prior regular session), onh, onl (overnight), pmh, pml (premarket), ib_high, ib_low (first hour), day_open, minutes_since_open and more. in_session("0930-1030") tests any window.

indicator("Prior day", overlay = true)

plot(pdh, "PDH", color = green, style = step)
plot(pdl, "PDL", color = red, style = step)
killzone = in_session("0930-1100")
bgcolor(killzone ? fade(sky, 5) : na)

Delta is buy volume minus sell volume. bar_delta() and cum_delta() use real trade sides when the chart has them; otherwise they estimate from where each bar closed in its range, and delta_is_real() tells you which.

indicator("Session delta", overlay = false)

cd = cum_delta("rth")
plot(cd, "Cumulative delta", color = cd > 0 ? green : red, style = area)

htf(timeframe, expression) evaluates an expression on a higher timeframe of the same symbol, and security(symbol, timeframe, expression) reads another symbol. Both use completed bars only, so the values never change after the fact.

indicator("Daily RSI on intraday", overlay = false)

dailyRsi = htf("D", rsi(close, 14))
hourlyTrend = htf("60", close > ema(close, 50))
plot(dailyRsi, "Daily RSI", color = violet)
bgcolor(hourlyTrend ? fade(green, 5) : fade(red, 5))

Key takeaways

  • Session levels come built in, in New York time.
  • Delta is real with trade sides, estimated otherwise.
  • htf() and security() never repaint: completed bars only.

Next: Backtest a strategy