Moving Average Crossover Watchlist Column for ThinkorSwim

rad14733

Well-known member
VIP
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...???
 

Madhu

Member
VIP
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.
 

rad14733

Well-known member
VIP
@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...???
 

JamesF

New member
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);
 

JamesF

New member
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!
 

Pensar

Well-known member
VIP
@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);
 

JamesF

New member
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!
 

Pensar

Well-known member
VIP
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.
 

JamesF

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

Pensar

Well-known member
VIP
@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.
 

JamesF

New member
That is it!

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

Always good to learn something new.

Keep well!
 

rickbw

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

rad14733

Well-known member
VIP
@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);
 

wilmanv

Member
VIP
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
 

Pensar

Well-known member
VIP
@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);
 

raghavag2004

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

Member
VIP
@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
 

wilmanv

Member
VIP
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
 

Similar threads

Top