EMAclouds PriceROC Chart Setup For ThinkOrSwim

boogz101

New member
VIP

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

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.AssignNormGradientColor(colorNormLength, ROC.Color("Lowest"), ROC.Color("Highest"));
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;
AddLabel(yes, if LONGBUY then " BUY LONG " else if SHORTBUY then " Sell SHORT " else "", if LONGBUY then Color.GREEN else if SHORTBUY then Color.RED else Color.WHITE);

# 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);
AddCloud(ROC, zeroline , globalColor("Bullish"), globalColor("Bearish"));
## end code
Can you please share your EMA's. Thanks
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
516 Online
Create Post

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