#aroon_cloud_upper
#https://usethinkscript.com/threads/adding-clouds-to-aroon-indicator.12559/
#Adding Clouds to Aroon Indicator
def na = double.nan;
def bn = barnumber();
def avg1_type = AverageType.exponential;
def avg1_length = 2;
input f = 0.004;
#def f = 0;
def cldhi = MovingAverage(avg1_type, high, avg1_length ) * (1 + f);
def cldlo = MovingAverage(avg1_type, low, avg1_length ) * (1 - f);
# ------------------
# aroon
# declare lower;
input length = 25;
#Assert(length > 0, "'length' must be positive: " + length);
def Up = (length - 1 - GetMaxValueOffset(high, length)) * 100.0 / (length - 1);
def Down = (length - 1 - GetMinValueOffset(low, length)) * 100.0 / (length - 1);
#def OverBought = 70;
#def OverSold = 30;
#Up.SetDefaultColor(GetColor(1));
#Down.SetDefaultColor(GetColor(5));
#OverBought.SetDefaultColor(GetColor(8));
#OverSold.SetDefaultColor(GetColor(8));
AddCloud(if Up > 90 and Down < 10 then cldhi else Double.NEGATIVE_INFINITY, if Up > 90 and Down < 10 then cldlo else Double.NEGATIVE_INFINITY,color.CYAN);
AddCloud(if Up < 10 and Down > 90 then cldlo else Double.NEGATIVE_INFINITY, if Up < 10 and Down > 90 then cldhi else Double.NEGATIVE_INFINITY, color.MAGENTA);
input show_lines = no;
plot z = if show_lines then cldhi else na;
plot z2 = if show_lines then cldlo else na;
#