Indicator · Pine Script v4 · Own pane

Sirius Wavetrend

by jerryinyang· code credited to Jerry

Sirius Wavetrend is an oscillator-style indicator that requests higher-timeframe MACD and Wave Trend values and compares them with optional RSI or Stochastic filters.

View on GitHub

GitHub stars5on the repository
Pine versionv4older, still runs
Lines of code185
Settings29inputs
LicenceNone statedfile: MPL-2.0
Last update2 years ago12 May 2024

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

185 lines of Pine Script v4 from Incomplete/Sirius System.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Sirius System.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Jerry

//@version=4
study("Sirius Wavetrend", overlay=1)

//*************** SIRIUS SYSTEM ***************//

//GENERAL SETTINGS
useGenObOs = input(true, "Use General Overbought/Oversold?", group="General Settings")
genOb = input(70, "General Overbought Level", group="General Settings")
genOs = input(30, "General Oversold Level", group="General Settings")


firstInd = input("MACD", "First Indicator", options=["MACD", "Wave Trend"])
scndInd = input("RSI", "Sirius Second Indicator", options = ["RSI", "Stochastic", "Any", "Both"], group="General Settings")
incAltMacd = input(false, "Include Alternative MACD Rule?")

//***** INDICATORS *****//

// HTF MACD
// {

// INPUTS
//{
macdRes     = input("120", "HTF MACD TimeFrame", input.resolution, group="HTF MACD")
macdSrc = input(close, "MACD Source", input.source, group="HTF MACD")
macdflen = input(12, "MACD Fast Length", group="HTF MACD")
macdslen = input(26, "MACD Slow Length", group="HTF MACD")
siglen = input(9, "MACD Signal Line", group="HTF MACD")
macdMeth = input("Calculate", "MACD Calculation Method", options=["Calculate", "HTF Import"])
//}

