Strategy · Pine Script v6 · On the chart

PineForge — Terrace Pyramid

by pineforge-4pass· code credited to PineForge

This strategy plots the Trend EMA and Deep Terrace levels on the price chart to identify rising trends.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code41
Settings5inputs
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

41 lines of Pine Script v6 from validation/pyramid-terrace-staged-entry-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: Terrace Pyramid
// Three explicit one-contract terraces stage exposure only in a rising trend.
strategy("PineForge — Terrace Pyramid", overlay=true,
     initial_capital=100000,
     default_qty_type=strategy.fixed, default_qty_value=1,
     pyramiding=3, 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)

trendLength = input.int(42, "Trend EMA", minval=5, group="Signal")
atrLength = input.int(16, "ATR Length", minval=2, group="Signal")
firstPullback = input.float(0.25, "First Terrace ATR", minval=0, step=0.05, group="Execution")
secondPullback = input.float(0.70, "Second Terrace ATR", minval=0.1, step=0.05, group="Execution")
stopAtr = input.float(2.8, "Portfolio Stop ATR", minval=0.5, step=0.1, group="Risk")

trend = ta.ema(close, trendLength)
atrValue = ta.atr(atrLength)
risingTrend = trend > trend[1] and close > trend
firstTerrace = trend + atrValue * firstPullback
secondTerrace = trend - atrValue * secondPullback

if risingTrend and ta.crossover(close, firstTerrace)
    strategy.entry("Terrace One", strategy.long, qty=1)
if risingTrend and strategy.position_size == 1 and ta.crossunder(close, trend)
    strategy.entry("Terrace Two", strategy.long, qty=1)
if risingTrend and strategy.position_size == 2 and ta.crossunder(close, secondTerrace)
    strategy.entry("Terrace Three", strategy.long, qty=1)

if strategy.position_size > 0
    strategy.exit("Terrace Guard", stop=strategy.position_avg_price - atrValue * stopAtr)
if strategy.position_size > 0 and trend < trend[1]
    strategy.close("Terrace One")
    strategy.close("Terrace Two")
    strategy.close("Terrace Three")

plot(trend, "Trend EMA", color=color.blue)
plot(secondTerrace, "Deep Terrace", color=color.orange)

Overview

PineForge — Terrace Pyramid signals long pyramid entries in staged terraces when price crosses above the first, second, or third ATR-based levels during an upward trend, with up to three contracts per level. Exits occur via an ATR-based stop loss from the average entry price or when the trend reverses and all positions close. Main settings adjust the EMA length, ATR length, terrace pullback distances, and stop multiplier. It draws exclusively on the price chart.

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

Trend, Moving averages, Volatility & bands, Support & resistance

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • The strategy can add several entries in the same direction

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
Trend EMAint42trendLength
ATR Lengthint16atrLength
First Terrace ATRfloat0.25firstPullback
Second Terrace ATRfloat0.70secondPullback
Portfolio Stop ATRfloat2.8stopAtr
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

9 stars

Smooth Trend Radar Strategy calculates a double-smoothed Supertrend baseline using WMA and EMA to identify trend direction and sideway regimes. It plots baseline rejection signals on flips, trend slope filters, and statistical overextension highlights with can

Strategy v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of Smooth Trend Radar Strategy
8 stars

This strategy combines moving averages, ATR volatility bands and ADX trend strength on the price chart. It calculates ADX from price data and adjusts the ATR multiplier dynamically based on whether ADX is rising or falling. Long and short entries are controlle

Strategy v4 TrendMoving averages
Updated 4 years ago · None stated GitHub repository of MA+ATR+ADX+PP Strategy

The AI SuperTrend x Pivot Percentile strategy combines SuperTrend trend following with KNN-based AI predictions, Pivot Percentile levels, and ADX/DMI filtering. SuperTrend indicators run on multiple higher timeframes with configurable lengths and factors, whil

Strategy v5 TrendMoving averages
Updated 1 year ago · None stated GitHub repository of AI SuperTrend x Pivot Percentile - Strategy

ALGOX

by thino-dev
2 stars

ALGOX is a Pine Script v5 strategy that overlays SuperTrend, ATR bands, Heikin Ashi candles, EMA ribbons and an RSI table on the price chart. It generates long and short entries based on signal sensitivity settings with optional lower-timeframe or higher-timef

Strategy v5 TrendVolatility & bands Repaints
Updated 7 months ago · None stated GitHub repository of ALGOX
1 stars

This strategy calculates the Supertrend using ATR period and factor inputs, then plots green lines for up direction and red lines for down direction on the price chart. It signals long entries when Supertrend changes to positive and short entries when changing

Strategy v5 TrendMoving averages
Updated 2 years ago · MPL-2.0 GitHub repository of Hello World, Supertrend

Pivot Point SuperTrend

by kanylbullen
1 stars

This Pine Script strategy plots pivot points and a SuperTrend-style trailing line based on ATR and center line derived from pivots. It calculates trend direction and generates buy and sell signals on trend reversals. Signals are filtered by a user-selected mov

Strategy v5 TrendVolatility & bands Repaints
Updated 6 days ago · None stated GitHub repository of Pivot Point SuperTrend

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