You are using an out of date browser. It may not display this or other websites correctly.

You should upgrade or use an alternative browser.

You should upgrade or use an alternative browser.

- Thread starter poparhon
- Start date

Having someone who can take the Trading View script and convert it over to TOSI suggest including all relevant links from your request, so it's easier for us to know exactly what you're talking about.

Code:

```
//
// @author Jadbrother modified by gero
//
//@version=2
study(title = "RCI3lines", shorttitle = "RCI3lines")
itvs = input(9, "short interval")
itvm = input(26, "middle interval")
itvl = input(52, "long interval")
src = input(close, "source")
upperband=input(title="High line[%]",defval=80,type=integer)
middleband=input(title="Mid line[%]",defval=0,type=integer)
lowerband=input(title="Low line[%]",defval=-80,type=integer)
ord(seq, idx, itv) =>
p = seq[idx]
o = 1
s = 0
for i = 0 to itv - 1
if p < seq[i]
o := o + 1
else
if p == seq[i]
s := s+1
o+(s-1)/2.0
o
d(itv) =>
sum = 0.0
for i = 0 to itv - 1
sum := sum + pow((i + 1) - ord(src, i, itv), 2)
sum
rci(itv) => (1.0 - 6.0 * d(itv) / (itv * (itv * itv - 1.0))) * 100.0
hline(upperband,color=gray,linestyle=dashed)
hline(lowerband,color=gray,linestyle=dashed)
hline(middleband,color=gray,linestyle=dashed)
plot(rci(itvs), title = "RCI short", color = red)
plot(rci(itvm), title = "RCI middle", color = blue)
plot(rci(itvl), title = "RCI long", color = green)
```

Last edited:

I've included an image below and also the TV code if anyone wants to take a stab at converting it.

Code:

```
//
// @author Jadbrother modified by gero
//
//@version=2
study(title = "RCI3lines", shorttitle = "RCI3lines")
itvs = input(9, "short interval")
itvm = input(26, "middle interval")
itvl = input(52, "long interval")
src = input(close, "source")
upperband=input(title="High line[%]",defval=80,type=integer)
middleband=input(title="Mid line[%]",defval=0,type=integer)
lowerband=input(title="Low line[%]",defval=-80,type=integer)
ord(seq, idx, itv) =>
p = seq[idx]
o = 1
s = 0
for i = 0 to itv - 1
if p < seq[i]
o := o + 1
else
if p == seq[i]
s := s+1
o+(s-1)/2.0
o
d(itv) =>
sum = 0.0
for i = 0 to itv - 1
sum := sum + pow((i + 1) - ord(src, i, itv), 2)
sum
rci(itv) => (1.0 - 6.0 * d(itv) / (itv * (itv * itv - 1.0))) * 100.0
hline(upperband,color=gray,linestyle=dashed)
hline(lowerband,color=gray,linestyle=dashed)
hline(middleband,color=gray,linestyle=dashed)
plot(rci(itvs), title = "RCI short", color = red)
plot(rci(itvm), title = "RCI middle", color = blue)
plot(rci(itvl), title = "RCI long", color = green)
//end of code
```

Rick, thanks. I think something is wrong with code.

Maybe we can use this with the Acc Dist CCI strategy. The strategy is amzing from my point of view and we should work on the details.

Let us improve it together. Thanks

Sounds great. Yeah, that's a staple indicator for me. Still trying to figure out how to hit it just right though. I was thinking that if the RCI_3Lines could be converted for TOS, it could be combined with the AccDist_CCI strat to (hopefully) make absolute surefire signals.

Question: you didn't think the code I posted above was thinkscript, did you? That's the original pinescript from Trading View.

Sorry @BenTen, I thought that a new post might gain some new eyeballs. Wow! The admin chores on this site must keep you busy.

I thought it is a TOS Code first, sorry. The basic of your ACC CCI strategy is amazing. I think Gehege is only a small piece of the Puzzle to solve. Let us work on that.

Gehege? I think I missed something along the way. What's Gehege?

Sorry I meant “there is only...“

I am from Switzerland and the sometimes the words in English get a German suggestion

Hahaha..... that's funny. Before I posted that I actually googled the def of gehege and I saw that there was a german language connection.

Through some sleuthing on the google machine I found out that the RCI_3_Lines indicator is nothing other than 3 instances of the Spearman indicator. So, I pieced it together and, behold....the RCI_3_Lines indicator (below).

I was happy to have figured this out on my own, but as it turns out I'm not so thrilled with the indicator after all. I added some alerts to see what scenarios might work, but they were very inconsistent so I commented them out. You can turn them back on by editing the code.

Anyway, unless someone can come up with a good use for this in terms of entries, exits, etc. .... I'm sort of done with this.

Code:

