Indicator causing "java.lang.nullpointerexception" error

Glefdar

Active member
I can't imagine how or why this is happening but it started after the TOS maintenance that occurred yesterday.

This is the indicator code:

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2014-2021
#

declare lower;
declare zerobase;

input length = 60;
input numDev = 2.0;
input allowNegativeValues = yes;

def rawRelVol = (volume - Average(volume, length)) / StDev(volume, length);
plot RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
plot StDevLevel = if close>0 then numDev else double.nan;

RelVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RelVol.SetLineWeight(3);
RelVol.DefineColor("UpCandleAbove", Color.Light_Green);
RelVol.DefineColor("DownCandleAbove", Color.Red);
RelVol.DefineColor("UpCandleBelow", Color.CYAN);
RelVol.DefineColor("DownCandleBelow", Color.DARK_ORANGE);
RelVol.DefineColor("DownCandleNegBelow", CreateColor(60,25,25));
RelVol.DefineColor("UpCandleNegBelow", CreateColor(25,60,25));
RelVol.AssignValueColor(if RelVol >= numDev and RelVol>0 and open<close then RelVol.Color("UpCandleAbove") else if RelVol < numDev and RelVol<0 and open>close then RelVol.Color("DownCandleNegBelow") else if RelVol < numDev and RelVol<0 and open<close then RelVol.Color("UpCandleNegBelow")  else if RElVol>0 and open<close then RelVol.Color("UpCandleBelow") else if RelVol >= numDev and RelVol>0 and open>close then RelVol.Color("DownCandleAbove") else if RElVol>0 and open>close then  RelVol.Color("DownCandleBelow") else  Color.Gray);
StDevLevel.SetDefaultColor(GetColor(7));
StDevLevel.SetStyle(Curve.SHORT_DASH);

What's particularly frustrating is that I'd combined this indicator into others that I've made and so a lot of my saved study and style layouts have been corrupted.

I tried removing from the code the option to allow negative values but it still gives the error. What is aggravating is that the study is loading properly and displaying properly on a chart, but it just somehow after yesterday is corrupting the study sets and styles if it's saved into any study set. The same problem is also occurring in some of my other indicators that incorporated the same logic for displaying different colors for different sigma thresholds of volume that are either up candles or down candles.
 
Solution
Well, when I remove this script from my workspace then I stop getting the error. And when I re-add it to the workspace, the error comes back.

OK, I just tested this some more, and it looks like when I remove all the transparency / opacity settings for the colors in the indicator, the problem goes away.

The other indicator that was being affected which had some of the same logic integrated into it is also saving to a study set fine now that the color transparencies were all reset.

I'm curious if anyone has heard of this problem before or if anyone else would see the same issue if they set all the indicator's bar colors to 64 opacity (which is what mine were set at).
There are no "transparency / opacity settings for the...
I can't imagine how or why this is happening but it started after the TOS maintenance that occurred yesterday.

This is the indicator code:

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2014-2021
#

declare lower;
declare zerobase;

input length = 60;
input numDev = 2.0;
input allowNegativeValues = yes;

def rawRelVol = (volume - Average(volume, length)) / StDev(volume, length);
plot RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
plot StDevLevel = if close>0 then numDev else double.nan;

RelVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RelVol.SetLineWeight(3);
RelVol.DefineColor("UpCandleAbove", Color.Light_Green);
RelVol.DefineColor("DownCandleAbove", Color.Red);
RelVol.DefineColor("UpCandleBelow", Color.CYAN);
RelVol.DefineColor("DownCandleBelow", Color.DARK_ORANGE);
RelVol.DefineColor("DownCandleNegBelow", CreateColor(60,25,25));
RelVol.DefineColor("UpCandleNegBelow", CreateColor(25,60,25));
RelVol.AssignValueColor(if RelVol >= numDev and RelVol>0 and open<close then RelVol.Color("UpCandleAbove") else if RelVol < numDev and RelVol<0 and open>close then RelVol.Color("DownCandleNegBelow") else if RelVol < numDev and RelVol<0 and open<close then RelVol.Color("UpCandleNegBelow")  else if RElVol>0 and open<close then RelVol.Color("UpCandleBelow") else if RelVol >= numDev and RelVol>0 and open>close then RelVol.Color("DownCandleAbove") else if RElVol>0 and open>close then  RelVol.Color("DownCandleBelow") else  Color.Gray);
StDevLevel.SetDefaultColor(GetColor(7));
StDevLevel.SetStyle(Curve.SHORT_DASH);

What's particularly frustrating is that I'd combined this indicator into others that I've made and so a lot of my saved study and style layouts have been corrupted.

I tried removing from the code the option to allow negative values but it still gives the error. What is aggravating is that the study is loading properly and displaying properly on a chart, but it just somehow after yesterday is corrupting the study sets and styles if it's saved into any study set. The same problem is also occurring in some of my other indicators that incorporated the same logic for displaying different colors for different sigma thresholds of volume that are either up candles or down candles.

Here is a troubleshooting fix that TOS offers to fix problems caused by updates.

General troubleshooting instructions for getting stuck on “Installing Updates”.​

