Supertrend CCI ATR in 1 Plot For Mobile For ThinkOrSwim

@BenTen for a swing trade of 3-5 days, would you use 15 minute, 4 hour, and Day as your 3 aggs to start with? Also, I believe the chart bubbles would need to be adjusted.
@Tostechnical Read up on CCI if you are not familiar with its nuances. Also use this tab in TOS to learn more: Click Education>Learning Center>Technical Analysis.
 

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

@markos I am pretty familiar with the nuances, seems like these dashboards of MTF kinda take them out. Viewing CCI on its own allows me to see them. I pretty much left this indicator because it leaves out a lot of data you cannot see in the dots.

After using it, IMO it seems like a standalone CCI would be better, and just use a flex grid for different time frames. This brings up a bigger issues I have with CSA indicators like the CSA dashboard. Although they do allow you to combine multiple indicators or timeframes into one, a big problem with them is that you cannot see the nuances of the indicators. Such as divergences, whether the indicators is making new highs/lows, how steep is the slope of the indicator, and the distance between indicator and signal lines. I tried adding those data points into a CSA indicator like the one above but it jsut became too cluttered.

Just my two cents.
 
This code has been posted before but I was wondering if someone can help me delete the gray line that gets plotted, and just keep the cyan and magenta colors. Thanks in advance
Code:
def c = close;
def h = high;
def l = low;
def pricedata = hl2;

#SUPERTREND
input tradesize = 2;
input ST_Atr_Mult = 1.0;
input ST_Length = 4;
input ST_AvgType = AverageType.HULL;

def ATR = MovingAverage(ST_AvgType, TrueRange(high, close, low), ST_Length);
def UP = HL2 + (ST_Atr_Mult * ATR);
def DN = HL2 + (-ST_Atr_Mult * ATR);
def ST = if close < ST[1] then UP else DN;

def SuperTrend = ST;


#CCI_ATR
input lengthCCI = 50;
input lengthATR = 21;
input AtrFactor = 1.0;

def ATRcci = Average(TrueRange(h, c, l), lengthATR) * AtrFactor;
def price = c + l + h;
def linDev = LinDev(price, lengthCCI);
def CCI = if linDev == 0
          then 0
          else (price - Average(price, lengthCCI)) / linDev / 0.015;

def MT1 = if CCI > 0
          then Max(MT1[1], pricedata - ATRcci)
          else Min(MT1[1], pricedata + ATRcci);
def CCI_ATR_TREND = MT1;

plot ST_ATR_COMBO = if c > ST and c > CCI_ATR_TREND then Min(CCI_ATR_TREND, ST) else if c < ST and c < CCI_ATR_TREND then Max(CCI_ATR_TREND, ST) else CCI_ATR_TREND;

ST_ATR_COMBO.AssignValueColor(if c < MT1 and c < ST then Color.MAGENTA else if c > MT1 and c > ST then Color.CYAN else Color.LIGHT_GRAY);
ST_ATR_COMBO.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
 
Why?
There is only one plot. The gray points are areas where c is equal to MT1 and ST. So a flat area. It is showing an area of consolidation. But if you want gray to be gone you could use this code instead.

ST_ATR_COMBO.AssignValueColor(if c < MT1 and c < ST then Color.MAGENTA else Color.CYAN );
 
NFTuh6U.png


@horserider As you can see it gives me wrong entries
 
I would use cross of price just looking at it. I do not use this study so not familiar with how it works in trading. I was just commenting on how the code worked. Maybe someone else can answer.
 
Can someone help to make this watchlist column script to show the bearish signal? This one only show the bullish signal.
 
Leakywaders... Great minds must think alike as I created a ST_SuperTrend_CCI_ATR_Combo as well with the help of a friend (the ST in the name) using Mobius's SuperTrend and CCI ATR as well and I shared it in the TSL room in Feb because I used Mobius's studies to create them and wanted to show him. Your code does look different and the study looks different so I am going to share my study here for you and all others to check out. Mine creates a cloud range area and has a bunch of other labels ,bubbles, color candle options and other bells and whistles with on off toggles to make it look any way others want to see it and use it. The settings are a little different too so check it out and tell me what you all think.

