How can i create a column for Tos to show a 5/8 ema crossover ?
Thanks
def xUp = ExpAverage("data" = CLOSE, "length" = 5) crosses above ExpAverage("data" = CLOSE, "length" = 8);
def xDn = ExpAverage("data" = CLOSE, "length" = 5) crosses below ExpAverage("data" = CLOSE, "length" = 8);
AddLabel(yes, if xUp then "xUp" else if xDn then "xDn" else " ", Color.CURRENT);
AssignBackgroundColor(if xUp then Color.GREEN else if xDn then Color.RED else Color.GRAY);
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
I am trying to do something extremely similar so I didn’t want to create a new thread. The column shows all results as gray if I use this exact code and it shows all results as black if I use my code attached screenshot.The following code should suffice for a Custom Watchlist Column...
Ruby:def xUp = ExpAverage("data" = CLOSE, "length" = 5) crosses above ExpAverage("data" = CLOSE, "length" = 8); def xDn = ExpAverage("data" = CLOSE, "length" = 5) crosses below ExpAverage("data" = CLOSE, "length" = 8); AddLabel(yes, if xUp then "xUp" else if xDn then "xDn" else " ", Color.CURRENT); AssignBackgroundColor(if xUp then Color.GREEN else if xDn then Color.RED else Color.GRAY);
def ema4 = ExpAverage(close, 4);
def ema21 = ExpAverage(close, 21);
def isBullish = ema4 > ema21;
def isBearish = ema4 < ema21;
AddLabel(yes, if isBullish then "Bullish" else if isBearish then "Bearish" else "Neutral", if isBullish then color.GREEN else if isBearish then color.RED else color.LIGHT_GRAY);
def EMA4 = ExpAverage(close, 4);
def EMA21 = ExpAverage(close, 21);
def Bullish = EMA4 > EMA21;
def Bearish = EMA4 < EMA21;
ADDlabel(bullish, "Bullish", color.black);
ADDlabel(bearish, "Bearish", color.black);
ADDlabel(!bullish and !bearish, "", color.black);
AssignBackgroundColor (if bullish then color.green else if bearish then color.red else color.black);
I just tested now and compared both the Watchlist data with each ticker's Chart. This worked perfect. Thank you so much for the help! Here is my code below for anyone that likes the look. Screenshot attached.
Code:def EMA4 = ExpAverage(close, 4); def EMA21 = ExpAverage(close, 21); def Bullish = EMA4 > EMA21; def Bearish = EMA4 < EMA21; ADDlabel(bullish, "Bullish", color.black); ADDlabel(bearish, "Bearish", color.black); ADDlabel(!bullish and !bearish, "", color.black); AssignBackgroundColor (if bullish then color.green else if bearish then color.red else color.black);
Yes. I am pretty much trading with a hybrid approach.For some columns you’re using the 8 I see? Can you talk a bit about your experience with choosing the aggs and the ema’s ? Are you waiting for a stacked alignement to take positions? Obviously a cross happening on the 10m will lag against the hourly, so just curious on the approach. Thanks!
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
M | combine 2 indicators for 3 EMA crossover | Questions | 5 | |
M | EMA crossover stop and take profit | Questions | 10 | |
A | 9 EMA crossover | Questions | 1 | |
![]() |
EMA 20/50 crossover Scanner | Questions | 2 | |
T | Price hit EMA 20 and MACD crossover average | Questions | 3 |
Start a new thread and receive assistance from our community.
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.
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.