title: Cannot use a mutable variable as an argument of the security function?
body: <p>I have experiencing problem to include a mutable variable as an argument for security function. I tried wrapping the code with a mutable variable in a function, like this article suggested. But it doesn't seem to work for me on v4. The security function is required because my strategy runs on 4 different timeframes. The following code is a simplified version to show where the issue occurs. Any advices?
  <a href="https://www.tradingview.com/wiki/Pine_Version_3_Migration_Guide#Resolving_a_problem_with_a_mutable_variable_in_the_security_expression" rel="nofollow noreferrer">https://www.tradingview.com/wiki/Pine_Version_3_Migration_Guide#Resolving_a_problem_with_a_mutable_variable_in_the_security_expression</a></p>
  <pre><code>//@version=4
  strategy(title=&quot;My Strategy&quot;, overlay=true, process_orders_on_close=true)
  
  
  // —————————— STATE
  
  hasOpenTrade = strategy.opentrades != 0
  
  
  // —————————— VARIABLES
  
  var maxSinceLastBuySell = 0.
  var minSinceLastBuySell = 0.
  
  
  // —————————— FUNCTIONS
  
  if hasOpenTrade
      maxSinceLastBuySell := max(maxSinceLastBuySell, high)
      minSinceLastBuySell := min(minSinceLastBuySell, low)
  
  
  // —————————— MAIN
  
  price_B = low &lt; maxSinceLastBuySell * 0.9 ? 1 : 0
  price_B_persistence = sum(price_B, 2) == 2 ? true : false
  
  price_S() =&gt; 
      sum((high &gt; minSinceLastBuySell * 1.1 ? 1 : 0), 2) == 2
  
  
  // —————————— EXECUTIONS
  
  longCondition = security(syminfo.tickerid, &quot;60&quot;, price_B_persistence)
  if (longCondition)
      strategy.entry(&quot;My Long Entry Id&quot;, strategy.long)
  
  shortCondition_sec = security(syminfo.tickerid, &quot;60&quot;, price_S())
  if (shortCondition_sec)
      strategy.entry(&quot;My Short Entry Id&quot;, strategy.short)
  </code></pre>