Strategy · Pine Script v5 · Own pane

Ultimate Oscillator - Eterna MCP

by EternaHybridExchange

This strategy calculates the Ultimate Oscillator in a separate pane from buying pressure and true range over fast, medium, and slow lengths, combined with a four-two-one weighting.

View on GitHub

GitHub stars9on the repository
Pine versionv5runs as is
Lines of code113
Settings7inputs
LicenceMIT
Last update7 months ago12 Mar 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

113 lines of Pine Script v5 from strategies/momentum/ultimate_oscillator.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

ultimate_oscillator.pine
//@version=5
strategy("Ultimate Oscillator - Eterna MCP", 
         shorttitle="UO",
         overlay=false,
         default_qty_type=strategy.percent_of_equity,
         default_qty_value=100,
         initial_capital=1000)

// ============================================
// PARAMETERS
// ============================================
length1 = input.int(7, "Fast Length", minval=1)
length2 = input.int(14, "Medium Length", minval=1)
length3 = input.int(28, "Slow Length", minval=1)
overboughtLevel = input.int(70, "Overbought", minval=50, maxval=100)
oversoldLevel = input.int(30, "Oversold", minval=0, maxval=50)
leverageSize = input.float(5.0, "Leverage", minval=1, maxval=100)
positionSize = input.float(0.01, "Position Size", minval=0.001, maxval=1)

// ============================================
// ULTIMATE OSCILLATOR CALCULATION
// ============================================
// Buying pressure
bp = close - math.min(low, close[1])
// True range
tr = math.max(high, close[1]) - math.min(low, close[1])

// Average calculations for three timeframes
avg1 = ta.sum(bp, length1) / ta.sum(tr, length1)
avg2 = ta.sum(bp, length2) / ta.sum(tr, length2)
avg3 = ta.sum(bp, length3) / ta.sum(tr, length3)

// Ultimate Oscillator formula (weighted average)
uo = 100 * ((4 * avg1) + (2 * avg2) + avg3) / (4 + 2 + 1)

// ============================================
// SIGNAL GENERATION
// ============================================
// Oversold reversal
bullishSignal = ta.crossover(uo, oversoldLevel) and uo < 50

// Overbought reversal
bearishSignal = ta.crossunder(uo, overboughtLevel) and uo > 50

// Divergence detection
pivotLength = 5
priceLow = ta.pivotlow(low, pivotLength, pivotLength)
priceHigh = ta.pivothigh(high, pivotLength, pivotLength)
uoLow = ta.pivotlow(uo, pivotLength, pivotLength)
uoHigh = ta.pivothigh(uo, pivotLength, pivotLength)

var float lastPriceLow = na
var float lastUoLow = na
var float lastPriceHigh = na
var float lastUoHigh = na

if not na(priceLow)
    lastPriceLow := priceLow
    lastUoLow := uoLow

if not na(priceHigh)
    lastPriceHigh := priceHigh
    lastUoHigh := uoHigh

// Bullish divergence
bullishDiv = not na(lastUoLow) and not na(lastPriceLow) and 
             low < lastPriceLow and uo > lastUoLow and uo < oversoldLevel

// Bearish divergence
bearishDiv = not na(lastUoHigh) and not na(lastPriceHigh) and 
             high > lastPriceHigh and uo < lastUoHigh and uo > overboughtLevel

// Combined signals
buySignal = bullishSignal or bullishDiv
sellSignal = bearishSignal or bearishDiv

// ============================================
// STRATEGY LOGIC
// ============================================
if buySignal and strategy.position_size == 0
    strategy.entry("Long", strategy.long)
    alert('{"action":"buy","symbol":"' + syminfo.ticker + '","size":' + str.tostring(positionSize) + ',"leverage":' + str.tostring(leverageSize) + '}', alert.freq_once_per_bar_close)

if sellSignal and strategy.position_size == 0
    strategy.entry("Short", strategy.short)
    alert('{"action":"sell","symbol":"' + syminfo.ticker + '","size":' + str.tostring(positionSize) + ',"leverage":' + str.tostring(leverageSize) + '}', alert.freq_once_per_bar_close)

// Exit on opposite signal
if sellSignal and strategy.position_size > 0
    strategy.close("Long")

if buySignal and strategy.position_size < 0
    strategy.close("Short")