ST_SuperTrend_CCI_ATR_Combo https://tos.mx/RKdoB7q

Thanks

Hguru
Hello Hguru, Could you possibly modify this code to be used in a watchlist. i'd like to be able to see the Buy / Sell Signals across Mutiple Timeframes.

Code:
# SuperTrend CCI ATR Base
# hguru | Paris | BLT
# 5.27.2019

# Paris: I dissected the ST Supertrend CCI ATR study hguru posted earlier,
# this combo study is a mashup of three major components (1) Super Trend
# Syracuse + BLT Extensions  (2) Mobius CCI ATR Trendline and (3) Combo
# Additions from Ghost. I have sectionalized the study, moved some of the
# variable/input definitions to the appropriate segment, and inserted the
# headers for any future work surrounding this study. Loaded it, and it
# works great.
#
# Paris: From an earlier request from hguru, I coordinated an MTF approach
# to this study with "extensive" collaboration from BLT. The code has been
# reorganized as well as introduced other mods to accomodate a MTF look.
#
# Due to the complexities of the info being processed, the approach taken
# does not streamline combining the MTF in a single study as found in many
# other MTF studies previously posted. Rather, we have implemented this
# MTF using the following two studies
#
# [1] SuperTrend CCI ATR Base
# [2] SuperTrend CCI ATR HigherAgg
#
# The 'base' study is used with possible settings made for the chart agg
# while the 'higher agg' study is configured for the type of settings one
# wants for those higher aggs. There are very slight differences between
# these two studies.
#
# To run through an illustration, for a 5m/15m/30m MTF setup, we have a
# 'base' set at 5m with two 'higher agg' set at 15m and 30m. For an actual
# chart setup, please refer to the attached tos.mx link.
#
# If you'd like an alternate MTF setup, say 4hour, Day, and Week, set the
# base aggregation to 4h, and two instances of the higher aggregation study,
# one to Day, and the other to Week. You get the idea.
#
# There is a workaround for the entry/exit arrows/bubbles and vertical
# lines to only display the first bar of the 'higher agg' being displayed
# on the 'lower agg'. Usually, when a condition is met on a 'higher agg'
# being displayed on the 'lower agg', an arrow, bubble or vertical is
# displayed on each bar of the 'lower agg' for the 'higher agg' period.

input agg = AggregationPeriod.FIVE_MIN;
def c = close(period = agg);
def h = high(period = agg);
def l = low(period = agg);
def pricedata = hl2(period = agg);

input pricecolor = {none, default combopricecolor, stpricecolor,  CCIATRPriceColor};

input showentrybubble = yes;
input number_entry_bubbles_tobe_displayed = 3;
input showlocationbubble = no;
input showpositionbubble = no;

input show_cloud = yes;
input show_vertLine = yes;
input show_entryarrows = yes;

DefineGlobalColor("TrendUp", CreateColor(0, 255, 255));
DefineGlobalColor("TrendDown", CreateColor(0, 102, 255));

# Super Trend Syracuse + BLT Extensions + PSAR
# Syracuse
# 10.29.2018

# This SuperTrend might be the best one as it does not 
# sit on top of a candle it gives room to make decisions

#============================= SuperTrend 2016 ===========================#
#==================== Translation for TOS by Syracusepro =================#
input Factor = 1.3;
input Pd = 60;
input Lookback = 3;

def atr_st = Average(TrueRange(h, c, l), Pd);
def Up = pricedata[Lookback] - (Factor * atr_st);
def Dn = pricedata[Lookback] + (Factor * atr_st);
def TrendUp = if c > TrendUp[1] then Max(Up, TrendUp[1]) else Up;
def TrendDown = if c < TrendDown[1] then Min(Dn, TrendDown[1]) else Dn;
def Trend = if c > TrendDown[1] then 1 else if c < TrendUp[1] then -1 else (Trend[1]);
def Trendbn = if c > TrendDown[1] then BarNumber() else if c < TrendUp[1] then BarNumber() else (Trendbn[1]);
def Trendc = if c > TrendDown[1] then c else if c < TrendUp[1] then c else (Trendc[1]);

