# Definition of "CLOSE" Price Including the Current Bar?

#### windowshopr

##### Member
Simple question here, but in ThinkScript, when we define "close", does that include the current bar? If so, I want to be mindful of indicator repainting, because the close price of the current bar is ever changing. Wondering if it would be better to work off the last close, close[1]. Thanks!

Yes

hi guys, just checking similar problem..does above means that if I put close (for current bar) it will return me current price? ..it will be not active just after current period is closed?(lets say working with 1 hour)..thanx

I have a few scans setup that are running on DAY WEEK and HOUR aggregations. Is there a way to write the scan so that it looks at the most recent bar if it is closed and if it has not yet closed, then it will look at the prior closed bar?

Code below as an example. I have played with incrementing the offsets from, e.g. (Value[0] - Value[1]) to (Value[1] - Value[2]) but this will skip over the most recent bar regardless of whether or not it is closed or not. An example of the code I'm using is below.

Code:
``````input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageTypeMACD = AverageType.EXPONENTIAL;

def Diff = MACD(fastLength, slowLength, MACDLength, averageTypeMACD).Diff;

def Value = MovingAverage(averageTypeMACD, close, fastLength) - MovingAverage(averageTypeMACD, close, slowLength);
def Avg = MovingAverage(averageTypeMACD, Value, MACDLength);
def height = avg - avg[1];

def "Angle, deg" = (Value[0]-Value[1])/2;``````

I have a few scans setup that are running on DAY WEEK and HOUR aggregations. Is there a way to write the scan so that it looks at the most recent bar if it is closed and if it has not yet closed, then it will look at the prior closed bar?

Code below as an example. I have played with incrementing the offsets from, e.g. (Value[0] - Value[1]) to (Value[1] - Value[2]) but this will skip over the most recent bar regardless of whether or not it is closed or not. An example of the code I'm using is below.

Code:
``````input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageTypeMACD = AverageType.EXPONENTIAL;

def Diff = MACD(fastLength, slowLength, MACDLength, averageTypeMACD).Diff;

def Value = MovingAverage(averageTypeMACD, close, fastLength) - MovingAverage(averageTypeMACD, close, slowLength);
def Avg = MovingAverage(averageTypeMACD, Value, MACDLength);
def height = avg - avg[1];

def "Angle, deg" = (Value[0]-Value[1])/2;``````
@joker12
The current bar will never be closed, ( unless it is the end of the day, and after hours are off).
If you want to read data from the most recent closed bar, you will need to use an offset of 1 , [1].

Last edited by a moderator:

87k+ Posts
261 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?