title: How do i ensure no signal repaint in this pinescript code?
body: <blockquote>
  <p>I have this script and I believe it repaints.What changes can I make
  so that it doesn't repaint on tradingview, please explain in detail
  why and if you could reference me to the necessary resources?
  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x x x x x xxxxxxxxxx xxxxxx xxxx x xxxxx xxxxxx xxxxx xxxx xx</p>
  </blockquote>
  <pre><code>//@version=2
      // Any timeFrame ok but good on 15 minute &amp; 60 minute , Ichimoku + Daily-Candle_cross(DT) + HULL-MA_cross + MacD combination 420 special blend
      strategy(&quot;Custom 15m strat&quot;,overlay=true)
      keh=input(title=&quot;Double HullMA&quot;,type=integer,defval=14, minval=1)
      dt = input(defval=0.0010, title=&quot;Decision Threshold (0.001)&quot;, type=float, step=0.0001)
      SL = input(defval=-500.00, title=&quot;Stop Loss in $&quot;, type=float, step=1)
      TP = input(defval=25000.00, title=&quot;Target Point in $&quot;, type=float, step=1)
      ot=1
      n2ma=2*wma(close,round(keh/2))
      nma=wma(close,keh)
      diff=n2ma-nma
      sqn=round(sqrt(keh))
      n2ma1=2*wma(close[1],round(keh/2))
      nma1=wma(close[1],keh)
      diff1=n2ma1-nma1
      sqn1=round(sqrt(keh))
      n1=wma(diff,sqn)
      n2=wma(diff1,sqn)
      b=n1&gt;n2?lime:red
      c=n1&gt;n2?green:red
      d=n1&gt;n2?red:green
      confidence=(security(tickerid, 'D', close)-security(tickerid, 'D', close[1]))/security(tickerid, 'D', close[1])
      conversionPeriods = input(9, minval=1, title=&quot;Conversion Line Periods&quot;)
      basePeriods = input(26, minval=1, title=&quot;Base Line Periods&quot;)
      laggingSpan2Periods = input(52, minval=1, title=&quot;Lagging Span 2 Periods&quot;)
      displacement = input(26, minval=1, title=&quot;Displacement&quot;)
      donchian(len) =&gt; avg(lowest(len), highest(len))
      conversionLine = donchian(conversionPeriods)
      baseLine = donchian(basePeriods)
      leadLine1 = avg(conversionLine, baseLine)
      leadLine2 = donchian(laggingSpan2Periods)
      LS=close, offset = -displacement
      MACD_Length = input(9)
      MACD_fastLength = input(12)
      MACD_slowLength = input(26)
      MACD = ema(close, MACD_fastLength) - ema(close, MACD_slowLength) //macd
      aMACD = ema(MACD, MACD_Length) //signal
      closelong = n1&lt;n2 and close&lt;n2 and confidence&lt;dt or strategy.openprofit&lt;SL or strategy.openprofit&gt;TP
      
  
  
  //SHORTS 
  shortCondition = n1&lt;n2 and strategy.opentrades&lt;ot and confidence&lt;dt and close&lt;n2 and leadLine1&lt;leadLine2 and open&gt;LS and MACD&lt;aMACD
  if (shortCondition)
      strategy.entry(&quot;Short&quot;,strategy.short, comment = &quot;SHORT ETH&quot;)
  
  
  if (closelong)
      strategy.entry(&quot;Short&quot;,strategy.short, comment = &quot;SHORT ETH&quot;)
      //strategy.close(&quot;Long&quot;)
      
      
  //LONGS   
      
  longCondition = n1&gt;n2 and strategy.opentrades&lt;ot and confidence&gt;dt and close&gt;n2 and leadLine1&gt;leadLine2 and open&lt;LS and MACD&gt;aMACD
  if (longCondition)
      strategy.entry(&quot;Long&quot;,strategy.long, comment = &quot;LONG ETH&quot;)    
  closeshort = n1&gt;n2 and close&gt;n2 and confidence&gt;dt or strategy.openprofit&lt;SL or strategy.openprofit&gt;TP
  if (closeshort)
      strategy.entry(&quot;Long&quot;,strategy.long, comment = &quot;LONG ETH&quot;)
      //strategy.close(&quot;Short&quot;)
      
      
  
  a1=plot(n1,color=c)
  a2=plot(n2,color=c)
  plot(cross(n1, n2) ? n1 : na, style = circles, color=b, linewidth = 4)
  plot(cross(n1, n2) ? n1 : na, style = line, color=d, linewidth = 4)
  plot(conversionLine, color=#0496ff, title=&quot;Conversion Line&quot;)
  plot(baseLine, color=#991515, title=&quot;Base Line&quot;)
  //plot(longCondition == true ? 4000:4100,title=&quot;long&quot;)
  plot(close, offset = -displacement, color=#459915, title=&quot;Lagging Span&quot;)
  p1=plot (leadLine1, offset = displacement, color=green,  title=&quot;Lead 1&quot;)
  p2=plot (leadLine2, offset = displacement, color=red,  title=&quot;Lead 2&quot;)
  fill(p1, p2, color = leadLine1 &gt; leadLine2 ? green : red)
  // remove the &quot;//&quot; from before the plot script if want to see the indicators on chart
  </code></pre>
  <p>'''</p>