CCI with Volume and MA

Zlotko

Active member
VIP
Could someone help with this CCI with Volume and MA Labels? I deleted some text on the end it is not working now.

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 = 34;
input length50 = 55;
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 " (34) " + Average (close, 35) else "", Color.RED);
AddLabel (yes, if close > avg35 then " (34) " + Average (close, 35) else "", Color.GREEN);
AddLabel (yes, if close < avg50 then " (55) " + Average (close, 50) else "", Color.RED);
AddLabel (yes, if close > avg50 then " (55) " + 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);

declare lower;



#THE END------------------------------------------------------------------------------------------------------------
 
Solution
Could someone help with this CCI with Volume and MA Labels? I deleted some text on the end it is not working now.
Label, Lines, Scan and Watchlist Requests:
Labels, lines, watchlist columns and/or scans can usually be easily adapted from existing studies.

The greatest difficulty is that labels, watchlists and scans requires a precise mathematical-based logic.

It is critical that you define your logic map:
if condition 1 is what then what else
if condition 2 is what then what else
if condition 3 is what then what else what?
By providing the EXACT math and logic that you want the label/watchlist/scan, it is a simple step to provide the syntax.

From what I have observed, posts without a visual presentation...
Could someone help with this CCI with Volume and MA Labels? I deleted some text on the end it is not working now.

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 = 34;
input length50 = 55;
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 " (34) " + Average (close, 35) else "", Color.RED);
AddLabel (yes, if close > avg35 then " (34) " + Average (close, 35) else "", Color.GREEN);
AddLabel (yes, if close < avg50 then " (55) " + Average (close, 50) else "", Color.RED);
AddLabel (yes, if close > avg50 then " (55) " + 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);

declare lower;



#THE END------------------------------------------------------------------------------------------------------------
Can you provide what the script looked like before you deleted portions of it?
Plus please detail what you want your labels to display
 
That is all I have after I deleted ;(
Did you know that ToS saves the last 10 versions of your study?
zIXCUkl.png
 
Last edited:
That is the Correct study.

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 = 34;
input length50 = 55;
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 " (34) " + Average (close, 35) else "", Color.RED);
AddLabel (yes, if close > avg35 then " (34) " + Average (close, 35) else "", Color.GREEN);
AddLabel (yes, if close < avg50 then " (55) " + Average (close, 50) else "", Color.RED);
AddLabel (yes, if close > avg50 then " (55) " + 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------------------------------------------------------------------------------------------------------------
 
Could someone help with this CCI with Volume and MA Labels? I deleted some text on the end it is not working now.
Label, Lines, Scan and Watchlist Requests:
Labels, lines, watchlist columns and/or scans can usually be easily adapted from existing studies.

The greatest difficulty is that labels, watchlists and scans requires a precise mathematical-based logic.

It is critical that you define your logic map:
if condition 1 is what then what else
if condition 2 is what then what else
if condition 3 is what then what else what?
By providing the EXACT math and logic that you want the label/watchlist/scan, it is a simple step to provide the syntax.

From what I have observed, posts without a visual presentation indicating the precise points you are attempting to scan seldom get responses.
Unsure of how to upload screenshots to the forum,
Here are directions.
And here are some Cool Tips For Creating The Perfect Post.
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
396 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top