Dominant Cycle + RSI = Cyclic RSI for ThinkOrSwim

Assuming the price is represented by the purple line? Also, looking at your image, it shows an exit after the first buy but when do you buy again? If you exit on the first exit, how can you sell on the two sells if you already edited? Sell when purple drops below green?
Hi, I was just showing what could be better bought after the green bar on cyclic RSI. I am not looking at the purple line but the green and red bar on the indicator. It will be buying again when the green bar hit and after that, the blue candle appears. exit when red candle hit or take part profit when gray candle appears.
 
@mfox thanks for posting, this seems fantastic. especially on daily 10 min it does a good job of identifying tops and bottoms. majority of the time stocks don't trend a straight direction throughout the day so this looks to identify tops/bottoms pretty well
 
@mfox thanks for posting, this seems fantastic. especially on daily 10 min it does a good job of identifying tops and bottoms. majority of the time stocks don't trend a straight direction throughout the day so this looks to identify tops/bottoms pretty well
I'm glad to hear it works for you. I mostly look at it to confirm opening-bell reversals and play short morning flips. I would still like to circle back to this in the future and make it faster, if that's even possible, but unfortunately I still work aside from day trading and my time is currently too limited to dive into it again. Best of luck with it in the future.
 
Hi @mfox,

There seems no thinkscript version of Detrended Rhythm Oscillator (DRO) available on site, as it is required for input into the cRSI?

I done a little research, it seems the DRO is based on thinkscript default Detrended Price Osc (DPO) with the following improvements:
https://docs.cycle.tools/books/trad...ndicator/page/detrended-rhythm-oscillator-dro

1) Using a DPO to detrend the price (can be turned on or off)
2) Indicate the turns of the detrended price with a ZigZag lines to better see the tops/bottoms
3) Detrend the ZigZag to remove price amplitude between turns to even better see the cyclic turns ("rhythm")
4) Measure the distance from last detrended zigzag pivot (high-high / low-low) and plot the distance in bars above/below the turn

The TradingView pine code is available below. Please help to make this thinkscript please:
https://www.tradingview.com/script/nzvqcuSh-Detrended-Rhythm-Oscillator-DRO/
 
Last edited:
@mfox I also did a little comparison with the post's cRSI study against whats on the TradingView.

As shown below, the cRSI indicator graph from this post seems quite different to the TradingView's, especially the shape of the dynamic top/bottom extremes:

This post:

00.png


TradingView:

01.png


==> The thinkscript version of cRSI's OB/OS plots are not as SMOOTH as the one shown on TradingView. Why is that?
 
Last edited:
Repainting?

(1) Does the cRSI indicator repaints?
(2) It seems the Detrended Rhythm Oscillator (DRO) uses zigzag, so DRO should be a repainting indicator? Therefore making cRSI repainting too?
 
hello can i get some help putting this indicator in an mtf version thanks
Ruby:
# Cyclic RSI
# Origanlly found on Tradingview: https://www.tradingview.com/v/TmqiR1jp/
# Shout out to WentToTrade for the amazing indicator.
# Written in ThinkScript by mfox

# The cyclic smoothed RSI indicator is an enhancement of the classic RSI , adding
# additional smoothing according to the market vibration,
# adaptive upper and lower bands according to the cyclic memory and
# using the current dominant cycle length as input for the indicator.

# The cRSI is used like a standard indicator. The chart highlights trading signals where the signal line # crosses above or below the adaptive lower/upper bands. It is much more responsive to market moves than the basic RSI.

# The indicator uses the dominant cycle as input to optimize signal, smoothing and cyclic memory. To get more in-depth information on the cyclic-smoothed RSI indicator, please read Chapter 4 "Fine tuning technical indicators" of the book "Decoding the Hidden Market Rhythm, Part 1" available at your favorite book store.

declare lower;

def src = close;
input domcycle = 20;
def cyclelen = domcycle /1.5;
def vibration = 10;
def leveling = 10.0;
def cyclicmemory = domcycle * 2;

plot h1 = 10;
h1.SetDefaultColor(Color.White);
h1.SetPaintingStrategy(PaintingStrategy.DASHES);
h1.SetlineWeight(1);

plot h2 = 80;
h2.SetDefaultColor(Color.White);
h2.SetPaintingStrategy(PaintingStrategy.DASHES);
h2.SetlineWeight(1);

def torque = 2.0 / (vibration + 1.0);
def phasingLag = (vibration - 1.0) / 2.0;

