Having trouble with Custom Column Indicator - Multiple averages

livefire

New member
Hi All,

I am just beginning to get into ThinkScript and wanted to create a multiple average order check that I can add as a column on my TOS watchlist. I am having some issues with getting it to work properly.

If I do a check of just ema 1 > ema 2 this seems to work fine on different time frame selections as I confirm back to a chart.

When I attempt to mix ema and sma together such as below ema1 > ema2 > sma1 > sma2, it doesn't seem to work. I am using "AAPL" as my symbol which should be a "YES"(darkgreen) on the daily chart, but shows up as "NO"(darkred).

Is there something else required? How can I use both exponential and simple moving averages together to tell me if they are in alignment or not?

Thanks for any community assistance with this.

Code:
input ema1_len = 8;
input ema2_len = 21;
input sma1_len = 50;
input sma2_len = 200;

def ema1 = MovAvgExponential(length=ema1_len);
def ema2 = MovAvgExponential(length=ema2_len);
def sma1 = SimpleMovingAvg(length=sma1_len);
def sma2 = SimpleMovingAvg(length=sma2_len);

def multi_good = ema1 > ema2 > sma1 > sma2;
def multi_bad = ema1 < ema2 < sma1 < sma2;

AddLabel(yes, if multi_good then "YES" else if multi_bad then "NO" else "~");
AssignBackgroundColor(if multi_good then Color.DARK_GREEN else if multi_bad then Color.DARK_RED else Color.DARK_ORANGE);
 
Hi All,

I am just beginning to get into ThinkScript and wanted to create a multiple average order check that I can add as a column on my TOS watchlist. I am having some issues with getting it to work properly.

If I do a check of just ema 1 > ema 2 this seems to work fine on different time frame selections as I confirm back to a chart.

When I attempt to mix ema and sma together such as below ema1 > ema2 > sma1 > sma2, it doesn't seem to work. I am using "AAPL" as my symbol which should be a "YES"(darkgreen) on the daily chart, but shows up as "NO"(darkred).

Is there something else required? How can I use both exponential and simple moving averages together to tell me if they are in alignment or not?

Thanks for any community assistance with this.

Code:
input ema1_len = 8;
input ema2_len = 21;
input sma1_len = 50;
input sma2_len = 200;

def ema1 = MovAvgExponential(length=ema1_len);
def ema2 = MovAvgExponential(length=ema2_len);
def sma1 = SimpleMovingAvg(length=sma1_len);
def sma2 = SimpleMovingAvg(length=sma2_len);

def multi_good = ema1 > ema2 > sma1 > sma2;
def multi_bad = ema1 < ema2 < sma1 < sma2;

AddLabel(yes, if multi_good then "YES" else if multi_bad then "NO" else "~");
AssignBackgroundColor(if multi_good then Color.DARK_GREEN else if multi_bad then Color.DARK_RED else Color.DARK_ORANGE);

have to join comparisons with logic

ema1 > ema2 AND ema2 > sma1 AND sma1 > sma2
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
425 Online
Create Post

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