#study(title="5 in 1 ", shorttitle="5 in 1", overlay=false)
declare lower;
input showAroon = no; #e,title="AROON")
input aroonLength = 14; #, minval=1)
input showRsi = yes; #input(true,title="RSI");
input rsiSource = close;
input rsiLength = 14; #, minval=1, title="Length RSI")
input rsiSmoothing = 5; #, minval=1, title="Length sma RSI")
input showMacd = no; #input(false,title="MACD")
input macdSource = close;
input macdFastLength = 12; #, minval=1),
input macdSlowLength = 26; #,minval=1)
input macdSignalLength = 9; #,minval=1)
input showStochastic = no; #,title="STOCHASTIC")
input periodK = 14; #, title="K", minval=1)
input periodD = 3; #, title="D", minval=1)
input smoothK = 3; #, title="Smooth", minval=1)
input showAdx = no; #,title="ADX DI")
input diLength = 14; #, minval=1, title="DI Length")
input adxSmoothingLength = 14; #, title="ADX Smoothing", minval=1, maxval=50)
input adxThreshold = 25; #(title="threshold", type=integer, defval=25)
def na = Double.NaN;
def last = IsNaN(close);
def pos = Double.POSITIVE_INFINITY;
def neg = Double.NEGATIVE_INFINITY;
#-- color
DefineGlobalColor("line", CreateColor(59, 179, 228));
DefineGlobalColor("swa", CreateColor(255, 0, 0));
DefineGlobalColor("purple", Color.MAGENTA);
DefineGlobalColor("orange", Color.ORANGE);
# stoch(source, high, low, length) =>
script stoch {
input src = close;
input h = high;
input l = low;
input len = 14;
def hh = highest(h, len);
def ll = lowest(l, len);
def stoch = 100 * (src - ll) / (hh - ll);
plot return = stoch;
}
def upper = aroonLength - 100 * (GetMaxValueOffset(high, aroonLength + 1) + aroonLength) / aroonLength;
def lower = aroonLength - 100 * (GetMinValueOffset(low, aroonLength + 1) + aroonLength) / aroonLength;
def oscillator = upper - lower;
plot osc = if showAroon then oscillator else na; #, color=red)
plot mp = if showAroon and !last then 0 else na;
plot top = if showAroon and !last then 85 else na;
plot bot = if showAroon and !last then -85 else na;
osc.SetDefaultColor(GlobalColor("swa"));
top.SetDefaultColor(GlobalColor("line"));
bot.SetDefaultColor(GlobalColor("line"));
def co = if oscillator >= 95 and oscillator[1] >= oscillator then -1 else
if oscillator <= -88 then 1 else 0;
def bgswaUp = co > 0 or co[1] > 0;
def bgswaDn = co < 0 or co[1] < 0;
AddCloud(if showAroon and bgswaUp then pos else na, neg, Color.DARK_GREEN);
AddCloud(if showAroon and bgswaDn then pos else na, neg, Color.DARK_RED);
# //rsi
def nRSI = RSI(Price = rsiSource, length = rsiLength);
def mr = Average(nRSI, rsiSmoothing);
plot rsiLine = if showRsi then nRSI else na; #,title="RSI", color=purple,transp=0)
plot smoothRSi = if showRsi then mr else na; #,title="sma RSI", color=red,transp=0)
plot h00 = if !last and showRsi then 70 else na;
plot mid = if !last and showRsi then 50 else na;
plot h11 = if !last and showRsi then 30 else na;
rsiLine.SetDefaultColor(GlobalColor("purple"));
smoothRSi.SetDefaultColor(GlobalColor("orange"));
h00.SetDefaultColor(GlobalColor("line"));
mid.SetDefaultColor(Color.GRAY);
h11.SetDefaultColor(GlobalColor("line"));
#//macd
def fastMA = ExpAverage(macdSource, macdFastLength);
def slowMA = ExpAverage(macdSource, macdSlowLength);
def macd = fastMA - slowMA;
def signal = ExpAverage(macd, macdSignalLength);
def hist = macd - signal;
plot Diff = if showMacd then hist else na; #, color=red, style=histogram)
plot Value = if showMacd then macd else na; #, color=blue)
plot Avg = if showMacd then signal else na; #, color=orange)
Value.SetDefaultColor(GetColor(1));
Avg.SetDefaultColor(GetColor(8));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
#//stoc
def k = Average(stoch(close, high, low, periodK), smoothK);
def d = Average(k, periodD);
plot kLine = if showStochastic then k else na; #, title="%K", color=blue)
plot dLine = if showStochastic then d else na; #, title="%D", color=orange)
def h0 = if !last and (showStochastic) then 80 else na;
def h1 = if !last and (showStochastic) then 20 else na;
AddCloud(h0, h1, Color.PLUM, Color.PLUM, yes);
#//ADX
def hiDiff = high - high[1];
def loDiff = low[1] - low;
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM = if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def trur = atr(Length = diLength);
def plus = 100 * WildersAverage(plusDM, diLength) / trur;
def minus = 100 * WildersAverage(minusDM, diLength) / trur;
def DX = if (plus + minus > 0) then 100 * AbsValue(plus - minus) / (plus + minus) else 0;
def ADX = WildersAverage(DX, adxSmoothingLength);
plot "+DI" = if showAdx then plus else na; #, color=blue, title="+DI")
plot "-DI" = if showAdx then minus else na; #, color=orange, title="-DI")
plot nADX = if showAdx then adx else na; #, color=red, title="ADX")
plot th = if !last and showAdx then adxThreshold else na; #, color=black, title="th")
"+DI".SetDefaultColor(Color.CYAN);
"-DI".SetDefaultColor(Color.DARK_ORANGE);
nADX.SetDefaultColor(Color.WHITE);
th.SetDefaultColor(Color.GRAY);
#-- END of CODE