banuzi
Pine Script Rookie
Pine Script Rookie
Posts: 2
Joined: May 20th, 2022

Adding ATR stop to strategy script

hey guys , any idea how to add an ATR stop/take profit to a strategy script . thanks

banuzi
Pine Script Rookie
Pine Script Rookie
Posts: 2
Joined: May 20th, 2022

Re: Adding ATR stop to strategy script

Any idea how to add atr based stops/take-profits in a strategy script ? I can't reference the strategy(entry) function because it cannot be declared as a variable. thanks

processingclouds
Pine Script Master
Pine Script Master
Posts: 115
Joined: January 30th, 2022

Re: Adding ATR stop to strategy script

You can use stop parameter in strategy.entry to define stop any value .
To take profit you can have something like
tp = 10
if (strategy.position_size > 0)
strategy.exit(id="TakeProfit", from_entry="Long", profit=takeProfitAtValue)

Return to “Pine Script Q&A”