plot Tsl = if Trend == 1 then TrendUp else TrendDown;
Tsl.AssignValueColor(if Trend == 1 then GlobalColor("TrendUp") else GlobalColor("TrendDown"));
Tsl.SetLineWeight(1);

plot entryArrow = (if Trend == 1 and Trend[1] == -1 then First(Trendbn) else Double.NaN); #Up Entry Arrow
entryArrow.SetDefaultColor(Color.WHITE);
entryArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
entryArrow.SetHiding(!show_entryarrows);

plot exitArrow = (if Trend == -1 and Trend[1] == 1 then First(Trendbn) else Double.NaN); #Down Entry Arrow
exitArrow.SetDefaultColor(Color.YELLOW);
exitArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
exitArrow.SetHiding(!show_entryarrows);

#========================== End SuperTrend 2016 ===========================#

# CCI_ATR Trendline
# Mobius | Syracusepro
# Chat room request 01.28.2016
# 10.31.2018

# CCI is a study that measures distance from the mean. This study plots
# a trend line based on that distance using ATR as the locator for the line.

input lengthCCI = 20;
input lengthATR = 4;
input AtrFactor = 0.7;

def ATRcci = Average(TrueRange(h, c, l), lengthATR) * AtrFactor;
def price = c + l + h;
def linDev = LinDev(price, lengthCCI);
def CCI = if linDev == 0
          then 0
          else (price - Average(price, lengthCCI)) / linDev / 0.015;
def MT1 = if CCI > 0
          then Max(MT1[1], pricedata - ATRcci)
          else Min(MT1[1], pricedata + ATRcci);
plot data = MT1;
data.AssignValueColor(if c < MT1 then Color.RED else Color.GREEN);#TAKEN FROM SUPERTREND AND APPLIED ACCORDING THE VARIABLES FOR GREEN, RED LINE -----#

# End Code CCI_ATR Trend

########################################################
# Combo Additions
# Ghost / Hguru
# 2.3.2019

def ComboUpTrend = data > Tsl;
def ComboDnTrend = data < Tsl;
def crossup = ComboUpTrend == 1 and ComboUpTrend[1] <> 1;
def crossdn = ComboDnTrend == 1 and ComboDnTrend[1] <> 1;

AddCloud(if show_cloud and ComboUpTrend == 1 then data
                             else Double.NaN, if show_cloud and ComboUpTrend then Tsl
                             else Double.NaN, GlobalColor("TrendUp"), GlobalColor("TrendUp"));
AddCloud(if show_cloud and ComboDnTrend == 1 then Tsl
                             else Double.NaN, if show_cloud and ComboDnTrend == 1 then data
                             else Double.NaN, GlobalColor("TrendDown"), GlobalColor("TrendDown"));

AddVerticalLine(show_vertLine and entryarrow , astext(c), Color.UPTICK, Curve.POINTS);
AddVerticalLine(show_vertLine and exitarrow, astext(c), Color.DOWNTICK, Curve.POINTS);

################################################################
#Price Color

#Combo pricecolor
AssignPriceColor(if pricecolor == pricecolor.combopricecolor
                 then if ComboUpTrend == 1
                      then Color.GREEN
                      else if ComboDnTrend == 1 then Color.RED
                 else Color.GRAY else Color.CURRENT);

#Supertrend pricecolor
AssignPriceColor(if pricecolor == pricecolor.stpricecolor
                 then if !IsNaN(entryArrow)
                      then Color.WHITE   
                      else if !IsNaN(exitArrow)   
                      then Color.YELLOW
                      else if Trend == 1
                      then Color.GREEN
                      else if Trend == -1 then Color.RED
                 else Color.CURRENT else Color.CURRENT);

#CCI ATR pricecolor
AssignPriceColor(if pricecolor == pricecolor.CCIATRPriceColor and c < MT1
                 then GlobalColor("TrendDown")
                 else if pricecolor == pricecolor.CCIATRPriceColor and c > MT1
                      then GlobalColor("TrendUp")
                      else Color.CURRENT);

