title: Convert data to OHLC (Open, High, Low, Close) in JavaScript?
body: <p>Similar to <a href="https://stackoverflow.com/questions/24780823/create-an-ohlc-data-from-date-time-price-using-c-sharp">create an OHLC data from Date, time, price using C#</a>, how does one take the theory of converting basic trade data to OHLC (or Open, High, Low, Close) and apply it to this distinct case?</p>
  
  <pre><code>var data = [{
      "tid": 283945,
      "date": 1384934366,
      "amount": "0.08180000",
      "price": "501.30"
  }, {
      "tid": 283947,
      "date": 1384934066,
      "amount": "0.06110000",
      "price": "490.66"
  },
  ...
  ];
  
  function convertToOHLC(data) {
      // What goes here?
  }
  convertToOHLC(data);
  </code></pre>
  
  <p>Here is the fiddle: <a href="https://jsfiddle.net/5dfjhnLw/" rel="nofollow noreferrer">https://jsfiddle.net/5dfjhnLw/</a></p>