• Get $40 off VIP by signing up for a free account! Sign Up

Formula in watchlist symbol column

TCB

Member
Hi, I would like to have this formula on my watchlist under the symbol column. I know you can do formulas there, for instance you can have a couple of symbols together example AMZN+AAPL+NFLX and it will display the result, and also like the 10 yr yield divided by 10 = TNX\10. How could I get this formula to work $DXY * (TNX/10) / 1.61. This would be the Dollar index symbol multiplied by the 10yr yield formula divided by 1.61 and have this in the symbol column. Everytime I try to enter the formula in the symbol column it gives me a syntax error. Thanks for your help!
 
Solution
Hey I really appreciate that and all the help. I will try it. Is there a way to just have the value of that formula displayed on the watchlist?
try this
Code:
# symbolcombo_02_col

# for a column , just close data
# set time to day

#  $DXY * (TNX/10) / 1.61.

def na = double.nan;

input sym1 = "$DXY";
input sym2 = "TNX";
input sym3 = "--";

def sym1c = if sym1 == "--" then 0 else close(sym1);
def sym2c = if sym2 == "--" then 0 else close(sym2);
def sym3c = if sym3 == "--" then 0 else close(sym3);

# create a formula

#  $DXY * (TNX/10) / 1.61.
def x1 = sym1c * (sym2c / 10 ) / 1.61;
plot line1 = x1;

#
I tried it will not let me enter $DXY*TNX. It gives me a syntax error. Also tnx/10 does work and gives the desired value. It will let me enter $dxy*.1*.62 but when I enter the symbol TNX it gives the syntax error
 
I tried it will not let me enter $DXY*TNX. It gives me a syntax error. Also tnx/10 does work and gives the desired value. It will let me enter $dxy*.1*.62 but when I enter the symbol TNX it gives the syntax error
here is a study that combines prices from different symbols.
it draws a line and new candles.
it turns off the main candles, from the symbol in the symbol field, but that symbol can still affect the scaling of what is seen. experiment with different symbols and times. i put C in the top left symbol field and it seems to plot combined candles ok.
i have your formula hard coded in the code. it can be manually changed if desired.

Ruby:
# symbolcombo_01

#addlabel(1," symbolcombo_01",color.yellow);

#  $DXY * (TNX/10) / 1.61.

def na = double.nan;

# turn off mprimary candles
input turn_off_main_candles = yes;
HidePricePlot(turn_off_main_candles);

input show_combined_line = yes;
input show_combined_candles = yes;

# -------------------

input sym1 = "$DXY";
input sym1multi = 1.0;
addlabel((sym1 <> "--"), "symbol1 " + sym1, color.yellow);

input sym2 = "TNX";
input sym2multi = 0.1;
addlabel((sym2 <> "--"), "symbol2 " + sym2, color.yellow);

input sym3 = "--";
#  1 / 1.61 = 0.621118
input sym3multi = 0.621118;
addlabel( (sym3 <> "--"), "symbol3 " + sym3, color.yellow);

input sym4 = "--";
input sym4multi = 0;
addlabel((sym4 <> "--"), "symbol4 " + sym4, color.yellow);

input sym5 = "--";
input sym5multi = 0;
addlabel((sym5 <> "--"), "symbol5 " + sym5, color.yellow);

# -----------------------

def sym1o = if sym1 == "--" then 0 else open(sym1);
def sym1h = if sym1 == "--" then 0 else high(sym1);
def sym1l = if sym1 == "--" then 0 else low(sym1);
def sym1c = if sym1 == "--" then 0 else close(sym1);

def sym2o = if sym2 == "--" then 0 else open(sym2);
def sym2h = if sym2 == "--" then 0 else high(sym2);
def sym2l = if sym2 == "--" then 0 else low(sym2);
def sym2c = if sym2 == "--" then 0 else close(sym2);

def sym3o = if sym3 == "--" then 0 else open(sym3);
def sym3h = if sym3 == "--" then 0 else high(sym3);
def sym3l = if sym3 == "--" then 0 else low(sym3);
def sym3c = if sym3 == "--" then 0 else close(sym3);

# ------------------

# create a formula

#  $DXY * (TNX/10) / 1.61.
def x1 = sym1c * (sym2c / 10 ) / 1.61;
plot line1 = if show_combined_line then x1 else na;
line1.setdefaultcolor(color.yellow);


# calc open,high,low,close for all
def xo = if !show_combined_candles then na else ( sym1o * (sym2o / 10 ) / 1.61);
def xh = sym1h * (sym2h / 10 ) / 1.61;
def xl = sym1l * (sym2l / 10 ) / 1.61;
def xc = sym1c * (sym2c / 10 ) / 1.61;

AddChart(high = xh, low = xl, open = xo, close = xc, type = ChartType.CANDLE, growcolor = color.cyan);

#

cQIxZjo.jpg
 
Hey I really appreciate that and all the help. I will try it. Is there a way to just have the value of that formula displayed on the watchlist?
 
Hey I really appreciate that and all the help. I will try it. Is there a way to just have the value of that formula displayed on the watchlist?
try this
Code:
# symbolcombo_02_col

# for a column , just close data
# set time to day

#  $DXY * (TNX/10) / 1.61.

def na = double.nan;

input sym1 = "$DXY";
input sym2 = "TNX";
input sym3 = "--";

def sym1c = if sym1 == "--" then 0 else close(sym1);
def sym2c = if sym2 == "--" then 0 else close(sym2);
def sym3c = if sym3 == "--" then 0 else close(sym3);

# create a formula

#  $DXY * (TNX/10) / 1.61.
def x1 = sym1c * (sym2c / 10 ) / 1.61;
plot line1 = x1;

#
 
  • Like
Reactions: TCB
Solution
@halcyonguy
Hi, just got home and tried the custom column symbol and it worked great, thank you! One other question, is it possible to do that formula in the symbol column without having to have it calculated in the script for a custom column. The reason I am asking is that formula is displaying all the way down on the column for the other symbols and I really would like it to be just on the one row with the symbol and value. I would upload a image but do not know how to do that. Thanks again for your help
 
Last edited by a moderator:
@halcyonguy
Hi, just got home and tried the custom column symbol and it worked great, thank you! One other question, is it possible to do that formula in the symbol column without having to have it calculated in the script for a custom column. The reason I am asking is that formula is displaying all the way down on the column for the other symbols and I really would like it to be just on the one row with the symbol and value. I would upload a image but do not know how to do that. Thanks again for your help
that is the way column studies work, they populate a value in the column for every row. this study is hard coded for specific symbols, so it will show the same value for all rows. sometimes i don't ask questions and just do what is asked, so that people will see and learn.

you can experiment and see watchlist symbols used in the column by changing the x1 formula, change sym1c to close.
 

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