# Price Rate of Change (ROC) For ThinkOrSwim

#### cabe1332

##### Active member
Updated version can be found: https://usethinkscript.com/threads/price-rate-of-change-roc-for-thinkorswim.8549/#post-102522

The Rate Of Change (ROC) is an oscillator calculating the percentage change of the security price relative to the price of a specified number (length) of periods before. The higher/lower the ROC, the more overbought/oversold the security; when the ROC falls, a rally might occur.

When I am in a price action trade or scalping I tend to watch the Time and Sales or Level2 price to get the most entry/exit of the position. That took too much brain energy to watch like I am in a Twilight Zone. So, I've come up with a simple ROC lower indicator to help me see the average of the last period prices if the price is increasing/decreasing and direction. This beats watching the Time and Sales or Level2. It works well on trending and momentum with price action securities. It works for me and would like to share it with you all. Let me know if ROC works and helps you too. Good luck! @cabe1332.
Ruby:
``````# Price Rate of Change
# cabe1332 10/20/2021
# The Rate Of Change (ROC) is an oscillator calculating the percentage change of the security price relative to the price of a specified number (length) of periods before. The higher the ROC, the more overbought the security; when the ROC falls, a rally might occur.

# code start

declare lower;

input length = 7;
input colorNormLength = 7;
input price = close;

assert(length > 0, "'length' must be positive: " + length);

plot ROC = if price[length] != 0 then (price / price[length] - 1) * 100 else 0;

ROC.DefineColor("Highest", Color.green);
ROC.DefineColor("Lowest", Color.red);
ROC.SetLineWeight(2);

plot zeroline = if !isnan(close) then 0 else double.nan;
zeroline.assignValueColor(if Roc > 0 then Color.green else color.light_red);
zeroline.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
zeroline.SetLineWeight(1);

AddLabel(yes, if roc > roc[1] then "Price ROC Increasing " + round(roc,2) else "Price ROC Status Decreasing " + round(roc,2), if roc > roc[1] then color.green else color.red);

AddLabel(yes, if roc > buy_threshold then "Trending UP: BUY or Take Profits if needed! " else if roc between 0 and buy_threshold then "Wait and Watch!" else if roc < roc[1] and roc < 0 then "Trending DOWN! Wait for the rally!" else if roc > roc[1] and roc < 0 then "Trending DOWN! Wait for the rally !" else " ", if roc > 0 and roc > buy_threshold then color.green else color.red);
# end code``````

Last edited by a moderator:
Hi all, really worked well for me last week I spent more time today refining the study and sharing it with you all. Good Luck! @cabe1332

# added support and condition for bulls and bears labels
# added RSI and EMA stacked for better entry/exit labels
# added support for Profit Taking conditions with labels

Code:
``````# Rate of Change
# cabe1332
#The Rate Of Change (ROC) is an oscillator calculating the percentage change of the security price relative to the price a specified number (length) of periods before. The higher the ROC, the more overbought the security; when the ROC falls, a rally might occur.

# 10/20/2021 Rev.1
# TOC ROC with labels

# 10/23/2021 Rev.2
# added support and condition for bulls and bears labels
# added RSI and EMA stacked for better entry/exit labels
# added support for Profit Taking conditions with labels

## code start

declare lower;

input length = 7;
input colorNormLength = 7;
input price = close;
input bullthreshold = 2;
input bearthreshold = -2;

assert(length > 0, "'length' must be positive: " + length);

plot ROC = if price[length] != 0 then (price / price[length] - 1) * 100 else 0;
ROC.DefineColor("Highest", Color.green);
ROC.DefineColor("Lowest", Color.red);
ROC.SetLineWeight(2);

plot zeroline = if !isnan(close) then 0 else double.nan;
zeroline.assignValueColor(if Roc > 0 then Color.green else color.light_red);
zeroline.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
zeroline.SetLineWeight(1);

# RSI
def rsi = RSI()."RSI" is greater than or equal to 30 and RSI()."RSI" is less than or equal to 70 within 2 bar;

#EMAstacked#
def BULLISHstackedUp = MovAvgExponential("length" = 8)."AvgExp" is greater than MovAvgExponential("length" = 21)."AvgExp"
and MovAvgExponential("length" = 21)."AvgExp" is greater than MovAvgExponential("length" = 34)."AvgExp"
and MovAvgExponential("length" = 34)."AvgExp" is greater than MovAvgExponential("length" = 50)."AvgExp" within 2 bars;

