Add overbought and oversold levels to MarkerIndicator

L

lmk99

Member
VIP
Hi all,

This should be very simple but I haven't figured it out yet. MarkerIndicator doesn't have horizontal lines for overbought and oversold by default. The study displays the indicator in a lower chart that has a y-axis of 0 to 100%. I want to have lines appear at 30% and 70% so I wrote this and merged it into the same section:
Code:
input oversoldMI = 30;
input overboughtMI = 70;
plot line1 = oversoldMI;
plot line2 = overboughtMI;
line1.SetDefaultColor(GetColor(339700));
line2.SetDefaultColor(GetColor(339700));

What happens is the lines appear at the very top and bottom of the section instead of at 30% and 70%. If I try to change "input oversoldMI =" to "30%" instead of "30" then of course that doesn't work. How can I make the lines appear at 30% and 70%?
 
BenTen

BenTen

Administrative
Staff
VIP
Here you go:

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2007-2020
#

declare lower;

input overbought = 70;
input oversold = 30;

def high_diff = Max(0, high - high[1]);
def low_diff = Max(0, low[1] - low);

def high_avg = Average(high_diff, 8);
def low_avg = Average(low_diff, 8);
plot TD_I = if high_avg == 0 && low_avg == 0 then 0 else high_avg / (high_avg + low_avg) * 100;
TD_I.SetDefaultColor(GetColor(1));

plot ob = overbought;
plot os = oversold;
 

Similar threads

Top