Register Chart Data

With the help of this function, you can fetch the chart data for a given contract. It takes seven parameters: the contract, resolutionType, resolutionRange, indicators, callback function, the asyncCallback function and the limit. Particular for this case, indicators is a list of indicators, every indicator having it’s own set of parameters. I will describe in a separate chapter how you can get the entire list of Indicators available with the function indicatorsData. The callback function is used to process the initial snapshot. The asyncCallback function is called on every chart update.

function registerChartData(contract, resolutionType, resolutionRange, indicators, callback, asyncCallback, limit)

Possible Responses:

  • Success

{
    "RQT":"register_chart",             // Request Type
    "RQI":"14",                         // Request Id
    "RES":"OK",                         // Result
    "ID":"27",                          // Chart Id
    "INS":"ESZ19"                       // Contract
    "REST":"day"                        // Resolution Type
    "RESR":"1",                         // Resolution Range
    "INDS":[                            // Indicators
    {
        "IND": "IND1",                  // Indicator 1
        "NAME": "SMA",                  // Name
        "PR": "CLOSE",                  // Price
        "LNG": "50"                     // Length
    },
    {
        "IND": "IND2",                  // Indicator 2
        "NAME": "SMA",                  // Name
        "PR": "CLOSE",                  // Price
        "LNG": "200"                    // Length
    },
    {
        "IND": "IND3",                  // Indicator 3
        "NAME": "SSTO",                 // Name
        "LNG": "50",                    // Length
        "KLNG": "3.0",                  // KLength
        "DLNG": "5.0",                  // DLength
        "UPL": "80",                    // Up Level
        "DWL": "20",                    // Down Level
        "COMP":[                        // Components
        {
            "COMP":"C1",                // Component 1
            "NAME":"%K"                 // Name
        },
        {
            "COMP":"C2",                // Component 2
            "NAME":"%D"                 // Name
        },
        {
            "COMP":"C3",                // Component 3
            "NAME":"Up Level",          // Name
            "VALUE": "80"               // Value
        },
        {
            "COMP":"C4",                // Component 4
            "NAME":"Down Level",        // Name
            "VALUE": "20"               // Value
        }
        ]
    },
    ...
    ],
    "ChartData":[                       // Chart Data
    {
        "NR": "1"                       // Number of Bar
        "TS": "1541005200",             // Timestamp
        "OP": "5250",                   // Open
        "LW": "5050",                   // Low
        "HG": "5350",                   // High
        "LS": "5150",                   // Last
        "VL": "2000",                   // Volume
        "IND1": "2803.48",              // Indicator 1 - value
        "IND2": "2820.13",              // Indicator 2 - value
        "IND3.C1": "85.42",             // Indicator 3 - component 1 - value
        "IND3.C2": "78.66"              // Indicator 3 - component 2 - value
    },
    ...
    ]
}
  • Error

{
    "RQT":"register_chart",     // Request Type
    "RQI":"14",                 // Request Id
    "RES":"ERR",                // Result
    "MSG":"Unknown contract"    // Error Message

}