def BEARstackedUp = MovAvgExponential("length" = 8)."AvgExp" is less than MovAvgExponential("length" = 21)."AvgExp"
and MovAvgExponential("length" = 21)."AvgExp" is less than MovAvgExponential("length" = 34)."AvgExp"
and MovAvgExponential("length" = 34)."AvgExp" is less than MovAvgExponential("length" = 50)."AvgExp" within 2 bars;

# ROC increasing or decreasing label
AddLabel(yes, if roc > roc[1] then " ROC Increasing " + round(roc,2) + " " else " ROC Decreasing " + round(roc,2) + " ", if roc > roc[1] then color.green else color.red);

# BULLISH OR BULLISH OR NEUTRAL
AddLabel(yes, if roc >= bullthreshold then " BULLISH " else if roc <= bearthreshold then " BEARISH " else " Wait & Watch ", if roc >= bullthreshold then color.green else if roc <= bearthreshold then color.red else color.white);

# GOING LONG OR SHORT BUY
def LONGBUY = roc >= bullthreshold and rsi and BULLISHstackedUp;
def SHORTBUY = roc <= BEARthreshold and rsi and BEARstackedUp;

# PERSONAL MESSAGE TO TAKE PROFITS
def TakeProfit = (roc between 10 and 20) or (roc between -10 and -20);
def SeriouslyTakeProfit = (roc between 21 and 50) or (roc between -21 and -50);
def inTakeProfit = (roc between 51 and 99) or (roc between -51 and -99);
def DontBeLoser = (roc >= 100) or (roc <= -100);
AddLabel(yes, if TakeProfit then " Take Profit! " else if SeriouslyTakeProfit then " SERIOUSLY, Take Profit! " else if inTakeProfit then " ****IN! Take Profit! " else if DontBeLoser then " DON'T BE A LOSER! Take Profit! " else "", if TakeProfit then color.green else if SeriouslyTakeProfit then color.cyan else if inTakeProfit then color.orange else if DontBeLoser then color.magenta else color.black);

## end code``````

Last edited by a moderator:
Below is the Price ROC scan code. Good Luck! @cabe1332

Code:
``````# Rate of Change Scan
# cabe1332
#The Rate Of Change (ROC) is an oscillator calculating the percentage change of the security price relative to the price a specified number (length) of periods before. The higher the ROC, the more overbought the security; when the ROC falls, a rally might occur.

# 10/20/2021 Rev.1
# TOC ROC with labels

# 10/23/2021 Rev.2
# added support and condition for bulls and bears labels
# added RSI and EMA stacked for better entry/exit labels
# added support for Profit Taking conditions with labels and plots

## code start

# just cut and paste into a study for scan support
# replace the "#" if scanning for long or short scan

input length = 7;
input colorNormLength = 7;
input price = close;
input bullthreshold = 2;
input bearthreshold = -2;

assert(length > 0, "'length' must be positive: " + length);

def ROC = if price[length] != 0 then (price / price[length] - 1) * 100 else 0;

# RSI
def rsi = RSI()."RSI" is greater than or equal to 30 and RSI()."RSI" is less than or equal to 70 within 2 bar;

#EMAstacked#
def BULLISHstackedUp = MovAvgExponential("length" = 8)."AvgExp" is greater than MovAvgExponential("length" = 21)."AvgExp"
and MovAvgExponential("length" = 21)."AvgExp" is greater than MovAvgExponential("length" = 34)."AvgExp"
and MovAvgExponential("length" = 34)."AvgExp" is greater than MovAvgExponential("length" = 50)."AvgExp" within 2 bars;

def BEARstackedUp = MovAvgExponential("length" = 8)."AvgExp" is less than MovAvgExponential("length" = 21)."AvgExp"
and MovAvgExponential("length" = 21)."AvgExp" is less than MovAvgExponential("length" = 34)."AvgExp"
and MovAvgExponential("length" = 34)."AvgExp" is less than MovAvgExponential("length" = 50)."AvgExp" within 2 bars;

# GOING LONG OR SHORT BUY
def LONGBUY = roc >= bullthreshold and rsi and BULLISHstackedUp;
def SHORTBUY = roc <= BEARthreshold and rsi and BEARstackedUp;

# Scan support

## end code``````

@cabe1332 thanks you so much for fun indicator as I have followed you many post I picked up lot of toys from you

