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.
//@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.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Fast Length
int
7
length1
Medium Length
int
14
length2
Slow Length
int
28
length3
Overbought
int
70
overboughtLevel
Oversold
int
30
oversoldLevel
Leverage
float
5.0
leverageSize
Position Size
float
0.01
positionSize
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.
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
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
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
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
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
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