#################################################################
#Bubbles

#Buy/Sell Bubbles
input buysell_bubblemoversideways = 0;
def bm = buysell_bubblemoversideways + 1;
input buysell_bubblemoverupdown = 10;

def dataCount         = CompoundValue(1, if !IsNaN(entryArrow) or !IsNaN(exitArrow)
                                         then dataCount[1] + 1
                                         else dataCount[1], 0);
def HUp    = if entryarrow then l else double.nan ;
def HDn    = if exitarrow  then h else double.nan;

AddChartBubble(showentrybubble and crossdn and HighestAll(dataCount) - dataCount <= number_entry_bubbles_tobe_displayed - 1, hdn + ticksize()*buysell_bubblemoverupdown, agg/60000 + " min\nSell @ " + astext(c), Color.MAGENTA, yes);
AddChartBubble(showentrybubble and crossup and HighestAll(dataCount) - dataCount <= number_entry_bubbles_tobe_displayed - 1, hup-ticksize()*buysell_bubblemoverupdown, agg/60000 + " min\nBuy @ " + astext(c), Color.YELLOW, no);

#Location Bubble - Supertrend
input Location_Horizontal = 3;
input Location_Vertical = 0;

def X_h = Location_Horizontal;
def Y_v = Location_Vertical;
def X_h1  = X_h + 1;

input Location_bubbledecimal = 2;
AddChartBubble(showlocationbubble and IsNaN(c[X_h]) and !IsNaN(c[X_h1]), close[X_h1] + TickSize() * Y_v,  "ST: " + Round(Tsl[X_h1], Location_bubbledecimal), if Trend[X_h1] == 1 then Color.GREEN else
Color.PINK, no);#if Trend[X_h1] == -1 then Color.MAGENTA else Color.WHITE, no);

#Position Bubble - Supertrend
input Position_bubblemoverside = 3;
def bubm = Position_bubblemoverside + 1;
input Position_bubblemoverVert   = 0;
input Position_bubbledec = 2;

AddChartBubble(showpositionbubble and IsNaN(close[Position_bubblemoverside]) and !IsNaN(close[bubm]), Tsl[bubm] + Position_bubblemoverVert * TickSize(), "ST      " + Round(Tsl[bubm], Position_bubbledec), if Tsl[bubm]
< data[bubm] then Color.MAGENTA else Color.YELLOW, if Tsl[bubm] < data[bubm] then no else yes);

#Position Bubble - CCI
AddChartBubble(showpositionbubble and IsNaN(close[Position_bubblemoverside]) and !IsNaN(close[bubm]), data[bubm] + Position_bubblemoverVert * TickSize(), "CCI      " + Round(data[bubm], Position_bubbledec), if data
[bubm] < Tsl[bubm] then Color.MAGENTA else Color.YELLOW, if data[bubm] < Tsl[bubm] then yes else no);

# END STUDY
 
Hello Hguru, Could you possibly modify this code to be used in a watchlist. i'd like to be able to see the Buy / Sell Signals across Mutiple Timeframes.

Code:
# SuperTrend CCI ATR Base
# hguru | Paris | BLT
# 5.27.2019

# Paris: I dissected the ST Supertrend CCI ATR study hguru posted earlier,
# this combo study is a mashup of three major components (1) Super Trend
# Syracuse + BLT Extensions  (2) Mobius CCI ATR Trendline and (3) Combo
# Additions from Ghost. I have sectionalized the study, moved some of the
# variable/input definitions to the appropriate segment, and inserted the
# headers for any future work surrounding this study. Loaded it, and it
# works great.
#
# Paris: From an earlier request from hguru, I coordinated an MTF approach
# to this study with "extensive" collaboration from BLT. The code has been
# reorganized as well as introduced other mods to accomodate a MTF look.
#
# Due to the complexities of the info being processed, the approach taken
# does not streamline combining the MTF in a single study as found in many
# other MTF studies previously posted. Rather, we have implemented this
# MTF using the following two studies
#
# [1] SuperTrend CCI ATR Base
# [2] SuperTrend CCI ATR HigherAgg
#
# The 'base' study is used with possible settings made for the chart agg
# while the 'higher agg' study is configured for the type of settings one
# wants for those higher aggs. There are very slight differences between
# these two studies.
#
# To run through an illustration, for a 5m/15m/30m MTF setup, we have a
# 'base' set at 5m with two 'higher agg' set at 15m and 30m. For an actual
# chart setup, please refer to the attached tos.mx link.
#
# If you'd like an alternate MTF setup, say 4hour, Day, and Week, set the
# base aggregation to 4h, and two instances of the higher aggregation study,
# one to Day, and the other to Week. You get the idea.
#
# There is a workaround for the entry/exit arrows/bubbles and vertical
# lines to only display the first bar of the 'higher agg' being displayed
# on the 'lower agg'. Usually, when a condition is met on a 'higher agg'
# being displayed on the 'lower agg', an arrow, bubble or vertical is
# displayed on each bar of the 'lower agg' for the 'higher agg' period.