So your code logic is when above 2 = bullish correct ?
when below 2 = Bearish correct ?

what is the max and min that ROC can go to ?

I used lot of indicator to measure momentum like RSI cross 50 or CCI cross Zero as well as ROC cross Zero

RSI got overbought. over sold . CCI got 200 to 300

what about this ROC ? what highest level they can go to for overbought and oversold (7? 10 or -7 or -10 ) ???

Do you normally enter trade when cross zero or cross 2. ? for long and short
I saw the label really like it "wait and watch" come to my logic
I only wait for right set up , don't force trade

lastly, thanks a lot. for those toys when combine all together i got from you with TTM SQ pro really fun to get the right set up

I use DMI and ADX which can tell me the strength of trend but when I got your version dammmmm so good but I change setting 6 to 7

and I agreed. for those level 1. and level 2 when I am scalping took my eyes and brain lot of energy monitoring

Last edited:
@cabe1332 by the way if you ever get to tweak cci into your own version please let me know
I used cci. with your roc is more fun to measure momentum
I feel like I saw your cci somewhere but not. sure for Watchlist or for label stats

thanks a lot

@cabe1332 thanks you so much for fun indicator as I have followed you many post I picked up lot of toys from you

So your code logic is when above 2 = bullish correct ?
when below 2 = Bearish correct ?

what is the max and min that ROC can go to ?

I used lot of indicator to measure momentum like RSI cross 50 or CCI cross Zero as well as ROC cross Zero

RSI got overbought. over sold . CCI got 200 to 300

what about this ROC ? what highest level they can go to for overbought and oversold (7? 10 or -7 or -10 ) ???

Do you normally enter trade when cross zero or cross 2. ? for long and short
I saw the label really like it "wait and watch" come to my logic
I only wait for right set up , don't force trade

lastly, thanks a lot. for those toys when combine all together i got from you with TTM SQ pro really fun to get the right set up

I use DMI and ADX which can tell me the strength of trend but when I got your version dammmmm so good but I change setting 6 to 7

and I agreed. for those level 1. and level 2 when I am scalping took my eyes and brain lot of energy monitoring

My ROC is (custom) value is in percent, not 0 to 2 or 0 to -2. It is much easier to understand with converted values with a wider range. The higher percentage of the ROC the greater probability of success in the position (bullish/green, bearish/red). No limits on ROC, but I prefer entry decisions on using high ROC than RVI.

ROC calculates price changes specifically. Overbought/oversold you can use RSI or Stochastic.

edited: this post or reply has been updated to not mislead readers of the missing image or grid. The image or grid has been removed by the site administrator.

Good luck and good trading! @cabe1332

Last edited:

My ROC is (custom) value is in percent, not 0 to 2 or 0 to -2. It is much easier to understand with converted values with a wider range. The higher percentage of the ROC the greater probability of success in the position (bullish/green, bearish/red). No limits on ROC, but I prefer entry decisions on using high ROC than RVI.

ROC calculates price changes specifically. Overbought/oversold you can use RSI or Stochastic.

I enter a trade with multiple confirmations. On my chart, I enter in white or yellow arrows only. I customized this indicator to my style and strategy. It is a combined indicator code logic of MACD, Momentum, RSI, ADX_DMI, SqueezePro, and Moving Averages. Along with the indicators, my entries include the Fibinnaci and Pullback strategy, which takes out the guessing and it allows me to plot my stop loss/exit ahead of time. I don't chaste, I wait, and follow a plan as much as I can. If I missed an opportunity for an entry, there should be another (multiple) entries following the previous if that stock is that good. You just have to be patient. And yes, the "Watch/Wait" helps with entry with the right setup.

My ADX_DMI help me a lot in maximizing profits to stay on a trade longer. I am glad you like it and has been a lifesaver. There are other indicators in my chart also that help me with warning signs for exit/entry.

I suggest a good watchlist and fill it with columns with useful data that will easily help you a glance at the state of a stock/security. A trend column(s) and market stage of the stock are great to have. On my watchlist, you will see to the right (TS5, TS15, TS30, and Stage), with 10 = trending and EMAs are stacked, Stage tells you the market status it is in "Accm: 4" means it is in the accumulation stage for the last 4 candles, etc.

I wish I had more capital to scale up on positions, limited at this time. Got any ideas and experience where I can get more capital?

thanks for clarify how to use ROC properly

