Paint Candle touching 500 SMA

vsr138173

New member
VIP
Hi All,
Can you please help me with code to highlight a candle where it touch 500 SMA and also UPTICK to the next candle after touch 500 SMA?

Thanks
 
Here you go:

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2017-2020
#

input price = close;
input length = 500;
input displace = 0;

plot SMA = Average(price[-displace], length);

AssignPriceColor(if close crosses SMA then color.white else color.current);
 
Ben,

I am looking for a only UPTICK to the candle where candle touches 500 SMA and also uptick to the next candle after touching 500 SMA. I don't want to plot 500 SMA line.

v8Zm5Ui.png


Thanks for your help.
 
If you just wanted arrows, then you don't even need a custom script. Just enable the "Show breakout signals" option in your default moving average indicator.

KIlCKLM.png
 
Hi @BenTen, i tried to use this quote and scan for the last candle that touches 50SMA, but it does not scan out the results i wanted. May i also know what is the function of displace and how to modify the plot to scan for any candles that touches the 50SMA? Thanks
 
@Nick You don't need that code to scan for candle crossing the 50 SMA. All you have to do is go to the Scan tab, create a new condition, and set it up where close crosses above, crosses below, or crosses the 50 SMA.

Here is an example:

T2K35Gg.png


Make sure to adjust the "length" to your desired moving average length.
 

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