Strategy · Pine Script v6 · On the chart

PF Pyramid carry 01 - deferred flip

by pineforge-4pass· code credited to PineForge contributors 2026

This strategy tests deferred position flips under pyramiding.

View on GitHub

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

44 lines of Pine Script v6 from validation/pyramid-deferred-flip-close-all-01/strategy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

strategy.pine
// This Pine Script® code is licensed under Apache-2.0
// SPDX-License-Identifier: Apache-2.0
// © PineForge contributors 2026
//
// Pyramid carry probe 01 — deferred flip across close_all
//
// Purpose: pyramiding=4 with alternating market and stop entries,
// punctuated by `strategy.close_all` mid-session. Tests deferred-
// flip carry: when a stop entry queued the prior bar would flip
// the position, but `close_all` fires the same bar, the runtime
// must correctly sequence (close-then-flip vs flip-then-close)
// across the pyramid stack.
//
// Trade shape: alternating long market entries (RSI cross-up) and
// short stop entries (break of prior low) up to pyramiding=4. Once
// per session (hour==21, minute==45) we close_all, expecting any
// pending stop entries queued by previous bar to carry into the
// next bar after the flat reset.
//
// TV setup: 15m chart, ETH-USDT-USDT, same window as
// data/ohlcv_ETH-USDT-USDT_15m.csv. TradingView strategy report for this window.
//@version=6
strategy("PF Pyramid carry 01 - deferred flip", shorttitle="PYR_p01_FLIP", overlay=true,
     initial_capital=1000000,
     commission_type=strategy.commission.percent, commission_value=0, slippage=0,
     default_qty_type=strategy.fixed, default_qty_value=1, pyramiding=4,
     process_orders_on_close=false)

rsiVal  = ta.rsi(close, 14)
emaFast = ta.ema(close, 9)
emaSlow = ta.ema(close, 21)
atrVal  = ta.atr(14)

bool longCond  = ta.crossover(emaFast, emaSlow) and rsiVal < 70
bool shortStop = ta.crossunder(rsiVal, 50)

if longCond
    strategy.entry("L", strategy.long, qty=1, comment="add long market")

if shortStop
    strategy.entry("S", strategy.short, qty=1, stop=low - atrVal * 0.25, comment="flip short stop")

if hour == 21 and minute == 45
    strategy.close_all(comment="session close_all")

Overview

PF Pyramid carry 01 - deferred flip enters long at market when a 9-period EMA crosses above a 21-period EMA and RSI stays below 70, and it queues short stop entries when RSI crosses under 50, with the stop placed a quarter of ATR below the bar low. It allows up to four entries of one unit each. At 21:45 it closes every position. It draws on the price chart and has no protective stop loss.

Details

Published by

pineforge-4pass on GitHub

Code credit

PineForge contributors 2026, as written in the script's header

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Oscillators & momentum, Moving averages, Breakout

Markets

Crypto

Timeframes

M15-H1

Risk Notes

  • The strategy can add several entries in the same direction
  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingbacktestingparitypine-scriptpinescriptquantitative-financetest-corpustradingview

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

106 stars

Calculates a momentum squeeze using Bollinger Bands and Keltner Channels alongside a trend-filtering moving average. It generates long and short entries based on squeeze momentum bar conditions and an optional pre-squeeze dot count filter. Exits can trigger on

Strategy v5 Oscillators & momentumVolatility & bands
Updated 2 years ago · GPL-3.0 GitHub repository of Athena Momentum Squeeze - Autoview

Bollinger bands examples

by tradingstrategy-ai
53 stars

This strategy plots exponential-moving-average Bollinger bands on the price chart and calculates RSI. It opens a long position when close crosses above the upper band while RSI is at or above a threshold, the date filter allows trading, and no position is open

Strategy v5 Volatility & bandsOscillators & momentum
Updated 3 years ago · None stated GitHub repository of Bollinger bands examples

ADA4H Optuna Strategy

by skywalker0803r
42 stars

This strategy trades longs and shorts on the price chart. Long entries require a close above the prior Donchian high, a close above a long-term SMA, and RSI above a threshold, with size set as a percentage of equity. Long exits use a stop at the prior Donchian

Strategy v5 TrendOscillators & momentum
Updated 2 months ago · None stated GitHub repository of ADA4H Optuna Strategy

Edge 59

by subos2008
6 stars

Edge 59 is a price-chart strategy that combines an ADX directional filter, a weighted moving average, and a trend-follower channel. The channel uses an exponential moving average of close, optionally smoothed by linear regression, and a percentage of a fixed 2

Strategy v5 TrendOscillators & momentum Repaints
Updated 2 years ago · Custom licence GitHub repository of Edge 59

AG Momentum Breakout

by eltonaguiar
4 stars

AG Momentum Breakout is a strategy that identifies continuation signals after pullbacks in trending markets. It filters for uptrends using EMAs and detects recent pullbacks via RSI conditions before entering on RSI crossovers above 50 with ADX confirmation. Th

Strategy v6 TrendOscillators & momentum
Updated today · None stated GitHub repository of AG Momentum Breakout
4 stars

Christian Qullamaggie Strategy is a trend-following and breakout strategy overlay designed to identify high-momentum trading opportunities directly on the price chart. It evaluates market conditions using fast, mid, and slow EMAs, average true range (ATR), and

Strategy v6 BreakoutTrend
Updated 7 months ago · None stated GitHub repository of Christian Qullamaggie 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