Watchlist Items Color and EMA Strategy

ToSdrew777

New member
Hello All,
I am wondering if someone can help me. I have a simple EMA scalp strategy that is working great that is shared below:

A) I wait until the 20EMA is above the 50EMA, the 50EMA is above the 100EMA, and the 100EMA is above the 150EMA and the slope looks strong. The script is below and this is built into my Watchlist of usual stocks called STACKBULL

MovAvgExponential("length" = 20)."AvgExp" is less than MovAvgExponential("length" = 50)."AvgExp" and MovAvgExponential("length" = 50)."AvgExp" is less than MovAvgExponential("length" = 100)."AvgExp" and MovAvgExponential("length" = 100)."AvgExp" is less than MovAvgExponential("length" = 150)."AvgExp"

B) When lowest price of the 1min candle touches between the 20EMA and the 100EMA on an existing uptrend from above, I watch for the first candle to open back above the 20 (Best results are when the candle touches between the 20EMA and 50EMA and has a bullish pattern like a hammer.) The script is below which is also built into my Watchlist of usual stocks called MA-BULL

low is greater than or equal to MovAvgExponential("length" = 75)."avgexp" and low is less than or equal to MovAvgExponential("length" = 20)."avgexp"

O the watchlist, the STACKBULL column displays number “1” then I look for the MA-BULL column to also have a number “1” for the individual stock on the Watchlist then I see if the setup is something I am interested in.
1) How can I color code and make the “1s” to display as GREEN and if it is “0” - no color. It hurts my eyes and is sometimes confusing tracing the “1s” all the time??? I have been fooling around googling and nothing seems to work when I try to code it.
2) In addition, is there a way to combine the above parts A and B so I can have only 1 column on my watchlist where individual stocks are green when all conditions are satisfied?
3) Also, is it possible to add to the code for part A above to add a slope condition such as all slopes of 20/50/100/150EMAs are at least 30% up???
 
@ToSdrew777 Perhaps the easiest method is to use AddLabel instead of plot... Then you can ditch the number altogether by displaying a blank space and use conditional code to paint the watchlist cell... That's how I code my custom watchlist columns that are for indication only and don't require numbers... For watchlist column cells you won't get an error if you use AddLabel and don't have a plot... You can also use multiple criteria and paint the cells accordingly...

Slopes can be calculated using Tan() or Atan()... Check the Thinkscript Learning Center for their implementation...
 

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

@ToSdrew777 Here is something such as you are asking about. There is a discrepancy between your write-up and the code in section "A)" of your post, so I followed the description instead of the actual provided code. I also colored the background of each "1" watchlist cell green, you can delete that portion if you like.

Code:
# @ToSdrew777 at usethinkscript.com - "I wait until the 20EMA is above the 50EMA, the 50EMA is above the 100EMA, and the 100EMA is above the 150EMA and the slope looks strong. When lowest price of the 1min candle touches between the 20EMA and the 100EMA on an existing uptrend from above, I watch for the first candle to open back above the 20 (Best results are when the candle touches between the 20EMA and 50EMA and has a bullish pattern like a hammer."

def stackbull = expaverage(close,20) > expaverage(close,50)
                && expaverage(close,50) > expaverage(close,100)
                && expaverage(close,100) > expaverage(close,150);

def mabull = low >= expaverage(close,75) && low <= expaverage(close,20);

plot myconditions = if stackbull and mabull then 1 else 0;
myconditions.assignvaluecolor(if myconditions == 1 then color.green else color.black);

assignbackgroundcolor(if myconditions == 1 then color.green else color.black);
 
@ToSdrew777 Here is something such as you are asking about. There is a discrepancy between your write-up and the code in section "A)" of your post, so I followed the description instead of the actual provided code. I also colored the background of each "1" watchlist cell green, you can delete that portion if you like.

Code:
# @ToSdrew777 at usethinkscript.com - "I wait until the 20EMA is above the 50EMA, the 50EMA is above the 100EMA, and the 100EMA is above the 150EMA and the slope looks strong. When lowest price of the 1min candle touches between the 20EMA and the 100EMA on an existing uptrend from above, I watch for the first candle to open back above the 20 (Best results are when the candle touches between the 20EMA and 50EMA and has a bullish pattern like a hammer."

def stackbull = expaverage(close,20) > expaverage(close,50)
                && expaverage(close,50) > expaverage(close,100)
                && expaverage(close,100) > expaverage(close,150);

def mabull = low >= expaverage(close,75) && low <= expaverage(close,20);

plot myconditions = if stackbull and mabull then 1 else 0;
myconditions.assignvaluecolor(if myconditions == 1 then color.green else color.black);

assignbackgroundcolor(if myconditions == 1 then color.green else color.black);

Pensar, Thank you a hundred times. That is exactly it. When it is written like that, it is a nice lesson also for the future.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
417 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