Strategy · Pine Script v6 · Own pane

S_pending_entries

by GammaExpansion

S_pending_entries is a strategy that places different types of pending buy and sell orders including limit, stop, and stop-limit orders at specific phases in a 68-bar cycle.

View on GitHub

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

86 lines of Pine Script v6 from packages/golden/fixtures/strategy/v6/S_pending_entries/source.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

source.pine
//@version=6
// 挂单进场的生命周期:limit/stop/stop-limit 放在市价上方/下方、挂着不重发直到成交、同 ID 改价、cancel、平仓后 exit 自动取消
strategy("S_pending_entries", overlay = false,
  initial_capital = 100000, currency = currency.NONE,
  default_qty_type = strategy.fixed, default_qty_value = 1, pyramiding = 1,
  commission_type = strategy.commission.percent, commission_value = 0, slippage = 0,
  margin_long = 0, margin_short = 0, close_entries_rule = "FIFO",
  process_orders_on_close = false, calc_on_order_fills = false, calc_on_every_tick = false,
  backtest_fill_limits_assumption = 0, use_bar_magnifier = false, fill_orders_on_standard_ohlc = false)
int cycleLen = 68
int phase = bar_index % cycleLen
int cycle = math.floor(bar_index / cycleLen)

float pxM04 = close * (1 - 0.004)
float pxP04 = close * (1 + 0.004)
float pxP03 = close * (1 + 0.003)
float pxP06 = close * (1 + 0.006)
float pxM10 = close * (1 - 0.010)
float pxM05 = close * (1 - 0.005)
float pxM20 = close * (1 - 0.020)
float pxP01 = close * (1 + 0.001)
if phase == 0
    strategy.entry("LimBuyBelow", strategy.long, limit = pxM04)          // 常规:低于市价的买入限价,等价格下来
if phase == 8
    strategy.close_all(comment = "c1")
    strategy.cancel("LimBuyBelow")
if phase == 10
    strategy.entry("LimBuyAbove", strategy.long, limit = pxP04)          // 高于市价的买入限价:应像市价单下个 tick 成交
if phase == 14
    strategy.close_all(comment = "c2")
    strategy.cancel("LimBuyAbove")
if phase == 16
    strategy.entry("StopBuyAbove", strategy.long, stop = pxP04)          // 常规:高于市价的买入止损,等价格上去
    strategy.exit("GhostExit", "StopBuyAbove", stop = pxM20)             // 平仓后应被自动取消,后续不得再成交
if phase == 24
    strategy.close_all(comment = "c3")
    strategy.cancel("StopBuyAbove")
if phase == 26
    strategy.entry("StopBuyBelow", strategy.long, stop = pxM04)          // 低于市价的买入止损:应立即触发
if phase == 30
    strategy.close_all(comment = "c4")
    strategy.cancel("StopBuyBelow")
if phase == 32
    strategy.entry("StopLimit", strategy.long, stop = pxP03, limit = pxP06)   // stop-limit:触发后 limit 在上方
if phase == 40
    strategy.close_all(comment = "c5")
    strategy.cancel("StopLimit")
if phase == 42
    strategy.entry("Mod", strategy.long, limit = pxM10)                  // 先挂 1% 下方
if phase == 44
    strategy.entry("Mod", strategy.long, limit = pxM05)                  // 同 ID 改价到 0.5% 下方
if phase == 50
    strategy.close_all(comment = "c6")
    strategy.cancel("Mod")
if phase == 52
    strategy.entry("LimSellAbove", strategy.short, limit = pxP04)        // 常规:高于市价的卖出限价
if phase == 58
    strategy.close_all(comment = "c7")
    strategy.cancel("LimSellAbove")
if phase == 60
    strategy.entry("StopLimitLow", strategy.long, stop = pxP03, limit = pxP01)   // stop-limit:limit 在 stop 之下,触发后等回撤
