Momentum Paint Candles

hockeycoachdoug

Active member
2019 Donor
VIP
----------------------------------------------------------------------------------------------------
mod note:
original can be found:
https://usethinkscript.com/threads/a-trend-momentum-and-cycle-trading-system-v3-0-csa.1596/

----------------------------------------------------------------------------------------------------
I watched a webinar awhile back that made the premise that combining a trend based indicator, a momentum based indicator and a cycle based indicator gives a good indication of directional bias. I would like to combine these 3 components into one paintbar type indicator and am hoping one of you coding pros might find value in this and be willing to code it here for the community.
For the trend indicator I want to use supertrend available here by Mobius. Here is the link SuperTrend by Mobius
For the momentum indicator I want to use True Momentum Oscillator (TMO). Here is the link TMO for TOS
For the cycle indicator I want to use TOP Cycle Trader. I am posting the code for this indicator here-

Code:
declare lower;
#plot Data = close;
input   FastCycleLength = 5;
input   SlowCycleLength = 8;
#def   CycleLineColor=DefineGlobalColor(Color.RED);
#input   CycleHistColor=Color.BLUE;
#input   ZeroLineColor1 = GetColor(1);
DefineGlobalColor("CycleLineColor", Color.RED);
DefineGlobalColor("CyclehistColor", Color.BLUE);
DefineGlobalColor("ZeroLineColor", Color.YELLOW);
def H = high;
def L = low;
#def FastVar(0),SlowVar(0),DiffVar(0);

def FastVar = ExpAverage((H + L) / 2, FastCycleLength);
def SlowVar = Average((H + L) / 2, SlowCycleLength);
def DiffVar = FastVar - SlowVar;

plot pDiffVar = DiffVar;
pDiffVar.SetDefaultColor(GlobalColor("CycleLineColor"));
plot pDiffVar2 = DiffVar;
pDiffVar2.SetDefaultColor(GlobalColor("CycleHistColor"));
plot pZeroLine = 0;
pZeroLine.SetDefaultColor(GlobalColor("ZeroLineColor"));
#Plot1(DiffVar,"Cycle",CycleLineColor);
#Plot2(DiffVar,"CycleHist",CycleHistColor);
#Plot3(0    ,"Zero",ZeroLineColor);

Here is how I envision the paintbar working-
When the supertrend indicator is long that would equal +1, when its short -1.
When the TMO is green that would equal +1. when its red its -1.
When the TOP Cycle Trader is above zero that would equal +1, when its below zero -1.
When all 3 indicators are equal to +1 making +3 total the price bars would paint green.
When all 3 indicators are equal to -1 making -3 total the price bars would paint red.
If the combination of all 3 indicators equals anything else, the price bars would paint gray meaning all 3 indicators were not in agreement.

I am open to any and all suggestions. I considered MACD for the momentum indicator but thought TMO was better. Considered Doncian channel for trend but thought supertrend was better. I am hoping one of you coders out there find this idea worthy of putting in the effort to code and share with us here.

