Пользовательский индикатор TradingView форматирует числа в формате B / M / K - PullRequest
0 голосов
/ 25 января 2019

Я работаю над TradingView (v 1.13) и реализовал пользовательский UDF Datafeed.Я строю объем как пользовательский индикатор.Определено в файле custom_indicators.Я застрял на том, как я могу отформатировать числа, появляющиеся на оси у в формате B / M / K.Как показано на диаграмме .Я ничего не смог найти в документации.

Вот мой конструктор виджетов

var widget = window.tvWidget = new TradingView.widget({
                // debug: true, // uncomment this line to see Library errors and warnings in the console
                fullscreen: true,
                symbol: self.subject,
                interval: '15',
                container_id: "coins_trading_view_coin",
                datafeed: new Datafeeds.UDFCompatibleDatafeed(window.base_url,6000000),
                library_path: "/charting_library/",
                locale: self.getParameterByName('lang') || "en",
                indicators_file_name: window.base_url+"/charting_library/custom_indicators.js",

                disabled_features: ["use_localstorage_for_settings","header_compare","header_chart_type"],
                enabled_features: [""],
                charts_storage_url: 'https://saveload.tradingview.com',
                charts_storage_api_version: "1.1",
                client_id: 'tradingview.com',
                user_id: 'public_user_id',
                theme: self.getParameterByName('theme'),
                allow_symbol_change : false,
                hide_side_toolbar : true,
                overrides: {
                    "mainSeriesProperties.candleStyle.upColor": "#0C8912",
                    "mainSeriesProperties.candleStyle.downColor": "#C23A40"
                  },
                time_frames: []  
                });

А вот моя конфигурация пользовательских индикаторов для тома

{
        name: "Trading Volume",
        metainfo: {
            "_metainfoVersion": 40,
            "id": "Trading Volume@tv-basicstudies-1",
            "scriptIdPart": "",
            "name": "Trading Volume",
            "description": "TIE: Trading Volume",
            "shortDescription": "Volume",

            "is_hidden_study": true,
            "is_price_study": false,
            "isCustomIndicator": true,
            "plots": [{"id": "plot_2", "type": "line"}],
            "defaults": {
                "styles": {
                    "plot_2": {
                        "linestyle": 0,
                        "visible": true,
                        "linewidth": 1,
                        "plottype": 5,
                        "trackPrice": false,

                        "transparency": 40,
                        "color": "#BFBFBF"
                    }
                },
                "precision": 1,

                "inputs": {}
            },
            "styles": {
                "plot_2": {
                    "title": "Volume",
                    "histogramBase": 0,
                }
            },
            "inputs": [],
        },
...