Modify Script so as to not display the inputs

Mike

Member
Does anyone know how I can change the partially modified script below so as to not display the inputs. I received the following errors:

Incompatible parameter: "XLRE" at 10:5
Expected double at 10:5
Expected class com.devexperts.tos.thinkscript.data.SymbolType at 17:29
Expected class com.devexperts.tos.thinkscript.data.SymbolType at 17:76

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2015-2023
#

declare lower;

def price1 = FundamentalType.CLOSE;
def price2 = FundamentalType.CLOSE;
def symbol1 = ("SPY");
def symbol2 = ("XLRE");
def multiplier1 = 1.0;
def multiplier2 = 1.0;
def fastLength = 4;
def slowLength = 40;
def averageType = AverageType.SIMPLE;

plot Ratio = (multiplier1 * Fundamental(price1, symbol1)) / (multiplier2 * Fundamental(price2, symbol2));
plot FastAvg = MovingAverage(averageType, Ratio, fastLength);
plot SlowAvg = MovingAverage(averageType, Ratio, slowLength);

Ratio.DefineColor("Up", Color.UPTICK);
Ratio.DefineColor("Down", Color.DOWNTICK);
Ratio.AssignValueColor(if Ratio >= Ratio[1] then Ratio.Color("Up") else Ratio.Color("Down"));
FastAvg.SetDefaultColor(GetColor(1));
SlowAvg.SetDefaultColor(GetColor(4));

Thanks!
 
You are supposed to use "input" not "def" and remove the parenthesis for symbol1 and symbol2.

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2015-2023
#

declare lower;

def price1 = FundamentalType.CLOSE;
def price2 = FundamentalType.CLOSE;
input symbol1 = "SPY";
input symbol2 = "XLRE";
def multiplier1 = 1.0;
def multiplier2 = 1.0;
def fastLength = 4;
def slowLength = 40;
def averageType = AverageType.SIMPLE;

plot Ratio = (multiplier1 * Fundamental(price1, symbol1)) / (multiplier2 * Fundamental(price2, symbol2));
plot FastAvg = MovingAverage(averageType, Ratio, fastLength);
plot SlowAvg = MovingAverage(averageType, Ratio, slowLength);

Ratio.DefineColor("Up", Color.UPTICK);
Ratio.DefineColor("Down", Color.DOWNTICK);
Ratio.AssignValueColor(if Ratio >= Ratio[1] then Ratio.Color("Up") else Ratio.Color("Down"));
FastAvg.SetDefaultColor(GetColor(1));
SlowAvg.SetDefaultColor(GetColor(4));

I'm unsure why you would want to use "def" and not "input." That would create the error you see above.
 

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

@BenTen I actually modified the code by changing all of the lines containing "input" to "def" and added the parenthesis for symbol1 and symbol2 with the objective that input values would not be displayed in the chart title. I have changed "input" to "def" with other indicators that I have modified and been successful. Couldn't get it to work with this indicator. Any help would be appreciated. Thanks....
 
@Mike For some, it will work and for some, it won't. Just depends on the use case, I guess. But so far, I've tried multiple variations and everything took me back to "input" :D
 
@Mike For some, it will work and for some, it won't. Just depends on the use case, I guess. But so far, I've tried multiple variations and everything took me back to "input" :D
Thanks. I tried several variations also before posting my request. Given your exceptional script knowledge, coupled with your attempts, guess I'll go back to "input" also :)
 
@Mike I am guessing what you are asking is not to display the Indicator name or the parameters on TOS screen or screenshots. if that is what you are looking we do not have the ability to mask those with scripting. However, you can do this with TOS settings though.

Click on the Wheel Icon, next to Studies, on General Tab, Under DataBox, Select "Fixed" and the "Autohide Status String".

Now there will be a pop-up window where all the stings, input values will go, but you can minimize that window, not close.

Let me know if that helps.

But I like leaving most of the definitions as Input, so that way I can customize the parameters based on my need as input instead of editing the scripts.

-Surya
 
Does anyone know how I can change the partially modified script below so as to not display the inputs. I received the following errors:

Incompatible parameter: "XLRE" at 10:5
Expected double at 10:5
Expected class com.devexperts.tos.thinkscript.data.SymbolType at 17:29
Expected class com.devexperts.tos.thinkscript.data.SymbolType at 17:76

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2015-2023
#

declare lower;

def price1 = FundamentalType.CLOSE;
def price2 = FundamentalType.CLOSE;
def symbol1 = ("SPY");
def symbol2 = ("XLRE");
def multiplier1 = 1.0;
def multiplier2 = 1.0;
def fastLength = 4;
def slowLength = 40;
def averageType = AverageType.SIMPLE;

plot Ratio = (multiplier1 * Fundamental(price1, symbol1)) / (multiplier2 * Fundamental(price2, symbol2));
plot FastAvg = MovingAverage(averageType, Ratio, fastLength);
plot SlowAvg = MovingAverage(averageType, Ratio, slowLength);

Ratio.DefineColor("Up", Color.UPTICK);
Ratio.DefineColor("Down", Color.DOWNTICK);
Ratio.AssignValueColor(if Ratio >= Ratio[1] then Ratio.Color("Up") else Ratio.Color("Down"));
FastAvg.SetDefaultColor(GetColor(1));
SlowAvg.SetDefaultColor(GetColor(4));

Thanks!

def can only assign a number to a variable, not text.
so you can't assign a stock symbol with def.
you can hard code the symbol, by putting a symbol inside a price function, to read a price.
. Fundamental(price1, "SPY"))
or
. def price1 = close("SPY");


this version has the symbol inside the fundamental function

Code:
declare lower;

def price1 = FundamentalType.CLOSE;
def price2 = FundamentalType.CLOSE;
#def symbol1 = ("SPY");
#def symbol2 = ("XLRE");
def multiplier1 = 1.0;
def multiplier2 = 1.0;
def fastLength = 4;
def slowLength = 40;
def averageType = AverageType.SIMPLE;
#plot Ratio = (multiplier1 * Fundamental(price1, symbol1)) / (multiplier2 * Fundamental(price2, symbol2));
plot Ratio = (multiplier1 * Fundamental(price1, "SPY")) / (multiplier2 * Fundamental(price2, "XLRE"));

#====================
# alt method
#def price1 = close("SPY");
#def price2 = close("XLRE");
#plot Ratio = (multiplier1 * price1) / (multiplier2 * price2);
#====================


plot FastAvg = MovingAverage(averageType, Ratio, fastLength);
plot SlowAvg = MovingAverage(averageType, Ratio, slowLength);

Ratio.DefineColor("Up", Color.UPTICK);
Ratio.DefineColor("Down", Color.DOWNTICK);
Ratio.AssignValueColor(if Ratio >= Ratio[1] then Ratio.Color("Up") else Ratio.Color("Down"));
FastAvg.SetDefaultColor(GetColor(1));
SlowAvg.SetDefaultColor(GetColor(4));
#
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
359 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