==>for "Accm: 4" that look like the one I get from Tosindicator called " Market Pulse Indicator
identified 4 stage of the market
https://tosindicators.com/indicators/market-pulse
https://tosindicators.com/dashboards/market-pulse-dashboard

but your version got number on last XX candles that nice one to have on main chart and watchlist

==>for yellow and white arrow that good logic that you combine all profitable indicator and look like predict squeeze direction before FIRE !!

==> your cloud on chart is that EMA cloud ?? Have ya ever tried Hull +EMA+ MArket pulse together or maybe too noisy for you
I use EMA ( 8 21 34 50) STACKed with hull as of now

lastly , one of the best indicator that I forget to mention beside you mentioned above to get along well with those is TMO
if u wanna try that TMO would be great to replace Stochastic
I personally use 3 Tmo with High Agg on my chart
here if u wanna try https://tos.mx/hJH0Crq

good luck and thanks lot

Last edited by a moderator:
cabe: lovin' this indicator not so much for what it does -- i'm more of a mean-reversion guy -- but for the labels, which are beyond great and give me superior chuckles whenever they pop up. so, for them alone, thanks a mil!

Thanks for sharing your code! Made some changes to make it a bit more visually pleasing.

Code:
``````# Rate of Change
# cabe1332
#The Rate Of Change (ROC) is an oscillator calculating the percentage change of the security price relative to the price a specified number (length) of periods before. The higher the ROC, the more overbought the security; when the ROC falls, a rally might occur.

# 10/20/2021 Rev.1
# TOC ROC with labels

# 10/23/2021 Rev.2
# added support and condition for bulls and bears labels
# added RSI and EMA stacked for better entry/exit labels
# added support for Profit Taking conditions with labels

## code start

declare lower;

input length = 7;
input colorNormLength = 7;
input price = close;
input bullthreshold = 2;
input bearthreshold = -2;

Assert(length > 0, "'length' must be positive: " + length);

plot ROC = if price[length] != 0 then (price / price[length] - 1) * 100 else 0;
ROC.DefineColor("Highest", Color.GREEN);
ROC.DefineColor("Lowest", Color.RED);
ROC.SetLineWeight(2);

plot zeroline = if !IsNaN(close) then 0 else Double.NaN;
zeroline.AssignValueColor(if ROC > 0 then Color.GREEN else Color.LIGHT_RED);
zeroline.SetPaintingStrategy(PaintingStrategy.dashES);
zeroline.SetLineWeight(1);

# RSI
def rsi = RSI()."RSI" is greater than or equal to 30 and RSI()."RSI" is less than or equal to 70 within 2 bar;

#EMAstacked#
def BULLISHstackedUp = MovAvgExponential("length" = 8)."AvgExp" is greater than MovAvgExponential("length" = 21)."AvgExp"
and MovAvgExponential("length" = 21)."AvgExp" is greater than MovAvgExponential("length" = 34)."AvgExp"
and MovAvgExponential("length" = 34)."AvgExp" is greater than MovAvgExponential("length" = 50)."AvgExp" within 2 bars;

def BEARstackedUp = MovAvgExponential("length" = 8)."AvgExp" is less than MovAvgExponential("length" = 21)."AvgExp"
and MovAvgExponential("length" = 21)."AvgExp" is less than MovAvgExponential("length" = 34)."AvgExp"
and MovAvgExponential("length" = 34)."AvgExp" is less than MovAvgExponential("length" = 50)."AvgExp" within 2 bars;

# ROC increasing or decreasing label
AddLabel(yes, if ROC > ROC[1] then " ROC Increasing " + Round(ROC, 2) + " " else " ROC Decreasing " + Round(ROC, 2) + " ", if ROC > ROC[1] then Color.GREEN else Color.RED);

# BULLISH OR BULLISH OR NEUTRAL
AddLabel(yes, if ROC >= bullthreshold then " BULLISH " else if ROC <= bearthreshold then " BEARISH " else " Wait & Watch ", if ROC >= bullthreshold then Color.GREEN else if ROC <= bearthreshold then Color.RED else Color.WHITE);

# GOING LONG OR SHORT BUY
def LONGBUY = ROC >= bullthreshold and rsi and BULLISHstackedUp;
def SHORTBUY = ROC <= bearthreshold and rsi and BEARstackedUp;

