RSI, MACD, MFI, CCI, ROC Labels For ThinkOrSwim

Ajordan930

Member
VIP
Just a label indicator I have been messing around with. Currently using 2 candles and showing the current candle value along with previous candle close value and will color green if higher, red if lower, and grey if no change. It will plot the values for 5 momentum indicators. RSI, MACD,MFI, CCI, and ROC. I have 3 settings for display purposes that you can select from. They are Big 5, Fast Scalping, and Trend Continuation. Big 5 shows all 5, Fast Scalping shows RSI, CCI, and ROC, and Trend Continuation shows RSI, MACD, and MFI. I created this just as a visual label to see how these traditional indicators are moving.

1769262676268.png


Code:
# === 2-Candle Momentum Labels with Presets + MRM ===
declare upper;

# =======================
# USER INPUTS
# =======================
input showLabels = yes;

input momentumPreset = {
default BIG_5,
FAST_SCALPING,
TREND_CONTINUATION
};

# =======================
# Preset Indicators
# Big 5 RSI · MACD · MFI · CCI · ROC
# Fast Scalping RSI · CCI · ROC
# Trend Continuation RSI · MACD · MFI
# =======================

input rsiLength = 14;
input mfiLength = 14;
input cciLength = 20;
input rocLength = 9;

# =======================
# INDICATORS
# =======================
def rsi = RSI(length = rsiLength);
def macdValue = MACD()."Value";
def mfi = MoneyFlowIndex(length = mfiLength)."MoneyFlowIndex";
def cci = CCI(length = cciLength);
def roc = RateOfChange(price = close, length = rocLength);

# =======================
# 2-CANDLE DIRECTION LOGIC
# =======================
def rsiUp = rsi > rsi[1];
def rsiDn = rsi < rsi[1];

def macdUp = macdValue > macdValue[1];
def macdDn = macdValue < macdValue[1];

def mfiUp = mfi > mfi[1];
def mfiDn = mfi < mfi[1];

def cciUp = cci > cci[1];
def cciDn = cci < cci[1];

def rocUp = roc > roc[1];
def rocDn = roc < roc[1];

# =======================
# PRESET SELECTION FLAGS
# =======================
def useRSI =
momentumPreset == momentumPreset.BIG_5 or
momentumPreset == momentumPreset.FAST_SCALPING or
momentumPreset == momentumPreset.TREND_CONTINUATION;

def useMACD =
momentumPreset == momentumPreset.BIG_5 or
momentumPreset == momentumPreset.TREND_CONTINUATION;

def useMFI =
momentumPreset == momentumPreset.BIG_5 or
momentumPreset == momentumPreset.TREND_CONTINUATION;

def useCCI =
momentumPreset == momentumPreset.BIG_5 or
momentumPreset == momentumPreset.FAST_SCALPING;

def useROC =
momentumPreset == momentumPreset.BIG_5 or
momentumPreset == momentumPreset.FAST_SCALPING;

# =======================
# LABELS (SEPARATE)
# =======================
AddLabel(
showLabels and useRSI,
"RSI " + Round(rsi, 0) + " → " + Round(rsi[1], 0),
if rsiUp then Color.GREEN else if rsiDn then Color.RED else Color.GRAY
);

AddLabel(
showLabels and useMACD,
"MACD " + Round(macdValue, 2) + " → " + Round(macdValue[1], 2),
if macdUp then Color.GREEN else if macdDn then Color.RED else Color.GRAY
);

AddLabel(
showLabels and useMFI,
"MFI " + Round(mfi, 0) + " → " + Round(mfi[1], 0),
if mfiUp then Color.GREEN else if mfiDn then Color.RED else Color.GRAY
);

AddLabel(
showLabels and useCCI,
"CCI " + Round(cci, 0) + " → " + Round(cci[1], 0),
if cciUp then Color.GREEN else if cciDn then Color.RED else Color.GRAY
);

AddLabel(
showLabels and useROC,
"ROC " + Round(roc, 2) + " → " + Round(roc[1], 2),
if rocUp then Color.GREEN else if rocDn then Color.RED else Color.GRAY
);
 
Last edited by a moderator:
Updated code to be able to modify location where it displays as well as a header of which option you have selected. It will also color green when the majority are aligned.

1771774185323.png


1771774221545.png
1771774267392.png


# === 2-Candle Momentum Labels with Presets + MRM (Header Score) ===
declare upper;

# =======================
# USER INPUTS
# =======================
input showLabels = yes;
input showHeader = yes;

input labelLocation = {
default UPPER_LEFT,
UPPER_RIGHT,
LOWER_LEFT,
LOWER_RIGHT
};

input momentumPreset = {
default BIG_5,
FAST_SCALPING,
TREND_CONTINUATION
};

# =======================
# LOCATION MAPPING
# =======================
def loc =
if labelLocation == labelLocation.UPPER_LEFT then Location.TOP_LEFT
else if labelLocation == labelLocation.UPPER_RIGHT then Location.TOP_RIGHT
else if labelLocation == labelLocation.LOWER_LEFT then Location.BOTTOM_LEFT
else Location.BOTTOM_RIGHT;

# =======================
# INPUT LENGTHS
# =======================
input rsiLength = 14;
input mfiLength = 14;
input cciLength = 20;
input rocLength = 9;

# =======================
# INDICATORS
# =======================
def rsi = RSI(length = rsiLength);
def macdValue = MACD()."Value";
def mfi = MoneyFlowIndex(length = mfiLength)."MoneyFlowIndex";
def cci = CCI(length = cciLength);
def roc = RateOfChange(price = close, length = rocLength);

# =======================
# 2-CANDLE DIRECTION
# =======================
def rsiUp = rsi > rsi[1];
def rsiDn = rsi < rsi[1];

def macdUp = macdValue > macdValue[1];
def macdDn = macdValue < macdValue[1];

def mfiUp = mfi > mfi[1];
def mfiDn = mfi < mfi[1];

def cciUp = cci > cci[1];
def cciDn = cci < cci[1];

def rocUp = roc > roc[1];
def rocDn = roc < roc[1];

# =======================
# PRESET FLAGS
# =======================
def useRSI =
momentumPreset == momentumPreset.BIG_5 or
momentumPreset == momentumPreset.FAST_SCALPING or
momentumPreset == momentumPreset.TREND_CONTINUATION;

def useMACD =
momentumPreset == momentumPreset.BIG_5 or
momentumPreset == momentumPreset.TREND_CONTINUATION;

def useMFI =
momentumPreset == momentumPreset.BIG_5 or
momentumPreset == momentumPreset.TREND_CONTINUATION;

def useCCI =
momentumPreset == momentumPreset.BIG_5 or
momentumPreset == momentumPreset.FAST_SCALPING;

def useROC =
momentumPreset == momentumPreset.BIG_5 or
momentumPreset == momentumPreset.FAST_SCALPING;

# =======================
# BULL / BEAR COUNT
# =======================
def bullCount =
(useRSI and rsiUp) +
(useMACD and macdUp) +
(useMFI and mfiUp) +
(useCCI and cciUp) +
(useROC and rocUp);

def bearCount =
(useRSI and rsiDn) +
(useMACD and macdDn) +
(useMFI and mfiDn) +
(useCCI and cciDn) +
(useROC and rocDn);

# total indicators used in preset
def totalIndicators = (useRSI) + (useMACD) + (useMFI) + (useCCI) + (useROC);

# =======================
# HEADER WITH SCORE
# =======================
AddLabel(
showLabels and showHeader,
if momentumPreset == momentumPreset.BIG_5 then "=== BIG 5 MOMENTUM (" + bullCount + "/" + totalIndicators + ") ==="
else if momentumPreset == momentumPreset.FAST_SCALPING then "=== FAST SCALPING MOMENTUM (" + bullCount + "/" + totalIndicators + ") ==="
else "=== TREND CONTINUATION MOMENTUM (" + bullCount + "/" + totalIndicators + ") ===",
if bullCount > bearCount then Color.GREEN
else if bearCount > bullCount then Color.RED
else Color.GRAY,
loc
);

# =======================
# INDICATOR LABELS
# =======================
AddLabel(
showLabels and useRSI,
"RSI " + Round(rsi, 0) + " → " + Round(rsi[1], 0),
if rsiUp then Color.GREEN else if rsiDn then Color.RED else Color.GRAY,
loc
);

AddLabel(
showLabels and useMACD,
"MACD " + Round(macdValue, 2) + " → " + Round(macdValue[1], 2),
if macdUp then Color.GREEN else if macdDn then Color.RED else Color.GRAY,
loc
);

AddLabel(
showLabels and useMFI,
"MFI " + Round(mfi, 0) + " → " + Round(mfi[1], 0),
if mfiUp then Color.GREEN else if mfiDn then Color.RED else Color.GRAY,
loc
);

AddLabel(
showLabels and useCCI,
"CCI " + Round(cci, 0) + " → " + Round(cci[1], 0),
if cciUp then Color.GREEN else if cciDn then Color.RED else Color.GRAY,
loc
);

AddLabel(
showLabels and useROC,
"ROC " + Round(roc, 2) + " → " + Round(roc[1], 2),
if rocUp then Color.GREEN else if rocDn then Color.RED else Color.GRAY,
loc
);
 

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
821 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