Indicator · Pine Script v5 · Own pane

Omega Ratio

by Teerth1· code credited to balipour

Draws Omega ratio curves for the chart symbol and a second comparison symbol across a range of minimum acceptable return levels.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code121
Settings6inputs
LicenceNone statedfile: MPL-2.0
Last update6 months ago10 Apr 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 indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

121 lines of Pine Script v5 from deal-api/src/main/resources/PineScript/Omega Ratio.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Omega Ratio.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © balipour

//@version=5
var maxLines = 500
indicator('️Omega Ratio', 'Ω Ratio', max_lines_count=maxLines, max_bars_back=5000)

bgcolor(#000000c0)
group_1 = 'Color Settings'
t = ticker.new(syminfo.prefix, syminfo.ticker)
sec1in = input.symbol('SPX500USD', 'Low-Risk Security', tooltip='A low risk security used to generate Minimal Acceptable Return (MAR) levels for Omega calculations', confirm=true)
period = input.int(252, 'Omega Period', minval=1)
lineCount = input.int(50, 'Increments', tooltip='Number of MARs the calculation is carried on', minval=1, maxval=maxLines, step=5)
sec2in = input.symbol('INDEX:BTCUSD', '  Other Symbol', tooltip='A comparison security for preformance evaluation')
c1 = input.color(#FF22FFff, 'On Chart Symbol', inline='On Chart Symbol', group=group_1)
c2 = input.color(#0080FFff, 'Other Symbol', inline='On Chart Symbol', group=group_1)


var maxMinusOne = lineCount - 1
var periodMinusOne = period - 1
var OTHER_SYMBOL = sec2in
var LOW_RISK_SECURITY = sec1in
var TICKER_ID_SYMBOL = syminfo.prefix + ':' + syminfo.ticker
var TICKER_ID_OTHER = sec2in

lrs = request.security(LOW_RISK_SECURITY, timeframe.period, close)
otherSym = request.security(OTHER_SYMBOL, timeframe.period, close)

lastLRS = nz(lrs[1], lrs)
lowRiskReturn = (lrs - lastLRS) / lastLRS * 100.0
mar = ta.stdev(lowRiskReturn, period) * 3.0 * math.sqrt(period / (period - 1))

src = close
src2 = otherSym
r1 = math.log(src / nz(src[1], src)) * 100
r2 = math.log(src2 / nz(src2[1], src2)) * 100

var aOmega = array.new_float(lineCount + 1)
var bOmega = array.new_float(lineCount + 1)
var aLines = array.new_line(lineCount)
var bLines = array.new_line(lineCount)
var Mari = array.new_float(lineCount + 1)
var rvalue = array.new_label(lineCount)
var linesAreNA = true

Omg(array, return_1) =>
    if barstate.islast
        for i = 0 to lineCount by 1
            Ps = 0.0
            Ns = 0.0
            for j = 0 to periodMinusOne by 1
                ex = return_1[j] - mar[j] * i / lineCount
                Ps += (ex > 0 ? ex : 0.0)
                Ns -= (ex < 0 ? ex : 0.0)
                Ns
            array.set(array, i, Ps / Ns)

Omg(aOmega, r1)
Omg(bOmega, r2)

for i = 0 to maxMinusOne by 1
    array.set(Mari, i, mar * i / lineCount)

drawLine(X1, Y1, X2, Y2, LineStyle, Color, LineWidth) =>
    var line Line = na
    if barstate.islast
        if na(Line)
            Line := line.new(X1, Y1, X2, Y2, xloc.bar_index, style=LineStyle, color=Color, width=LineWidth)
            Line
        else
            line.set_xy1(Line, X1, Y1)
            line.set_xy2(Line, X2, Y2)
            Line

drawlabel(X, Y, T, labelstyle, TColor, labelsize) =>
    var label _label = na
    if barstate.islast
        if na(_label)
            _label := label.new(X, Y, T, color=color.new(color.black, 99), textcolor=TColor, style=labelstyle, size=labelsize)
            _label
        else
            label.set_xy(_label, X, Y)
            _label


if barstate.islast
    if linesAreNA
        for i = 0 to maxMinusOne by 1
            barIndexMinusI = bar_index - maxMinusOne + i
            array.set(aLines, i, line.new(barIndexMinusI - 1, array.get(aOmega, i), barIndexMinusI, array.get(aOmega, i + 1), color=c1, width=2))
            array.set(bLines, i, line.new(barIndexMinusI - 1, array.get(bOmega, i), barIndexMinusI, array.get(bOmega, i + 1), color=c2, width=2))
        for j = 0 to maxMinusOne by 3
            barIndexMinusj = bar_index - maxMinusOne + j - 1
            array.set(rvalue, j, label.new(barIndexMinusj, -0.005, text='⃓\n' + str.tostring(math.round(array.get(Mari, j), 3)), color=#00000000, textcolor=#C0C0C0ff, style=label.style_label_center, size=size.small))
        linesAreNA := false
        linesAreNA
    else
        for i = 0 to maxMinusOne by 1
            barIndexMinusI = bar_index - maxMinusOne + i
            lineID1 = array.get(aLines, i)
            lineID2 = array.get(bLines, i)
            line.set_xy1(lineID1, barIndexMinusI - 1, array.get(aOmega, i))
            line.set_xy2(lineID1, barIndexMinusI, array.get(aOmega, i + 1))
            line.set_xy1(lineID2, barIndexMinusI - 1, array.get(bOmega, i))
            line.set_xy2(lineID2, barIndexMinusI, array.get(bOmega, i + 1))
        for j = 0 to maxMinusOne by 3
            label1 = array.get(rvalue, j)
            barIndexMinusj = bar_index - maxMinusOne + j - 1
            label.set_x(label1, barIndexMinusj)
        na
    maxh = math.max(array.get(aOmega, 0), array.get(bOmega, 0))
    barIndexMinusLineCount = bar_index - lineCount
    drawLine(barIndexMinusLineCount, 0.0, bar_index, 0.0, line.style_arrow_right, #DDDDDDff, 1)
    drawLine(barIndexMinusLineCount, 0.0, barIndexMinusLineCount, maxh * 1.1, line.style_arrow_right, #DDDDDDff, 1)
    drawlabel(bar_index, 0, '𝒓 %', label.style_label_left, #FFFFFFff, size.large)
    drawlabel(barIndexMinusLineCount, maxh * 1.1, 'Ω', label.style_label_down, #FFFFFFff, size.large)
    drawlabel(barIndexMinusLineCount, array.get(aOmega, 1), TICKER_ID_SYMBOL, label.style_label_up, c1, size.normal)
    drawlabel(barIndexMinusLineCount, array.get(bOmega, 1), TICKER_ID_OTHER, label.style_label_right, c2, size.normal)

hline(1.0, color=#C0C000ff, linestyle=hline.style_dotted)
hline(-0.1, color=#00000000)

Overview

The levels are derived from the volatility of a reference security, and inputs set the calculation period, the number of increments and the two line colours. The curves are drawn with lines on the last bar only, in a separate pane, and the indicator provides no entry or exit signals.

Details

Published by

Teerth1 on GitHub

Code credit

balipour, as written in the script's header

Draws

Separate pane below the chart

Markets

Any symbol

Timeframes

H4 and above

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

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

SettingTypeDefaultVariable
Low-Risk SecuritysymbolSPX500USDsec1in
Omega Periodint252period
Incrementsint50lineCount
  Other SymbolsymbolINDEX:BTCUSDsec2in
On Chart Symbolcolor#FF22FFffc1
Other Symbolcolor#0080FFffc2
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

Asymmetrical RSI

by everget
947 stars

Asymmetrical RSI is an indicator that computes a custom relative strength index from the rate of change of a user-selected source. It plots the resulting ARSI line in a separate pane with color coding that turns green above the overbought level and red below t

Indicator v4 Oscillators & momentum
Updated 12 days ago · GPL-3.0 GitHub repository of Asymmetrical RSI

This indicator calculates momentum setups based on the Relative Strength Index (RSI) and plots in a separate pane. It offers multiple scanning modes such as Continuous Break, Continuous Retracement, Flip Break, Flip Retracement, and both regular and hidden div

Indicator v6 Oscillators & momentumDivergence Repaints
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - RSI Directional Momentum Indicator
550 stars

Range Volume Change compares volume inside a chosen session window with the same window on the previous day and plots that change as a percentage. It accumulates volume during the window and, when enabled, volume outside it, drawing growing columns in a separa

Indicator v5 VolumeSessions & time Repaints
Updated 10 months ago · None stated GitHub repository of Range Volume Change

Beep Boop

by magic8bot
409 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop

Mojito v3 Strategy

by namuan
318 stars

The Mojito v3 Strategy indicator evaluates volatility term structure by calculating the ratio between front-month and second-month VIX futures contracts. It smooths this ratio using a configurable median filter and compares the result against user-defined uppe

Indicator v5 Volatility & bands
Updated 2 months ago · MIT GitHub repository of Mojito v3 Strategy

More indicators

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers