Create Labels for RSI-DMI-SMI


Category:
0
0

Hello all,

I did not know where to start in creating labels for this indicator. I would like to have 3 separate labels for each one, that reflects its current value and color (Red/Green). It will show something like this: “RSI” in RED or Green, based on settings. Same for DMI and STO, Using these names.

Below is the code:

declare lower;

input length = 14;

#RSI Settings
plot rsi1 = if reference RSI(length = 14).”RSI” >= 50 then 10 else 9;
plot rsi2 = if reference RSI(length = 14).”RSI” < 50 then 10 else 9;
AddCloud(rsi1, rsi2, Color.Green, Color.red);

#DMI Settings
plot dmi1 = if DMI(length = 14).”DI+” >= DMI(length = 14).”DI-” then 8 else 7;
plot dmi2 = if DMI(length = 14).”DI+” < DMI(length = 14).”DI-” then 8 else 7;
AddCloud(dmi1, dmi2, Color.Green, Color.red);

#Stochastics Settings
plot sto1 = if StochasticMomentumIndex().”SMI” >= StochasticMomentumIndex().”AvgSMI” then 6 else 5;
plot sto2 = if StochasticMomentumIndex().”SMI” < StochasticMomentumIndex().”AvgSMI” then 6 else 5;
AddCloud(sto1, sto2, Color.Green, Color.red);

rsi1.SetDefaultColor(Color.GRAY);
rsi2.SetDefaultColor(Color.GRAY);
dmi1.SetDefaultColor(Color.GRAY);
dmi2.SetDefaultColor(Color.GRAY);
sto1.SetDefaultColor(Color.GRAY);
sto2.SetDefaultColor(Color.GRAY);

Marked as spam
Posted by (Questions: 5, Answers: 16)
Asked on June 3, 2019 5:21 am
446 views
0
Just a quick note, I have reviewed a couple of videos and post, and tried changing "Plot" to "Def" and modified the color trigger lines with the AddLabel, but cant seem to bring it all together. Also note that I no longer want to use the lower level indicator, I want to replace it with these labels. Example trying with one of the settings RSI: def rsi1 = if reference RSI(length = 14)."RSI" >= 50 then 10 else 9; def rsi2 = if reference RSI(length = 14)."RSI" < 50 then 10 else 9; AddLabel(yes, Concat (“rsi: “,rsi1), rsi2, Color.Green, Color.red);
( at June 4, 2019 5:32 am)
0
Private answer

I updated the question title. You had listed STO (Stochastic) when in reality your code is using the SMI (Stochastic Momentum Index). I also eliminated the slash marks because they do not work well in search results.

Your code is a bit too complex for my taste to I decided to build this from scratch. But I used some of the same elements from your code in case you wanted to follow along.

Here it is:

def rsi = reference RSI(length = 14).”RSI”;
def dmiPlus = DMI(length = 14).”DI+”;
def dmiNegative = DMI(length = 14).”DI-”;
def smi = reference StochasticMomentumIndex().”SMI”;
def smiAvg = StochasticMomentumIndex().”AvgSMI”;
AddLabel(yes, "RSI", if rsi >= 50 then Color.GREEN else Color.RED);
AddLabel(yes, "DMI", if dmiPlus >= dmiNegative then Color.GREEN else Color.RED);
AddLabel(yes, "SMI", if smi >= smiAvg then Color.GREEN else Color.RED);

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on June 4, 2019 12:49 pm
0
Pete, first off... it's great to have you back, and second you are amazing at what you do, I sure appreciate you not only answering my question, but cleaning things up for me. It worked great! Enjoy your day.
( at June 4, 2019 4:20 pm)