# PERSONAL MESSAGE TO TAKE PROFITS
def TakeProfit = (ROC between 10 and 20) or (ROC between -10 and -20);
def SeriouslyTakeProfit = (ROC between 21 and 50) or (ROC between -21 and -50);
def FinTakeProfit = (ROC between 51 and 99) or (ROC between -51 and -99);
def DontBeLoser = (ROC >= 100) or (ROC <= -100);
AddLabel(yes, if TakeProfit then " Take Profit! " else if SeriouslyTakeProfit then " SERIOUSLY, Take Profit! " else if FinTakeProfit then " ****IN! Take Profit! " else if DontBeLoser then " DON'T BE A LOSER! Take Profit! " else "", if TakeProfit then Color.GREEN else if SeriouslyTakeProfit then Color.CYAN else if FinTakeProfit then Color.ORANGE else if DontBeLoser then Color.MAGENTA else Color.BLACK);

DefineGlobalColor("Bullish", Color.cyan);
DefineGlobalColor("Bearish", Color.pink);
## end code``````

Last edited:
Updated version can be found: https://usethinkscript.com/threads/price-rate-of-change-roc-for-thinkorswim.8549/#post-102522

The Rate Of Change (ROC) is an MTF oscillator calculating the percentage change of the security price relative to the price of a specified number (length) of periods before. The higher/lower the ROC, the more overbought/oversold the security; when the ROC falls, a rally might occur.

When I am in a price action trade or scalping I tend to watch the Time and Sales or Level2 price to get the most entry/exit of the position. That took too much brain energy to watch like I am in a Twilight Zone. So, I've come up with a simple ROC lower indicator to help me see the average of the last period prices if the price is increasing/decreasing and direction. This beats watching the Time and Sales or Level2. It works well on trending and momentum with price action securities. It works for me and would like to share it with you all. Let me know if ROC works and helps you too. Good luck! @cabe1332.
Ruby:
``````# Price Rate of Change
# cabe1332 10/20/2021
# The Rate Of Change (ROC) is an oscillator calculating the percentage change of the security price relative to the price of a specified number (length) of periods before. The higher the ROC, the more overbought the security; when the ROC falls, a rally might occur.

# code start

declare lower;

input length = 7;
input colorNormLength = 7;
input price = close;

assert(length > 0, "'length' must be positive: " + length);

plot ROC = if price[length] != 0 then (price / price[length] - 1) * 100 else 0;

ROC.DefineColor("Highest", Color.green);
ROC.DefineColor("Lowest", Color.red);
ROC.SetLineWeight(2);

plot zeroline = if !isnan(close) then 0 else double.nan;
zeroline.assignValueColor(if Roc > 0 then Color.green else color.light_red);
zeroline.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
zeroline.SetLineWeight(1);

AddLabel(yes, if roc > roc[1] then "Price ROC Increasing " + round(roc,2) else "Price ROC Status Decreasing " + round(roc,2), if roc > roc[1] then color.green else color.red);

AddLabel(yes, if roc > buy_threshold then "Trending UP: BUY or Take Profits if needed! " else if roc between 0 and buy_threshold then "Wait and Watch!" else if roc < roc[1] and roc < 0 then "Trending DOWN! Wait for the rally!" else if roc > roc[1] and roc < 0 then "Trending DOWN! Wait for the rally !" else " ", if roc > 0 and roc > buy_threshold then color.green else color.red);
# end code``````
can u kindly provide some details on how u use this to find entries / exits? Would love some visual screenshot of trades! i have been looking everywhere for help understanding ROC but not much out there

can u kindly provide some details on how u use this to find entries / exits? Would love some visual screenshot of trades! i have been looking everywhere for help understanding ROC but not much out there

Did you know that clicking on a member's name will allow you to see when a member was last seen on the uTS forum? @cab1332 has not been seen in a while.

And then read his top 100 posts in how he trades these indicators (sorted by popularity):
https://usethinkscript.com/search/870503/

Thanks for sharing your code! Made some changes to make it a bit more visually pleasing.

Code:
``````# Rate of Change
# cabe1332
#The Rate Of Change (ROC) is an oscillator calculating the percentage change of the security price relative to the price a specified number (length) of periods before. The higher the ROC, the more overbought the security; when the ROC falls, a rally might occur.

# 10/20/2021 Rev.1
# TOC ROC with labels

# 10/23/2021 Rev.2
# added support and condition for bulls and bears labels
# added RSI and EMA stacked for better entry/exit labels
# added support for Profit Taking conditions with labels

## code start

declare lower;

