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.