Color coding a Watchlist for stocks that test and bounce over a 20 SMA same day.


  • Questions
  • Watch Lists
  • Color coding a Watchlist for stocks that test and bounce over a 20 SMA same day.
Category:
0
0

Hello,

I am new to think scripts and this site as well.  I am glad I found such a valuable site.

I was wondering how I could add a custom column to my watchlists with color changes whenever a stock price went below and above a moving average like 20 SMA after opening above 20SMA. For example AAPL opened above 20 SMA on a daily chart, and went below 20 SMA intraday and bounced back. I am only interested in daily charts, but that 20SMA testing happens intraday. Can you please help me to develop a script for this task?

Also, it would be great if I could get an email and text alerts.

 

Thanks a lot.

SR

Marked as spam
Posted by (Questions: 2, Answers: 1)
Asked on January 26, 2020 7:55 am
200 views
0
Private answer

There is no way to get the code for a custom watchlist column to generate alerts/notifications of any kind. We can only change the value displayed, or the color of the background and/or value.

So it seems what you are asking for is code that runs on a daily time frame that triggers when the low of the current daily bar is less than the 20 SMA while the open and close of that same bar is above it.

def sma = Average(close, 20);
plot data = low < sma and open > sma and close > sma;
AssignBackgroundColor(if data then Color.GREEN else Color.CURRENT);

Marked as spam
Posted by (Questions: 37, Answers: 4117)
Answered on January 26, 2020 8:44 am
0
Thanks. That helped.
( at January 26, 2020 9:53 am)