input length = 7;
input colorNormLength = 7;
input price = close;
input bullthreshold = 2;
input bearthreshold = -2;

Assert(length > 0, "'length' must be positive: " + length);

plot ROC = if price[length] != 0 then (price / price[length] - 1) * 100 else 0;
ROC.DefineColor("Highest", Color.GREEN);
ROC.DefineColor("Lowest", Color.RED);
ROC.SetLineWeight(2);

plot zeroline = if !IsNaN(close) then 0 else Double.NaN;
zeroline.AssignValueColor(if ROC > 0 then Color.GREEN else Color.LIGHT_RED);
zeroline.SetPaintingStrategy(PaintingStrategy.dashES);
zeroline.SetLineWeight(1);

# RSI
def rsi = RSI()."RSI" is greater than or equal to 30 and RSI()."RSI" is less than or equal to 70 within 2 bar;

#EMAstacked#
def BULLISHstackedUp = MovAvgExponential("length" = 8)."AvgExp" is greater than MovAvgExponential("length" = 21)."AvgExp"
and MovAvgExponential("length" = 21)."AvgExp" is greater than MovAvgExponential("length" = 34)."AvgExp"
and MovAvgExponential("length" = 34)."AvgExp" is greater than MovAvgExponential("length" = 50)."AvgExp" within 2 bars;

def BEARstackedUp = MovAvgExponential("length" = 8)."AvgExp" is less than MovAvgExponential("length" = 21)."AvgExp"
and MovAvgExponential("length" = 21)."AvgExp" is less than MovAvgExponential("length" = 34)."AvgExp"
and MovAvgExponential("length" = 34)."AvgExp" is less than MovAvgExponential("length" = 50)."AvgExp" within 2 bars;

# ROC increasing or decreasing label
AddLabel(yes, if ROC > ROC[1] then " ROC Increasing " + Round(ROC, 2) + " " else " ROC Decreasing " + Round(ROC, 2) + " ", if ROC > ROC[1] then Color.GREEN else Color.RED);

# BULLISH OR BULLISH OR NEUTRAL
AddLabel(yes, if ROC >= bullthreshold then " BULLISH " else if ROC <= bearthreshold then " BEARISH " else " Wait & Watch ", if ROC >= bullthreshold then Color.GREEN else if ROC <= bearthreshold then Color.RED else Color.WHITE);

# GOING LONG OR SHORT BUY
def LONGBUY = ROC >= bullthreshold and rsi and BULLISHstackedUp;
def SHORTBUY = ROC <= bearthreshold and rsi and BEARstackedUp;

# PERSONAL MESSAGE TO TAKE PROFITS
def TakeProfit = (ROC between 10 and 20) or (ROC between -10 and -20);
def SeriouslyTakeProfit = (ROC between 21 and 50) or (ROC between -21 and -50);
def FinTakeProfit = (ROC between 51 and 99) or (ROC between -51 and -99);
def DontBeLoser = (ROC >= 100) or (ROC <= -100);
AddLabel(yes, if TakeProfit then " Take Profit! " else if SeriouslyTakeProfit then " SERIOUSLY, Take Profit! " else if FinTakeProfit then " ****IN! Take Profit! " else if DontBeLoser then " DON'T BE A LOSER! Take Profit! " else "", if TakeProfit then Color.GREEN else if SeriouslyTakeProfit then Color.CYAN else if FinTakeProfit then Color.ORANGE else if DontBeLoser then Color.MAGENTA else Color.BLACK);

DefineGlobalColor("Bullish", Color.cyan);
DefineGlobalColor("Bearish", Color.pink);
## end code``````

The value of ROC is never going to reach the values in the section "PERSONAL MESSAGE TO TAKE PROFITS" so that portion of the code will never be triggered.

# PERSONAL MESSAGE TO TAKE PROFITS
def TakeProfit = (ROC between 10 and 20) or (ROC between -10 and -20);
def SeriouslyTakeProfit = (ROC between 21 and 50) or (ROC between -21 and -50);
def FinTakeProfit = (ROC between 51 and 99) or (ROC between -51 and -99);
def DontBeLoser = (ROC >= 100) or (ROC <= -100);

My ROC is (custom) value is in percent, not 0 to 2 or 0 to -2. It is much easier to understand with converted values with a wider range. The higher percentage of the ROC the greater probability of success in the position (bullish/green, bearish/red). No limits on ROC, but I prefer entry decisions on using high ROC than RVI.

ROC calculates price changes specifically. Overbought/oversold you can use RSI or Stochastic.

edited: this post or reply has been updated to not mislead readers of the missing image or grid. The image or grid has been removed by the site administrator.

Good luck and good trading! @cabe1332
@cabe1332 thanks for posting this indicator. Its been a big help over the last several weeks that ive been testing it. Is it possible to adapt this to a watch list column where the ROC values would match the color of the ROC line on the indicator?

Hi,

Hope all is well. If anyone can help with modifying the add cloud script. I want to only show one color depending Line (RSI) > 0 or Line (RSI) <0 - The color should only cover this script.

If I use the background script code it changes the whole chart which makes it hard to read the candles.

I am not sure if it's even possible. Thank you.

Thank you.

Code:
``````# Rate of Change
# cabe1332 - usethinkscript.com

## code start

declare lower;

input length = 7;

input colorNormLength = 7;

input price = close;

input bullthreshold = 0.2;

input bearthreshold = -0.2;

Assert(length > 0, "'length' must be positive: " + length);

plot ROC = if price[length] != 0 then (price / price[length] - 1) * 100 else 0;

plot zeroline = if !IsNaN(close) then 0 else Double.NaN;

# Define global colors

DefineGlobalColor("Above", Color.LIGHT_GREEN);

DefineGlobalColor("Below", Color.LIGHT_RED);

def backgroundAbove = if ROC > zeroline then Double.POSITIVE_INFINITY else Double.NaN;

def backgroundBelow = if ROC < zeroline then Double.NEGATIVE_INFINITY else Double.NaN;

#### Attachments

• Screenshot 2024-08-02 124259.png
115.5 KB · Views: 50
Last edited by a moderator:
Hi,

Hope all is well. If anyone can help with modifying the add cloud script. I want to only show one color depending Line (RSI) > 0 or Line (RSI) <0 - The color should only cover this script.

If I use the background script code it changes the whole chart which makes it hard to read the candles.

I am not sure if it's even possible. Thank you.

Thank you. View attachment 22514

Code:
``````# Rate of Change
# cabe1332 - usethinkscript.com

## code start

declare lower;

input length = 7;

input colorNormLength = 7;

input price = close;

input bullthreshold = 0.2;

input bearthreshold = -0.2;

Assert(length > 0, "'length' must be positive: " + length);

plot ROC = if price[length] != 0 then (price / price[length] - 1) * 100 else 0;

plot zeroline = if !IsNaN(close) then 0 else Double.NaN;

# Define global colors

DefineGlobalColor("Above", Color.LIGHT_GREEN);

DefineGlobalColor("Below", Color.LIGHT_RED);

def backgroundAbove = if ROC > zeroline then Double.POSITIVE_INFINITY else Double.NaN;

def backgroundBelow = if ROC < zeroline then Double.NEGATIVE_INFINITY else Double.NaN;

The following image shows GOOGL with a 10 minute cloud (as in your 1st image).
Below that is my modified version of your ROC script with a cloud and the ROC line that also changes color (up = green / down = red).
Note: Compare the cloud difference in the 2 charts.
The bottom chart is the tos default RateOfChange study with the same settings you had.
This study appears to be where you gathered much of your script:

Code:
``````# Rate of Change
# cabe1332 - usethinkscript.com
## code start

declare lower;

input price = close;
input length = 7;
input colorNormLength = 7;
input bullthreshold = 0.2;
input bearthreshold = -0.2;
input Cloud = yes;

Assert(length > 0, "'length' must be positive: " + length);

def ROC = if price[length] != 0 then (price / price[length] - 1) * 100 else 0;
plot s = ROC;
s.DefineColor("Up", GetColor(6));
s.DefineColor("Down", GetColor(5));
s.AssignValueColor(if s > s[1] then s.Color("Up") else s.Color("Down"));
s.SetLineWeight(1);
s.SetStyle(1);

# zeroLine
plot zeroLine = 0;
zeroLine.SetDefaultColor(GetColor(7));
zeroLine.SetLineWeight(1);
zeroLine.SetStyle(1);

def hiLevel = if s >= s[-1] then Double.POSITIVE_INFINITY else Double.NEGATIVE_INFINITY;
AddCloud(if cloud and -hiLevel then -hiLevel else double.NaN, hiLevel, color.GREEN, color.RED);``````

Eyl

87k+ Posts
429 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?