Paint Candle touching 500 SMA

S

sreenivasaraovaka

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
 
BenTen

BenTen

Administrative
Staff
VIP
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);
 
S

sreenivasaraovaka

New member
VIP
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.



Thanks for your help.
 
BenTen

BenTen

Administrative
Staff
VIP
Your original request was to highlight the candle that crosses the 500 SMA. Now you want to add arrows?
 
BenTen

BenTen

Administrative
Staff
VIP
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.

 
N

Nick

Active member
2019 Donor
VIP
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
 
BenTen

BenTen

Administrative
Staff
VIP
@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:



Make sure to adjust the "length" to your desired moving average length.
 
Thread starter Similar threads Forum Replies Date
Yo Adrian How to paint the active candle? Questions 5
MBF Candle Paint help Questions 3
B Volume Paint Bars Questions 3
T How to make indicator paint behind price Questions 12
Pelonsax Need help paint horizontal pivot lines Questions 5

Similar threads

Top