// FUNCTIONS
//{
htf_macd() =>
    htfFastMa = sma(macdSrc, macdflen)
    htfSlowMa = sma(macdSrc, macdslen)
    htfMacd    = htfFastMa - htfSlowMa
    htfSignal  = sma(htfMacd, siglen)
    htfHist    = htfMacd - htfSignal
    clr = (htfHist>=0 ? (htfHist[1] < htfHist ? #26A69A : #B2DFDB) : (htfHist[1] < htfHist ? #FFCDD2 : #EF5350) )
    
    [htfMacd, htfSignal, htfHist, clr]
//}

// CALCULATIONS
//{

[calcMacd, calcSignal, calcHist, calcHistcolor] = security(syminfo.tickerid, macdRes, htf_macd(), barmerge.gaps_off, barmerge.lookahead_off)
[impMacd, impSignal, impHist] = security(syminfo.tickerid, macdRes, macd(macdSrc, macdflen, macdslen, siglen), barmerge.gaps_off, barmerge.lookahead_off)
impHistColor = impHist >= 0 ? ( impHist[1] < impHist ? #26A69A : #B2DFDB ) : ( impHist[1] < impHist ? #FFCDD2 : #EF5350 ) 


htfMacd = macdMeth == "Calculate" ? calcMacd : impMacd
htfSignal = macdMeth == "Calculate" ? calcSignal : impSignal
htfHist = macdMeth == "Calculate" ? calcHist : impHist
mcolor = macdMeth == "Calculate" ? calcHistcolor : impHistColor


//}

// SIGNALS 
//{
htfMacdLong = mcolor == #FFCDD2 and htfMacd < 0
htfMacdShort = mcolor == #B2DFDB and htfMacd > 0 

altHtfMacdLong = mcolor == #26A69A and htfMacd < 0
altHtfMacdShort = mcolor == #EF5350 and htfMacd > 0
//}

//}
// SIGNAL ==> htfMacdLong, htfMacdShort, altHtfMacdLong, altHtfMacdShort

//WAVE TREND
// {

wtRes = input("120", "Wave Trend Timeframe", input.resolution, group="WAVE TREND")
wtChannelLen = input(10, "Channel Length", inline="wt1", group="WAVE TREND")
wtAvgLen = input(21, "Average Length", inline="wt1", group="WAVE TREND")
wtOb = input(50, "WT Overbought", group="WAVE TREND", inline="wtObOs")
wtOs = input(-50, "WT Oversold", group="WAVE TREND", inline="wtObOs")
wtUseObOs = input(true, "Use Wave Trend Overbought/Oversold Levels", group="WAVE TREND")
 
wtSrc = security(syminfo.tickerid, wtRes, hlc3, barmerge.gaps_off, barmerge.lookahead_off) 
wtEsa = security(syminfo.tickerid, wtRes, ema(wtSrc, wtChannelLen), barmerge.gaps_off, barmerge.lookahead_off)
d = security(syminfo.tickerid, wtRes, ema(abs(wtSrc - wtEsa), wtChannelLen), barmerge.gaps_off, barmerge.lookahead_off)
ci = (wtSrc - wtEsa) / (0.015 * d)
tci = ema(ci, wtAvgLen)
 
wtLine = tci
wtSignal = sma(wtLine,4)
wtHist = wtLine - wtSignal

wtHistColor = wtHist >= 0 ? ( wtHist[1] < wtHist ? #26A69A : #B2DFDB ) : ( wtHist[1] < wtHist ? #FFCDD2 : #EF5350 ) 

isWtOb = wtUseObOs ? wtLine >= wtOb : wtLine > 0
isWtOs = wtUseObOs ? wtLine <= wtOs : wtLine < 0

wtLong = wtHistColor == #FFCDD2 and isWtOs
wtShort = wtHistColor == #B2DFDB and isWtOb


//}
//SIGNALS ==> wtLong, wtShort

//Alternative signal for Wave trend is if HTF Wavetrend has a bullish configuration (wtLine > wtSignal) or bearish

//HTF RSI
// {

//INPUTS 
// {
rsiRes = input("60", "RSI Timeframe", input.resolution, group="RSI")
rsiSrc = input(close, "RSI Source", input.source, group="RSI")
rsiLen = input(14, "RSI Length", group="RSI")
rsiOb  = input(60, "Overbought", group="RSI", inline ="rsiObOs")
rsiOs  = input(40, "Oversold", group="RSI", inline ="rsiObOs")
// }

//CALCULATION
// {
rsi = security(syminfo.tickerid, rsiRes, rsi(rsiSrc, rsiLen), barmerge.gaps_off, barmerge.lookahead_off)

isRsiOb = useGenObOs ? rsi >= genOb : rsi >= rsiOb
isRsiOs = useGenObOs ? rsi <= genOs : rsi <= rsiOs
// }

//}
// SIGNAL ==> isRsiOb, isRsiOs

// HTF STOCHASTIC
// {

stRes = input("60", "Stochastic Timeframe", input.resolution, group="STOCHASTIC")
stLen = input(10, title="%K Length", minval=1, group="STOCHASTIC")
stSmooth = input(3, title="%K Smoothing", minval=1, group="STOCHASTIC")
stSigLen = input(3, title="%D Smoothing", minval=1, group="STOCHASTIC")
stOb = input(70,  "Overbought", group="STOCHASTIC", inline="stObOs")
stOs = input(30,  "Oversold", group="STOCHASTIC", inline="stObOs")

stoch = security(syminfo.tickerid, stRes, sma(stoch(close, high, low, stLen), stSmooth), barmerge.gaps_off, barmerge.lookahead_off) 
stSignal = sma(stoch, stSigLen)

isStOb = useGenObOs ? stoch >= genOb : stoch >= stOb
isStOs = useGenObOs ? stoch <= genOs : stoch <= stOs

//}
//SIGNAL ==> isStOb, isStOs


//***** SIRIUS SIGNALS *****//
// {

srMacdLong = incAltMacd ? htfMacdLong or altHtfMacdLong : htfMacdLong
srMacdShort = incAltMacd ? htfMacdShort or altHtfMacdShort : htfMacdShort

sr1stIndLong = firstInd == "MACD" ? srMacdLong : firstInd == "Wave Trend" ? wtLong : na
sr1stIndShort = firstInd == "MACD" ? srMacdShort : firstInd == "Wave Trend" ? wtShort : na

sr2ndIndLong  = 
  scndInd == "Both" ? isRsiOs and isStOs :
  scndInd == "Any" ? isRsiOs or isStOs :
  scndInd == "RSI" ? isRsiOs :
  scndInd == "Stochastic" ? isStOs :
  na


sr2ndIndShort  = 
  scndInd == "Both" ? isRsiOb and isStOb :
  scndInd == "Any" ? isRsiOb or isStOb :
  scndInd == "RSI" ? isRsiOb :
  scndInd == "Stochastic" ? isStOb :
  na
  
  
srLong = sr1stIndLong and sr2ndIndLong
srShort = sr1stIndShort and sr2ndIndShort
//}
//SIGNALS ==> srLong, srShort

plotshape(srLong, "Long", shape.triangleup, location.belowbar, color.lime, size = size.small)
plotshape(srShort, "Short", shape.triangledown, location.abovebar, color.maroon, size = size.small)

plot(na)

Overview

Sirius Wavetrend marks long and short MACD states from histogram color and the MACD sign, with an optional alternative color rule. Users choose the first indicator, the second oscillator, calculation versus imported MACD, lengths, sources, and overbought or oversold levels. The study is set to overlay the price chart. The supplied file stops before later plot and signal logic.

Details

Published by

jerryinyang on GitHub

Code credit

Jerry, as written in the script's header

Type

Indicator, Pine Script v4

Draws

Separate pane below the chart

Markets

Any symbol

Timeframes

Any timeframe

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
Use General Overbought/Oversold?booltrueuseGenObOs
General Overbought Levelint70genOb
General Oversold Levelint30genOs
First IndicatorstringMACDfirstInd
Sirius Second IndicatorstringRSIscndInd
Include Alternative MACD Rule?boolfalseincAltMacd
HTF MACD TimeFrametimeframe120macdRes
MACD SourcesourceclosemacdSrc
MACD Fast Lengthint12macdflen
MACD Slow Lengthint26macdslen
MACD Signal Lineint9siglen
MACD Calculation MethodstringCalculatemacdMeth
Show all 29 settings
SettingTypeDefaultVariable
Wave Trend Timeframetimeframe120wtRes
Channel Lengthint10wtChannelLen
Average Lengthint21wtAvgLen
WT Overboughtint50wtOb
WT Oversoldint-50wtOs
Use Wave Trend Overbought/Oversold LevelsbooltruewtUseObOs
RSI Timeframetimeframe60rsiRes
RSI SourcesourceclosersiSrc
RSI Lengthint14rsiLen
Overboughtint60rsiOb
Oversoldint40rsiOs
Stochastic Timeframetimeframe60stRes
%K Lengthint10stLen
%K Smoothingint3stSmooth
%D Smoothingint3stSigLen
Overboughtint70stOb
Oversoldint30stOs
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

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

This indicator demonstrates an experimental graph-style scatter visualization within a separate pane using Pine Script arrays. It tracks two features across recent bars: the single-bar price change and a scaled 14-period Relative Strength Index. Values are loa

Indicator v4 Oscillators & momentum
Updated 4 years ago · None stated GitHub repository of Example: Graph Style - 4th Dimension RSI
228 stars

This indicator detects a Bollinger Band squeeze when the bands sit inside Keltner Channels, marking low volatility. It plots red dots during a squeeze and green dots when the bands are outside, in a separate pane. An optional histogram shows momentum as the cl

Indicator v6 Volatility & bandsOscillators & momentum
Updated 3 months ago · None stated GitHub repository of Bollinger Band Squeeze Detector

More Oscillators & momentum scripts

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