# Stock + ATR port from pine

##### New member
Found this on tradingview. @BenTen was wondering if you knew of anything similar?

Code:
``````//@version=3
strategy("Stoch + ATR", overlay=false, pyramiding = 0, calc_on_order_fills = false, commission_type =  strategy.commission.percent, commission_value = 0.0454, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)

Len= input(34, minval=1, title="Length for Main Stochastic & ATR")
Input = smoothK(2, minval=1, title="SmoothK for Main Stochastic")
Input=lowLine (10, minval=-50, maxval=50, title="Multiplier for up/low lines")

//Stoch formula
Def k = sma(stoch(close, high, low, len), smoothK)
plot(k, color=aqua, title = "Stoch")

//len=input
atr=atr(len)
plot(rsi(atr, len)+lowLine , color=red,linewidth=2, title = "low line")
plot(rsi(atr, len)*-1+100-lowLine, color=lime,linewidth=2, title = "up line")

aboveLine = crossunder(k,(rsi(atr, len)+lowLine))? 1 : 0
belowLine = crossover(k,(rsi(atr, len)*-1+100-lowLine))? 1 : 0

aboveLine2 = crossover(k,(rsi(atr, len)+lowLine))? 1 : 0
belowLine2 = crossunder(k,(rsi(atr, len)*-1+100-lowLine))? 1 : 0

skip=(aboveLine2==1 or belowLine2==1) and (aboveLine==1 or belowLine==1)? 1 : 0

//BackGroound Color Plots
plotchar(belowLine==1 and skip==0, title="Buy Signal", char='B', location=location.bottom, color=white, transp=0, offset=0)
plotchar(aboveLine==1 and skip==0, title="Sell Signal", char='S', location=location.top, color=white, transp=0, offset=0)
plotchar(belowLine2==1 and skip==0, title="Close Signal", char='C', location=location.bottom, color=white, transp=0, offset=0)
plotchar(aboveLine2==1 and skip==0, title="Close Signal", char='C', location=location.top, color=white, transp=0, offset=0)

bgcolor(aboveLine==1 ? red : na, transp=30, title = "sell signal")
bgcolor(belowLine==1 ? lime : na, transp=30, title = "buy signal")

bgcolor(aboveLine2==1 ? lime : na, transp=80, title = "close short")
bgcolor(belowLine2==1 ? red : na, transp=80, title = "close long")

bgcolor(skip==1 ? black : na, transp=0, title = "skip signal")

//strategy
longCondition = belowLine==1
shortCondition = aboveLine==1

strategy.entry("SELL", strategy.short, when = shortCondition)
strategy.cancel_all(when = skip==1)``````

#### BenTen

Staff member
Staff
VIP
I'm not familiar with this indicator.

##### Active member
2019 Donor
@tomsk Could you please convert this code ?

#### diazlaz

##### Well-known member
2019 Donor
VIP
this looks interesting, going to add into my backlog and see if I can port this one over the next week or so. thanks @Ken_Adams for the find!

##### New member
Thank you. Will be on the lookout for the port

## 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?