Strategy · Pine Script v6 · Own pane

PineForge MTF tutorial — lower-TF intra-bar range

by pineforge-4pass

This tutorial strategy demonstrates lower-timeframe multi-timeframe functionality in Pine Script using request.security_lower_tf.

View on GitHub

GitHub stars193on the repository
Pine versionv6current
Lines of code58
Settings1inputs
LicenceApache-2.0
Last updatetoday28 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

58 lines of Pine Script v6 from tutorial/mtf/strategy_ltf.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

strategy_ltf.pine
//@version=6
//
// PineForge tutorial — MTF demo (lower-timeframe via request.security_lower_tf).
//
// Chart cadence is the input feed (15m by default). Inside each chart
// bar, request.security_lower_tf("1", close) returns an array of
// synthetic 1-minute closes covering that bar. The engine builds those
// sub-bars from the chart bar's own OHLC path — there is no separate
// finer feed (contrast with TradingView, which downloads a real 1m
// stream when you switch the timeframe).
//
// Entry signal: the realized 1m range exceeds a threshold, i.e. the
// chart bar moved a meaningful distance intra-bar. This is the kind of
// signal you cannot compute from chart-TF OHLC alone — that's the
// point of the lower-TF surface.
//
// Read alongside generated_ltf.cpp for the C++ shape the runtime
// actually loads as strategy_ltf.so.
//
strategy("PineForge MTF tutorial — lower-TF intra-bar range",
     overlay            = false,
     initial_capital    = 1000000,
     currency           = currency.USD,
     process_orders_on_close = false,
     pyramiding         = 1,
     commission_type    = strategy.commission.percent,
     commission_value   = 0,
     slippage           = 0,
     default_qty_type   = strategy.fixed,
     default_qty_value  = 1)

// === Inputs ===
rangePct = input.float(0.5, "Range threshold (% of bar close)", minval=0.0)

// === Lower-TF sub-bar closes for the current chart bar ===
//
// PF only supports lookahead=off, gaps=off on this builtin (TV does
// not expose them anyway). Target TF "1" must be a clean integer
// divisor of the chart's input TF.
sub = request.security_lower_tf(syminfo.tickerid, "1", close)

// === Realized intra-bar range from the sub-bar array ===
float subHi = na
float subLo = na
if array.size(sub) > 0
    subHi := array.max(sub)
    subLo := array.min(sub)

float pct = nz((subHi - subLo) / close * 100.0)

// === Entries: long when intra-bar move was large *and* up ===
longCond  = pct > rangePct and close > open and strategy.position_size == 0
exitCond  = strategy.position_size > 0 and close < open

if longCond
    strategy.entry("Long", strategy.long)
if exitCond
    strategy.close("Long")

Overview

PineForge MTF tutorial — lower-TF intra-bar range evaluates synthetic lower-timeframe 1-minute close prices within each chart bar to calculate the intra-bar price range percentage. The strategy enters a long position when the intra-bar range percentage exceeds a user-defined threshold and the bar closes above its open. It exits the position when a bar closes below its open. The script serves as an example for sub-bar array processing and includes no default stop loss.

Details

Published by

pineforge-4pass on GitHub

Type

Strategy, Pine Script v6

Draws

Separate pane below the chart

Category

Volatility & bands

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingbacktestingc-apicppcpp17cryptodeterministicffifinancepine-script

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Range threshold (% of bar close)float0.5rangePct
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

330 stars

A momentum strategy combining the TTM Squeeze oscillator with an RSI filter. It calculates linear regression momentum relative to Bollinger Bands and Keltner Channels alongside an RSI oscillator. Long signals trigger when momentum rises from below zero while R

Strategy v5 Oscillators & momentumVolatility & bands
Updated 2 months ago · None stated GitHub repository of TTM Squeeze [Alorse]

2xTP, SL to Entry

by hasnocool
106 stars

This strategy executes mean-reversion trades based on Bollinger Bands and the Stochastic Oscillator. Long orders trigger when price dips below the lower band alongside a bullish Stochastic crossover, with an optional oversold threshold. Short orders execute on

Strategy v5 Mean reversionOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of 2xTP, SL to Entry

EMA Ribbon MACD

by iamrichardD
57 stars

This strategy combines an EMA ribbon with MACD confirmation and plots in a separate pane. It enters when ribbon alignment, optional MACD zero or signal crosses, volume, smart-money, and multi-timeframe filters agree, then exits with percentage stop loss and ta

Strategy v6 TrendMoving averages
Updated 1 year ago · Apache-2.0 GitHub repository of EMA Ribbon MACD
25 stars

This Pine Script strategy calculates Bayesian probabilities of price breaking up or down relative to Bollinger Bands and a Simple Moving Average. It plots these breakout and breakdown probability lines as oscillators in a separate pane. Long entries trigger wh

Strategy v4 Oscillators & momentumVolatility & bands
Updated 6 years ago · None stated GitHub repository of Bayesian BBSMA Oscillator Strategy

Greeffer BB Strategy

by SammyEnigma
18 stars

This strategy fades Bollinger Band extremes using the close. It enters short when price crosses above the upper band and the 14-period RSI is above 70, and enters long when price crosses below the lower band and RSI is below 30. It closes half of an open short

Strategy v4 Volatility & bandsOscillators & momentum
Updated 6 years ago · None stated GitHub repository of Greeffer BB Strategy

AwesomeADX

by koradiyakaushal
12 stars

AwesomeADX is a Pine Script v4 strategy that combines an Awesome Oscillator, ADX directional movement, and Bollinger percent B with an optional four-length moving-average trend filter. It sizes each position as a percentage of equity and can limit trades to a

Strategy v4 Oscillators & momentumMoving averages
Updated 5 years ago · MIT GitHub repository of AwesomeADX

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers