Indicator · Pine Script v6 · Own pane

C41 Oscillator

by damianpitt· code credited to Capital41 | MIT License

The C41 Oscillator is a separate pane composite momentum indicator designed to companion the C41 Core Strategy.

View on GitHub

GitHub stars6on the repository
Pine versionv6current
Lines of code102
Settings15inputs
LicenceMIT
Last update8 weeks ago31 Aug 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

102 lines of Pine Script v6 from Capital41_Core Strategy/Capital41_Core_Strategy_Oscillator.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

Capital41_Core_Strategy_Oscillator.pine
// Copyright (c) 2026 Capital41 | MIT License
// C41 OSCILLATOR (Companion)

// What it does:
// - Plots a 0-100 C41 oscillator from the same three metrics used in
//   C41 Core Strategy (MA trend, RSI, Williams %R).
// - Designed as a separate panel for fast setup confirmation.
//
// TradingView setup:
// 1) Open TradingView -> Pine Editor.
// 2) Paste this script, Save, and Add to chart.
// 3) Use 30m on BTC or US stocks.
// 4) Keep inputs synced with C41 Core Strategy.

// Usage guide (30m):
// - Higher values = stronger bullish alignment.
// - Lower values = stronger bearish alignment.
// - Use with C41 strategy entries/exits for cleaner timing.



//@version=6
indicator("C41 Oscillator", overlay = false)

// Inputs (sync with C41 Core Strategy)
maType      = input.string("EMA", "MA type", options = ["EMA", "SMA"])
maLen       = input.int(50, "MA length", minval = 5)

rsiLen      = input.int(14, "RSI length", minval = 2)
rsiOB       = input.int(65, "RSI overbought", minval = 50, maxval = 90)
rsiOS       = input.int(35, "RSI oversold", minval = 10, maxval = 50)

wrLen       = input.int(14, "Williams %R length", minval = 2)
wrOB        = input.float(-20.0, "W%R overbought")
wrOS        = input.float(-80.0, "W%R oversold")

requireTurn = input.bool(true, "Require RSI/W%R turn")

oscSmooth   = input.int(3, "Oscillator smoothing", minval = 1, maxval = 20)
upperZone   = input.float(66.7, "Upper zone", minval = 50.0, maxval = 100.0, step = 0.1)
midZone     = input.float(50.0, "Mid zone", minval = 0.0, maxval = 100.0, step = 0.1)
lowerZone   = input.float(33.3, "Lower zone", minval = 0.0, maxval = 50.0, step = 0.1)

showZones   = input.bool(true, "Show zones")
showBg      = input.bool(true, "Background highlight")

colorBull = color.new(color.lime, 0)
colorBear = color.new(color.red, 0)


// Shared helper
wr_manual(_high, _low, _close, _len) =>
    hh = ta.highest(_high, _len)
    ll = ta.lowest(_low, _len)
    rng = hh - ll
    rng == 0 ? -50.0 : (hh - _close) / rng * -100


// Core metrics (same as C41 strategy)
ma = maType == "EMA" ? ta.ema(close, maLen) : ta.sma(close, maLen)
trendLong = close > ma
trendShort = close < ma

rsi = ta.rsi(close, rsiLen)
rsiLongTurn = rsi[1] < rsiOS and rsi > rsi[1]
rsiShortTurn = rsi[1] > rsiOB and rsi < rsi[1]
rsiLong = requireTurn ? rsiLongTurn : rsi < rsiOS
rsiShort = requireTurn ? rsiShortTurn : rsi > rsiOB

wr = wr_manual(high, low, close, wrLen)
wrLongTurn = wr[1] < wrOS and wr > wr[1]
wrShortTurn = wr[1] > wrOB and wr < wr[1]
wrLong = requireTurn ? wrLongTurn : wr < wrOS
wrShort = requireTurn ? wrShortTurn : wr > wrOB


// C41 Oscillator (0-100) from three metrics
scoreLong = (trendLong ? 1 : 0) + (rsiLong ? 1 : 0) + (wrLong ? 1 : 0)
scoreShort = (trendShort ? 1 : 0) + (rsiShort ? 1 : 0) + (wrShort ? 1 : 0)

c41Raw = scoreLong - scoreShort
c41 = (c41Raw + 3.0) * (100.0 / 6.0)
c41Sm = ta.sma(c41, oscSmooth)

oscColor = c41Raw > 0 ? colorBull : c41Raw < 0 ? colorBear : color.new(color.gray, 0)
plot(c41Sm, title = "C41 Oscillator", color = oscColor, linewidth = 2)

plot(showZones ? upperZone : na, title = "Upper", color = color.new(color.gray, 70))
plot(showZones ? midZone : na, title = "Mid", color = color.new(color.gray, 80))
plot(showZones ? lowerZone : na, title = "Lower", color = color.new(color.gray, 70))

bgcolor(showBg ? (c41Sm >= upperZone ? color.new(colorBull, 90) : c41Sm <= lowerZone ? color.new(colorBear, 90) : na) : na)

longSetup = trendLong and rsiLong and wrLong and barstate.isconfirmed
shortSetup = trendShort and rsiShort and wrShort and barstate.isconfirmed
bullCross = ta.crossover(c41Sm, upperZone)
bearCross = ta.crossunder(c41Sm, lowerZone)

alertcondition(longSetup, title = "C41 Osc Long Setup", message = "C41 Oscillator: long setup on {{ticker}} ({{interval}})")
alertcondition(shortSetup, title = "C41 Osc Short Setup", message = "C41 Oscillator: short setup on {{ticker}} ({{interval}})")
alertcondition(bullCross, title = "C41 Osc Bull Cross", message = "C41 Oscillator: crossed above upper zone on {{ticker}} ({{interval}})")
alertcondition(bearCross, title = "C41 Osc Bear Cross", message = "C41 Oscillator: crossed below lower zone on {{ticker}} ({{interval}})")

Overview

C41 Oscillator combines a moving average trend filter with RSI and Williams %R overbought or oversold reversal conditions into a normalized 0 to 100 score. The resulting line is smoothed using a simple moving average and colored to indicate bullish or bearish alignment. User settings allow customisation of the moving average type and length, oscillator periods, threshold zones, optional turning requirements, and background highlight fills.

Details

Published by

damianpitt on GitHub

Code credit

Capital41 | MIT License, as written in the script's header

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum, Trend, Moving averages

Markets

Crypto, Stocks

Timeframes

M15-H1, 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.

Topics

cryptoindicatorsmarket-structureorder-blockspinescriptsmart-moneytechnical-analysistechnical-analysis-indicatorstradingtradingview

Settings

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

SettingTypeDefaultVariable
MA typestringEMAmaType
MA lengthint50maLen
RSI lengthint14rsiLen
RSI overboughtint65rsiOB
RSI oversoldint35rsiOS
Williams %R lengthint14wrLen
W%R overboughtfloat-20.0wrOB
W%R oversoldfloat-80.0wrOS
Require RSI/W%R turnbooltruerequireTurn
Oscillator smoothingint3oscSmooth
Upper zonefloat66.7upperZone
Mid zonefloat50.0midZone
Show all 15 settings
SettingTypeDefaultVariable
Lower zonefloat33.3lowerZone
Show zonesbooltrueshowZones
Background highlightbooltrueshowBg
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

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
218 stars

Multi-Timeframe Analysis Suite calculates trend direction and momentum conditions across five user-selected timeframes using moving averages, RSI, and Stochastic oscillators. It evaluates moving average slope and oscillator levels to compute trend alignment, m

Indicator v6 Screeners & dashboardsTrend
Updated 3 months ago · None stated GitHub repository of Multi-Timeframe Analysis Suite

KamaFama

by Mastaaa1987
141 stars

KamaFama is an indicator that translates a Freqtrade trading strategy into Pine Script for visualization. It combines Kaufman Adaptive Moving Average (KAMA), MAMA/FAMA calculations derived via Hilbert Transform, Williams %R, and correlation trend filters to ev

Indicator v6 Moving averagesOscillators & momentum
Updated 6 weeks ago · MIT GitHub repository of KamaFama

MultiIndicator

by capissimo
114 stars

MultiIndicator combines multiple technical indicators into a single separate pane to save chart space. It calculates and displays market regime detection based on ordinary least squares regression, a Holt exponential smoothing crossover, normalized RSI, ADX, a

Indicator v4 Oscillators & momentumTrend
Updated 1 year ago · None stated GitHub repository of MultiIndicator

Elder Impulse System

by mihakralj
99 stars

Elder Impulse System plots a column series in a separate pane. It compares a 13-period exponential moving average with its previous value and a MACD histogram with its previous value. A rising EMA and rising histogram print 1, a falling EMA and falling histogr

Indicator v5 TrendOscillators & momentum
Updated 4 weeks ago · Apache-2.0 GitHub repository of Elder Impulse System
47 stars

This indicator calculates the Williams Gator Oscillator derived from Bill Williams Alligator lines and plots dual histograms in a separate pane. The upper histogram displays the absolute difference between the Jaw and Teeth moving averages, while the lower his

Indicator v6 Oscillators & momentumMoving averages
Updated 8 months ago · MIT GitHub repository of Williams Gator Oscillator

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers