Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Rainbow Oscillator [Strategy]

A Pine Script v5 strategy built on CCI or RSI or Stoch (close, 16), Crossunder (sampledMagicSlow, sampledMagicFast) and Crossover (sampledMagicSlow, sampledMagicFast). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 16 settings; defaults include RSI Weight 0.33, CCI Weight 0.33 and Stoch Weight 0.33.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does Rainbow Oscillator [Strategy] repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Rainbow Oscillator [Strategy] do on BTCUSDT 1D with default settings?
Not measured
It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its entry conditions never all held on this data. On ETHUSDT 4h it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
Does Rainbow Oscillator [Strategy] run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 0 before, 27 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does Rainbow Oscillator [Strategy] use a stop loss?
Yes
strategy.exit sets a stop on line 102, 103.
Does Rainbow Oscillator [Strategy] run in Zeal Terminal?
Yes
It compiles in 73 ms and runs 1,000 bars in 159 ms, in the browser.

BTCUSDT · 1D · default settings

  • fast
  • slow
  • Plot
  • Plot
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (16)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctfast$2,000$4,051Equity from $2,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
Net profit
0.00%
$0.00
Buy and hold
+102.5%
same period
Closed trades
0
0 won · 0 lost
Profitable
0.0%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
0.00%
$0.00

One run with the author's default settings, $2,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

  • Note

    Uses an argument v6 removed

    when = on line 98, 99, 100, 101. The upgraded version below moves each call inside an if block.

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Use trend filtertrueboolbuySignal sellSignal
RSI Weight0.33floatmagicFast magicSlow
CCI Weight0.33floatmagicFast magicSlow
Stoch Weight0.33floatmagicFast magicSlow
Ocillograph Fast Period16intmagicFast
Ocillograph Slow Period22intmagicSlow
Oscillograph Samples Period8intsampledMagicFast sampledMagicSlow
Oscillograph Samples Count2intsampledMagicFast sampledMagicSlow
Oscillograph Samples TypeRMAstring · options ["EMA", "SMA", "RMA", "WMA"]sampledMagicFast sampledMagicSlow
Level Period26intlevel1up level2up level3up level4up level1low level2low level3low level4low
Level Offset0intlevel1up level2up level3up level4up level1low level2low level3low level4low
Level Redunant0.5floatlastUpperValue lastLowerValue
Level Smooth Samples2intlevel1up level2up level3up level4up level1low level2low level3low level4low
Level MA typeRMAstring · options ["EMA", "SMA", "RMA", "WMA"]level1up level2up level3up level4up level1low level2low level3low level4low
% Take profit5float · step 0.1long_take_level short_take_level
% Stop Loss2float · step 0.1long_stop_level short_stop_level

What it calculates

  • CCI / RSI / Stochclose, Ocillograph Fast Period (16)magicFast · line 38
  • CCI / RSI / Stochclose, Ocillograph Slow Period (22)magicSlow · line 39
  • CrossundersampledMagicSlow, sampledMagicFastbuySignal · line 87
  • CrossoversampledMagicSlow, sampledMagicFastsellSignal · line 88

Signal flow

How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