input agg = AggregationPeriod.FIVE_MIN;
def c = close(period = agg);
def h = high(period = agg);
def l = low(period = agg);
def pricedata = hl2(period = agg);

input pricecolor = {none, default combopricecolor, stpricecolor,  CCIATRPriceColor};

input showentrybubble = yes;
input number_entry_bubbles_tobe_displayed = 3;
input showlocationbubble = no;
input showpositionbubble = no;

input show_cloud = yes;
input show_vertLine = yes;
input show_entryarrows = yes;

DefineGlobalColor("TrendUp", CreateColor(0, 255, 255));
DefineGlobalColor("TrendDown", CreateColor(0, 102, 255));

# Super Trend Syracuse + BLT Extensions + PSAR
# Syracuse
# 10.29.2018

# This SuperTrend might be the best one as it does not
# sit on top of a candle it gives room to make decisions

#============================= SuperTrend 2016 ===========================#
#==================== Translation for TOS by Syracusepro =================#
input Factor = 1.3;
input Pd = 60;
input Lookback = 3;

def atr_st = Average(TrueRange(h, c, l), Pd);
def Up = pricedata[Lookback] - (Factor * atr_st);
def Dn = pricedata[Lookback] + (Factor * atr_st);
def TrendUp = if c > TrendUp[1] then Max(Up, TrendUp[1]) else Up;
def TrendDown = if c < TrendDown[1] then Min(Dn, TrendDown[1]) else Dn;
def Trend = if c > TrendDown[1] then 1 else if c < TrendUp[1] then -1 else (Trend[1]);
def Trendbn = if c > TrendDown[1] then BarNumber() else if c < TrendUp[1] then BarNumber() else (Trendbn[1]);
def Trendc = if c > TrendDown[1] then c else if c < TrendUp[1] then c else (Trendc[1]);

plot Tsl = if Trend == 1 then TrendUp else TrendDown;
Tsl.AssignValueColor(if Trend == 1 then GlobalColor("TrendUp") else GlobalColor("TrendDown"));
Tsl.SetLineWeight(1);

plot entryArrow = (if Trend == 1 and Trend[1] == -1 then First(Trendbn) else Double.NaN); #Up Entry Arrow
entryArrow.SetDefaultColor(Color.WHITE);
entryArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
entryArrow.SetHiding(!show_entryarrows);

plot exitArrow = (if Trend == -1 and Trend[1] == 1 then First(Trendbn) else Double.NaN); #Down Entry Arrow
exitArrow.SetDefaultColor(Color.YELLOW);
exitArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
exitArrow.SetHiding(!show_entryarrows);

#========================== End SuperTrend 2016 ===========================#

# CCI_ATR Trendline
# Mobius | Syracusepro
# Chat room request 01.28.2016
# 10.31.2018

# CCI is a study that measures distance from the mean. This study plots
# a trend line based on that distance using ATR as the locator for the line.

input lengthCCI = 20;
input lengthATR = 4;
input AtrFactor = 0.7;

def ATRcci = Average(TrueRange(h, c, l), lengthATR) * AtrFactor;
def price = c + l + h;
def linDev = LinDev(price, lengthCCI);
def CCI = if linDev == 0
          then 0
          else (price - Average(price, lengthCCI)) / linDev / 0.015;
