input price = close;
input deviation2 = 2.0;
input deviation1 = 1.8;
input fullRange = Yes;
input length = 21;
def regression;
def stdDeviation;
if (fullRange) {
regression = InertiaAll(price);
stdDeviation = StDevAll(price);
} else {
regression = InertiaAll(price, length);
stdDeviation = StDevAll(price, length);
}
plot UpperLine = regression + deviation2 * stdDeviation;
plot MiddleLine = regression;
plot LowerLine = regression - deviation2 * stdDeviation;
UpperLine.SetDefaultColor(GetColor(8));
MiddleLine.SetDefaultColor(GetColor(8));
LowerLine.SetDefaultColor(GetColor(8));
def regression1;
def stdDeviation1;
if (fullRange) {
regression1 = InertiaAll(price);
stdDeviation1 = StDevAll(price);
} else {
regression1 = InertiaAll(price, length);
stdDeviation1 = StDevAll(price, length);
}
plot UpperLine1 = regression1 + deviation1 * stdDeviation1;
plot MiddleLine1 = regression1;
plot LowerLine1 = regression1 - deviation1 * stdDeviation1;
Alert(pricetype.mark < UpperLine1, "BEARISH!", Alert.BAR, Sound.Bell);
def price = close;
def deviations = 2.0;
def fullRange = Yes;
def length = 21;
def regression;
def stdDeviation;
if (fullRange) {
regression = InertiaAll(price);
stdDeviation = stdevAll(price);
} else {
regression = InertiaAll(price, length);
stdDeviation = stdevAll(price, length);
}
def UpperLine = regression + deviations * stdDeviation;
def MiddleLine = regression;
def LowerLine = regression - deviations * stdDeviation;
plot scan = close is greater than or equal to lowerline;
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.