Strategy · Pine Script v6 · On the chart

Gyroscope CMO Median

by pineforge-4pass· code credited to PineForge

A long-only strategy that pairs a rolling median line with the Chande Momentum Oscillator.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code35
Settings6inputs
LicenceApache-2.0
Last update6 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

35 lines of Pine Script v6 from validation/ta-gyroscope-cmo-median-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 Owned Strategy: Gyroscope CMO Median
// A robust rolling center and bounded momentum jointly define the regime.
strategy("PineForge — Gyroscope CMO Median", overlay=true,
     initial_capital=100000,
     default_qty_type=strategy.fixed, default_qty_value=2,
     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)

medianLength = input.int(27, "Median Length", minval=3, group="Signal")
cmoLength = input.int(16, "CMO Length", minval=2, group="Momentum")
entryMomentum = input.float(12.0, "Entry CMO", minval=-80, maxval=80, step=1, group="Momentum")
exitMomentum = input.float(-9.0, "Exit CMO", minval=-80, maxval=80, step=1, group="Momentum")
atrLength = input.int(19, "ATR Length", minval=2, group="Risk")
maximumAtrLoss = input.float(2.1, "Maximum ATR Loss", minval=0.5, step=0.1, group="Risk")

medianLine = ta.median(close, medianLength)
cmoValue = ta.cmo(close, cmoLength)
atrValue = ta.atr(atrLength)

enterLong = ta.crossover(close, medianLine) and cmoValue > entryMomentum
momentumEnded = close < medianLine or cmoValue < exitMomentum
riskExceeded = strategy.position_size > 0 and close < strategy.position_avg_price - atrValue * maximumAtrLoss

if strategy.position_size == 0 and enterLong
    strategy.entry("Gyroscope Long", strategy.long)
else if strategy.position_size > 0 and (momentumEnded or riskExceeded)
    strategy.close("Gyroscope Long", comment=riskExceeded ? "ATR risk" : "Momentum ended")

plot(medianLine, "Rolling Median", color=color.yellow)
plot(cmoValue, "CMO", color=color.blue, display=display.data_window)

Overview

Gyroscope CMO Median enters long when price crosses above the median while the oscillator is above an entry level. It exits when price drops below the median, the oscillator falls under an exit level, or price falls a set multiple of ATR below the average entry. The median line is drawn on the price chart and the oscillator in the data window.

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

Oscillators & momentum, Trend

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

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
Median Lengthint27medianLength
CMO Lengthint16cmoLength
Entry CMOfloat12.0entryMomentum
Exit CMOfloat-9.0exitMomentum
ATR Lengthint19atrLength
Maximum ATR Lossfloat2.1maximumAtrLoss
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

2 EMA/SMA + RSI Strategy [Alorse] combines three configurable moving averages with a short-period Relative Strength Index filter. It plots fast, slow, and trend moving averages on the price chart. Long entries trigger when the fast moving average is above the

Strategy v4 TrendOscillators & momentum
Updated 2 months ago · None stated GitHub repository of 2 EMA/SMA + RSI Strategy [Alorse]

Acrypto - Weighted Strategy

by AlbertoCuadra
318 stars

This strategy plots on the price chart and opens long or short positions when a weighted score from MACD, Stochastic RSI, RSI, Supertrend and a moving-average crossover exceeds a user-set trigger. Each component has its own weight and candle delay. Entries can

Strategy v5 TrendOscillators & momentum
Updated 3 years ago · Custom licence GitHub repository of Acrypto - Weighted Strategy
285 stars

Mean Reversion Strategy is an overlay strategy that identifies pullbacks using a long-term EMA, RSI, and candlestick patterns. It generates long signals when a bullish engulfing candle forms below the EMA while RSI is oversold, and short signals when a bearish

Strategy v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Strategy
218 stars

This strategy generates trading signals based on a selectable momentum engine, supporting MACD, RSI, Stochastic, or Rate of Change. Entries trigger on signal crosses, zero-line crosses, or threshold crosses, with an optional moving average trend filter. Risk m

Strategy v6 Oscillators & momentumTrend
Updated 3 months ago · None stated GitHub repository of Momentum Strategy Template

255 EMA Strategy

by hasnocool
106 stars

255 EMA Strategy combines an exponential moving average with Average True Range bands and standard MACD crossovers to generate entry signals. Drawn directly on the price chart, it plots the central 255 EMA along with upper and lower volatility envelopes. Trade

Strategy v4 Moving averagesOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of 255 EMA 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