def MT1 = if CCI > 0
          then Max(MT1[1], pricedata - ATRcci)
          else Min(MT1[1], pricedata + ATRcci);
plot data = MT1;
data.AssignValueColor(if c < MT1 then Color.RED else Color.GREEN);#TAKEN FROM SUPERTREND AND APPLIED ACCORDING THE VARIABLES FOR GREEN, RED LINE -----#

# End Code CCI_ATR Trend

########################################################
# Combo Additions
# Ghost / Hguru
# 2.3.2019

def ComboUpTrend = data > Tsl;
def ComboDnTrend = data < Tsl;
def crossup = ComboUpTrend == 1 and ComboUpTrend[1] <> 1;
def crossdn = ComboDnTrend == 1 and ComboDnTrend[1] <> 1;

AddCloud(if show_cloud and ComboUpTrend == 1 then data
                             else Double.NaN, if show_cloud and ComboUpTrend then Tsl
                             else Double.NaN, GlobalColor("TrendUp"), GlobalColor("TrendUp"));
AddCloud(if show_cloud and ComboDnTrend == 1 then Tsl
                             else Double.NaN, if show_cloud and ComboDnTrend == 1 then data
                             else Double.NaN, GlobalColor("TrendDown"), GlobalColor("TrendDown"));

AddVerticalLine(show_vertLine and entryarrow , astext(c), Color.UPTICK, Curve.POINTS);
AddVerticalLine(show_vertLine and exitarrow, astext(c), Color.DOWNTICK, Curve.POINTS);

################################################################
#Price Color

#Combo pricecolor
AssignPriceColor(if pricecolor == pricecolor.combopricecolor
                 then if ComboUpTrend == 1
                      then Color.GREEN
                      else if ComboDnTrend == 1 then Color.RED
                 else Color.GRAY else Color.CURRENT);

#Supertrend pricecolor
AssignPriceColor(if pricecolor == pricecolor.stpricecolor
                 then if !IsNaN(entryArrow)
                      then Color.WHITE 
                      else if !IsNaN(exitArrow) 
                      then Color.YELLOW
                      else if Trend == 1
                      then Color.GREEN
                      else if Trend == -1 then Color.RED
                 else Color.CURRENT else Color.CURRENT);

#CCI ATR pricecolor
AssignPriceColor(if pricecolor == pricecolor.CCIATRPriceColor and c < MT1
                 then GlobalColor("TrendDown")
                 else if pricecolor == pricecolor.CCIATRPriceColor and c > MT1
                      then GlobalColor("TrendUp")
                      else Color.CURRENT);

#################################################################
#Bubbles

#Buy/Sell Bubbles
input buysell_bubblemoversideways = 0;
def bm = buysell_bubblemoversideways + 1;
input buysell_bubblemoverupdown = 10;

def dataCount         = CompoundValue(1, if !IsNaN(entryArrow) or !IsNaN(exitArrow)
                                         then dataCount[1] + 1
                                         else dataCount[1], 0);
def HUp    = if entryarrow then l else double.nan ;
def HDn    = if exitarrow  then h else double.nan;

AddChartBubble(showentrybubble and crossdn and HighestAll(dataCount) - dataCount <= number_entry_bubbles_tobe_displayed - 1, hdn + ticksize()*buysell_bubblemoverupdown, agg/60000 + " min\nSell @ " + astext(c), Color.MAGENTA, yes);
AddChartBubble(showentrybubble and crossup and HighestAll(dataCount) - dataCount <= number_entry_bubbles_tobe_displayed - 1, hup-ticksize()*buysell_bubblemoverupdown, agg/60000 + " min\nBuy @ " + astext(c), Color.YELLOW, no);

#Location Bubble - Supertrend
input Location_Horizontal = 3;
input Location_Vertical = 0;

def X_h = Location_Horizontal;
def Y_v = Location_Vertical;
def X_h1  = X_h + 1;

