title: Get indicator with trade entry value - Pine Script
body: <p>I want to set stop loss of 2ATR at moment of trade entry. With Pine Script I set stop loss of 2ATR, however not at moment of trade entry, but Pine Script updates ATR value to last closed candle.Preferred verion is v4 are v5 of PS.</p>
  <p>Thanks</p>
  <pre><code>atr = atr(14)
  
  if EntryShortCondiction1 and EntryShortCondiction2
      strategy.entry(&quot;Short&quot;, false, 100)
      
  ShortStop = (strategy.position_avg_price + atr*2)
  ShortProfit = (strategy.position_avg_price - atr*2)
  
  if strategy.position_size&lt;0
      strategy.exit(id = &quot;Short&quot;, stop=ShortStop, limit=ShortProfit)
  </code></pre>