Every time the thinkorswim software is opened, you will see a window that reads “Installing Updates”. During this time, the platform will install any available updates. Please note, the platform will always check for updates, if none are available, it will then take you to the login screen. If you get stuck on this screen, try left clicking directly on the words “Installing Updates”, this will open up a hidden window where you can check to see if things are progressing, or if there is an error message. If you look towards the right of the window, you will also see a scroll bar, this doubles as a progress bar. The smaller the bar gets, the closer it is to completing. If you see an error message or if the process stops progressing, please take the following steps.
If you are connected wirelessly, you can start troubleshooting by shutting the computer down and power cycling your router. This involves unplugging the router from the power source for 30 seconds, then reconnect the router, and finally, reboot the computer. If you are hard wired, check that your Ethernet cable is securely connected on both ends. If this does not resolve the issue you may want to reach out to your internet service provider for further support.
If you find that your connection is not the root cause of the problem, something else you can try is to delete the "usergui" folder. Please note; if there are indeed connection issues, deleting this folder will slow the "Installing Updates" screen even further. It is imperative that any connection issues are ruled out before trying this option. You will find the steps below.
On Windows Machine:
  1. Exit the thinkorswim software
  2. Right click on the thinkorswim icon
  3. Left-click on PROPERTIES
  4. Left-click on OPEN FILE LOCATION
  5. In the resulting window, right-click on the USERGUI folder
  6. Left-click on DELETE
  7. Restart thinkorswim.

On MAC:
  1. Exit the thinkorswim software
  2. Double click on Macintosh HD
  3. Double click on APPLICATIONS
  4. Double click on THINKORSWIM
  5. Drag the USERGUI folder to the apple trash and empty the trash
  6. Restart thinkorswim
Deleting the USERGUI file folder is similar to clearing your cache and it will prompt a fresh download of the most recent update. This will not affect your layout settings.
 
I added that script to my setup, and it's working/loading just fine. Are you sure this is the culprit?

Well, when I remove this script from my workspace then I stop getting the error. And when I re-add it to the workspace, the error comes back.

OK, I just tested this some more, and it looks like when I remove all the transparency / opacity settings for the colors in the indicator, the problem goes away.

The other indicator that was being affected which had some of the same logic integrated into it is also saving to a study set fine now that the color transparencies were all reset.

I'm curious if anyone has heard of this problem before or if anyone else would see the same issue if they set all the indicator's bar colors to 64 opacity (which is what mine were set at).
 
Last edited:
Well, when I remove this script from my workspace then I stop getting the error. And when I re-add it to the workspace, the error comes back.

OK, I just tested this some more, and it looks like when I remove all the transparency / opacity settings for the colors in the indicator, the problem goes away.

The other indicator that was being affected which had some of the same logic integrated into it is also saving to a study set fine now that the color transparencies were all reset.

I'm curious if anyone has heard of this problem before or if anyone else would see the same issue if they set all the indicator's bar colors to 64 opacity (which is what mine were set at).
There are no "transparency / opacity settings for the colors in the indicator"
In the script that you posted.
And it doesn't result in errors.

I have run into your situation innumerable number of times.
You only have two options:
Best option:
re-install ThinkOrSwim
All your indicators, watchlists, scans, styles, charts, grids are stored on TDA servers.
The only thing you lose are your workspaces which are easily rebuildable from your styles, charts, and grids.

Other option:
Here is a clean uncorrupted chart: http://tos.mx/xqDrGXd
9LHOB3T.png

Rebuild your studies within it.

FYI: I do a clean ToS install about every 45-60days.
I am loading 100s of setups into my app every week, so I find that corruption is part of life.
I proactively ALWAYS save my chart setups and styles and do new installs to keep it clean.

I also keep a brand new installed ToS app in a separate library; just in case the instances that I am running during the trading day get corrupted at an inopportune time.


Good luck.
 
Last edited:
Solution
There are no "transparency / opacity settings for the colors in the indicator"
In the script that you posted.
And it doesn't result in errors.

I have run into your situation innumerable number of times.
You only have two options:
Best option:
re-install ThinkOrSwim
All your indicators, watchlists, scans, styles, charts, grids are stored on TDA servers.
The only thing you lose are your workspaces which are easily rebuildable from your styles, charts, and grids.

Other option:
Here is a clean uncorrupted chart: http://tos.mx/xqDrGXd
9LHOB3T.png

Rebuild your studies within it.

FYI: I do a clean ToS install about every 45-60days.
I am loading 100s of setups into my app every week, so I find that corruption is part of life.
I proactively ALWAYS save my chart setups and styles and do new installs to keep it clean.

I also keep a brand new installed ToS app in a separate library; just in case the instances that I am running during the trading day get corrupted at an inopportune time.


Good luck.

Thanks for this helpful response. I wanted to clarify in case it helps someone else in the future who comes across the same error, this is what I meant by transparency/opacity settings:

ev3lcln.png


Interestingly enough, when this slider was reset to have no transparency for any of the plot colors in the indicators that were corrupting my workspaces, the problem stopped finally: I stopped getting the java error code popup and I was once again able to save and load the study sets / styles / workspace normally. (This slider for transparency is accessed by clicking the gear icon next to the study name in the list of studies on a chart to configure the inputs and then where plots are shown and colors can be selected for them, the opacity can be configured.)

I’ll also mention that it’s possible that the reason that resetting the transparency fixed the problem is not so much because of the opacity being 0 but maybe instead is because the saved “as default” style for the indicator when clicking the gear icon was removed by clicking “reset to factory default” (these configuration options for an indicator are in the top right corner of the window that opens after clicking the gear icon.)

I would rather be able to reinstate the former transparency settings eventually, and your advice is helpful: when I have time I may rebuild those workspaces on fresh installs. Thank you.
 
Last edited:
Thanks for this helpful response. I wanted to clarify in case it helps someone else in the future who comes across the same error, this is what I meant by transparency/opacity settings:



Interestingly enough, when this slider was reset to have no transparency for any of the plot colors in the indicators that were corrupting my workspaces, the problem stopped finally: I stopped getting the java error code popup and I was once again able to save and load the study sets / styles / workspace normally.

I would rather be able to reinstate the former transparency settings eventually, and your advice is helpful: when I have time I may rebuild those workspaces on fresh installs. Thank you.
please edit your post, and mention how to navigate to that color window.
 

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