I found this in the thinkScript lounge. Anyone knows how this works?
Code:
# Combined Signal P3 Squeeze
# Mobius
# Chat Room 09.01.2020
# PPO
# Mobius
# V01.03.2014
declare lower;
input c = close;
input AvgType = AverageType.Simple;
input nFast = 8;
input nSlow = 13;
input nSmooth = 5;
def h = high;
def l = low;
plot PPO = ((MovingAverage(AverageType = AvgType, c, nFast) -
MovingAverage(AverageType = AvgType, c, nSlow)) /
MovingAverage(AverageType = AvgType, c, nSlow));
plot smooth = MovingAverage(AverageType = AvgType, PPO, nSmooth);
PPO.AssignValueColor(if PPO > smooth
then Color.Green
else Color.Red);
smooth.AssignValueColor(if PPO > smooth
then Color.Green
else Color.Red);
addCloud(PPO, smooth, Color.Green, Color.Red);
# Scale Algorithm
script Scale {
input c = close;
input data = close;
def Min = lowestAll(data);
def Max = highestAll(data);
def hh = HighestAll(c);
def ll = LowestAll(c);
plot Range = (((Max - Min) * (c - ll)) / (hh - ll)) + Min;
}
# Scaled DMI+ DMI-
input length = 14;
input averageType = AverageType.WILDERS;
def hiDiff = h - h[1];
def loDiff = l[1] - l;
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 ATR = MovingAverage(averageType, TrueRange(h, c, l), length);
def Di_plus = MovingAverage(averageType, plusDM, length) / ATR;
def Di_minus = MovingAverage(averageType, minusDM, length) / ATR;
plot DIplus = Scale(c = Di_plus, data = PPO);
plot DIminus = Scale(c = Di_minus, data = PPO);
DIplus.SetDefaultColor(Color.Cyan);
DIminus.SetDefaultColor(Color.Yellow);
addCloud(DIplus, DIminus, Color.Cyan, Color.Yellow);
# End Code # Combined Signal P3 Squeeze