Script help: Previous candle close price minus current price

D

drbdanish

New member
Can someone make a label for me which shows the price change from previous 1 hour candle to current price please.
Label can look something like this:



I want the label to show the price change not percentage please.

I will appreciate it.
 
BenTen

BenTen

Administrative
Staff
VIP
What exactly are you asking for? Your question is about a price range, but your image is pointing at the labels.
 
D

drbdanish

New member
@BenTen Sorry for the confusion, what I'm requesting is on a 1 hour chart last bar close price minus current stock price to be shown on the label at the top of the chart.
 
BenTen

BenTen

Administrative
Staff
VIP
@drbdanish So the value would continuously change because the current stock price is always moving?
 
BenTen

BenTen

Administrative
Staff
VIP
@drbdanish Here you go:

Code:
# Difference between previous Hourly candle and current price
# Assembled by BenTen at UseThinkScript.com

input aggregationPeriod = AggregationPeriod.HOUR;
def prev_close = close(period = aggregationPeriod)[1];
input priceType = PriceType.LAST;
def LastPrice = close(priceType = priceType);
def difference = prev_close - LastPrice;

AddLabel(yes, Concat("Difference=", difference), Color.YELLOW);
 
D

drbdanish

New member
@BenTen You my friend is the best, thank you so much. I really appreciate this community.
 

Similar threads

Top