// 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.
Composite score combining MA trend, RSI, and Williams %R
Optional turning requirement for RSI and Williams %R reversals
Smoothed oscillator plot with configurable upper, mid, and lower zone lines
Dynamic background highlight fills during extreme zone breaches
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
MA type
string
EMA
maType
MA length
int
50
maLen
RSI length
int
14
rsiLen
RSI overbought
int
65
rsiOB
RSI oversold
int
35
rsiOS
Williams %R length
int
14
wrLen
W%R overbought
float
-20.0
wrOB
W%R oversold
float
-80.0
wrOS
Require RSI/W%R turn
bool
true
requireTurn
Oscillator smoothing
int
3
oscSmooth
Upper zone
float
66.7
upperZone
Mid zone
float
50.0
midZone
Show all 15 settings
Setting
Type
Default
Variable
Lower zone
float
33.3
lowerZone
Show zones
bool
true
showZones
Background highlight
bool
true
showBg
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.
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
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
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
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
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
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