Just change 100 to 200.@horserider hi. thank you for share with us, a quick question, i see the script have overbought 1 and oversold -1, that mean 100 and -100? can you do overbought 200 and oversold -200? thanks
Just change 100 to 200.@horserider hi. thank you for share with us, a quick question, i see the script have overbought 1 and oversold -1, that mean 100 and -100? can you do overbought 200 and oversold -200? thanks
declare lower;
input shortLength = 6;
input longLength = 14;
input lowerSideWinderLimit = 30.0;
input upperSideWinderLimit = 100.0;
input hideSideWinder = No;
def LinearReg = Inertia(close, 25);
def expAvg = ExpAverage(close, 34);
def diff = close - expAvg;
def yyyyMmDd = getYyyyMmDd();
def session_duration_minutes = (regularTradingEnd(yyyyMmDd) - regularTradingStart(yyyyMmDd)) / AggregationPeriod.MIN;
def interval_size_raw;
def aggregation = getAggregationPeriod();
if (aggregation == AggregationPeriod.DAY) {
interval_size_raw = session_duration_minutes * 60;
} else if (aggregation == AggregationPeriod.TWO_DAYS) {
interval_size_raw = session_duration_minutes * 60 * 2;
} else if (aggregation == AggregationPeriod.THREE_DAYS) {
interval_size_raw = session_duration_minutes * 60 * 3;
} else if (aggregation == AggregationPeriod.FOUR_DAYS) {
interval_size_raw = session_duration_minutes * 60 * 4;
} else if (aggregation == AggregationPeriod.WEEK) {
interval_size_raw = session_duration_minutes * 60 * 5;
} else if (aggregation == AggregationPeriod.MONTH or aggregation == AggregationPeriod.OPT_EXP) {
interval_size_raw = session_duration_minutes * 60 * 22;
} else if (aggregation >= AggregationPeriod.MIN) {
interval_size_raw = aggregation / AggregationPeriod.MIN;
} else {
interval_size_raw = aggregation;
}
def ema_angle_factor = Sqrt(interval_size_raw / 180);
def avg_ema = (expAvg[2] + expAvg[1]) / 2;
def avg_lsma = (LinearReg[2] + LinearReg[1]) / 2;
def lsma_slope = (LinearReg - avg_lsma) / tickSize();
def lsma_angle = ATan(lsma_slope / ema_angle_factor) / Double.Pi * 180;
def ema_slope = (expAvg - avg_ema) / tickSize();
def ema_angle = ATan(ema_slope / ema_angle_factor) / Double.Pi * 180;
def sw = lsma_angle + ema_angle;
def swabs = AbsValue(sw);
plot CCI = cci(length = longLength);
plot "CCI Hist" = CCI;
plot "SW +200" = if IsNaN(close) then Double.NaN else 200;
plot "SW -200" = if IsNaN(close) then Double.NaN else -200;
plot ZeroLine = if IsNaN(close) then Double.NaN else 0;
CCI.SetDefaultColor(GetColor(1));
CCI.SetLineWeight(1);
"SW +200".SetDefaultColor(GetColor(1));
"SW +200".SetLineWeight(2);
"SW +200".SetPaintingStrategy(PaintingStrategy.DASHES);
"SW +200".HideTitle();
"SW +200".HideBubble();
"SW +200".DefineColor("Trending", Color.GREEN);
"SW +200".DefineColor("Normal", Color.YELLOW);
"SW +200".DefineColor("Flat", Color.RED);
"SW +200".AssignValueColor(
if swabs >= upperSideWinderLimit then "SW +200".color("Trending")
else if swabs > lowerSideWinderLimit then "SW +200".color("Normal")
else "SW +200".color("Flat"));
"SW -200".AssignValueColor("SW +200".TakeValueColor());
"SW -200".SetDefaultColor(GetColor(1));
"SW -200".SetLineWeight(2);
"SW -200".SetPaintingStrategy(PaintingStrategy.DASHES);
"SW -200".HideTitle();
"SW -200".HideBubble();
ZeroLine.SetDefaultColor(GetColor(9));
ZeroLine.SetPaintingStrategy(PaintingStrategy.DASHES);
ZeroLine.SetLineWeight(1);
ZeroLine.HideTitle();
AddLabel (yes,if close then " CCI " else "", Color.CYAN);
#Label Rise and Fall-------------------------------------------------------------------------------------
input n = 1;
def VUP = CCI > CCI[n];
def VDN = CCI < CCI[n];
AddLabel(1, " CCI : " + Round(CCI, 1) + (if VUP then " RISING " + "" else if VDN then " FALLING " + "" else " --NEUTRAL"),
if VUP then Color.green else if VDN then color.RED else Color.YELLOW);
#end CCI-----------------------------
input Show30DayAvg = yes;
input ShowTodayVolume = yes;
input ShowPercentOf30DayAvg = yes;
input UnusualVolumePercent = 200;
input Show30BarAvg = yes;
input ShowCurrentBar = yes;
input ShowPercentOf30BarAvg = yes;
input ShowSellVolumePercent = yes;
def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def buying = V*(C-L)/(H-L);
def selling = V*(H-C)/(H-L);
#Volume Data
def volLast30DayAvg = (volume(period = "DAY")[1] + volume(period = "DAY")[2] + volume(period = "DAY")[3] + volume(period = "DAY")[4] + volume(period = "DAY")[5] + volume(period = "DAY")[6] + volume(period = "DAY")[7] + volume(period = "DAY")[8] + volume(period = "DAY")[9] + volume(period = "DAY")[10] + volume(period = "DAY")[11] + volume(period = "DAY")[12] + volume(period = "DAY")[13] + volume(period = "DAY")[14] + volume(period = "DAY")[15] + volume(period = "DAY")[16] + volume(period = "DAY")[17] + volume(period = "DAY")[18] + volume(period = "DAY")[19] + volume(period = "DAY")[20] + volume(period = "DAY")[21] + volume(period = "DAY")[22] + volume(period = "DAY")[23] + volume(period = "DAY")[24] + volume(period = "DAY")[25] + volume(period = "DAY")[26] + volume(period = "DAY")[27] + volume(period = "DAY")[28] + volume(period = "DAY")[29] + volume(period = "DAY")[30]) / 30;
def today = volume(period = "DAY");
def percentOf30Day = Round((today / volLast30DayAvg) * 100, 0);
def avg30Bars = (volume[1] + volume[2] + volume[3] + volume[4] + volume[5] + volume[6] + volume[7] + volume[8] + volume[9] + volume[10] + volume[11] + volume[12] + volume[13] + volume[14] + volume[15] + volume[16] + volume[17] + volume[18] + volume[19] + volume[20] + volume[21] + volume[22] + volume[23] + volume[24] + volume[25] + volume[26] + volume[27] + volume[28] + volume[29] + volume[30]) / 30;
def curVolume = volume;
def percentOf30Bar = Round((curVolume / avg30Bars) * 100, 0);
def SellVolPercent = Round((Selling / Volume) * 100, 0);
# Labels-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
AddLabel (yes,if close then " V " else "", Color.CYAN);
AddLabel(ShowSellVolumePercent, " Volume %: " + SellVolPercent, (if SellVolPercent >= 51 then Color.RED else if SellVolPercent < 49 then Color.GREEN else Color.GREEN));
#Branch Moving Averages Label ---------------------------------------------------------------------------
#MOVING AVERAGES-----------------------------------------------------------------
input length2 = 2;
input length5 = 5;
input length8 = 8;
input length10 = 10;
input length13 = 13;
input length21 = 21;
input length35 = 35;
input length50 = 50;
input length100 = 100;
input length200 = 200;
input over_Bought = 80;
input over_Sold = 20;
input price = close;
input averageType = AverageType.SIMPLE;
input showBreakoutSignals = no;
input averageType1 = AverageType.SIMPLE;
input crossingType = {default above, below};
def NetChgAvg = MovingAverage(averageType, price - price[1], length10);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length10);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def avg2 = MovingAverage(averageType1, price, length2);
def avg5 = MovingAverage(averageType1, price, length5);
def avg8 = MovingAverage(averageType1, price, length8);
def avg10 = MovingAverage(averageType1, price, length10);
def avg13 = MovingAverage(averageType1, price, length13);
def avg21 = MovingAverage(averageType1, price, length21);
def avg35 = MovingAverage(averageType1, price, length35);
def avg50 = MovingAverage(averageType1, price, length50);
def avg100 = MovingAverage(averageType1, price, length100);
def avg200 = MovingAverage(averageType1, price, length200);
#MOVING AVERGERS LABELS-----------------------------------------------------------------------------------
AddLabel (yes, if close then " MA " else "", Color.CYAN);
AddLabel(yes, if close < avg2 then " (2) " + Average (close, 2) else "", Color.RED);
AddLabel (yes, if close > avg2 then " (2) " + Average (close, 2) else "", Color.GREEN);
AddLabel(yes, if close < avg5 then " (5) " + Average (close, 5) else "", Color.RED);
AddLabel (yes, if close > avg5 then " (5) " + Average (close, 5) else "", Color.GREEN);
AddLabel(yes, if close < avg8 then " (8) " + Average (close, 8) else "", Color.RED);
AddLabel (yes, if close > avg8 then " (8) " + Average (close, 8) else "", Color.GREEN);
AddLabel(yes, if close < avg10 then " (10) " + Average (close, 10) else "", Color.RED);
AddLabel (yes, if close > avg10 then " (10) " + Average (close, 10) else "", Color.GREEN);
AddLabel(yes, if close < avg13 then " (13) " + Average (close, 13) else "", Color.RED);
AddLabel (yes, if close > avg13 then " (13) " + Average (close, 13) else "", Color.GREEN);
AddLabel (yes, if close < avg21 then " (21) " + Average (close, 21) else "", Color.RED);
AddLabel (yes, if close > avg21 then " (21) " + Average (close, 21) else "", Color.GREEN);
AddLabel (yes, if close < avg35 then " (35) " + Average (close, 35) else "", Color.RED);
AddLabel (yes, if close > avg35 then " (35) " + Average (close, 35) else "", Color.GREEN);
AddLabel (yes, if close < avg50 then " (50) " + Average (close, 50) else "", Color.RED);
AddLabel (yes, if close > avg50 then " (50) " + Average (close, 50) else "", Color.GREEN);
AddLabel (yes, if close < avg100 then " (100) " + Average (close, 100) else "", Color.RED);
AddLabel (yes, if close > avg100 then " (100) " + Average (close, 100) else "", Color.GREEN);
AddLabel (yes, if close < avg200 then " (200) " + Average (close, 200) else "", Color.RED);
AddLabel (yes, if close > avg200 then " (200) " + Average (close, 200) else "", Color.GREEN);
#THE END------------------------------------------------------------------------------------------------------------
input cciAvgLength = 9;
def CCIAvg = Average(CCI(14), cciAvgLength);
addLabel(3,"BAR 3 " + (cciavg[3] - cciAvg[4]));
addLabel(2,"BAR 2 " + (cciavg[2] - cciAvg[3]));
AddLabel(1, "BAR 1 " + (cciavg[1] - cciAvg[2]));
this script is doing exactly what I want however I can't figure out how to get the labels to change color based on their value.
input cciAvgLength = 9;
def CCIAvg = Average(CCI(14), cciAvgLength);
addLabel(3,"BAR 3 " + (cciavg[3] - cciAvg[4]), if (cciavg[3] - cciAvg[4])>0 then color.green else color.red);
addLabel(2,"BAR 2 " + (cciavg[2] - cciAvg[3]));
AddLabel(1, "BAR 1 " + (cciavg[1] - cciAvg[2]));
Ah, I see. Thank you!
# ########################################################
# TOS CCI Average Labels & Watchlist by @MerryDay 12/20
# https://www.stockmarkethacks.com/commodity-channel.html
declare lower;
def cci_length = 14 ;
def cci_avg_length = 9 ;
def over_sold = -100 ;
def over_bought = 100 ;
def CCI = reference CCIAverage("cci length" = cci_length, "cci avg length" = cci_avg_length)."CCI" ;
def CCIAvg = reference CCIAverage("cci length" = cci_length, "cci avg length" = cci_avg_length)."CCIAvg" ;
# ########################################################
# Charting & Formatting
AddLabel(yes,
if CCI < over_sold and CCI >=CCIAvg then "BUY " + Round(CCI, 0) else
if CCI < over_sold and CCI > CCI[1] then "Reversing " + Round(CCI, 0) else
if CCI < over_sold then "Bottom " + Round(CCI, 0) else
if CCI >= over_bought and CCI >= CCI[1] then "Strong Trend " + Round(CCI, 0) else
if CCI > over_bought then "Watch It " + Round(CCI, 0) else
if CCI crosses above CCIAvg then "TREND BEGIN " + Round(CCI, 0) else
if CCI crosses below CCIAvg then "TREND END " + Round(CCI, 0) else
if CCI < CCIAvg and CCI>CCI[1] then "pre-trend " + Round(CCI, 0) else
if CCI > CCI[1] then "👍 " + Round(CCI, 0) else
"👎 " + Round(CCI, 0) );
AssignBackgroundColor(
if CCI < over_sold and CCI >=CCIAvg then color.cyan else
if CCI < over_sold and CCI > CCI[1] then color.cyan else
if CCI < over_sold then CreateColor(124, 10, 2) else
if CCI > over_bought and CCI > CCI[1] then color.dark_orange else
if CCI > over_bought then CreateColor(153, 153, 255) else
if CCI crosses above CCIAvg then CreateColor(0, 0, 255) else
if CCI crosses below CCIAvg then CreateColor(255, 204, 0) else
if CCI < CCIAvg and CCI>CCI[1] then color.violet else
if CCI > CCI[1] then color.green else
CreateColor(225, 0, 0) ) ;
@MerryDay per your request of using color.black on text and change "TREND BEGIN" to color.lime. Thanks again. Good luck! @cabe1332@cabe1332
As many members use dark mode, could you post your dark-mode friendly version of the watchlist?
# TOS CCI Average Labels & Watchlist by @MerryDay 12/20
# https://www.stockmarkethacks.com/commodity-channel.html
# declare lower;
def cci_length = 14 ;
def cci_avg_length = 9 ;
def over_sold = -100 ;
def over_bought = 100 ;
def CCI = reference CCIAverage("cci length" = cci_length, "cci avg length" = cci_avg_length)."CCI" ;
def CCIAvg = reference CCIAverage("cci length" = cci_length, "cci avg length" = cci_avg_length)."CCIAvg" ;
# Charting & Formatting
AddLabel(yes,
if CCI < over_sold and CCI >=CCIAvg then "BUY " + Round(CCI, 0) else
if CCI < over_sold and CCI > CCI[1] then "Reversing " + Round(CCI, 0) else
if CCI < over_sold then "Bottom " + Round(CCI, 0) else
if CCI >= over_bought and CCI >= CCI[1] then "Strong Trend " + Round(CCI, 0) else
if CCI > over_bought then "Watch It " + Round(CCI, 0) else
if CCI crosses above CCIAvg then "TREND BEGIN " + Round(CCI, 0) else
if CCI crosses below CCIAvg then "TREND END " + Round(CCI, 0) else
if CCI < CCIAvg and CCI>CCI[1] then "Pre-Trend " + Round(CCI, 0) else
if CCI > CCI[1] then "👍 " + Round(CCI, 0) else
"👎 " + Round(CCI, 0), color.black );
AssignBackgroundColor(
if CCI < over_sold and CCI >=CCIAvg then color.cyan else
if CCI < over_sold and CCI > CCI[1] then color.cyan else
if CCI < over_sold then CreateColor(124, 10, 2) else
if CCI > over_bought and CCI > CCI[1] then color.dark_orange else
if CCI > over_bought then CreateColor(153, 153, 255) else
#if CCI crosses above CCIAvg then CreateColor(0, 0, 255) else
if CCI crosses above CCIAvg then color.lime else
if CCI crosses below CCIAvg then CreateColor(255, 204, 0) else
if CCI < CCIAvg and CCI>CCI[1] then color.violet else
if CCI > CCI[1] then color.green else
CreateColor(225, 0, 0) ) ;
# code end
@MerryDay per your request of using color.black on text and change "TREND BEGIN" to color.lime. Thanks again. Good luck! @cabe1332
Ruby:# TOS CCI Average Labels & Watchlist by @MerryDay 12/20 # https://www.stockmarkethacks.com/commodity-channel.html # declare lower; def cci_length = 14 ; def cci_avg_length = 9 ; def over_sold = -100 ; def over_bought = 100 ; def CCI = reference CCIAverage("cci length" = cci_length, "cci avg length" = cci_avg_length)."CCI" ; def CCIAvg = reference CCIAverage("cci length" = cci_length, "cci avg length" = cci_avg_length)."CCIAvg" ; # Charting & Formatting AddLabel(yes, if CCI < over_sold and CCI >=CCIAvg then "BUY " + Round(CCI, 0) else if CCI < over_sold and CCI > CCI[1] then "Reversing " + Round(CCI, 0) else if CCI < over_sold then "Bottom " + Round(CCI, 0) else if CCI >= over_bought and CCI >= CCI[1] then "Strong Trend " + Round(CCI, 0) else if CCI > over_bought then "Watch It " + Round(CCI, 0) else if CCI crosses above CCIAvg then "TREND BEGIN " + Round(CCI, 0) else if CCI crosses below CCIAvg then "TREND END " + Round(CCI, 0) else if CCI < CCIAvg and CCI>CCI[1] then "Pre-Trend " + Round(CCI, 0) else if CCI > CCI[1] then "👍 " + Round(CCI, 0) else "👎 " + Round(CCI, 0), color.black ); AssignBackgroundColor( if CCI < over_sold and CCI >=CCIAvg then color.cyan else if CCI < over_sold and CCI > CCI[1] then color.cyan else if CCI < over_sold then CreateColor(124, 10, 2) else if CCI > over_bought and CCI > CCI[1] then color.dark_orange else if CCI > over_bought then CreateColor(153, 153, 255) else #if CCI crosses above CCIAvg then CreateColor(0, 0, 255) else if CCI crosses above CCIAvg then color.lime else if CCI crosses below CCIAvg then CreateColor(255, 204, 0) else if CCI < CCIAvg and CCI>CCI[1] then color.violet else if CCI > CCI[1] then color.green else CreateColor(225, 0, 0) ) ; # code end
hi all. New here as a member but have been using this CCI watchlist for a few weeks doing paper TOS trades and LOVE the results. I **** at coding and have a question. Is this same type of watchlist column possible with a True Strength Indicator (TSI)?View attachment 1010
CCI Stages Watchlist Column Color Key:
Same data as post#1. Changed up the look a wee bit.
View attachment 1011
the shared watchlist column link: http://tos.mx/Pmnncmk Click here for --> Easiest way to load shared links
View attachment 1012
CCI Stages Watchlist code:
Ruby:# ######################################################## # TOS CCI Average Labels & Watchlist by @MerryDay 12/20 # https://www.stockmarkethacks.com/commodity-channel.html declare lower; def cci_length = 14 ; def cci_avg_length = 9 ; def over_sold = -100 ; def over_bought = 100 ; def CCI = reference CCIAverage("cci length" = cci_length, "cci avg length" = cci_avg_length)."CCI" ; def CCIAvg = reference CCIAverage("cci length" = cci_length, "cci avg length" = cci_avg_length)."CCIAvg" ; # ######################################################## # Charting & Formatting AddLabel(yes, if CCI < over_sold and CCI >=CCIAvg then "BUY " + Round(CCI, 0) else if CCI < over_sold and CCI > CCI[1] then "Reversing " + Round(CCI, 0) else if CCI < over_sold then "Bottom " + Round(CCI, 0) else if CCI >= over_bought and CCI >= CCI[1] then "Strong Trend " + Round(CCI, 0) else if CCI > over_bought then "Watch It " + Round(CCI, 0) else if CCI crosses above CCIAvg then "TREND BEGIN " + Round(CCI, 0) else if CCI crosses below CCIAvg then "TREND END " + Round(CCI, 0) else if CCI < CCIAvg and CCI>CCI[1] then "pre-trend " + Round(CCI, 0) else if CCI > CCI[1] then "👍 " + Round(CCI, 0) else "👎 " + Round(CCI, 0) ); AssignBackgroundColor( if CCI < over_sold and CCI >=CCIAvg then color.cyan else if CCI < over_sold and CCI > CCI[1] then color.cyan else if CCI < over_sold then CreateColor(124, 10, 2) else if CCI > over_bought and CCI > CCI[1] then color.dark_orange else if CCI > over_bought then CreateColor(153, 153, 255) else if CCI crosses above CCIAvg then CreateColor(0, 0, 255) else if CCI crosses below CCIAvg then CreateColor(255, 204, 0) else if CCI < CCIAvg and CCI>CCI[1] then color.violet else if CCI > CCI[1] then color.green else CreateColor(225, 0, 0) ) ;
@cabe1332 @Hybety Based on poster feedback, I re-created this post with clear explanations. Hope this helps.
TSI & CCI are both trend indicators. It would not be necessary to have BOTH on your charts. This can sometimes lead to Analysis Paralysis.hi all. New here as a member but have been using this CCI watchlist for a few weeks doing paper TOS trades and LOVE the results. I **** at coding and have a question. Is this same type of watchlist column possible with a True Strength Indicator (TSI)?
I use the TSI in think or swim and really like it as well for confirmations.
Thanks for ALL the hard work and passion you folks put into your work.
Eddie.
Trading experience: Over 3 years on options and futures
Trading platform: Think or Swim
Coding experience: Almost zero. What I have learned and used has been from public forums such as this and a few others
Thanks for the kwik reply. I have momentum, vol and directional indicators for confirmation and like the TSI best. If a similar watchlist column as this CCI was available/possible with the TSI I would rather use it. If not, I appreciate the great work on the CCI and look forward to more great work/ideas here.TSI & CCI are both trend indicators. It would not be necessary to have BOTH on your charts. This can sometimes lead to Analysis Paralysis.
You want to have different TYPES of indicators on your charts.
Read more here:
https://usethinkscript.com/threads/...nt-to-successful-trading-in-thinkorswim.6114/
https://usethinkscript.com/threads/what-are-the-different-types-of-indicators-heres-one-answer.298/
Do you have a link to the TSI script that you are using?Thanks for the kwik reply. I have momentum, vol and directional indicators for confirmation and like the TSI best. If a similar watchlist column as this CCI was available/possible with the TSI I would rather use it. If not, I appreciate the great work on the CCI and look forward to more great work/ideas here.
Currently I only use the true strength index Think or Swim has built in for charts. Here is a watchlist script I had copied from a forum (memory is crap and don't remember where I got it or I would give the source credit) that I stopped using when I found the CCI watchlist here.Do you have a link to the TSI script that you are using?
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.