if phase == 66
    strategy.close_all(comment = "c8")
    strategy.cancel("StopLimitLow")
if phase == 67
    strategy.cancel_all()
plot(pxM04, "px_m0p4")
plot(pxP04, "px_p0p4")
plot(pxP03, "px_p0p3")
plot(pxP06, "px_p0p6")
plot(pxM10, "px_m1p0")
plot(pxM05, "px_m0p5")
plot(pxM20, "px_m2p0")
plot(pxP01, "px_p0p1")

// ---- 对齐列 ----
plot(bar_index, "bar_index")
plot(cycle, "cycle")
plot(phase, "phase")
plot(strategy.position_size, "pos")
plot(strategy.position_avg_price, "avg_price")
plot(strategy.equity, "equity")
plot(strategy.openprofit, "openprofit")
plot(strategy.netprofit, "netprofit")
plot(strategy.closedtrades, "closedtrades")
plot(strategy.opentrades, "opentrades")

Overview

S_pending_entries calculates reference price levels around the current close and plots them along with bar index, cycle, phase, and current position size in a separate pane. The strategy enters long or short positions by setting these pending orders which can be modified before fill and automatically cancels or closes them at defined phases with some order lifecycle features like ghost exits after fill.

Details

Published by

GammaExpansion on GitHub

Type

Strategy, Pine Script v6

Draws

Separate pane below the chart

Category

Support & resistance, Sessions & time

Markets

Forex

Timeframes

Any timeframe

Risk Notes

  • The strategy can add several entries in the same direction
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

Daily Bias + FVG Strategy

by TradersPost
218 stars

This overlay strategy plots previous-day high and low, the daily open, and fair value gap zones on the price chart. It takes entries on a selectable timeframe when the FVG requirement and an optional session window allow them, then uses an ATR or fixed pip sto

Strategy v6 SMC / ICT / price actionSupport & resistance Repaints
Updated 3 months ago · None stated GitHub repository of Daily Bias + FVG Strategy
106 stars

This script monitors opening gap conditions and breakout behavior relative to the first candle's range across up to twenty configurable stock tickers. It detects whether following bars remain inside the opening range before breaking out, displaying the status

Strategy v4 Screeners & dashboardsBreakout Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of 1St Bar GAP+BkOut Screener v2 by RM

ATOM 1m scalp HK

by dearvn
43 stars

This overlay strategy targets one-minute ATOM scalps. It tracks pivot highs and lows as resistance and support, compares a three-period EMA with a multi-stage smoothed close, and flags long or short when price crosses that curve in the matching direction. Dail

Strategy v5 ScalpingSupport & resistance Repaints
Updated 2 years ago · None stated GitHub repository of ATOM 1m scalp HK

P404 Smoke

by Musyimi97
16 stars

P404 Smoke is a price-chart strategy that sequences an optional higher-timeframe EMA bias, a liquidity range from recent pivots, a sweep of buy-side or sell-side liquidity, and a market structure shift within a set bar window. Comments state it then looks for

Strategy v5 SMC / ICT / price actionSupport & resistance
Updated 6 months ago · MIT GitHub repository of P404 Smoke

Fibonacci strategy

by JoelPasapera
11 stars

This strategy plots a Fibonacci retracement of the previous day's high-low range on the price chart. It places a single long limit order at that level when the bar hour matches the chosen entry hour and the close is below the level. Position size follows the l

Strategy v6 Support & resistanceSessions & time
Updated 5 months ago · Apache-2.0 GitHub repository of Fibonacci strategy

1-Min Gold Taylor Technique

by eddiebelaval
7 stars

This intraday strategy implements session-based trading rules tailored for gold on short timeframes. It tracks the Asian session price range, VWAP, 20-period EMA, and previous day high and low levels to identify liquidity sweeps during London and New York trad

Strategy v6 Sessions & timeSupport & resistance
Updated 3 months ago · None stated GitHub repository of 1-Min Gold Taylor Technique

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