I also want to create a scan/ watchlist using this where I can add a number of stock symbols to a watchlist and have the following columns showing symbol, color of bar on a daily basis (or long term) (red, green, or gray), color of bar on a 15 or 30 minute basis (short term)(red, green, or gray, and a column showing average volatility for some period of bars to use as a sort column to find the symbols that are moving.

I want to use this in 3 ways. First as a way to confirm directional bias of trade I am in ( I should be long if bars are green). second with the scanner portion, when both a long term (daily) and a short term (15 or 30 min) are both same color then enter a trade in that colors direction. Lastly as a portfolio management feature. Take a portion of money and break into 5-10 slots each represented by a sector ETF such as 50K broken into 5 trading slots of 10K committed to each ETF. When daily bars are green for a specific ETF, that slot is long all 10K, when its red that slot is in cash.
Thank you in advance.
 
Last edited by a moderator:
Will there be a scan for this also? TIA


@tenacity11 I observed that in version 1.7 of the study @diazlaz had inserted hooks/options to make this scannable. Unfortunately when referencing the native V1.7 study from the scanner, it reported complexity issues. Hence I took the liberty of converting this into a native scan.

Here is a bullish scan of the Trend V1.7 study. I optimized this to be able to be used by the scanner thereby circumventing the complexity issue earlier flagged by the scanner. I noticed that within the code the variable "threshold" was set to 4, I believe this needs to be modified to 8 to reflect the confluence of the 8 sub indicators within the Trend V1.7 code. Otherwise you're not catching all the signals intended. Noticed that @diazlaz had mentioned that in his earlier post, just reiterating it here just to help any novice users.

If you'd like to configure this as a bearish scan, just replace the plot statement (on the last line) with

plot scan = sBearish >= threshold;

Testing the scan on a daily aggregation of the S&P 500 I obtained 2 results for the bullish scan and 14 results for the bearish scan.

Code:
# Trend v1.7 Bullish Scan
# tomsk
# 1.4.2020

# tomsk: Here is a bullish scan of the Trend V1.7 study, based on the study that @diazlaz posted
# If you'd like to configure this as a bearish scan, just replace the plot statement with
#
# plot scan = sBearish >= threshold;
#
#
#trend, a momentum and a cycle based indicator for ThinkorSwim V1.7
#@hockeycoachdoug Community Request
#
# https://usethinkscript.com/threads/i-request-combining-3-indicators-into-1-paintbar-study.1390/page-3#post-13087
#
#VERSION
# 2020.01.04 V1.7 @diazlaz - Integrated Slim Ribbon.
# 2020.01.02 V1.6 @diazlaz - Integrated DMI and BOP, restructured INPUTS to each module.
#                            threshold increased to 4 by default.
# 2020.01.01 V1.5 @diazlaz - Integrated ADX Trending States and BAR Line
# 2020.01.01 V1.4 @diazlaz - Integrated TTM Trends, modules selection
#                            and added threshold for signals
# 2019.12.31 V1.2 @diazlaz - Integrated FREMA
# 2019.12.30 V1.1 @diazlaz - Labels, Additional Dashboard, Lower Study
# 2019.12.30 V1.0 @diazlaz - Community Ask/Release

input threshold = 8;

input enableTTM = yes;
input enableSuperTrend = yes;
input enableFrema = yes;
input enableTMO = yes;
input enableSlim = yes;
input enableTOP = yes;
input enableDMI = yes;
input enableBOP = yes;

input displace = 0;

def h = high;
def l = low;
def o = open;
def c = close;

# TTM Trend
def TrendUp = if TTM_Trend().TrendUp == 1 then 1 else 0;
def TrendDown = if TTM_Trend().TrendDown == 1 then 1 else 0;
def sBullish_TTM = enableTTM and TrendUp;
def sBearish_TTM = enableTTM and TrendDown;

# SuperTrend (Mobius)
input AtrMult = 1.0;
input nATR = 4;
input AvgType = AverageType.HULL;

def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = HL2 + (AtrMult * ATR);
def DN = HL2 + (-AtrMult * ATR);
def ST = if close < ST[1] then UP else DN;
def sBullish_SuperTrend = enableSuperTrend and close >= ST;
def sBearish_SuperTrend = enableSuperTrend and close < ST;

# FREMA
input AA = .1;

def CC = if CC[1] == 0 then .9 else 1 – AA;
def EMA = AA * close + CC * EMA[1];
def RE1 = CC * EMA + EMA[1];
def RE2 = Power(CC, 2) * RE1 + RE1[1];
def RE3 = Power(CC, 4) * RE2 + RE2[1];
def RE4 = Power(CC, 8) * RE3 + RE3[1];
def RE5 = Power(CC, 16) * RE4 + RE4[1];
def RE6 = Power(CC, 32) * RE5 + RE5[1];
def RE7 = Power(CC, 64) * RE6 + RE6[1];
def RE8 = Power(CC, 128) * RE7 + RE7[1];
def EMA_Signal = EMA – AA * RE8;
def sBullish_Frema = enableFrema and EMA_Signal > 0;
def sBearish_Frema = enableFrema and EMA_Signal <= 0;

# TMO
input length = 14;
input calcLength = 5;
input smoothLength = 3;

def data = fold i = 0 to length
           with s
           do s + (if c > getValue(o, i)
                   then 1
                   else if c < getValue(o, i)
                        then - 1
                        else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);
def sBullish_TMO = enableTMO and Main > Signal;
def sBearish_TMO = enableTMO and Main <= Signal;

# SLIM
input sSuperFast = 8;
input sFast = 13;
input sSlow = 21;

def SuperFastM1 = ExpAverage(close[-displace], sSuperFast);
def FastM1 = ExpAverage(close[-displace], sFast);
def SlowM1 = ExpAverage(close[-displace], sSlow);
def buyM1 = SuperFastM1 > FastM1 and FastM1 > SlowM1 and low > SuperFastM1;
def stopbuyM1 = SuperFastM1 <= FastM1;
def buynowM1 = buyM1 and !buyM1[1];
def buysignalM1 = if buynowM1 and !stopbuyM1 then 1
                  else if buysignalM1[1] and stopbuyM1 then 0
                  else buysignalM1[1];
def Buy_SignalM1 = buysignalM1 and !buysignalM1[1];
def sellM1 = SuperFastM1 < FastM1 and FastM1 < SlowM1 and high < SuperFastM1;
def stopsellM1 = SuperFastM1 >= FastM1;
def sellnowM1 = sellM1 and !SellM1[1];
def sellsignalM1 = if sellnowM1 and !stopsellM1 then 1
                   else if sellsignalM1[1] and stopsellM1 then 0
                   else sellsignalM1[1];
def Sell_SignalM1 = sellsignalM1 and !sellsignalM1[1];
def sBullish_SLIM = enableSLIM and Buy_SignalM1;
def sBearish_SLIM = enableSLIM and Sell_SignalM1;

# TOP Cycle Trader
input FastCycleLength = 5;
input SlowCycleLength = 8;

def FastVar = ExpAverage((H + L) / 2, FastCycleLength);
def SlowVar = Average((H + L) / 2, SlowCycleLength);
def DiffVar = FastVar - SlowVar;
def sBullish_TOP = enableTOP and DiffVar > 0;
def sBearish_TOP = enableTOP and DiffVar <= 0;

# DMITrend
input DMIlength = 13;

def hiDiff = high - high[1];
def loDiff = low[1] - low;
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATRDMI = WildersAverage(TrueRange(high, close, low), DMIlength);
Def DIPlus = 100 * WildersAverage(plusDM, DMIlength) / ATRDMI;
Def DIMinus = 100 * WildersAverage(minusDM, DMIlength) / ATRDMI;
def sBullish_DMI = enableDMI and DIPlus > DIMinus;
def sBearish_DMI = enableDMI and DIMinus > DIPlus;

# BOP indicator
input averageType = {Simple, Exponential, default Weighted, Wilders, Hull,  Disabled};
input BoPlength = 16;

def rawBMP = if high != low then (close - open) / (high - low) else 1;
def BMP;
switch (averageType) {
case Simple:
    BMP = Average(rawBMP, BoPlength);
case Exponential:
    BMP = ExpAverage(rawBMP, BoPlength);
case Weighted:
    BMP = wma(rawBMP, BoPlength);
case Wilders:
    BMP = WildersAverage(rawBMP, BoPlength);
case Hull:
    BMP = HullMovingAvg(rawBMP, BoPlength);
case Disabled:
    BMP = rawBMP;
}
def sBullish_BOP = enableBOP and BMP > 0;
def sBearish_BOP = enableBOP and BMP <= 0;

# SCAN

def sBullish = sBullish_TTM + sBullish_SuperTrend + sBullish_Frema + sBullish_TMO + sBullish_TOP + sBullish_DMI + sBullish_BOP + sBullish_SLIM;
def sBearish = sBearish_TTM + sBearish_SuperTrend + sBearish_Frema + sBearish_TMO + sBearish_TOP + sBearish_DMI + sBearish_BOP + sBearish_SLIM;

plot scan = sBullish >= threshold;

# End Trend v1.7 Bullish Scan
 
Integrated Slim Ribbon into Version 1.7 - at any time feel free to disable indicators and set the thresholds to trigger number of confirmed entries for bullish or bearish signals.

Ruby:
#trend, a momentum and a cycle based indicator for ThinkorSwim V1.7
#@hockeycoachdoug Community Request
#
#VERSION
# 2020.01.04 V1.7 @diazlaz - Integrated Slim Ribbon.
# 2020.01.02 V1.6 @diazlaz - Integrated DMI and BOP, restructured INPUTS to each module.
#                            threshold increased to 4 by default.
# 2020.01.01 V1.5 @diazlaz - Integrated ADX Trending States and BAR Line
# 2020.01.01 V1.4 @diazlaz - Integrated TTM Trends, modules selection
#                            and added threshold for signals
# 2019.12.31 V1.2 @diazlaz - Integrated FREMA
# 2019.12.30 V1.1 @diazlaz - Labels, Additional Dashboard, Lower Study
# 2019.12.30 V1.0 @diazlaz - Community Ask/Release
#
#LINK
#https://usethinkscript.com/threads/i-request-help-combining-3-indicators-into-1-paintbar-study.1390/
#
#INSTRUCTION
#Here is how I envision the paintbar working:
#When the supertrend indicator is long that would equal +1, when its short -1.
#When the TMO is green that would equal +1. when its red its -1.
#When the TOP Cycle Trader is above zero that would equal +1, when its below zero -1.
#When all 3 indicators are equal to +1 making +3 total the price bars would paint #green.
#When all 3 indicators are equal to -1 making -3 total the price bars would paint red.
#If the combination of all 3 indicators equals anything else, the price bars would #paint gray meaning all 3 indicators were not in agreement.
#
#Now includes: TTM Trend, Super Trend, Frema, TMO, TOP, DMI , BOP, Slim Ribbon and
#ADX as Trending/Non-Trending, with LONG/SHORT/HOLD signal selection
#based on threshold specified and indicators enabled.
#

declare upper;

#INPUTS
input showLabels = yes;
input PaintBars = yes;

input threshold = 4;

input enableTTM = yes;
input enableSuperTrend = yes;
input enableFrema = yes;
input enableTMO = yes;
input enableSlim = yes;
input enableTOP = yes;
input enableDMI = yes;
input enableBOP = yes;

input scanMode = no;  #turns the study into a scanner set to yes
input scanLongs = yes; #scanner mode scan for longs
input scanShorts = yes; #scanner mode scan for shorts

input displace = 0;

#CORE
DefineGlobalColor("CycleLineColor", Color.RED);
DefineGlobalColor("CyclehistColor", Color.BLUE);
DefineGlobalColor("ZeroLineColor", Color.YELLOW);
DefineGlobalColor("Bullish", Color.GREEN);
DefineGlobalColor("Bearish", Color.RED);
DefineGlobalColor("Neutral", Color.MAGENTA); #Color.YELLOW
DefineGlobalColor("Off", Color.DARK_GRAY);
DefineGlobalColor("On", Color.GREEN);
DefineGlobalColor("Sync1", Color.YELLOW);
DefineGlobalColor("Sync2", Color.CYAN);
DefineGlobalColor("Up", Color.GREEN);
DefineGlobalColor("Down", Color.RED);
DefineGlobalColor("NUp", Color.DARK_GREEN);
DefineGlobalColor("NDown", Color.DARK_RED);
DefineGlobalColor("Neutral", Color.BLUE);
DefineGlobalColor("Neutral2", Color.PLUM);

def h = high;
def l = low;
def o = open;
def c = close;
def na = Double.NaN;

AddLabel(showLabels, "A trend, momentum and cycle Trading System v1.7", Color.CYAN);

#TTM Trend
def TrendUp = if TTM_Trend().TrendUp == 1 then 1 else 0;
def TrendDown = if TTM_Trend().TrendDown == 1 then 1 else 0;
def sTTM = if TrendUp then 100 else if TrendDown then -100 else 0;
def sBullish_TTM = if(enableTTM and sTTM == 100,1,0);
def sBearish_TTM = enableTTM and sTTM == -100;
AddLabel(showlabels and enableTTM, "TTM", if IsNan(sTTM) then COLOR.DARK_GRAY else
if sTTM[-displace] > 0 then COLOR.GREEN else
if sTTM[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));

#SuperTrend (Mobius)
input AtrMult = 1.0; #SuperTrend
input nATR = 4; #SuperTrend
input AvgType = AverageType.HULL; #SuperTrend

def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = HL2 + (AtrMult * ATR);
def DN = HL2 + (-AtrMult * ATR);
def ST = if close < ST[1] then UP else DN;
def sSuperTrend = if close < ST then -100 else 100;
def sBullish_SuperTrend = enableSuperTrend and sSuperTrend == 100;
def sBearish_SuperTrend = enableSuperTrend and sSuperTrend == -100;
AddLabel(showlabels and enableSuperTrend, "SuperTrend", if IsNan(sSuperTrend) then COLOR.DARK_GRAY else
if sSuperTrend[-displace] > 0 then COLOR.GREEN else
if sSuperTrend[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));

#FREMA
input AA = .1; #FREMA

def CC;
def zeroLine = 0;
def RE1;
def RE2;
def RE3;
def RE4;
def RE5;
def RE6;
def RE7;
def RE8;
def EMA;
CC = if CC[1] == 0 then .9 else 1 – AA;
EMA = AA * close + CC * EMA[1];
RE1 = CC * EMA + EMA[1];
RE2 = Power(CC, 2) * RE1 + RE1[1];
RE3 = Power(CC, 4) * RE2 + RE2[1];
RE4 = Power(CC, 8) * RE3 + RE3[1];
RE5 = Power(CC, 16) * RE4 + RE4[1];
RE6 = Power(CC, 32) * RE5 + RE5[1];
RE7 = Power(CC, 64) * RE6 + RE6[1];
RE8 = Power(CC, 128) * RE7 + RE7[1];
def EMA_Signal = EMA – AA * RE8;
def sFrema = if (EMA_Signal > zeroLine) then 100 else -100;
def sBullish_Frema = enableFrema and sFrema == 100;
def sBearish_Frema = enableFrema and sFrema == -100;
AddLabel(showlabels and enableFrema, "Frema", if IsNan(sFrema) then COLOR.DARK_GRAY else
if sFrema[-displace] > 0 then COLOR.GREEN else
if sFrema[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));

#TMO
input length = 14; #TMO
input calcLength = 5; #TMO
input smoothLength = 3; #TMO

def data = fold i = 0 to length
           with s
           do s + (if c > getValue(o, i)
                   then 1
                   else if c < getValue(o, i)
                        then - 1
                        else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);
def sMain = if Main > Signal then 100 else -100;
def sSignal = if Main > Signal then 100 else - 100;
def ob = if isNaN(c) then double.nan else round(length * .7);
def os = if isNaN(c) then double.nan else -round(length * .7);
def sTMO = if Main > Signal then 100 else -100;
def sBullish_TMO = enableTMO and sTMO == 100;
def sBearish_TMO = enableTMO and sTMO == -100;
AddLabel(showlabels and enableTMO, "TMO", if IsNan(sTMO) then COLOR.DARK_GRAY else
if sTMO[-displace] > 0 then COLOR.GREEN else
if sTMO[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));

#SLIM
input sSuperFast = 8;
input sFast = 13;
input sSlow = 21;

def SuperFastM1 = ExpAverage(close[-displace], sSuperFast);
def FastM1 = ExpAverage(close[-displace], sFast);
def SlowM1 = ExpAverage(close[-displace], sSlow);
def buyM1 = SuperFastM1 > FastM1 and FastM1 > SlowM1 and low > SuperFastM1;
def stopbuyM1 = SuperFastM1 <= FastM1;
def buynowM1 = !buyM1[1] and buyM1;
def buysignalM1 = CompoundValue(1, if buynowM1 and !stopbuyM1 then 1
else if buysignalM1[1] == 1 and stopbuyM1 then 0 else buysignalM1[1], 0);
def Buy_SignalM1 = buysignalM1[1] == 0 and buysignalM1 == 1;
def Momentum_DownM1 = buysignalM1[1] == 1 and buysignalM1 == 0;
def sellM1 = SuperFastM1 < FastM1 and FastM1 < SlowM1 and high < SuperFastM1;
def stopsellM1 = SuperFastM1 >= FastM1;
def sellnowM1 = !sellM1[1] and sellM1;
def sellsignalM1 = CompoundValue(1, if sellnowM1 and !stopsellM1 then 1
else if sellsignalM1[1] == 1 and stopsellM1 then 0 else sellsignalM1[1], 0);
def Sell_SignalM1 = sellsignalM1[1] == 0 and sellsignalM1;
def Momentum_UpM1 = sellsignalM1[1] == 1 and sellsignalM1 == 0;
def sStateM1 = if Buy_SignalM1 then 100 else if Momentum_UpM1 then 10 else if Sell_SignalM1 then -100 else if Momentum_DownM1 then -10 else sStateM1[1];
def sBullish_SLIM = enableSLIM and sStateM1 == 100;
def sBearish_SLIM = enableSLIM and sStateM1 == -100;
AddLabel(showlabels and enableSLIM, "SLIM", if IsNan(sStateM1) then COLOR.DARK_GRAY else
if sStateM1[-displace] >= 100 then COLOR.GREEN else
if sStateM1[-displace] <= -100 then COLOR.RED
else COLOR.YELLOW);


#TOP Cycle Trader
input FastCycleLength = 5; #TOP
input SlowCycleLength = 8; #TOP

def FastVar = ExpAverage((H + L) / 2, FastCycleLength);
def SlowVar = Average((H + L) / 2, SlowCycleLength);
def DiffVar = FastVar - SlowVar;
def pDiffVar = DiffVar;
def pDiffVar2 = DiffVar;
def sTOP = if DiffVar > 0 then 100 else -100;
def sBullish_TOP = enableTOP and sTOP == 100;
def sBearish_TOP = enableTOP and sTOP == -100;
AddLabel(showlabels and enableTOP, "TOP", if IsNan(sTOP) then COLOR.DARK_GRAY else
if sTOP[-displace] > 0 then COLOR.GREEN else
if sTOP[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));

#DMITrend
input DMIlength = 13;

def hiDiff = high - high[1];
def loDiff = low[1] - low;
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATRDMI = WildersAverage(TrueRange(high, close, low), DMIlength);
Def DIPlus = 100 * WildersAverage(plusDM, DMIlength) / ATRDMI;
Def DIMinus = 100 * WildersAverage(minusDM, DMIlength) / ATRDMI;
def sDMI = if DIPlus > DIMinus then 100 else if DIMinus > DIPlus then -100 else 0;
def sBullish_DMI = enableDMI and sDMI == 100;
def sBearish_DMI = enableDMI and sDMI == -100;
AddLabel(showlabels and enableDMI, "DMI", if IsNan(sDMI) then COLOR.DARK_GRAY else
if sDMI[-displace] > 0 then COLOR.GREEN else
if sDMI[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));

#BOP indicator
input averageType = {Simple, Exponential, default Weighted, Wilders, Hull,  Disabled};
input BoPlength = 16;

def rawBMP = if high != low then (close - open) / (high - low) else 1;
def BMP;
switch (averageType) {
case Simple:
    BMP = Average(rawBMP, BoPlength);
case Exponential:
    BMP = ExpAverage(rawBMP, BoPlength);
case Weighted:
    BMP = wma(rawBMP, BoPlength);
case Wilders:
    BMP = WildersAverage(rawBMP, BoPlength);
case Hull:
    BMP = HullMovingAvg(rawBMP, BoPlength);
case Disabled:
    BMP = rawBMP;
}
def sBOP = if BMP > 0 then 100 else -100;
def sBullish_BOP = enableBOP and sBOP == 100;
def sBearish_BOP = enableBOP and sBOP == -100;
AddLabel(showlabels and enableBOP, "BOP", if IsNan(sBOP) then COLOR.DARK_GRAY else
if sBOP[-displace] > 0 then COLOR.GREEN else
if sBOP[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));


#ADX TRENDING
input ADXlength = 8; #ADX
input ADXTrending = 25; #ADX
input showADXBar = yes;

def ADX = DMI(ADXlength).ADX;
plot ADXCross = LowestAll(low);
ADXCross.SetPaintingStrategy(PaintingStrategy.LINE);
ADXCross.AssignValueColor(
    if ADX > ADXTrending then Color.LIME
    else Color.DARK_GRAY);
ADXCross.SetLineWeight(5);
ADXCross.SetHiding(!showADXBar);

AddLabel(showlabels,
if ADX > ADXTrending then "Trending" else
"Non Trending",
if IsNan(c) then COLOR.DARK_GRAY else
if ADX > ADXTrending then COLOR.GREEN else
COLOR.DARK_GRAY);

#STATE
def sResults = sSuperTrend + sTMO + sTOP + sFrema + sTTM + sDMI + sBOP + sStateM1;
def sBullish = sBullish_TTM + sBullish_SuperTrend + sBullish_Frema + sBullish_TMO + sBullish_TOP + sBullish_DMI + sBullish_BOP + sBullish_SLIM;
def sBearish = sBearish_TTM + sBearish_SuperTrend + sBearish_Frema + sBearish_TMO + sBearish_TOP + sBearish_DMI + sBearish_BOP + sBearish_SLIM;
def bullish = if(sBullish >= threshold,1,0);
def bearish = if(sBearish >= threshold,1,0);
def sState = if bullish then 100 else if bearish then -100 else 0;
def sState2 = if sState != 0 then sState else sState2[1];

#COLORBARS
AssignPriceColor(
if PaintBars then
    if bullish then COLOR.GREEN else if bearish then COLOR.RED
     else COLOR.GRAY
else COLOR.CURRENT);

AddLabel(showlabels,
if bullish[-displace] then "LONG" else
if bearish[-displace] then "SHORT"
else "HOLD",
if IsNan(c) then COLOR.DARK_GRAY else
if bullish[-displace] then COLOR.GREEN else
if bearish[-displace] then COLOR.RED
else COLOR.GRAY);

#SCAN MODE
def sScan = if (scanMode,if((scanLongs and bullish) or (scanShorts and bearish),1,0),0);
plot pScan = sScan;
pScan.SetHiding(!scanMode);

#END OF trend, a momentum and a cycle based indicator for ThinkorSwim V1.7
Can you replace TTM Trend with a script I'm posting that is much more accurate. If you don't want to replace TTM can you please add this as a option on top of TTM. Thanks.
Code:
# A buy/sell for CCI + TTM squeeze + TTM trend
#Fib Queen Ideal Setup Filter
    def CCIBuy = CCI(length = 14).CCI > 0 and CCI(length = 50).CCI > 0;
    def CCISell = CCI(length = 14).CCI < 0 and CCI(length = 50).CCI < 0;
 
    def TrendUp = TTM_Trend().TrendUp;
    def TrendDn = TTM_Trend().TrendDown;
 
    def SqueezeUp = TTM_Squeeze().Histogram >= 0;
    def SqueezeDn = TTM_Squeeze().Histogram <= 0;
 
    plot Buy = CCIBuy and TrendUp and SqueezeUp;
    plot Sell = CCISell and TrendDn and SqueezeDn;
    buy.assignvaluecolor(color.green);
    sell.assignvaluecolor(color.red);
    buy.setPaintingStrategy(PaintingStrategy.boolean_arrow_up);
    sell.setPaintingStrategy(PaintingStrategy.boolean_arrow_down);
    #---------------- End Of Code --------------------
 
Hi Everyone, I've queued up CCI + TTM squeeze + TTM trend and the CCI/ATR modules for this week. as I have time during week will get these two implemented. if there are any other modules or considerations you would like to see, in addition please let me know and will try to get as much of it done during this upcoming week.
 
Hi Everyone, I've queued up CCI + TTM squeeze + TTM trend and the CCI/ATR modules for this week. as I have time during week will get these two implemented. if there are any other modules or considerations you would like to see, in addition please let me know and will try to get as much of it done during this upcoming week.
Code:
#Hint: The NYSE TICK represents, at any given moment, the net number of stocks in the broad market that are trading at their offer prices minus those trading at their bids. When the NYSE TICK becomes very positive, it means that traders are lifting offers in the broad market: buyers are quite aggressive. When the TICK becomes very negative, it means that traders are hitting bids in the broad market: sellers are very aggressive. \n The swings in the NYSE TICK during the day, then, represent relative swings in short-term trader sentiment. The beauty of the measure is that it is assessing what bulls and bears are actually doing in the marketplace; not what they report as their sentiment or what they try to fool others into believing. \n

declare lower;
def upper = no;
input hidecumtick = yes;
input symbol = "$TICK"; #HINT symbol: Default SYMBOL is $TICK (New York Stock Exchange). This can be changed to see the tick values for the Russel 2000, the NASDAQ and many others.
input period = 20;
input smooth = 5;
input lookback = 4;
input filter = 300;
def p = period;
def i = barNumber();
def na = double.nan;
#input usetrend = {"No", default "Yes"};
def usetrend = yes;
rec htick = if IsNaN(high(symbol)) then htick[1] else high("$TICK") ;
rec ltick = if IsNaN(low(symbol)) then ltick[1] else low("$TICK");
rec avgh = if i == 1 then htick else Max(filter, avgh[1] + 2 / (p + 1) * (htick - avgh[1]));
rec avgl = if i == 1 then ltick else Min(-filter, avgl[1] + 2 / (p + 1) * (ltick - avgl[1]));

def hi = high("$TICK");
def lo = low("$TICK");

plot Last = if IsNaN(close(symbol)[-1]) then close(symbol) else double.nan;

plot amean = if IsNaN(close) then na else (avgh + avgl) / 2;
def trendmean = if usetrend AND (htick > avgh OR ltick < avgl) then amean else 0;

def bull = if htick > avgh then htick - avgh  else 0;
def bear = if ltick < avgl then ltick - avgl  else 0;

rec ctick = if i == 1 then 0 else if IsNaN(htick) OR IsNaN(ltick) then ctick[1] else ctick[1] + bull + bear + trendmean;

def ctickavg = ExpAverage(ctick, smooth);
plot cumtick = if IsNaN(close) then na else ctickavg;
plot nettick = if IsNaN(close) then na else ctick;

plot zero = 0;
cumtick.AssignValueColor(if cumtick > cumtick[lookback] then color.green else color.red);
AssignPriceColor(if !upper then color.current else if cumtick > cumtick[lookback] AND ltick < avgl then color.green else if cumtick > cumtick[lookback] then color.gray else if cumtick < cumtick[lookback] AND htick > avgh then color.red else color.gray);
cumtick.SetLineWeight(2);
def hcumtick=if !hidecumtick then cumtick else na;
def hzero=if !hidecumtick then zero else na;
AddCloud(hcumtick, hzero );
plot buy = if cumtick > cumtick[lookback] AND ltick < avgl then low - tickSize() else if cumtick > cumtick[lookback] then na else if cumtick < cumtick[lookback] AND htick > avgh then na else na;
plot sell = if cumtick > cumtick[lookback] AND ltick < avgl then na else if cumtick > cumtick[lookback] then na else if cumtick < cumtick[lookback] AND htick > avgh then high + tickSize() else na;

plot ahi = if IsNaN(close) then na else avgh;
plot alo = if IsNaN(close) then na else avgl;
plot hib = if hi < 0 then hi else na;
plot lob = if lo > 0 then lo else na;
plot phi = hi;
plot plo = lo;

buy.SetDefaultColor(color.green);
buy.SetPaintingStrategy(paintingStrategy.ARROW_UP);
sell.SetDefaultColor(color.red);
sell.SetPaintingStrategy(paintingStrategy.ARROW_DOWN);

#plot zero=0;
#
# Formatting:
#
hib.SetPaintingStrategy(paintingStrategy.HISTOGRAM);
hib.SetDefaultColor(color.black);
hib.SetLineWeight(5);
lob.SetPaintingStrategy(paintingStrategy.HISTOGRAM);
lob.SetDefaultColor(color.black);
lob.SetLineWeight(5);

Last.SetDefaultColor(Color.white);
Last.SetPaintingStrategy(paintingStrategy.DASHES);
phi.SetPaintingStrategy(paintingStrategy.HISTOGRAM);
phi.AssignValueColor(if hi > ahi then color.dark_GREEN else color.gray);
phi.SetLineWeight(5);
plo.SetPaintingStrategy(paintingStrategy.HISTOGRAM);
plo.AssignValueColor(if lo < alo then color.dark_red else color.gray);
plo.SetLineWeight(5);
zero.SetDefaultColor(color.gray);
zero.SetLineWeight(1);
amean.AssignValueColor(if cumtick > cumtick[lookback] then color.green else color.red);
amean.SetLineWeight(5);
amean.SetStyle(curve.POINTS);
ahi.SetDefaultColor(color.green);
ahi.SetStyle(curve.SHORT_DASH);
alo.SetDefaultColor(color.red);
alo.SetStyle(curve.SHORT_DASH);

#Hiding depending on if upper or lower
phi.setHiding(upper);
plo.setHiding(upper);
zero.setHiding(upper);
last.setHiding(upper);
hib.setHiding(upper);
lob.setHiding(upper);

ahi.setHiding(upper);
alo.setHiding(upper);
cumtick.setHiding(hidecumtick);
nettick.setHiding(hidecumtick);
buy.setHiding(!upper);
sell.setHiding(!upper);

amean.setHiding(upper);
I'll add this tick study to the queue if possible. Thanks.
 
Hi Everyone, I've queued up CCI + TTM squeeze + TTM trend and the CCI/ATR modules for this week. as I have time during week will get these two implemented. if there are any other modules or considerations you would like to see, in addition please let me know and will try to get as much of it done during this upcoming week.
any update on when you might implement these? Looking forward to it.
 
Here is Version 1.8, we now have over 10 indicators fully integrated (2 of them are tri-combos), for a total triage of 13 total.

Coverage in this release:
1.8 includes: TTM Trend, Super Trend, Frema, TMO, TOP, DMI , BOP, Slim Ribbon, Super Trend w/CCI and ATR combo, a CCI + TTM squeeze + TTM trend Combo and ADX as Trending/Non-Trending. All integrated with a LONG/SHORT/HOLD signal that is based on the threshold specified and indicators activated..

Changelog:

2020.01.09 V1.8 @diazlaz - Integrated Super Trend w/CCI and ATR
- Integrated CCI + TTM squeeze + TTM trend Combo
- Set treshold defaults to 7 (7 out of 10), removed scanmode.


Ruby:
#trend, a momentum and a cycle based indicator for ThinkorSwim V1.8
#@hockeycoachdoug Community Request
#
#VERSION
# 2020.01.09 V1.8 @diazlaz - Integrated Super Trend w/CCI and ATR
#                          - Integrated CCI + TTM squeeze + TTM trend Combo
#                          - Set treshold defaults to 7 (7 out of 10), removed scanmode.
# 2020.01.04 V1.7 @diazlaz - Integrated Slim Ribbon.
# 2020.01.02 V1.6 @diazlaz - Integrated DMI and BOP, restructured INPUTS to each module.
#                            threshold increased to 4 by default.
# 2020.01.01 V1.5 @diazlaz - Integrated ADX Trending States and BAR Line
# 2020.01.01 V1.4 @diazlaz - Integrated TTM Trends, modules selection
#                            and added threshold for signals
# 2019.12.31 V1.2 @diazlaz - Integrated FREMA
# 2019.12.30 V1.1 @diazlaz - Labels, Additional Dashboard, Lower Study
# 2019.12.30 V1.0 @diazlaz - Community Ask/Release
#
#LINK
#https://usethinkscript.com/threads/i-request-help-combining-3-indicators-into-1-paintbar-study.1390/
#
#INSTRUCTION
#Here is how I envision the paintbar working:
#When the supertrend indicator is long that would equal +1, when its short -1.
#When the TMO is green that would equal +1. when its red its -1.
#When the TOP Cycle Trader is above zero that would equal +1, when its below zero -1.
#When all 3 indicators are equal to +1 making +3 total the price bars would paint #green.
#When all 3 indicators are equal to -1 making -3 total the price bars would paint red.
#If the combination of all 3 indicators equals anything else, the price bars would #paint gray meaning all 3 indicators were not in agreement.
#
#Now includes: TTM Trend, Super Trend, Frema, TMO, TOP, DMI , BOP, Slim Ribbon and
#ADX as Trending/Non-Trending, Super Trend w/CCI and ATR combo and
#a CCI + TTM squeeze + TTM trend Combo with LONG/SHORT/HOLD signal selection
#based on threshold specified and indicators enabled.
#

declare upper;

#INPUTS
input showLabels = yes;
input PaintBars = yes;

input threshold = 7;

input enableTTM = yes;
input enableSuperTrend = yes;
input enableFrema = yes;
input enableTMO = yes;
input enableSlim = yes;
input enableTOP = yes;
input enableDMI = yes;
input enableBOP = yes;
input enableSuperTrendCCIATR = yes;
input enableCCITTM = yes;

input displace = 0;

#CORE
DefineGlobalColor("CycleLineColor", Color.RED);
DefineGlobalColor("CyclehistColor", Color.BLUE);
DefineGlobalColor("ZeroLineColor", Color.YELLOW);
DefineGlobalColor("Bullish", Color.GREEN);
DefineGlobalColor("Bearish", Color.RED);
DefineGlobalColor("Neutral", Color.MAGENTA); #Color.YELLOW
DefineGlobalColor("Off", Color.DARK_GRAY);
DefineGlobalColor("On", Color.GREEN);
DefineGlobalColor("Sync1", Color.YELLOW);
DefineGlobalColor("Sync2", Color.CYAN);
DefineGlobalColor("Up", Color.GREEN);
DefineGlobalColor("Down", Color.RED);
DefineGlobalColor("NUp", Color.DARK_GREEN);
DefineGlobalColor("NDown", Color.DARK_RED);
DefineGlobalColor("Neutral", Color.BLUE);
DefineGlobalColor("Neutral2", Color.PLUM);

def h = high;
def l = low;
def o = open;
def c = close;
def na = Double.NaN;

AddLabel(showLabels, "A trend, momentum and cycle Trading System v1.7", Color.CYAN);

#TTM Trend
def TrendUp = if TTM_Trend().TrendUp == 1 then 1 else 0;
def TrendDown = if TTM_Trend().TrendDown == 1 then 1 else 0;
def sTTM = if TrendUp then 100 else if TrendDown then -100 else 0;
def sBullish_TTM = if(enableTTM and sTTM == 100,1,0);
def sBearish_TTM = enableTTM and sTTM == -100;
AddLabel(showlabels and enableTTM, "TTM", if IsNan(sTTM) then COLOR.DARK_GRAY else
if sTTM[-displace] > 0 then COLOR.GREEN else
if sTTM[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));

#SuperTrend (Mobius)
input AtrMult = 1.0; #SuperTrend
input nATR = 4; #SuperTrend
input AvgType = AverageType.HULL; #SuperTrend

def ATR = MovingAverage(AvgType, TrueRange(high, close, low), nATR);
def UP = HL2 + (AtrMult * ATR);
def DN = HL2 + (-AtrMult * ATR);
def ST = if close < ST[1] then UP else DN;
def sSuperTrend = if close < ST then -100 else 100;
def sBullish_SuperTrend = enableSuperTrend and sSuperTrend == 100;
def sBearish_SuperTrend = enableSuperTrend and sSuperTrend == -100;
AddLabel(showlabels and enableSuperTrend, "SuperTrend", if IsNan(sSuperTrend) then COLOR.DARK_GRAY else
if sSuperTrend[-displace] > 0 then COLOR.GREEN else
if sSuperTrend[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));

#FREMA
input AA = .1; #FREMA

def CC;
def zeroLine = 0;
def RE1;
def RE2;
def RE3;
def RE4;
def RE5;
def RE6;
def RE7;
def RE8;
def EMA;
CC = if CC[1] == 0 then .9 else 1 – AA;
EMA = AA * close + CC * EMA[1];
RE1 = CC * EMA + EMA[1];
RE2 = Power(CC, 2) * RE1 + RE1[1];
RE3 = Power(CC, 4) * RE2 + RE2[1];
RE4 = Power(CC, 8) * RE3 + RE3[1];
RE5 = Power(CC, 16) * RE4 + RE4[1];
RE6 = Power(CC, 32) * RE5 + RE5[1];
RE7 = Power(CC, 64) * RE6 + RE6[1];
RE8 = Power(CC, 128) * RE7 + RE7[1];
def EMA_Signal = EMA – AA * RE8;
def sFrema = if (EMA_Signal > zeroLine) then 100 else -100;
def sBullish_Frema = enableFrema and sFrema == 100;
def sBearish_Frema = enableFrema and sFrema == -100;
AddLabel(showlabels and enableFrema, "Frema", if IsNan(sFrema) then COLOR.DARK_GRAY else
if sFrema[-displace] > 0 then COLOR.GREEN else
if sFrema[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));

#TMO
input length = 14; #TMO
input calcLength = 5; #TMO
input smoothLength = 3; #TMO

def data = fold i = 0 to length
           with s
           do s + (if c > getValue(o, i)
                   then 1
                   else if c < getValue(o, i)
                        then - 1
                        else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);
def sMain = if Main > Signal then 100 else -100;
def sSignal = if Main > Signal then 100 else - 100;
def ob = if isNaN(c) then double.nan else round(length * .7);
def os = if isNaN(c) then double.nan else -round(length * .7);
def sTMO = if Main > Signal then 100 else -100;
def sBullish_TMO = enableTMO and sTMO == 100;
def sBearish_TMO = enableTMO and sTMO == -100;
AddLabel(showlabels and enableTMO, "TMO", if IsNan(sTMO) then COLOR.DARK_GRAY else
if sTMO[-displace] > 0 then COLOR.GREEN else
if sTMO[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));

#SLIM
input sSuperFast = 8;
input sFast = 13;
input sSlow = 21;

def SuperFastM1 = ExpAverage(close[-displace], sSuperFast);
def FastM1 = ExpAverage(close[-displace], sFast);
def SlowM1 = ExpAverage(close[-displace], sSlow);
def buyM1 = SuperFastM1 > FastM1 and FastM1 > SlowM1 and low > SuperFastM1;
def stopbuyM1 = SuperFastM1 <= FastM1;
def buynowM1 = !buyM1[1] and buyM1;
def buysignalM1 = CompoundValue(1, if buynowM1 and !stopbuyM1 then 1
else if buysignalM1[1] == 1 and stopbuyM1 then 0 else buysignalM1[1], 0);
def Buy_SignalM1 = buysignalM1[1] == 0 and buysignalM1 == 1;
def Momentum_DownM1 = buysignalM1[1] == 1 and buysignalM1 == 0;
def sellM1 = SuperFastM1 < FastM1 and FastM1 < SlowM1 and high < SuperFastM1;
def stopsellM1 = SuperFastM1 >= FastM1;
def sellnowM1 = !sellM1[1] and sellM1;
def sellsignalM1 = CompoundValue(1, if sellnowM1 and !stopsellM1 then 1
else if sellsignalM1[1] == 1 and stopsellM1 then 0 else sellsignalM1[1], 0);
def Sell_SignalM1 = sellsignalM1[1] == 0 and sellsignalM1;
def Momentum_UpM1 = sellsignalM1[1] == 1 and sellsignalM1 == 0;
def sStateM1 = if Buy_SignalM1 then 100 else if Momentum_UpM1 then 10 else if Sell_SignalM1 then -100 else if Momentum_DownM1 then -10 else sStateM1[1];
def sBullish_SLIM = enableSLIM and sStateM1 == 100;
def sBearish_SLIM = enableSLIM and sStateM1 == -100;
AddLabel(showlabels and enableSLIM, "SLIM", if IsNan(sStateM1) then COLOR.DARK_GRAY else
if sStateM1[-displace] >= 100 then COLOR.GREEN else
if sStateM1[-displace] <= -100 then COLOR.RED
else COLOR.YELLOW);

#TOP Cycle Trader
input FastCycleLength = 5; #TOP
input SlowCycleLength = 8; #TOP

def FastVar = ExpAverage((H + L) / 2, FastCycleLength);
def SlowVar = Average((H + L) / 2, SlowCycleLength);
def DiffVar = FastVar - SlowVar;
def pDiffVar = DiffVar;
def pDiffVar2 = DiffVar;
def sTOP = if DiffVar > 0 then 100 else -100;
def sBullish_TOP = enableTOP and sTOP == 100;
def sBearish_TOP = enableTOP and sTOP == -100;
AddLabel(showlabels and enableTOP, "TOP", if IsNan(sTOP) then COLOR.DARK_GRAY else
if sTOP[-displace] > 0 then COLOR.GREEN else
if sTOP[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));

#DMITrend
input DMIlength = 13;

def hiDiff = high - high[1];
def loDiff = low[1] - low;
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATRDMI = WildersAverage(TrueRange(high, close, low), DMIlength);
Def DIPlus = 100 * WildersAverage(plusDM, DMIlength) / ATRDMI;
Def DIMinus = 100 * WildersAverage(minusDM, DMIlength) / ATRDMI;
def sDMI = if DIPlus > DIMinus then 100 else if DIMinus > DIPlus then -100 else 0;
def sBullish_DMI = enableDMI and sDMI == 100;
def sBearish_DMI = enableDMI and sDMI == -100;
AddLabel(showlabels and enableDMI, "DMI", if IsNan(sDMI) then COLOR.DARK_GRAY else
if sDMI[-displace] > 0 then COLOR.GREEN else
if sDMI[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));

#BOP indicator
input averageType = {Simple, Exponential, default Weighted, Wilders, Hull,  Disabled};
input BoPlength = 16;

def rawBMP = if high != low then (close - open) / (high - low) else 1;
def BMP;
switch (averageType) {
case Simple:
    BMP = Average(rawBMP, BoPlength);
case Exponential:
    BMP = ExpAverage(rawBMP, BoPlength);
case Weighted:
    BMP = wma(rawBMP, BoPlength);
case Wilders:
    BMP = WildersAverage(rawBMP, BoPlength);
case Hull:
    BMP = HullMovingAvg(rawBMP, BoPlength);
case Disabled:
    BMP = rawBMP;
}
def sBOP = if BMP > 0 then 100 else -100;
def sBullish_BOP = enableBOP and sBOP == 100;
def sBearish_BOP = enableBOP and sBOP == -100;
AddLabel(showlabels and enableBOP, "BOP", if IsNan(sBOP) then COLOR.DARK_GRAY else
if sBOP[-displace] > 0 then COLOR.GREEN else
if sBOP[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));


# SUPERTREND BY MOBIUS AND CCI ATR TREND COMBINED
input lengthCCI = 50;
input lengthATR = 21;
input AtrFactor = 1.0;
def pricedata = hl2;
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 sSuperTrendCCIATR = if c < MT1 and c < ST then -100 else if C > MT1 and c >ST then 100 else 0;
def sBullish_SuperTrendCCIATR = enableSuperTrendCCIATR and sSuperTrendCCIATR == 100;
def sBearish_SuperTrendCCIATR = enableSuperTrendCCIATR and sSuperTrendCCIATR == -100;
AddLabel(showlabels and enableSuperTrendCCIATR, "SuperTrendCCI", if IsNan(sSuperTrendCCIATR) then COLOR.DARK_GRAY else
if sSuperTrendCCIATR[-displace] > 0 then COLOR.GREEN else
if sSuperTrendCCIATR[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));

# CCI + TTM squeeze + TTM trend
def CCIBuy = CCI(length = 14).CCI > 0 and CCI(length = 50).CCI > 0;
def CCISell = CCI(length = 14).CCI < 0 and CCI(length = 50).CCI < 0;
def sTrendUp = TTM_Trend().TrendUp;
def sTrendDn = TTM_Trend().TrendDown;
def SqueezeUp = TTM_Squeeze().Histogram >= 0;
def SqueezeDn = TTM_Squeeze().Histogram <= 0;
def Buy = CCIBuy and sTrendUp and SqueezeUp;
def Sell = CCISell and sTrendDn and SqueezeDn;
def sCCITTM = if buy then 100 else if sell then -100 else 0;
def sBullish_CCITTM = enableCCITTM and sCCITTM == 100;
def sBearish_CCITTM = enableCCITTM and sCCITTM == -100;
AddLabel(showlabels and enableCCITTM, "TTM CCI", if IsNan(sCCITTM) then COLOR.DARK_GRAY else
if sCCITTM[-displace] > 0 then COLOR.GREEN else
if sCCITTM[-displace] < 0 then COLOR.RED
else GlobalColor("Off"));

#ADX TRENDING
input ADXlength = 8; #ADX
input ADXTrending = 25; #ADX
input showADXBar = yes;

def ADX = DMI(ADXlength).ADX;
plot ADXCross = LowestAll(low);
ADXCross.SetPaintingStrategy(PaintingStrategy.LINE);
ADXCross.AssignValueColor(
    if ADX > ADXTrending then Color.LIME
    else Color.DARK_GRAY);
ADXCross.SetLineWeight(5);
ADXCross.SetHiding(!showADXBar);

AddLabel(showlabels,
if ADX > ADXTrending then "Trending" else
"Non Trending",
if IsNan(c) then COLOR.DARK_GRAY else
if ADX > ADXTrending then COLOR.GREEN else
COLOR.DARK_GRAY);

#STATE
def sResults = sSuperTrend + sTMO + sTOP + sFrema + sTTM + sDMI + sBOP + sStateM1;
def sBullish = sBullish_TTM + sBullish_SuperTrend + sBullish_Frema + sBullish_TMO + sBullish_TOP + sBullish_DMI + sBullish_BOP + sBullish_SLIM + sBullish_SuperTrendCCIATR + sBullish_CCITTM;
def sBearish = sBearish_TTM + sBearish_SuperTrend + sBearish_Frema + sBearish_TMO + sBearish_TOP + sBearish_DMI + sBearish_BOP + sBearish_SLIM + sBearish_SuperTrendCCIATR + sBearish_CCITTM;
def bullish = if(sBullish >= threshold,1,0);
def bearish = if(sBearish >= threshold,1,0);
def sState = if bullish then 100 else if bearish then -100 else 0;
def sState2 = if sState != 0 then sState else sState2[1];

#COLORBARS
AssignPriceColor(
if PaintBars then
    if bullish then COLOR.GREEN else if bearish then COLOR.RED
     else COLOR.GRAY
else COLOR.CURRENT);

AddLabel(showlabels,
if bullish[-displace] then "LONG" else
if bearish[-displace] then "SHORT"
else "HOLD",
if IsNan(c) then COLOR.DARK_GRAY else
if bullish[-displace] then COLOR.GREEN else
if bearish[-displace] then COLOR.RED
else COLOR.GRAY);

#END OF trend, a momentum and a cycle based indicator for ThinkorSwim V1.8
 
Well I have to ask how the heck do ya trade this study I have no info...looks impressive?
You can use it to combine any of the 10 indicators into one combo paintbar study.
I'm posting my personal combo. If you find a trendy enough stock it will have success on its own. I'm trying to figure out the best way to confirm signals.

https://tos.mx/inh4SdH
you can check the inputs of my personalized version to see what I did and mess around with it.
 
With one study. And 2 minutes of finding a close match.
2020-01-10-TOS-CHARTS.png
 
Can someone please tell me what the gray candles represent? I turned everything to NO with the exception of CCI SuperTrend and the candles are all gray at all times...with the 1.7 version the candles were ONLY GREEN and RED...now with the 1.8 version do the gray candles mean no trade?
 
Figured it out...changed the setting to 5 from 7 and received the desired results...I am rather curious to see tho how a Heikin Ashi Trend would work with this as well... @Townsend made a MTF Heikin Ashi and I've been comparing the results of a 10 min MTF on a 5 min chart Heikin Ashi to this...really close and at times the Heikin Ashi hits even sooner even though its set to 10 min aggregation. @diazlaz do you think you'd be able toss in one more trend in there?
 
Figured it out...changed the setting to 5 from 7 and received the desired results...I am rather curious to see tho how a Heikin Ashi Trend would work with this as well... @Townsend made a MTF Heikin Ashi and I've been comparing the results of a 10 min MTF on a 5 min chart Heikin Ashi to this...really close and at times the Heikin Ashi hits even sooner even though its set to 10 min aggregation. @diazlaz do you think you'd be able toss in one more trend in there?
Sure, I added it to my backlog, will try to get it in over the weekend if not by mid week.

I will add as a mtf ha, one additional timeframe with input default to 10 mins.

Greens means all indicators enabled are in the long direction based on the number of indicators required to confirm bias, threshold. If reds shorts if gray then it's neutral conditions don't meet the thresholds.

I'm running a bit behind on the forums, I will need to block an entire day to catch up soon.
 
With one study. And 2 minutes of finding a close match.
2020-01-10-TOS-CHARTS.png
The chart you compared it to looks really nice on a chart but if you attempted to use that when trading it is way too indescisive ex Thursday and Friday, 14 color switches on yours as opposed to 7 on the one I posted (I didn't include changes in non trending periods on either tally). Almost all the gains on big runs will be lost to the double amount of entry's and exits. I'm not saying the trend study you posted isn't very similar, but it's combining multiple that gives it a slight but powerful trading edge over it.
 
Last edited:
It would be good to see to capture how ur all using this indicator, perhaps we can all develop a trading plan around it.

What assets do you trade, timeframe and your entry approach (which indicators you enable and what is ur threshold), and approach to exit and manage ur trades.

Good trading everyone!
 
It would be good to see to capture how ur all using this indicator, perhaps we can all develop a trading plan around it.

What assets do you trade, timeframe and your entry approach (which indicators you enable and what is ur threshold), and approach to exit and manage ur trades.

Good trading everyone!
I think I found a breakthrough when it comes to the accuracy of the settings I was using. Results were already really accurate but by chance I stumbled across this extra condition that seemed to greatly increase the response. That condition being coloring all grey bars left after using your paintbar study with my conditions. If you don't understand look at the chart I'm posting and imagine all grey candles colored by the corresponding led study below. https://tos.mx/oJFkW6B
This is the code for that study
Code:
#====== MACD.value is above MACD.avg (signal line)======
input fastLength_1 = 12;#hint fastLength_1:For the MACD plot that evaluates the MACD.Value being above the MACD.Avg (signal line).
input slowLength_1 = 26;#hint slowLength_1:For the MACD plot that evaluates the MACD.Value being above the MACD.Avg (signal line).
input MACDLength_1 = 9;#hint MACDLength_1:For the MACD plot that evaluates the MACD.Value being above the MACD.Avg (signal line).
input AverageType_1 = {SMA, default EMA};#hint AverageType_1:For the MACD plot that evaluates the MACD.Value being above the MACD.Avg (signal line).
def macd_Val_1 = MACD(fastLength_1, slowLength_1, MACDLength_1, AverageType_1).Value;
def macd_Avg1 = MACD(fastLength_1, slowLength_1, MACDLength_1, AverageType_1).Avg;
def MACD_trig = if MACD().value > MACD().avg then 1 else 0;
#def MACD_Value = MACD(MACDLength = MACDLength, AverageType = "EMA").Diff;
plot Macd_Line1 = 35;
Macd_Line1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Macd_Line1.SetLineWeight(5);
Macd_Line1.AssignValueColor(if macd_Val_1 > macd_Avg1 then Color.Green else Color.Red);
#== end ====
I hope you can also see the potential. If you are able to add this to the next version I will then easily make a strategy because the grey candles will be eliminated.
 

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
370 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