```
#
# RCI_3_Lines is simply 3 instances of the Spearman indicator
# set to lengths 9, 36 and 52. I eliminated the Spearman Average line.
# pieced together by @RickKennedy, thinkscript.com, 2020/11/22
declare lower;
input price = close;
input length_9 = 9;
input length_36 = 36;
input length_52 = 52;
input averageLength = 3;
input over_bought = 80;
input over_sold = -80;
input showBreakoutSignals =yes;
# instance 9 length
assert(length_9 >= 2, "'length' must be greater than or equal to 2: " + length_9);
def sumSqr9 = fold i9 = 0 to length_9 with sum9 do
sum9 + Sqr((length_9 - i9) - fold j9 = 0 to length_9 with rank9
do rank9 + if GetValue(price, i9, length_9 - 1) > GetValue(price, length_9 - j9 - 1) or GetValue(price, i9) == GetValue(price, length_9 - j9 - 1) and i9 <= length_9 - j9 - 1 then 1 else 0);
# instance 36 length
assert(length_36 >= 2, "'length' must be greater than or equal to 2: " + length_36);
def sumSqr36 = fold i36 = 0 to length_36 with sum36 do
sum36 + Sqr((length_36 - i36) - fold j36 = 0 to length_36 with rank36
do rank36 + if GetValue(price, i36, length_36 - 1) > GetValue(price, length_36 - j36 - 1) or GetValue(price, i36) == GetValue(price, length_36 - j36 - 1) and i36 <= length_36 - j36 - 1 then 1 else 0);
# instance 52 length
assert(length_52 >= 2, "'length' must be greater than or equal to 2: " + length_52);
def sumSqr52 = fold i52 = 0 to length_52 with sum52 do
sum52 + Sqr((length_52 - i52) - fold j52 = 0 to length_52 with rank52
do rank52 + if GetValue(price, i52, length_52 - 1) > GetValue(price, length_52 - j52 - 1) or GetValue(price, i52) == GetValue(price, length_52 - j52 - 1) and i52 <= length_52 - j52 - 1 then 1 else 0);
# plots
plot Spearman9 = 100 * (1 - 6 * sumSqr9 / (length_9 * (Sqr(length_9) - 1)));
plot Spearman36 = 100 * (1 - 6 * sumSqr36 / (length_36 * (Sqr(length_36) - 1)));
plot Spearman52 = 100 * (1 - 6 * sumSqr52 / (length_52 * (Sqr(length_52) - 1)));
plot OverBought = over_bought;
#plot ZeroLine = 0;
plot OverSold = over_sold;
Spearman9.SetDefaultColor(GetColor(9));
Spearman36.SetDefaultColor(GetColor(5));
Spearman52.SetDefaultColor(GetColor(6));
OverBought.SetDefaultColor(GetColor(3));
#ZeroLine.SetDefaultColor(GetColor(3));
OverSold.SetDefaultColor(GetColor(3));
# alerts and signals
#plot UpSignal = if Spearman9 <= over_sold and Spearman36 <= over_sold and Spearman52 <= over_sold then over_sold else Double.Nan;
#plot DownSignal = if Spearman9 >= over_bought and Spearman36 >= over_bought and Spearman52 >= over_bought then over_bought else Double.Nan;
#plot UpSignal = if Spearman9 > Spearman9[1] and Spearman36 > Spearman36[1] and Spearman52 > Spearman52[1] then over_sold else Double.Nan;
#plot DownSignal = if Spearman9 < Spearman9[1] and Spearman36 < Spearman36[1] and Spearman52 < Spearman52[1] then over_sold else Double.Nan;
#plot UpSignal = if Spearman9 > 50 and Spearman36 > Spearman36[1] and Spearman36 < -50 and Spearman52 <-50 and Spearman36 crosses above Spearman52 then over_sold else Double.Nan;
#plot DownSignal = if Spearman9 < -50 and Spearman36 < Spearman36[1] and Spearman36 > 50 and Spearman52 > 50 and Spearman36 crosses below Spearman52 then over_bought else Double.Nan;
#Alert(UpSignal, " LOOK FOR LONG ", Alert.Bar, Sound.Chimes);
#Alert(DownSignal, " LOOK FOR SHORT ", Alert.Bar, Sound.Bell);
#UpSignal.SetHiding(!showBreakoutSignals);
#DownSignal.SetHiding(!showBreakoutSignals);
#UpSignal.SetDefaultColor(Color.UPTICK);
#UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
#DownSignal.SetDefaultColor(Color.DOWNTICK);
#DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
```

Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|

F | Need someone help write this code for ThinkorSwim | Questions | 8 | |

Can someone please help create a label? | Questions | 9 | ||

Can someone help me write a HOD strategy? | Questions | 3 | ||

M | Can someone help me make a backtesting code? | Questions | 0 | |

Can someone help me code RSI + Momentum SMA? | Questions | 4 |