Moving Average Crossover Watchlist Column for ThinkorSwim

Hi Ben, i need to show if they moving avg are showing in a order - 8 , 8 below 21 ,21 below 50. If these three conditions are met show in a watch list with some me color indication. Could you please help me on this?

So now you're looking for ema8 > ema21 and ema21 < ema50...??? Or do you mean close < ema8 and ema8 < ema21 and ema21 < ema50...??? Or are you not providing enough information for us to adequately help you...??? Or are you expecting us to provide the entire script for you rather than the logic you should be able to work with...???
 
So now you're looking for ema8 > ema21 and ema21 < ema50...??? Or do you mean close < ema8 and ema8 < ema21 and ema21 < ema50...??? Or are you not providing enough information for us to adequately help you...??? Or are you expecting us to provide the entire script for you rather than the logic you should be able to work with...???
HI Rad,

AjXGBA3.png


I this image on 6/1--- 8 EMA(dark Blue) is above the 21 EMA(light yellow) and 21 EMA is above the 50 EMA(light Blue).

I am looking this type of set up. If it is there I need see this in watchlist.

thank you for helping.
 
@Madhu I was fairly certain I knew what you wanted when I initially replied... Are you unable to code in Thinkscript because you should be able to glean enough information in this very topic to achieve what you are looking for... I gave you the logic for the code but you know the logic already so it's a matter of adapting what is here... Or are you looking to have the code handed to you...??? I already asked you in the my previous post... Have you tried to code for yourself...???
 
Sorry, the code I am using and having trouble with is as follows:

def EMA50 = ExpAverage(close,50);
def EMA100 = ExpAverage(close,100);

def bullish = EMA50 > EMA100[1];
def count = if EMA50 > EMA100[1] then 1 else count [1]+1;
def bearish = EMA50 < EMA100 [1];
def count_2 = if EMA50 < EMA100 [1] then 1 else count [1]+1;

AddLabel(bullish, "" + count, color.black);
AddLabel(bearish, “” + count_2, color.black);

AssignBackgroundColor(if bullish then color.green else if bearish then color.red else color.black);
 
Thank you for your reply.

I gave your suggestion a try but for some reason, it is still not returning the correct number of periods from the most recent 50 ema / 100 ema cross.

Appreciate your help. I will keep working at it.

Keep well!
 
@JamesF Perhaps this?

Code:
def EMA50 = ExpAverage(close,50);
def EMA100 = ExpAverage(close,100);

def bullish = EMA50 > EMA100;
def count = if bullish and !bullish[1] then 1 else count[1] + 1;
def bearish = EMA50 < EMA100;
def count_2 = if bearish and !bearish[1] then 1 else count[1] + 1;

AddLabel(bullish, "" + count, color.black);
AddLabel(bearish, “” + count_2, color.black);

AssignBackgroundColor(if bullish then color.green else if bearish then color.red else color.black);
 
Thank you Pensar for your reply.

I appreciate you giving this a shot. I am still receiving a "funky" count that fails to match with the number of periods of the most recent ema cross.

I will keep at it.

Have a great day!
 
Thank you Pensar for your reply.

I appreciate you giving this a shot. I am still receiving a "funky" count that fails to match with the number of periods of the most recent ema cross.

I will keep at it.

Have a great day!
@JamesF Make sure that your aggregation of the column matches the aggregation of the chart. It worked fine for me.
 
Thanks again.

Yes, the aggregation does match however; still getting the same issue.

Example: Using a 1Y 1D chart, HTBX 50 ema most recently crossed below the 100 ema April 12th however, the code is returning a period of 66 days with the aggregation of the column set to D.

I'll keep going.

Really appreciate you taking the time.

Great community here.
 
@JamesF There's a error in the line of code for "count_2" - change the "count[1]" to "count_2[1]". It is referencing the bullish count instead of bearish. I hadn't checked the short side.
 
That is it!

Terrific. Thank you very much for your help here. Greatly appreciated.

Always good to learn something new.

Keep well!
 
How would I write thinkscript if I wanted to have several columns with different timeframes (i.e. 1 minute, 5 minutes, 10 minutes etc) that would compare a 9 EMA versus current price for each timeframe?

All I would want is a color if above the 9EMA and a different color if below?

Thanks,
 
@rickbw The simplest solution would be to use the following code for each Custom Watchlist Column and set the proper timeframe for each column...

Ruby:
AddLabel(yes, "", if close >= ExpAverage(close, 9) then Color.GREEN else Color.RED);
 
Any script for show the heat map for moving average that price is above or below for the moving averages , in my watchlist : Sample

EMA 5 Green for above, REd for below, and so on for EMA15, EMA 30

Thanks
 
@wilmanv Create a separate watchlist column for each timeframe and change the length input accordingly -

Code:
input length = 5;

def i = close > expaverage(close,length);
AddLabel(1, if i then "Above" else "Below", if i then color.green else color.red);
AssignBackgroundColor(if i then color.green else color.red);
 
@BenTen Hi bro how r U ?

need some help in a script for watch list column, i need 9 cross 21 along with your colour i need to know how many bars completed from the cross over? is there anyway i can use some Tick count for number of bars once cross over done?

i can do scanner with 9 cross 21 but number of bars some times will be many as i just want only New tickers which are crossed first time.
 
@wilmanv Create a separate watchlist column for each timeframe and change the length input accordingly -

Code:
input length = 5;

def i = close > expaverage(close,length);
AddLabel(1, if i then "Above" else "Below", if i then color.green else color.red);
AssignBackgroundColor(if i then color.green else color.red);
Thanks. I will try
 
Thanks. I will try
@wilmanv Create a separate watchlist column for each timeframe and change the length input accordingly -

Code:
input length = 5;

def i = close > expaverage(close,length);
AddLabel(1, if i then "Above" else "Below", if i then color.green else color.red);
AssignBackgroundColor(if i then color.green else color.red);
Good morning Sir, how add EMA to this script to show the heatmap how are the temporalities agains the EMA: sample: EMA 9, how is the price above or below in 5',10',30 ....
Thanks and have nice day
 

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