Use this one with thinkorswim program I use it to buy just after all lines go under 15. You will see what I mean after you work with it and in this market you just might need it.
# Capitulation (All lines under 15 (The Green Line)
# Enjoy: 8765309
declare lower;
declare all_for_one;
input over_bought = 80;
input over_sold = 15;
input smoothingType = 1;
input length = 2;
def priceH = high;
def priceL = low;
def priceC = close;
def KPeriod48 = 48;
def DPeriod48 = 3;
def slowing48 = 2;
def KPeriod17 = 17;
def DPeriod17 = 3;
def slowing17 = 5;
def KPeriod8 = 8;
def DPeriod8 = 3;
def slowing8 = 5;
def KPeriod5 = 5;
def DPeriod5 = 3;
def slowing5 = 3;
def KPeriod22 = 2;
def DPeriod22 = 3;
def slowing22 = 2;
def KPeriod211 = 2;
def DPeriod211 = 1;
def slowing211 = 1;
#### Stoc48 ####
def c148 = priceC - Lowest(priceL, KPeriod48);
def c248 = Highest(priceH, KPeriod48) - Lowest(priceL, KPeriod48);
def FastK48 = c148/c248*100;
plot FullK48;
if smoothingType == 1
then {
FullK48 = Average(FastK48, slowing48);
} else {
FullK48 = ExpAverage(FastK48, slowing48);
}
FullK48.setDefaultColor(Color.CYAN);
FullK48.setStyle(Curve.Firm);
FullK48.SetLineWeight(2);
#### Stoc17 ####
def c117 = priceC - Lowest(priceL, KPeriod17);
def c217 = Highest(priceH, KPeriod17) - Lowest(priceL, KPeriod17);
def FastK17 = c117/c217*100;
plot FullK17;
if smoothingType == 1
then {
FullK17 = Average(FastK17, slowing17);
} else {
FullK17 = ExpAverage(FastK17, slowing17);
}
FullK17.setDefaultColor(Color.RED);
FullK17.SetLineWeight(1);
#### Stoc8 ####
def c18 = priceC - Lowest(priceL, KPeriod8);
def c28 = Highest(priceH, KPeriod8) - Lowest(priceL, KPeriod8);
def FastK8 = c18/c28*100;
plot FullK8;
if smoothingType == 1
then {
FullK8 = Average(FastK8, slowing8);
} else {
FullK8 = ExpAverage(FastK8, slowing8);
}
FullK8.setDefaultColor(Color.GREEN);
FullK8.SetLineWeight(1);
#### Stoc5 ####
def c15 = priceC - Lowest(priceL, KPeriod5);
def c25 = Highest(priceH, KPeriod5) - Lowest(priceL, KPeriod5);
def FastK5 = c15/c25*100;
plot FullK5;
if smoothingType == 1
then {
FullK5 = Average(FastK5, slowing5);
} else {
FullK5 = ExpAverage(FastK5, slowing5);
}
FullK5.setDefaultColor(Color.YELLOW);
FullK5.SetLineWeight(1);
#### Stoc223 ####
def c122 = priceC - Lowest(priceL, KPeriod22);
def c222 = Highest(priceH, KPeriod22) - Lowest(priceL, KPeriod22);
def FastK22 = c122/c222*100;
plot FullK22;
if smoothingType == 1
then {
FullK22 = Average(FastK22, slowing22);
} else {
FullK22 = ExpAverage(FastK22, slowing22);
}
FullK22.setDefaultColor(Color.WHITE);
FullK22.SetLineWeight(1);
#### Stoc211 ####
def c1211 = priceC - Lowest(priceL, KPeriod211);
def c2211 = Highest(priceH, KPeriod211) - Lowest(priceL, KPeriod211);
def FastK211 = c1211/c2211*100;
plot FullK211;
if smoothingType == 1
then {
FullK211 = Average(FastK211, slowing211);
} else {
FullK211 = ExpAverage(FastK211, slowing211);
}
FullK211.setDefaultColor(Color.WHITE);
FullK211.SetStyle(Curve.SHORT_DASH);
FullK211.SetLineWeight(1);
def diff = if close > close[1] then close - close[1] else 0;
def diff2 = if close < close[1] then close[1] - close else 0;
rec avg = compoundValue(1, 2 / (length + 1) * diff + (length - 1) / (length + 1) * avg[1], diff * 2 / (length + 1));
rec avg2 = compoundValue(1, 2 / (length + 1) * diff2 + (length - 1) / (length + 1) * avg2[1], diff2 * 2 / (length + 1));
rec avgSMA = compoundValue(1, (avgSMA[1] + diff) / 2, diff);
rec avgSMA2 = compoundValue(1, (avgSMA2[1] + diff2) / 2, diff2);
def value = if avg2 != 0 then 100 - 100 / (1 + avg / avg2) else 0;
def valueSMA = if avg2 != 0 then 100 - 100 / (1 + avgSMA / avgSMA2) else 0;
plot RSI_EMA = ExpAverage(value, 2);
plot RSI_SMA = Average(valueSMA, 2);
RSI_EMA.SetDefaultColor(Color.DARK_ORANGE);
RSI_EMA.SetLineWeight(1);
RSI_SMA.SetDefaultColor(Color.MAGENTA);
RSI_SMA.SetLineWeight(1);
plot ZeroLine = 50;
ZeroLine.setDefaultColor(Color.gray);
ZeroLine.setStyle(Curve.long_Dash);
plot OverBought = over_bought;
OverBought.SetDefaultColor(Color.Red);
plot OverSold = over_sold;
OverSold.SetDefaultColor(Color.Green);
OverBought.SetLineWeight(2);
OverSold.SetLineWeight(2);