ExpAverage returns infinity for some lengths, but not others.

spongetrader

New member
I have the following code:

Screenshot 2024-04-16 at 1.24.25 PM.png


Basically, I'm getting the z-scores for the weighted closing price and then trying to get the 5 EMA of the z-scores.

For lengths 4, 5, and 6 the EMA is the infinity symbol like such:
Screenshot 2024-04-16 at 1.25.35 PM.png


For other lenghts like 3 and 7, it isn't infinity:
Screenshot 2024-04-16 at 1.26.14 PM.png


I'm really puzzled by this and don't understand how or why it would be happening.

This is the beginning of a longer script that I already have working in Python and PineScript. When trying to get it working in thinkScript, I'm running into this odd issue.
 
I am not able to get the infinity symbol using lengths of 4, 5, or 6.
This is the return on using length = 5 (same with 4 and 6):

1714531020242.png


Might the issue be in your Chart Settings?
Try using a basic default Chart separate from your problem chart with different time settings to see if the issue continues to show.
 
I would guess that your value for STDEV_wcp is zero at some point and you're seeing a divide by zero error represented as the symbol for infinity.

Plot the values for STDEV_wcp by themselves and see if they're going to zero at any point. If they do, you can try to trap for it with a conditional.

-Mashume

P.S. When you post code into useThinkScript, please use the "\[code\]" tag or the "</>" button at the top of the page. That way we can copy and past your code. :) Helps with debugging. Screenshots are really hard to deal with as we try to help.[/code]
 
Last edited:

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