input Location_bubbledecimal = 2;
AddChartBubble(showlocationbubble and IsNaN(c[X_h]) and !IsNaN(c[X_h1]), close[X_h1] + TickSize() * Y_v,  "ST: " + Round(Tsl[X_h1], Location_bubbledecimal), if Trend[X_h1] == 1 then Color.GREEN else
Color.PINK, no);#if Trend[X_h1] == -1 then Color.MAGENTA else Color.WHITE, no);

#Position Bubble - Supertrend
input Position_bubblemoverside = 3;
def bubm = Position_bubblemoverside + 1;
input Position_bubblemoverVert   = 0;
input Position_bubbledec = 2;

AddChartBubble(showpositionbubble and IsNaN(close[Position_bubblemoverside]) and !IsNaN(close[bubm]), Tsl[bubm] + Position_bubblemoverVert * TickSize(), "ST      " + Round(Tsl[bubm], Position_bubbledec), if Tsl[bubm]
< data[bubm] then Color.MAGENTA else Color.YELLOW, if Tsl[bubm] < data[bubm] then no else yes);

#Position Bubble - CCI
AddChartBubble(showpositionbubble and IsNaN(close[Position_bubblemoverside]) and !IsNaN(close[bubm]), data[bubm] + Position_bubblemoverVert * TickSize(), "CCI      " + Round(data[bubm], Position_bubbledec), if data
[bubm] < Tsl[bubm] then Color.MAGENTA else Color.YELLOW, if data[bubm] < Tsl[bubm] then yes else no);

# END STUDY
Hi @BenTen It's possible to add an audible alert when an arrow displays either up or down for this study? Thanks!
 
@Gvaro Add this to the bottom of your script:

Code:
# Alerts
Alert(entryArrow, " ", Alert.Bar, Sound.Chimes);
Alert(exitArrow, " ", Alert.Bar, Sound.Bell);
 
Hi All,

Great script and thank you all for your contribution. I have been using Column for ST CCI ATR Trend for last few months and it works great for me on 5min charts... I started playing with script below to see how can I add bar count since last signal fired, tried recycle peace of code from ORB watchlist column (included below).

I'm having hard time figuring out and identifying last fired signal Up/Dn and have reset count from last signal... Basically count bar until new signal fire Up or Dn, once new signal is fired count resets it to 0 and start counting bars until new signal fires or reversal happen. I was hopping somebody would take look modification below and adjusted to account this logic.

This would really quickly help identify reversal visually early in game. As current, color helps when is in trend but it does not tell me if trend is in early stage or later in stage without going through whole list of stock. Having color and bar count would help, let say for example signal is fired, watchlist color is green and bar count is 1 or 2, this would indicate that we're in early stage as suppose bar count of 18 or something like that. It does not tell me how long trend last but and I'm not after, I'm just trying identify potential candidate from the list with early entry.

Here is sample, hope this helps
Last signal is hard to see, it kind of right under yellow bubble, this is where counter is reset and start counting onward until new orange arrow appear, basically counter reset for last signal until new reversal. Can this be done? Any help would be greatly appreciated.
Chart.png


And here is watchlist, ST-CCI column
watchlist.jpg


Code I would like to modify to include count from last fired signal
Code:
#Combo ST and CCI ATR TREND Coloumn
def c = close;
def h = high;
def l = low;
def pricedata = hl2;
input show_inside_bar_count = Yes;

#SUPERTREND
input ST_Atr_Mult = 1.3;
input ST_Length = 60;
input ST_AvgType = AverageType.wilders;
def ATR = MovingAverage(ST_AvgType, TrueRange(high, close, low), ST_Length);
def UP = HL2 + (ST_Atr_Mult* ATR);
def DN = HL2 + (-ST_Atr_Mult * ATR);
def ST = if close < ST[1] then UP else DN;
def SuperTrend = ST;

#CCI_ATR
input lengthCCI = 50;
input lengthATR = 5;
input AtrFactor = 1.0;
def ATRcci = Average(TrueRange(h, c, l), lengthATR) * AtrFactor;
def price = c + l + h;
def linDev = LinDev(price, lengthCCI);
def CCI = if linDev == 0
          then 0
          else (price - Average(price, lengthCCI)) / linDev / 0.015;

