# ATR in Play For ThinkOrSwim

#### QUIKTDR1

##### Active member
VIP
Invalid statement: def at 11:1
def iATRPlay = Round((high(period = “DAY”) — low(period = “DAY”)) / iATR, 2);

#thinkscript indicator : ATR, ATR In Play
#Average True Range
#Average True Range label
#ATR in play — How many ATR stock did today
input ATRInPlay = {default “1”, “0”};
input ATR = {default “1”, “0”};
def iATR = Round(MovingAverage (AverageType.WILDERS, TrueRange(high(period = AggregationPeriod.DAY )[1], close(period = AggregationPeriod.DAY)[1], low(period = AggregationPeriod.DAY )[1]), 14), 2);
AddLabel (!ATR, “ATR “ + iATR, if iATR <= 0.5 then Color.RED else if iATR <= 2 then Color.DARK_GREEN else Color.WHITE);

def iATRPlay = Round((high(period = “DAY”) — low(period = “DAY”)) / iATR, 2);

AddLabel (!ATRInPlay, “ATRInPlay “ + iATRPlay, if iATRPlay <= 0.5 then Color.DARK_RED else if iATRPlay <= 1 then Color.WHITE else Color.DARK_GREEN);

Invalid statement: def at 11:1
def iATRPlay = Round((high(period = “DAY”) — low(period = “DAY”)) / iATR, 2);
Not sure what that symbol is in the equation but it is definitely not the correct subtraction symbol:
def iATRPlay = Round((high(period = “DAY”) - low(period = “DAY”)) / iATR, 2);

Ruby:
``````#thinkscript indicator : ATR, ATR In Play
#Average True Range
#Average True Range label
#ATR in play — How many ATR stock did today
input ATRInPlay = {default “1”, “0”};
input ATR = {default “1”, “0”};
def iATR = Round(MovingAverage (AverageType.WILDERS, TrueRange(high(period = AggregationPeriod.DAY )[1], close(period = AggregationPeriod.DAY)[1], low(period = AggregationPeriod.DAY )[1]), 14), 2);
AddLabel (!ATR, “ATR “ + iATR, if iATR <= 0.5 then Color.RED else if iATR <= 2 then Color.DARK_GREEN else Color.WHITE);

def iATRPlay = Round((high(period = “DAY”) - low(period = “DAY”)) / iATR, 2);

AddLabel (!ATRInPlay, “ATRInPlay “ + iATRPlay, if iATRPlay <= 0.5 then Color.DARK_RED else if iATRPlay <= 1 then Color.WHITE else Color.DARK_GREEN);``````

Not sure what that symbol is in the equation but it is definitely not the correct subtraction symbol:
def iATRPlay = Round((high(period = “DAY”) - low(period = “DAY”)) / iATR, 2);

Ruby:
``````#thinkscript indicator : ATR, ATR In Play
#Average True Range
#Average True Range label
#ATR in play — How many ATR stock did today
input ATRInPlay = {default “1”, “0”};
input ATR = {default “1”, “0”};
def iATR = Round(MovingAverage (AverageType.WILDERS, TrueRange(high(period = AggregationPeriod.DAY )[1], close(period = AggregationPeriod.DAY)[1], low(period = AggregationPeriod.DAY )[1]), 14), 2);
AddLabel (!ATR, “ATR “ + iATR, if iATR <= 0.5 then Color.RED else if iATR <= 2 then Color.DARK_GREEN else Color.WHITE);

def iATRPlay = Round((high(period = “DAY”) - low(period = “DAY”)) / iATR, 2);

AddLabel (!ATRInPlay, “ATRInPlay “ + iATRPlay, if iATRPlay <= 0.5 then Color.DARK_RED else if iATRPlay <= 1 then Color.WHITE else Color.DARK_GREEN);``````

That was indeed the problem, thanks so much!

good eye @MerryDay

i was going to say this,

try replacing all of the quote characters.
Sometimes when copy/paste text, quote symbols get changed into 2 apostrophes or some other version of them that isn't interpreted correctly.

87k+ Posts
318 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?