title: Pinescript - "Compare" Indicator with Percentage Change Function takes only last bar data
body: <p>need help pls.</p>
  
  <p>In Tradingview I use "Compare" to see the BTCUSDT vs. ETHUSDT on Binance and it's basically OK. But lines on the chart are too "up &amp; down" and I want to see the SMA or EMA for those tickers.</p>
  
  <p>I'm trying to do it step by step but I can't pass through the issue that my code takes only last calculated value in consideration and "percentage change line" starts from 0 with each new data. So it makes no sence. Meaning, my last data doesn't add upon prior value, but always starts from zero.</p>
  
  <p>So, data (value) that comes out is good (same as when I put same tickers on Tradingview "Compare") but Tradingview "Compare" calculates / adds data on historical data, while my code starts from 0.</p>
  
  <p>Here is the Pine script code:</p>
  
  <pre><code>//@version=4
  study(title="Compare", shorttitle="Compare", overlay=false, max_bars_back=0)
  
  perc_change = (((close[0] - open[0]) / open [0]) * 100)
  
  sym1 = "BINANCE:BTCUSDT", res1 = "30", source1 = perc_change
  
  plot(security(sym1, res1, source1), color=color.orange, linewidth=2)
  
  
  sym2 = "BINANCE:ETHUSDT", res2 = "30", source2 = perc_change
  
  plot(security(sym2, res2, source2), color=color.blue, linewidth=2)
  </code></pre>