lowlowprice datahighhighprice dataclosecloseprice dataw2CCI Weightsetting · 0.33fastPeriodOcillograph Fast Periodsetting · 16w1RSI Weightsetting · 0.33w3Stoch Weightsetting · 0.33slowPeriodOcillograph Slow Periodsetting · 22oscillographSamplesCountOscillograph Samples Co…setting · 2oscillographMATypeOscillograph Samples Ty…setting · RMAoscillographSamplePeriodOscillograph Samples Pe…setting · 8redunantLevel Redunantsetting · 0.5levelSampleCountLevel Smooth Samplessetting · 2levelTypeLevel MA typesetting · RMAlevelPeriodLevel Periodsetting · 26levelOffsetLevel Offsetsetting · 0takeProfit% Take profitsetting · 5stopLoss% Stop Losssetting · 2magicFastCCI / RSI / Stoch→ magicFastmagicSlowCCI / RSI / Stoch→ magicSlowbuySignalCrossunder→ buySignalsellSignalCrossover→ sellSignalmamavaluesampledMagicFastsampledMagicFastvaluesampledMagicSlowsampledMagicSlowvaluelastUpperValuelastUpperValuevaluelastLowerValuelastLowerValuevaluelevel1up, level2up, level3up, level4uplevel1up · level2up +24 valueslevel1low, level2low, level3low, level4lowlevel1low · level2low +24 valuesdiffdiffvaluelong_take_level, short_take_levellong_take_level · short…2 valueslong_stop_level, short_stop_levellong_stop_level · short…2 valuesupTrendupTrendconditiontransparent, overbough4Color, overbough3Color, overbough2Color, oversold4Color, oversold3Color, oversold2Color, fastColor, slowColorColourtransparent · overbough4Color…close:LongClose Longstrategy.closeclose:ShortClose Shortstrategy.closeentry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entryexit:Take Profit/ Stop Lossexit Take Profit/ Stop …strategy.exitplot:68Upper1plotplot:69Upper2plotplot:70Upper3plotplot:71Upper4plotplot:74fastplotplot:75slowplotplot:76Lower1plotplot:77Lower2plotplot:78Lower3plotplot:79Lower4plotfill:80Fillfill × 7fill:81Fillfill × 7fill:82Fillfill × 7fill:83Fillfill × 7fill:84Fillfill × 7fill:85Fillfill × 7fill:90Fillfill × 7plot:91plotplotplot:92plotplot

Order rules

OrderFires whenBy defaultLine
Close LongsellSignalOn98
Close ShortbuySignalOn99
Open Long longbuySignalOn100
Open Short shortsellSignalOn101
Exit Take Profit/ Stop Loss stop and limitevery barOn102
Exit Take Profit/ Stop Loss stop and limitevery barOn103

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

No

No repainting patterns in the source.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
  • ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D0.0%+102.5%00%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−7.7%+8.4%50%0.007.7%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−2.0%+16.7%825%0.262.5%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.2%+21.5%1527%0.770.4%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−1.5%+148.3%1625%0.795.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.4%+17.1%1242%0.892.3%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
Rainbow Oscillator [Strategy] this page—v5 strategy0.0%00.0%
CCI Level Zone by Naruephatcci rsi stochv5 strategyNo trades on this market
Suchit RSI CCI by SuchitRajucci rsiv4 strategy+11.4%6854.7%
3RSI 3CCI BB 5orders DCA strategy+ by rrolik66rsi cciv5 strategyNo trades on this market
Bitcoin Scalping Strategy (Sampled with- PMARP+MADRID MA RIBBON) by CheatCode1rsi stochv5 strategy−3.0%7245.4%
Momentum Explosion 2CCI RSI by capamcci rsiv4 strategy+24.1%642.3%

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • 4 strategy calls use the when = argument (line 98, 99, 100, 101). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

Same 5 trades and the same P&L on ETHUSDT 4h, 1,000 bars, in Zeal Terminal's engine.

  • Line 98: when = sellSignal → if block
  • Line 99: when = buySignal → if block
  • Line 100: when = buySignal → if block
  • Line 101: when = sellSignal → if block
⋯short_stop_level = strategy.position_avg_price * (1 + stopLoss)-strategy.close(id="Long", when=sellSignal, comment = "Exit")+if sellSignal+    strategy.close(id="Long", comment = "Exit")-strategy.close(id="Short", when=buySignal, comment = "Exit")+if buySignal+    strategy.close(id="Short", comment = "Exit")-strategy.entry("Long", strategy.long, when=buySignal)+if buySignal+    strategy.entry("Long", strategy.long)-strategy.entry("Short", strategy.short, when=sellSignal)+if sellSignal+    strategy.entry("Short", strategy.short)strategy.exit("Take Profit/ Stop Loss","Long", stop=long_stop_level, limit=long_take_level)⋯

Does it run in Pine Script v6?

No

