RSI cyclic smoothed by Lars von Thienen (the cRSI Indicator)

saturn33

Member
Joined
Feb 26, 2022
Posts
17
Likes
5
Has anyone made a version of this for the MotiveWave software?

The source code is attached below - the below was done for the TradingView platform:

//@version=4
//
// Copyright (C) 2017 CC BY, whentotrade / Lars von Thienen
// Source:
// Book: Decoding The Hidden Market Rhythm - Part 1: Dynamic Cycles (2017)
// Chapter 4: "Fine-tuning technical indicators for more details on the cRSI Indicator
//
// Usage:
// You need to derive the dominant cycle as input parameter for the cycle length as described in chapter 4.
//
// License:
// This work is licensed under a Creative Commons Attribution 4.0 International License.
// You are free to share the material in any medium or format and remix, transform, and build upon the material for any purpose,
// even commercially. You must give appropriate credit to the authors book and website, provide a link to the license, and indicate
// if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
//
study(title="RSI cyclic smoothed", shorttitle="cRSI")
src = close
domcycle = input(20, minval=10, title="Dominant Cycle Length")
crsi = 0.0
cyclelen = domcycle / 2
vibration = 10
leveling = 10.0
cyclicmemory = domcycle * 2
//set min/max ranges?

h1 = hline(30, color=color.silver, linestyle=hline.style_dashed)
h2 = hline(70, color=color.silver, linestyle=hline.style_dashed)

torque = 2.0 / (vibration + 1)
phasingLag = (vibration - 1) / 2.0

up = rma(max(change(src), 0), cyclelen)
down = rma(-min(change(src), 0), cyclelen)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
crsi := torque * (2 * rsi - rsi[phasingLag]) + (1 - torque) * nz(crsi[1])

lmax = -999999.0
lmin = 999999.0
for i = 0 to cyclicmemory - 1 by 1
if nz(crsi, -999999.0) > lmax
lmax := nz(crsi)
lmax
else
if nz(crsi, 999999.0) < lmin
lmin := nz(crsi)
lmin

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

db = 0.0
for steps = 0 to 100 by 1
testvalue = lmin + mstep * steps
above = 0
below = 0
for m = 0 to cyclicmemory - 1 by 1
below := below + iff(crsi[m] < testvalue, 1, 0)
below

ratio = below / cyclicmemory
if ratio >= aperc
db := testvalue
break
else
continue

ub = 0.0
for steps = 0 to 100 by 1
testvalue = lmax - mstep * steps
above = 0
for m = 0 to cyclicmemory - 1 by 1
above := above + iff(crsi[m] >= testvalue, 1, 0)
above

ratio = above / cyclicmemory
if ratio >= aperc
ub := testvalue
break
else
continue


lowband = plot(db, "LowBand", color.aqua)
highband = plot(ub, "HighBand", color.aqua)
fill(h1, h2, color=color.silver, transp=90)
fill(lowband, highband, color=color.gray, transp=90)
plot(crsi, "CRSI", color.fuchsia)
 

HalTrader

Active member
Joined
May 26, 2022
Posts
35
Likes
12
One of the studies I am using is based on RSI. A few weeks ago, I uploaded an RSI indicator on E-mini S&P 500 on TradingView on the 1 day chart, and also did the same on MotiveWave. Although I selected 14 as RSI length and SMA as the moving average, I noticed that the RSI value on TradingView is different from that of MotiveWave.

After examining the RSI source code on both platforms, I noticed that the one in TradingView uses a different moving average, called “RMA”, which is not included on MotiveWave. I am not a professional programmer but I have a basic knowledge of MotiveWave programming and actually wanted to code the TradingView version of RSI on MotiveWave. However, I had to give it up due to time constraints related to my job. The RSI cyclic smoothed indicator you mentioned also is a more developed version of the standard RSI, and it actually looks nice, but must be custom-coded.

There are a few programmers on this forum. I can recommend @Spin as I have already purchased a couple of custom-coded studies from him. So far, all his studies work properly. If you wish, you can contact him by email. His website information is mentioned in his signature on his profile:

https://support.motivewave.com/forum/index.php?members/spin.27/#about
 

saturn33

Member
Joined
Feb 26, 2022
Posts
17
Likes
5
Thank you for your response. I have written Spin and let's see if anything happens.

For anyone interested further, this indicator is called "RSI cyclic smoothed v2" on TradingView. The source code was presented in my first message. There is also another similar indicator called csRSI MTF (Multi-Time-Frame), which also looks helpful. I have yet to find any source code for that. I'm not sure if it is publicly available or not. Lars von Thienen, the author of the indicator, is a Board member of the Foundation for the Study of Cycles and has done a lot of interesting work regarding cycles, in case some wish to learn more.
 

HalTrader

Active member
Joined
May 26, 2022
Posts
35
Likes
12
Once you have the RSI cyclic smoothed v2, I believe it will be possible to code its MTF version on MotiveWave. Then, you can add a few features such as an overbought/oversold area with buy/sell arrows on both smaller and higher timeframes to facilitate better entry, customizing it according to your trading style.
 

saturn33

Member
Joined
Feb 26, 2022
Posts
17
Likes
5
One of the studies I am using is based on RSI. A few weeks ago, I uploaded an RSI indicator on E-mini S&P 500 on TradingView on the 1 day chart, and also did the same on MotiveWave. Although I selected 14 as RSI length and SMA as the moving average, I noticed that the RSI value on TradingView is different from that of MotiveWave.
I can't seem to find your RSI indicator - can you direct me to the proper link? Thank you.
 

HalTrader

Active member
Joined
May 26, 2022
Posts
35
Likes
12
I meant TradingView's built-in RSI indicator (see below the code). However, I am using MotiveWave's built-in RSI study since I didn't have time to convert TradingView's RSI code into MotiveWave.


Code:
//@version=5
indicator(title="RSI", shorttitle="RSI", format=format.price, precision=2, timeframe="", timeframe_gaps=true)

rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
rsiOB = input.int(70, "Overbought")
rsiMID = input.int(50, "RSI Middle Band")
rsiOS = input.int(30, "Oversold")

up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))

plot(rsi, "RSI", color=color.new(color.blue,0))


rsiUpperBand = hline(rsiOB, "RSI Upper Band", color=#787B86)
midline = hline(rsiMID, "RSI Middle Band", color=color.new(#787B86, 50))
rsiLowerBand = hline(rsiOS, "RSI Lower Band", color=#787B86)
fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill")
 

saturn33

Member
Joined
Feb 26, 2022
Posts
17
Likes
5
Hi, Hal,

I have a working version at: astrowin.org/AE_cRSI.java

It is not fully complete. But I have a problem. My y-axis scale does not seem to adjust itself automatically so that all lines are fully visible. How do I fix this?

See attached. Thank you.

UPDATE: I found these two lines in the script:

desc.setMaxBottomValue(15);
desc.setMinTopValue(85);

This is my problem.
 

Attachments

  • 2024-04-12 21_17_18.jpg
    2024-04-12 21_17_18.jpg
    116.8 KB · Views: 5
Last edited:

HalTrader

Active member
Joined
May 26, 2022
Posts
35
Likes
12
You could set "desc.setMaxBottomValue" and "desc.setMinTopValue" in the code to -20 and 120, respectively, and compile the code.

Alternatively, under the "Options" tab, set "Top Inset" and "Bottom Inset" to 50. On the same window, click "Apply", then click "Defaults", and select "Save Defaults". Click "Apply" again.
 
Top