// ============================================
// PLOTTING
// ============================================
plot(uo, "Ultimate Oscillator", color=color.blue, linewidth=2)
hline(overboughtLevel, "Overbought", color=color.red, linestyle=hline.style_dashed)
hline(oversoldLevel, "Oversold", color=color.green, linestyle=hline.style_dashed)
hline(50, "Midline", color=color.gray, linestyle=hline.style_dotted)

// Signal shapes
plotshape(buySignal, "Buy", shape.triangleup, location.bottom, color.green, size=size.normal)
plotshape(sellSignal, "Sell", shape.triangledown, location.top, color.red, size=size.normal)

// Divergence markers
plotshape(bullishDiv, "Bullish Div", shape.diamond, location.bottom, color.lime, size=size.small)
plotshape(bearishDiv, "Bearish Div", shape.diamond, location.top, color.orange, size=size.small)

// Background zones
bgcolor(uo > overboughtLevel ? color.new(color.red, 95) : 
        uo < oversoldLevel ? color.new(color.green, 95) : na)

Overview

Ultimate Oscillator - Eterna MCP enters long when the oscillator crosses above the oversold level while remaining below 50, or when bullish divergence appears, and enters short on the opposite overbought cross or bearish divergence. Entries occur only when flat, and the opposite signal closes the open position. Lengths, thresholds, leverage, and position size are adjustable. There is no stop loss.

Details

Published by

EternaHybridExchange on GitHub

Type

Strategy, Pine Script v5

Draws

Separate pane below the chart

Category

Oscillators & momentum, Divergence

Markets

Crypto

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingautomated-tradingbacktestingbybitcrypto-tradingeternamcppine-scripttrading-strategiestradingview

Settings

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

SettingTypeDefaultVariable
Fast Lengthint7length1
Medium Lengthint14length2
Slow Lengthint28length3
Overboughtint70overboughtLevel
Oversoldint30oversoldLevel
Leveragefloat5.0leverageSize
Position Sizefloat0.01positionSize
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

MACD + Divergences [Alorse] is a momentum strategy that calculates the MACD oscillator and identifies regular and hidden divergences using pivot high and low points. It filters trade signals with dual Exponential Moving Averages (EMA 150 and 600) to ensure tra

Strategy v4 Oscillators & momentumDivergence Repaints
Updated 2 months ago · None stated GitHub repository of MACD + Divergences [Alorse]
11 stars

The Stochastic Divergence Strategy calculates the Stochastic oscillator (%K and %D) to identify regular bullish and bearish divergence patterns against price pivots. It plots the oscillator and divergence lines in a separate indicator pane. Entries trigger on

Strategy v6 Oscillators & momentumDivergence
Updated 5 months ago · Apache-2.0 GitHub repository of Stochastic Divergence Strategy

This strategy calculates regular and hidden divergences across selectable momentum oscillators, including RSI, CCI, and MFI, and plots volatility-based divergence zones. It displays oscillator dynamics in a separate pane while projecting support and resistance

Strategy v6 DivergenceOscillators & momentum
Updated yesterday · MIT GitHub repository of Oscillator Divergence Zones [WavesUnchained] — Strategy

ETH_buy_3commas

by hasnocool
106 stars

This strategy overlays a Cipher B style WaveTrend study on the price chart and is titled for Ethereum buy alerts aimed at 3Commas. It calculates a WaveTrend channel and a short moving average, and can mark buy, sell, gold, and divergence dots. Settings change

Strategy v4 Oscillators & momentumDivergence
Updated 2 years ago · GPL-3.0 GitHub repository of ETH_buy_3commas
24 stars

This overlay strategy combines a Cipher B WaveTrend oscillator with two optional moving averages on the price chart. It exposes WaveTrend channel and average lengths, overbought and oversold levels, buy, sell and gold dots, and regular or hidden divergence mar

Strategy v5 Oscillators & momentumMoving averages
Updated 4 years ago · MPL-2.0 GitHub repository of Cipher B + EMAs Strategy

Divergenced A002

by ruckard
13 stars

Divergenced A002 is a momentum divergence strategy designed to identify entry opportunities using Squeeze Momentum Indicator shifts alongside price action. It enters long when momentum reaches higher lows during lower price lows and enters short on opposite di

Strategy v5 Oscillators & momentumDivergence
Updated 1 year ago · None stated GitHub repository of Divergenced A002

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