def MT1 = if CCI > 0
          then Max(MT1[1], pricedata - ATRcci)
          else Min(MT1[1], pricedata + ATRcci);
def CCI_ATR_TREND = MT1;

#plot ST_ATR_COMBO = if C> ST and C>CCI_ATR_TREND then 4 else if c< ST and c<CCI_ATR_TREND then -4 else 0;

#AssignBackgroundColor(if ST_ATR_COMBO ==4 then color.cyan else if ST_ATR_COMBO == -4 then color.yellow else color.black);

#ST_ATR_COMBO.assignValueColor(if ST_ATR_COMBO ==4 then color.cyan else if ST_ATR_COMBO == -4 then color.yellow else color.black);

# Count Bar
Def Bull = If C> ST and C>CCI_ATR_TREND then Up else 0;
Def Bear = if c< ST and c<CCI_ATR_TREND then Dn else 0;

Def current = if between(close, Bear, Bull) then 0
    Else if Close > Bull then 1
    Else if Close < Bear then -1
    Else Double.Nan;

def n1 = current == 1;
def n2 = current == -1;
def n3 = current == 0;
def count_up = if n1 and !n1[1] then 1 else count_up[1]+1;
def count_dn = if n2 and !n2[1] then 1 else count_dn[1]+1;
def count_in = if show_inside_bar_count then
               if n3 and !n3[1] then 1
               else count_in[1]+1
               else double.nan;

plot Number = if n1 then count_up
              else if n2 then count_dn
              else count_in;
#     Number.AssignValueColor(if n1 then color.green
#                             else if n2 then color.red
#                             else color.yellow);
#
     Number.AssignValueColor(if n1 then color.black
                             else if n2 then color.black
                             else color.black);

AssignBackgroundColor(if n1 then createColor(102,255,255)
                      else if n2 then createColor(204,51,0)
                      else createColor(180,180,5));
# Count Bar Ends



For reference, watchlist for ORB Column, works great with count of bar as it cross ORB H or L.

Code:
# Watchlist ORB Status
# Mobius
# V01 using getTIme()
# Note: Column Aggregation MUST be 30min or less
# Pensar - 07/06/2020 - modified to count bars above/below Opening Range
#        - 07/31/2020 - changed code to use plot instead of AddLabel
#                       so that column can be sorted numerically

# The input below will show the bar count when inside the Opening Range
# if set to "yes", otherwise it will display "NaN".
input show_inside_bar_count = Yes;

def Active = getTime() >= RegularTradingStart(getYYYYMMDD()) and
             getTime() <= RegularTradingStart(getYYYYMMDD()) +   
             AggregationPeriod.FIVE_MIN;

def hh = if Active and !Active[1] then high
         else if Active and high > hh[1] then high
         else hh[1];
def ll = if Active and !Active[1] then low
         else if Active and low < ll[1] then low
         else ll[1];
def current = if between(close, ll, hh) then 0
              else if close > hh then 1
              else if close < ll then -1
              else double.nan;
def n1 = current == 1;
def n2 = current == -1;
def n3 = current == 0;
def count_up = if n1 and !n1[1] then 1 else count_up[1]+1;
def count_dn = if n2 and !n2[1] then 1 else count_dn[1]+1;
def count_in = if show_inside_bar_count then
               if n3 and !n3[1] then 1
               else count_in[1]+1
               else double.nan;

plot Number = if n1 then count_up
              else if n2 then count_dn
              else count_in;
#     Number.AssignValueColor(if n1 then color.green
#                             else if n2 then color.red
#                             else color.yellow);
#
     Number.AssignValueColor(if n1 then color.black
                             else if n2 then color.black
                             else color.black);

AssignBackgroundColor(if n1 then createColor(0,255,0)
                      else if n2 then createColor(155,0,0)
                      else createColor(180,180,5));
# End Code ORB Status
 
Hi,
On the above chart there is price 639.775 with GREEN color highlighted. What does this signifies?
Also on my charts there is another prices shows up with RED color highlight below the GREEN price. what does these mean?
hi hmjassal can u share the script thanks
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
411 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