title: PineScript v2 to v4
body: <p>I've coded this pinescript a couple of year ago with little knowledge to code, I still dont have much coding knowledge and things seem to have updated and wondering if anyone can help me update my script to Version 4 or 5 of the pine script version. Thanks in advance.</p>
  <pre><code>strategy(&quot;Heikin Strategy&quot;,shorttitle=&quot;HeikStrat&quot;,overlay=true,max_bars_back=50,default_qty_type=strategy.cash,initial_capital=100,currency=currency.USD)
  res1 = input(title=&quot;Heikin Ashi EMA Time Frame&quot;, type=resolution, defval=&quot;D&quot;)
  test = input(1,&quot;Heikin Ashi EMA Shift&quot;)
  sloma = input(20,&quot;Slow EMA Period&quot;)
  
  // MA (Kaufman)
  Length = input(5, minval=1)
  xPrice = input(hlc3)
  xvnoise = abs(xPrice - xPrice[1])
  Fastend = input(2.5,step=.5)
  Slowend = input(20)
  nfastend = 2/(Fastend + 1)
  nslowend = 2/(Slowend + 1)
  nsignal = abs(xPrice - xPrice[Length])
  nnoise = sum(xvnoise, Length)
  nefratio = iff(nnoise != 0, nsignal / nnoise, 0)
  nsmooth = pow(nefratio * (nfastend - nslowend) + nslowend, 2) 
  nAMA = nz(nAMA[1]) + nsmooth * (xPrice - nz(nAMA[1]))
  
  //Heikin Ashi Open and Close Price
  ha_t = heikinashi(tickerid)
  ha_close = security(ha_t, period, nAMA)
  mha_close = security(ha_t, res1, hlc3)
  
  //Moving Average
  fma = ema(mha_close[test],1)
  sma = ema(ha_close,sloma)
  plot(fma,title=&quot;MA&quot;,color=yellow,linewidth=2,style=line)
  plot(sma,title=&quot;SMA&quot;,color=red,linewidth=2,style=line)
  
  //Strategy longs
  golong =  crossover(fma,sma) 
  longexit =   crossunder(fma,sma)
  
  goshort = crossunder(fma,sma)
  shortexit  = crossover(fma,sma)
  
  strategy.entry(&quot;Buy&quot;,strategy.long,when = golong)
  strategy.close(&quot;Buy&quot;,when = longexit)
  
  strategy.entry(&quot;Sell&quot;, strategy.short, when = goshort)
  strategy.close(&quot;Sell&quot;,when = shortexit)
  </code></pre>