Strategy · Pine Script v6 · On the chart

PineForge — Forge Loop Channel

by pineforge-4pass· code credited to PineForge

This strategy plots adaptive upper and lower triggers on the price chart.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code45
Settings4inputs
LicenceApache-2.0
Last update5 days ago23 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

45 lines of Pine Script v6 from validation/math-forge-log-channel-01/strategy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

strategy.pine
//@version=6
// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 PineForge
// PineForge Corporate Strategy: Forge Loop Channel
// Explicit iteration constructs a logarithmically adjusted breakout channel.
strategy("PineForge — Forge Loop Channel", overlay=true,
     initial_capital=100000,
     default_qty_type=strategy.percent_of_equity, default_qty_value=6,
     pyramiding=0, commission_type=strategy.commission.percent,
     commission_value=0.05, slippage=1,
     margin_long=100, margin_short=100,
     process_orders_on_close=false, calc_on_order_fills=false)

channelLength = input.int(24, "Channel Length", minval=5, maxval=80, group="Signal")
logBuffer = input.float(0.18, "Log Buffer Multiplier", minval=0, step=0.02, group="Signal")
atrLength = input.int(16, "ATR Length", minval=2, group="Risk")
stopAtr = input.float(2.3, "Stop ATR", minval=0.5, step=0.1, group="Risk")

float channelHigh = high[1]
float channelLow = low[1]
float logMovement = 0.0
for offset = 2 to channelLength
    channelHigh := math.max(channelHigh, high[offset])
    channelLow := math.min(channelLow, low[offset])
    logMovement += math.abs(math.log(close[offset - 1] / close[offset]))

averageLogMove = logMovement / math.max(channelLength - 1, 1)
upperTrigger = channelHigh * (1.0 + averageLogMove * logBuffer)
lowerTrigger = channelLow * (1.0 - averageLogMove * logBuffer)
atrValue = ta.atr(atrLength)

if ta.crossover(close, upperTrigger)
    strategy.entry("Forge Long", strategy.long)
if ta.crossunder(close, lowerTrigger)
    strategy.entry("Forge Short", strategy.short)

if strategy.position_size > 0
    strategy.exit("Forge Long Guard", from_entry="Forge Long",
         stop=strategy.position_avg_price - atrValue * stopAtr)
if strategy.position_size < 0
    strategy.exit("Forge Short Guard", from_entry="Forge Short",
         stop=strategy.position_avg_price + atrValue * stopAtr)

plot(upperTrigger, "Adaptive Upper", color=color.green)
plot(lowerTrigger, "Adaptive Lower", color=color.red)

Overview

PineForge — Forge Loop Channel builds the channel from the highest high and lowest low over channelLength bars, then adjusts the width by the average logarithmic price movement captured across the lookback period using logBuffer. Long entries trigger on close crossing above the upper trigger and short entries on crossing below the lower trigger. Exits use ATR-based stops sized at stopAtr multiples of the average entry price. Inputs modify channel length, log buffer scale, ATR period, and stop multiplier. The strategy draws directly on the price chart with no separate pane and employs percent-of-equity position sizing.

Details

Published by

pineforge-4pass on GitHub

Code credit

PineForge, as written in the script's header

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Breakout, Volatility & bands, Support & resistance

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingbacktestingparitypine-scriptpinescriptquantitative-financetest-corpustradingview

Settings

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

SettingTypeDefaultVariable
Channel Lengthint24channelLength
Log Buffer Multiplierfloat0.18logBuffer
ATR Lengthint16atrLength
Stop ATRfloat2.3stopAtr
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

257 stars

This strategy plots VWMA-based Bollinger bands on the 1-minute ES futures price chart for volatility analysis and potential breakout identification. It calculates dynamic long and short stop loss and take profit levels using percentage inputs relative to entry

Strategy v6 Volatility & bandsSupport & resistance
Updated 6 weeks ago · None stated GitHub repository of V1.6 ES - Futures 1M No Repaint
16 stars

This strategy trades Donchian breakouts measured on weekly bars while orders execute on the chart timeframe. It allows long and short entries when price breaks the prior weekly channel and exits against the shorter weekly channel. Position size risks a set per

Strategy v6 TrendBreakout
Updated 11 months ago · None stated GitHub repository of Seykota Alt 4: Weekly Donchian
11 stars

Calculates upper and lower Donchian Channel bands over a customizable lookback length and plots them on the main price chart. At a specified exchange hour, the strategy places a long buy stop order at the upper Donchian Channel level. Unfilled pending orders a

Strategy v6 BreakoutSupport & resistance
Updated 5 months ago · Apache-2.0 GitHub repository of Estrategia Donchian Breakout
6 stars

This overlay strategy builds independent timed session ranges and marks range, trendline, mean, VWAP, and high-low levels when those displays are enabled. It enters on range breakouts and exits with strategy exits, choosing among range, ATR, fixed-point, and r

Strategy v5 Sessions & timeBreakout
Updated 7 months ago · None stated GitHub repository of MSG Enhanced LEGO System Strategy
3 stars

Donchian Channel Breakout is a Pine Script v5 strategy drawn on the price chart. It enters long when close crosses above the previous upper Donchian band and short when close crosses below the previous lower band, reversing with the opposite signal. An ATR tra

Strategy v5 BreakoutVolatility & bands
Updated 7 months ago · MIT GitHub repository of Donchian Channel Breakout

The Range Percent Breakout Strategy identifies range contraction and inside bar patterns where the current bar's range is within a specified percentage threshold of the previous bar. When this condition is met while flat, breakout levels are established above

Strategy v5 BreakoutVolatility & bands
Updated 5 months ago · None stated GitHub repository of Range Percent Breakout Strategy

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