title: Turn on/off an SMA in TradingView
body: <p>I have the following code:</p>
  <pre><code>//@version=4
  // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  // © Coded by dUdU
  
  strategy(&quot;My Strategy&quot;, overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=15000, process_orders_on_close=true)
  
  // Settings
  
  candleLookback = input(5, minval=1)
  atrExitMultiplier = input(0.0, step=0.1)
  slowSMA = input(90, minval=0)
  fastSMA = input(10, minval=1)
  
  sSMA= sma(close, slowSMA)
  fSMA= sma(close, fastSMA)
  
  // Calculation
  
  inMarket = strategy.opentrades != 0
  opened = strategy.opentrades[0] &gt; strategy.opentrades[1]
  
  // Range check
  
  FromDay    = input(defval = 1, title = &quot;From Day&quot;, minval = 1, maxval = 31)
  FromMonth  = input(defval = 10, title = &quot;From Month&quot;, minval = 1, maxval = 12)
  FromYear   = input(defval = 2020, title = &quot;From Year&quot;, minval = 1990)
  ToDay      = input(defval = 1, title = &quot;To Day&quot;, minval = 1, maxval = 31)
  ToMonth    = input(defval = 1, title = &quot;To Month&quot;, minval = 1, maxval = 12)
  ToYear     = input(defval = 2021, title = &quot;To Year&quot;, minval = 1990)
  Start     = timestamp(FromYear, FromMonth, FromDay, 00, 00)
  Finish    = timestamp(ToYear, ToMonth, ToDay, 23, 59)
  Timerange() =&gt;
      time &gt;= Start and time &lt;= Finish ? true : false
  
  // Entry order
  
  longCondition = close &gt; fSMA and close &gt; sSMA
      
  if longCondition
      strategy.entry(&quot;Long&quot;, true, comment=&quot;Entry&quot;,when=Timerange())
          
  // Exit order
      
  exitPrice = highest(candleLookback) + atr(candleLookback) * atrExitMultiplier
  plot(longCondition or inMarket ? exitPrice : na, &quot;Exit Price&quot;, color.white, style=plot.style_linebr, offset=1)
  strategy.exit(&quot;Long&quot;, limit=exitPrice, comment=&quot;Exit&quot;)
      
  plot(sSMA,&quot;slow&quot;,#FFFFFF)
  plot(fSMA,&quot;fast&quot;,#EB4034)
  </code></pre>
  <p>I would like to be able to put the number &quot;0&quot; in slowSMA so that I can disable it and work only with fastSMA. However, when I put &quot;0&quot; it gives an error!</p>
  <p>I tried to put an 'if' like this:</p>
  <pre><code>...
  if slowSMA == 0
      longCondition = close &gt; fSMA
  else
      longCondition = close &gt; fSMA and close &gt; sSMA
  ...
  </code></pre>
  <p>Did not work! Would anyone have any other solutions?</p>
  <p>PS.: Explaining the operation of the algorithm: it buys when the price closes above the slow SMA and fast SMA and sells at the maximum of the last 5 candles, with the possibility of turning off the slow SMA and working with only one SMA.</p>