Helloworld with custom study

Sample of how to create a custom study calculation using the default line rendering function.

by sonylnagale

HTML

<link rel="stylesheet" type="text/css" href="https://jsfiddle.chartiq.com/chart/css/stx-chart.css" media="screen" />

<div class="chartContainer" style="width:600px;height:400px;position:relative;"></div>

JavaScript

import {
  CIQ
} from "https://jsfiddle.chartiq.com/chart/js/advanced.js";
import sampleData from "https://jsfiddle.chartiq.com/chart/examples/data/STX_SAMPLE_DAILY.js";


const masterData = [
    {
        "DT": "2022-01-27T05:00:00.000Z",
        "Open": 116.87,
        "High": 117.51,
        "Low": 115.82,
        "Close": 115.82,
        "Volume": 45173871,
        "Date": "20220127000000000",
        "IBM": {
            "DT": "2022-01-27T05:00:00.000Z",
            "Open": 100.25,
            "High": 100.93,
            "Low": 100.01,
            "Close": 100.34,
            "Volume": 60719616,
            "Date": "20220127000000000",
            "iqPrevClose": 100.09,
            "ratio": 1
        },
        "ratio": 1,
        "iqPrevClose": 115.63,
        "atr": 1.3005335152267556,
        "trueRange": 1.8800000000000097,
        "hl/2": 116.66499999999999,
        "hlc/3": 116.38333333333333,
        "hlcc/4": 116.24249999999999,
        "ohlc/4": 116.505,
        "tick": 698,
        "transform": {
            "cache": {
                "IBM.Close": 131.14980471003147
            },
            "DT": "2022-01-27T05:00:00.000Z",
            "Date": "20220127000000000",
            "Close": 0.1643,
            "Open": 1.0724,
            "High": 1.6259,
            "Low": 0.1643,
            "iqPrevClose": 0,
            "IBM": {
                "Close": 0.2498,
                "Open": 0.1599,
                "High": 0.8392,
                "Low": -0.0799,
                "iqPrevClose": 0
            }
        },
        "candleWidth": null,
        "cache": {}
    },
    {
        "DT": "2022-01-28T05:00:00.000Z",
        "Open": 116.25,
        "High": 117.29,
        "Low": 115.98,
        "Close": 115.98,
        "Volume": 46733737,
        "Date": "20220128000000000",
        "IBM": {
            "DT": "2022-01-28T05:00:00.000Z",
            "Open": 99.48,
            "High": 99.84,
            "Low": 99.44,
            "Close": 99.72,
          ...