input symbol = "/ES";
def c = close(symbol, period = AggregationPeriod.DAY);
def o = open(symbol, period = AggregationPeriod.DAY);
def diff = c - o;
def pct = diff / o;
DefineGlobalColor("LabelColor", Color.LIGHT_GRAY);
AddLabel(yes, symbol + " " + AsDollars(c) + if diff >= 0 then " Up " else " Down " + AsPrice(AbsValue(diff)) + " (" + AsPercent(pct) + ")", GlobalColor("LabelColor"));
input symbol = "/ES";
def c = close(symbol, period = AggregationPeriod.DAY);
def o = open(symbol, period = AggregationPeriod.DAY);
def diff = c - o;
def pct = diff / o;
DefineGlobalColor("LabelColor", Color.LIGHT_GRAY);
AddLabel(yes, symbol + " " + AsDollars(c) + if diff >= 0 then " Up " else " Down " + AsPrice(AbsValue(diff)) + " (" + AsPercent(pct) + ")", GlobalColor("LabelColor"));
@Slippage I only commented because you used a futures contract in your example. And, the open - close difference is not the correct price move. You need to use the last price (close) and the previous close for calculations: thus C - C[1]. That will take opening gaps into consideration. Your method does not. If a stock previously closed at 100 and opens at 120, your method would show the 1st price quote at zero change when in fact the price is up 20 at open. If this doesn't interest you, I apologize. I won't comment or read on any further.
you can add the data boxHow to add price labels like the one in stockchar
ts.
like when you check the Full qoute and price labels it will show the high and low in a given period. I dont know how to show the creen shot but going to stockcharts.com and clicking the price labels will show high/low thank you
# dummy label
AddLabel(1," ",color.black);
AddLabel(1,"High: " + High[1],color.green);
AddLabel(1,"Low: " + Low[1], color.red);
AddLabel(1,"High - Low: " + (High[1] - Low[1]),color.white);
its giving the current bar price, can we make it the previous closed bar. also i want the difference in terms of high - low = ....as example high is 1 and low is .50 = should display = .50@om4 The easiest way to do that is with labels. There is a catch, though, as ThinkScript only plots labels at the upper left corner of the chart. The way to move them to the upper right corner is to create empty "dummy" labels and string them across the top of your chart, pushing the actual labels over to the right. Here are the values you are looking for, as well as a empty label that you can copy and paste to shift the desired labels across. Just delete the dummy label if you prefer to not use that method.
Code:# dummy label AddLabel(1," ",color.black); AddLabel(1,"High: " + High,color.green); AddLabel(1,"Low: " + Low, color.red); AddLabel(1,"HL2: " + hl2,color.white);
@om4 Sure! The code above is updated, guess I did'nt pay close enough attention to what you asked for earlier.its giving the current bar price, can we make it the previous closed bar. also i want the difference in terms of high - low = ....as example high is 1 and low is .50 = should display = .50
thank you so much! it worked!@om4 Sure! The code above is updated, guess I did'nt pay close enough attention to what you asked for earlier.
AddLabel(3, " ",color.black);
AddLabel(2, " ",color.black);
AddLabel(1, " ",color.black);
PLOT CCIAverage;
def VAL1 = CCIAverage[1];
def VAL2 = CCIAverage[2];
def VAL3 = CCIAverage[3];
def VAL4 = CCIAverage[4];
AddLabel (3,"BAR 3: " + VAL4 < VAL3, color.green else color.red);
AddLabel(2,"BAR 2 : " + val3 < val2, color.green else color.red);
AddLabel(1,"BAR 1: " + val2 < val1 ,color.green else color.red);
I have been using this Label posted by Slippage above for a label. 2 questions.
1. Does anyone know how to make the label switch to the current symbol, when the symbol is added from a watchlist, rather than changing the symbol via the the Label study input?
2. Does anyone know how to also make the label change colors in relation to positive or negative for the day? I know how to do this but I can't seem to incorporate it into the existing code.
Thanks!!!
Ruby:input findsymbol = {default watchlist, manual}; input symbol = "/ES"; def c = if findsymbol == findsymbol.manual then close(symbol, period = AggregationPeriod.DAY) else close(period = AggregationPeriod.DAY); def o = if findsymbol == findsymbol.manual then open(symbol, period = AggregationPeriod.DAY) else open(period = AggregationPeriod.DAY); def diff = c - o; def pct = diff / o; DefineGlobalColor("UP", Color.LIGHT_GREEN); DefineGlobalColor("DN", Color.LIGHT_RED); AddLabel(yes, (if findsymbol == findsymbol.manual then symbol else GetSymbol()) + " " + AsDollars(c) + if diff >= 0 then " Up " else " Down " + AsPrice(AbsValue(diff)) + " (" + AsPercent(pct) + ")", if diff >= 0 then GlobalColor("UP") else GlobalColor("DN"));
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
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.
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.