script nz {
input data = 0;
def ret_val = if IsNaN(data) then 0 else data;
plot return = ret_val;
}

script rma {
input src = 0;
input length = 0;
def alpha = 1 / length;
def sum = alpha * src + ( 1 - alpha) * nz(sum[1]);
plot return = sum;
}

script change {
input data = 0;
plot return = data - GetValue(data, 1);
}

def up = rma(Max(change(src), 0), cyclelen);
def down = rma(-Min(change(src), 0), cyclelen);

def rsi = if down == 0 then 100 else if up == 0 then 0 else 100 - 100 / (1 + up / down);
def crsi = torque * (2 * rsi - rsi[phasingLag]) + (1 - torque) * nz(crsi[1]);

def lm_hist = if crsi > Highest(crsi, cyclicmemory - 1) and !IsNaN(lm_hist[1])
then crsi
else if -crsi < Lowest(crsi, cyclicmemory - 1) and !IsNaN(lm_hist[1])
then -crsi
else 0;

def lmax = -Highest(lm_hist, cyclicmemory - 1);
def lmin = -Lowest(lm_hist, cyclicmemory - 1);

def mstep = (lmax - lmin) / 100;
def aperc = leveling / 100;

def db = fold dbx = 0 to 100
while (fold blx = 0 to cyclicmemory - 1
with b
do b + if crsi[blx] < lmin + mstep * dbx
then 1
else 0) / cyclicmemory >= aperc
do lmin + mstep * dbx;

def ub = fold ubx = 0 to 100
while (fold ulx = 0 to cyclicmemory - 1
with a
do a + if crsi[ulx] >= lmax - mstep * ubx
then 1
else 0) / cyclicmemory >= aperc
do lmax - mstep * ubx;

plot lowband = db;
lowband.SetDefaultColor(Color.RED);

plot highband = ub;
highband.SetDefaultColor(Color.GREEN);

plot C = crsi;
C.SetDefaultColor(Color.PLUM);

AddCloud(db, ub, Color.Dark_Gray, Color.Dark_Gray);
AddCloud(h1, if c < h1 then c else Double.Nan, color.dark_red, color.dark_red);
AddCloud(h2, if c > h2 then c else Double.Nan, color.dark_green, color.dark_green);


#assignPriceColor(if c>h2 then color.red else
# color.gray);


assignpricecolor( if c > lowband and c< highband then color.gray else if c> highband then color.red else if c crosses below highband then color.yellow else color. white);
 
Last edited by a moderator:
anyone please?
Since everything seems to be based off of 'src' then modify the 'src' code with

Ruby:
input aggregationperiod = aggregationperiod.min;
input price = fundamentalType.CLOSE;
def src     = fundamental(price, period=aggregationperiod);
 
trying to get the assignvalue color on this any help. i got somewhat close but not entirely

Ruby:
# Cyclic RSI
# Origanlly found on Tradingview: https://www.tradingview.com/v/TmqiR1jp/
# Shout out to WentToTrade for the amazing indicator.
# Written in ThinkScript by mfox

# The cyclic smoothed RSI indicator is an enhancement of the classic RSI , adding
# additional smoothing according to the market vibration,
# adaptive upper and lower bands according to the cyclic memory and
# using the current dominant cycle length as input for the indicator.

# The cRSI is used like a standard indicator. The chart highlights trading signals where the signal line # crosses above or below the adaptive lower/upper bands. It is much more responsive to market moves than the basic RSI.

# The indicator uses the dominant cycle as input to optimize signal, smoothing and cyclic memory. To get more in-depth information on the cyclic-smoothed RSI indicator, please read Chapter 4 "Fine tuning technical indicators" of the book "Decoding the Hidden Market Rhythm, Part 1" available at your favorite book store.

declare lower;


input aggregationperiod = aggregationperiod.min;
input price = fundamentalType.CLOSE;
def src = fundamental(price, period=aggregationperiod);

input domcycle = 20;
def cyclelen = domcycle / 1.5;
def vibration = 10;
def leveling = 10.0;
def cyclicmemory = domcycle * 2;

plot h1 = 10;
h1.SetDefaultColor(Color.WHITE);
h1.SetPaintingStrategy(PaintingStrategy.DASHES);
h1.SetLineWeight(1);

plot h2 = 80;
h2.SetDefaultColor(Color.WHITE);
h2.SetPaintingStrategy(PaintingStrategy.DASHES);
h2.SetLineWeight(1);

