Login Page - Create Account

Support Board


Date/Time: Wed, 28 Jan 2026 17:52:39 +0000



Post From: Can you please add the RCI Ribbon indicator as this is better than Stochastics or RSI.

[2025-12-12 22:23:01]
User719512 - Posts: 408
RCI Ribbon is just 3 RCI studies on the same chart/plot. The 10, 30, 50 are its defaults on TradingView.

RCI itself can be calculated in Sierra with this code:


// RCI.cpp
// Compile this into a DLL for Sierra Chart using the ACSIL framework.

#include "sierrachart.h"

SCDLLName("RCI")

double ord(SCFloatArrayRef seq, int idx, int itv, int baseIndex) {
float p = seq[baseIndex - idx];
int o = 1;
int s = 0;
for (int i = 0; i < itv; i++) {
float seq_i = seq[baseIndex - i];
if (p < seq_i) {
o++;
}
else if (p == seq_i) {
s++;
}
}
return o + (s - 1) / 2.0;
}

double d_calc(int itv, SCFloatArrayRef seq, int baseIndex) {
double sum = 0.0;
for (int i = 0; i < itv; i++) {
double rank = ord(seq, i, itv, baseIndex);
sum += pow((i + 1) - rank, 2);
}
return sum;
}

double rci(int itv, SCFloatArrayRef seq, int baseIndex) {
return (1.0 - 6.0 * d_calc(itv, seq, baseIndex) / (itv * (itv * itv - 1.0))) * 100.0;
}

SCSFExport scsf_RCI(SCStudyInterfaceRef sc) {
SCInputRef IntervalInput = sc.Input[0];
SCInputRef SourceInput = sc.Input[1];

if (sc.SetDefaults) {
sc.GraphName = "RCI";
sc.StudyDescription = "Rank Correlation Index";
sc.AutoLoop = 1;
sc.GraphRegion = 1; // Separate region by default

IntervalInput.Name = "Interval";
IntervalInput.SetInt(12);
IntervalInput.SetIntLimits(1, MAX_STUDY_LENGTH);

SourceInput.Name = "Source";
SourceInput.SetInputDataIndex(SC_LAST); // Default to Close

sc.Subgraph[0].Name = "RCI";
sc.Subgraph[0].DrawStyle = DRAWSTYLE_LINE;
sc.Subgraph[0].PrimaryColor = RGB(0, 255, 0); // Green
sc.Subgraph[0].LineWidth = 1;

sc.Subgraph[1].Name = "Zero Line";
sc.Subgraph[1].DrawStyle = DRAWSTYLE_LINE;
sc.Subgraph[1].PrimaryColor = RGB(255, 0, 0); // Red
sc.Subgraph[1].LineWidth = 1;
sc.Subgraph[1].DrawZeros = 1;

return;
}

int itv = IntervalInput.GetInt();
if (sc.Index < itv - 1) {
return; // Not enough data
}

SCFloatArrayRef SourceArray = sc.BaseDataIn[SourceInput.GetInputDataIndex()];

sc.Subgraph[0][sc.Index] = (float)rci(itv, SourceArray, sc.Index);
sc.Subgraph[1][sc.Index] = 0.0f;
}