The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 0 before, 27 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © businessduck-//@version=5+//@version=6strategy("Rainbow Oscillator [Strategy]", overlay=false, margin_long=100, margin_short=100, initial_capital = 2000)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 73 msWith a workaround 1,000 bars in 159 msNot measured
PineTSNot testedNot testedNot measured

The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © businessduck//@version=5strategy("Rainbow Oscillator [Strategy]", overlay=false, margin_long=100, margin_short=100, initial_capital = 2000)bool trendFilter = input.bool(true, 'Use trend filter')float w1 = input.float(0.33, 'RSI Weight', 0, 1, 0.01)float w2 = input.float(0.33, 'CCI Weight', 0, 1, 0.01)float w3 = input.float(0.33, 'Stoch Weight', 0, 1, 0.01)int fastPeriod = input.int(16, 'Ocillograph Fast Period', 4, 60, 1)int slowPeriod = input.int(22, 'Ocillograph Slow Period', 4, 60, 1)int oscillographSamplePeriod = input.int(8, 'Oscillograph Samples Period', 1, 30, 1)int oscillographSamplesCount = input.int(2, 'Oscillograph Samples Count', 0, 4, 1)string oscillographMAType = input.string("RMA", "Oscillograph Samples Type", options = ["EMA", "SMA", "RMA", "WMA"])int levelPeriod = input.int(26, 'Level Period', 2, 100)int levelOffset = input.int(0, 'Level Offset', 0, 200, 10)float redunant = input.float(0.5, 'Level Redunant', 0, 1, 0.01)int levelSampleCount = input.int(2, 'Level Smooth Samples', 0, 4, 1)string levelType = input.string("RMA", "Level MA type", options = ["EMA", "SMA", "RMA", "WMA"])perc(current, prev) => ((current - prev) / prev) * 100smooth(value, type, period) =>    float ma = switch type        "EMA" => ta.ema(value, period)        "SMA" => ta.sma(value, period)        "RMA" => ta.rma(value, period)        "WMA" => ta.wma(value, period)        =>            runtime.error("No matching MA type found.")            float(na)getSample(value, samples, type, period) =>    float ma = switch samples        0 => value        1 => smooth(value, type, period)        2 => smooth(smooth(value, type, period), type, period)        3 => smooth(smooth(smooth(value, type, period), type, period), type, period)        4 => smooth(smooth(smooth(smooth(value, type, period), type, period), type, period), type, period)float takeProfit = input.float(5, "% Take profit", 0.8, 100, step = 0.1)  / 100float stopLoss = input.float(2, "% Stop Loss", 0.8, 100, step = 0.1) / 100float magicFast = w2 * ta.cci(close, fastPeriod) + w1 * (ta.rsi(close, fastPeriod) - 50) + w3 * (ta.stoch(close, high, low, fastPeriod) - 50)float magicSlow = w2 * ta.cci(close, slowPeriod) + w1 * (ta.rsi(close, slowPeriod) - 50) + w3 * (ta.stoch(close, high, low, slowPeriod) - 50)float sampledMagicFast = getSample(magicFast, oscillographSamplesCount, oscillographMAType, oscillographSamplePeriod)float sampledMagicSlow = getSample(magicSlow, oscillographSamplesCount, oscillographMAType, oscillographSamplePeriod)float lastUpperValue = 0float lastLowerValue = 0if (magicFast > 0)    lastUpperValue := math.max(magicFast, magicFast[1])else     lastUpperValue := math.max(0, lastUpperValue[1]) * redunant    if (magicFast <= 0)    lastLowerValue := math.min(magicFast, magicFast[1])else    lastLowerValue := math.min(0, lastLowerValue[1]) * redunantfloat level1up = getSample( (magicFast >= 0 ? magicFast : lastUpperValue) / 4, levelSampleCount, levelType, levelPeriod) + levelOffsetfloat level2up = getSample( (magicFast >= 0 ? magicFast : lastUpperValue) / 2, levelSampleCount, levelType, levelPeriod) + levelOffsetfloat level3up = getSample( magicFast >= 0 ? magicFast : lastUpperValue, levelSampleCount, levelType, levelPeriod) + levelOffsetfloat level4up = getSample( (magicFast >= 0 ? magicFast : lastUpperValue) * 2, levelSampleCount, levelType, levelPeriod) + levelOffsetfloat level1low = getSample( (magicFast <= 0 ? magicFast : lastLowerValue) / 4, levelSampleCount, levelType, levelPeriod) - levelOffsetfloat level2low = getSample( (magicFast <= 0 ? magicFast : lastLowerValue) / 2, levelSampleCount, levelType, levelPeriod) - levelOffsetfloat level3low = getSample( magicFast <= 0 ? magicFast : lastLowerValue, levelSampleCount, levelType, levelPeriod) - levelOffsetfloat level4low = getSample( (magicFast <= 0 ? magicFast : lastLowerValue) * 2, levelSampleCount, levelType, levelPeriod) - levelOffsetvar transparent = color.new(color.white, 100)var overbough4Color = color.new(color.red, 75)var overbough3Color = color.new(color.orange, 75)var overbough2Color = color.new(color.yellow, 75)var oversold4Color = color.new(color.teal, 75)var oversold3Color = color.new(color.blue, 75)var oversold2Color = color.new(color.aqua, 85)upperPlotId1 = plot(level1up, 'Upper1', transparent)upperPlotId2 = plot(level2up, 'Upper2', transparent)upperPlotId3 = plot(level3up, 'Upper3', transparent)upperPlotId4 = plot(level4up, 'Upper4', transparent)fastColor = color.new(color.teal, 60)slowColor = color.new(color.red, 60)fastPlotId = plot(sampledMagicFast, 'fast', color = fastColor)slowPlotId = plot(sampledMagicSlow, 'slow', color = slowColor)lowerPlotId1 = plot(level1low, 'Lower1', transparent)lowerPlotId2 = plot(level2low, 'Lower2', transparent)lowerPlotId3 = plot(level3low, 'Lower3', transparent)lowerPlotId4 = plot(level4low, 'Lower4', transparent)fill(upperPlotId4, upperPlotId3, overbough4Color)fill(upperPlotId3, upperPlotId2, overbough3Color)fill(upperPlotId2, upperPlotId1, overbough2Color)fill(lowerPlotId4, lowerPlotId3, oversold4Color)fill(lowerPlotId3, lowerPlotId2, oversold3Color)fill(lowerPlotId2, lowerPlotId1, oversold2Color)upTrend = sampledMagicFast > sampledMagicFast[1]buySignal = ((upTrend or not trendFilter) and ta.crossunder(sampledMagicSlow, sampledMagicFast)) ? sampledMagicSlow : nasellSignal = ((not upTrend or not trendFilter) and ta.crossover(sampledMagicSlow, sampledMagicFast)) ? sampledMagicSlow : nadiff = sampledMagicSlow - sampledMagicFastfill(fastPlotId, slowPlotId, upTrend ? fastColor : slowColor)plot(buySignal, color = color.aqua, style = plot.style_circles, linewidth = 4)plot(sellSignal, color = color.red, style = plot.style_circles, linewidth = 4)// longCondition = upTrend != upTrend[1] and upTrendlong_take_level = strategy.position_avg_price * (1 + takeProfit)long_stop_level = strategy.position_avg_price * (1 - stopLoss)short_take_level = strategy.position_avg_price * (1 - takeProfit)short_stop_level = strategy.position_avg_price * (1 + stopLoss)strategy.close(id="Long", when=sellSignal, comment = "Exit")strategy.close(id="Short", when=buySignal, comment = "Exit")strategy.entry("Long", strategy.long, when=buySignal)strategy.entry("Short", strategy.short, when=sellSignal)strategy.exit("Take Profit/ Stop Loss","Long", stop=long_stop_level, limit=long_take_level)strategy.exit("Take Profit/ Stop Loss","Short", stop=short_stop_level, limit=short_take_level)// plot(long_stop_level, color=color.red, overlay=true)// plot(long_take_level, color=color.green)