def torque = 2.0 / (vibration + 1.0);
def phasingLag = (vibration - 1.0) / 2.0;

script nz {
input data = 0;
def ret_val = if IsNaN(data) then 0 else data;
plot return = ret_val;
}

script rma {
input src = 0;
input length = 0;
def alpha = 1 / length;
def sum = alpha * src + ( 1 - alpha) * nz(sum[1]);
plot return = sum;
}

script change {
input data = 0;
plot return = data - GetValue(data, 1);
}

def up = rma(Max(change(src), 0), cyclelen);
def down = rma(-Min(change(src), 0), cyclelen);

def rsi = if down == 0 then 100 else if up == 0 then 0 else 100 - 100 / (1 + up / down);
def crsi = torque * (2 * rsi - rsi[phasingLag]) + (1 - torque) * nz(crsi[1]);

def lm_hist = if crsi > Highest(crsi, cyclicmemory - 1) and !IsNaN(lm_hist[1])
then crsi
else if -crsi < Lowest(crsi, cyclicmemory - 1) and !IsNaN(lm_hist[1])
then -crsi
else 0;

def lmax = -Highest(lm_hist, cyclicmemory - 1);
def lmin = -Lowest(lm_hist, cyclicmemory - 1);

def mstep = (lmax - lmin) / 100;
def aperc = leveling / 100;

def db = fold dbx = 0 to 100
while (fold blx = 0 to cyclicmemory - 1
with b
do b + if crsi[blx] < lmin + mstep * dbx
then 1
else 0) / cyclicmemory >= aperc
do lmin + mstep * dbx;

def ub = fold ubx = 0 to 100
while (fold ulx = 0 to cyclicmemory - 1
with a
do a + if crsi[ulx] >= lmax - mstep * ubx
then 1
else 0) / cyclicmemory >= aperc
do lmax - mstep * ubx;

plot lowband = db;
lowband.SetDefaultColor(Color.RED);

plot highband = ub;
highband.SetDefaultColor(Color.GREEN);

plot C = crsi;
c.assignValueColor(if src>= src[4] then Color.green else Color.red);
c.assignValueColor(if src<= src[4] then Color.red else Color.green);
AddCloud(db, ub, Color.DARK_GRAY, Color.DARK_GRAY);
AddCloud(h1, if C < h1 then C else Double.NaN, Color.DARK_RED, Color.DARK_RED);
AddCloud(h2, if C > h2 then C else Double.NaN, Color.DARK_GREEN, Color.DARK_GREEN);



#assignPriceColor(if c>h2 then color.red else
# color.gray);


AssignPriceColor( if C > lowband and C < highband then Color.GRAY else if C > highband then Color.RED else if C crosses below highband then Color.YELLOW else Color. WHITE);
input showBreakoutSignals = yes;
plot signaldown = if C crosses below highband then highband else Double.NaN;
signaldown.SetHiding(!showBreakoutSignals);
signaldown.SetDefaultColor(Color.RED);
signaldown.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
signaldown.HideTitle();
 

Attachments

  • 7-10-2022 6-30-06 PM.jpg
    7-10-2022 6-30-06 PM.jpg
    30 KB · Views: 314
Last edited by a moderator:
Hi @mfox,

There seems no thinkscript version of Detrended Rhythm Oscillator (DRO) available on site, as it is required for input into the cRSI?

I done a little research, it seems the DRO is based on thinkscript default Detrended Price Osc (DPO) with the following improvements:
https://docs.cycle.tools/books/trad...ndicator/page/detrended-rhythm-oscillator-dro

1) Using a DPO to detrend the price (can be turned on or off)
2) Indicate the turns of the detrended price with a ZigZag lines to better see the tops/bottoms
3) Detrend the ZigZag to remove price amplitude between turns to even better see the cyclic turns ("rhythm")
4) Measure the distance from last detrended zigzag pivot (high-high / low-low) and plot the distance in bars above/below the turn

The TradingView pine code is available below. Please help to make this thinkscript please:
https://www.tradingview.com/script/nzvqcuSh-Detrended-Rhythm-Oscillator-DRO/
Not to disappoint you, but I no longer spend much time developing scripts and even less trading as a whole. I would suggest you simply use the open source DRO on TV from WTT and plug in the domcycle into the TOS cRSI if there is one for the same stock/timeframe.

Best of luck to you.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
517 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top