JP782
Active member
Im trying to downsize the amount of junk on my screen and want to have Labels that tell which standard deviation level close is at.
I have no clue where to start... The way Im trying to do it adding conditions for every instance seems insane and loads my screen up with too many labels
Is there a way to have ONE label where the data changes in it telling me the current Std Dev level the close price is at??
Here is the code Im using (measure outs to 4 Devs)
I have no clue where to start... The way Im trying to do it adding conditions for every instance seems insane and loads my screen up with too many labels
Is there a way to have ONE label where the data changes in it telling me the current Std Dev level the close price is at??
Here is the code Im using (measure outs to 4 Devs)
Ruby:
# Standard 4Devs
input price = close;
input deviations1 = 1.0;
input deviations2 = 2.0;
input deviations3 = 3.0;
input deviations4 = 4.0;
input deviations5 = .5;
input deviations6 = 1.5;
input deviations7 = 2.5;
input deviations8 = 3.5;
input fullRange = Yes;
input length = 21;
def regression;
def stdDeviation;
if (fullRange) {
regression = InertiaAll(price, extendToRight = yes);
stdDeviation = stdevAll(price, extendToRight = yes);
} else {
regression = InertiaAll(price, length);
stdDeviation = stdevAll(price, length);
}
plot MiddleLine = regression;
MiddleLine.setLineWeight(2);
MiddleLine.SetPaintingStrategy(PaintingStrategy.LINE);
plot UpperLine = regression + deviations1 * stdDeviation;
UpperLine.SetPaintingStrategy(PaintingStrategy.LINE);
UpperLine.setLineWeight(2);
plot LowerLine = regression - deviations1 * stdDeviation;
LowerLine.SetPaintingStrategy(PaintingStrategy.LINE);
LowerLine.setLineWeight(2);
plot UpperLine2 = regression + deviations2 * stdDeviation;
UpperLine2.SetPaintingStrategy(PaintingStrategy.LINE);
UpperLine2.setLineWeight(2);
plot LowerLine2 = regression - deviations2 * stdDeviation;
LowerLine2.SetPaintingStrategy(PaintingStrategy.LINE);
LowerLine2.setLineWeight(2);
plot UpperLine3 = regression + deviations3 * stdDeviation;
UpperLine3.SetPaintingStrategy(PaintingStrategy.LINE);
UpperLine3.setLineWeight(2);
plot LowerLine3 = regression - deviations3 * stdDeviation;
LowerLine3.SetPaintingStrategy(PaintingStrategy.LINE);
LowerLine3.setLineWeight(2);
plot UpperLine4 = regression + deviations4 * stdDeviation;
UpperLine4.SetPaintingStrategy(PaintingStrategy.LINE);
UpperLine4.setLineWeight(2);
plot LowerLine4 = regression - deviations4 * stdDeviation;
LowerLine4.SetPaintingStrategy(PaintingStrategy.LINE);
LowerLine4.setLineWeight(2);
# half devs
plot UpperLine5 = regression + deviations5 * stdDeviation;
UpperLine5.SetStyle(Curve.SHORT_DASH);
UpperLine5.setLineWeight(2);
plot LowerLine5 = regression - deviations5 * stdDeviation;
LowerLine5.SetStyle(Curve.SHORT_DASH);
LowerLine5.setLineWeight(2);
plot UpperLine6 = regression + deviations6 * stdDeviation;
UpperLine6.SetStyle(Curve.SHORT_DASH);
UpperLine6.setLineWeight(2);
plot LowerLine6 = regression - deviations6 * stdDeviation;
LowerLine6.SetStyle(Curve.SHORT_DASH);
LowerLine6.setLineWeight(2);
plot UpperLine7 = regression + deviations7 * stdDeviation;
UpperLine7.SetStyle(Curve.SHORT_DASH);
UpperLine7.setLineWeight(2);
plot LowerLine7 = regression - deviations7 * stdDeviation;
LowerLine7.SetStyle(Curve.SHORT_DASH);
LowerLine7.setLineWeight(2);
plot UpperLine8 = regression + deviations8 * stdDeviation;
UpperLine8.SetStyle(Curve.SHORT_DASH);
UpperLine8.setLineWeight(2);
plot LowerLine8 = regression - deviations8 * stdDeviation;
LowerLine8.SetStyle(Curve.SHORT_DASH);
LowerLine8.setLineWeight(2);
# Colors
MiddleLine.SetDefaultColor(GetColor(7));
UpperLine5.SetDefaultColor(GetColor(0));
LowerLine5.SetDefaultColor(GetColor(0));
# 1dev
UpperLine.SetDefaultColor(GetColor(1));
LowerLine.SetDefaultColor(GetColor(1));
UpperLine6.SetDefaultColor(GetColor(1));
LowerLine6.SetDefaultColor(GetColor(1));
# 2dev
UpperLine2.SetDefaultColor(GetColor(4));
LowerLine2.SetDefaultColor(GetColor(4));
UpperLine7.SetDefaultColor(GetColor(4));
LowerLine7.SetDefaultColor(GetColor(4));
# 3dev
UpperLine3.SetDefaultColor(Color.LIGHT_RED);
LowerLine3.SetDefaultColor(Color.LIGHT_RED);
UpperLine8.SetDefaultColor(GetColor(5));
LowerLine8.SetDefaultColor(GetColor(5));
# 4dev
UpperLine4.SetDefaultColor(Color.DARK_RED);
LowerLine4.SetDefaultColor(Color.DARK_RED);
Last edited by a moderator: