Попытка создать пользовательские исследования в Tradingview, но при загрузке виджета tradingview появляется следующая ошибка:
Error: unexpected study id:abcd
at Function.o.findStudyMetaInfoByDescription (library.4b362457b3a7eceed386.js:29)
at y.createStudy (library.4b362457b3a7eceed386.js:718)
at t.<anonymous> (index.jsx:178)
at charting_library.min.js:1
at e.fire (library.4b362457b3a7eceed386.js:16)
at a (library.4b362457b3a7eceed386.js:22)
at Object.l [as emitOnce] (library.4b362457b3a7eceed386.js:22)
at ft (library.4b362457b3a7eceed386.js:441)
at t (library.4b362457b3a7eceed386.js:442)
at e.fire (library.4b362457b3a7eceed386.js:16)
Я следовал инструкциям на https://github.com/tradingview/charting_library/wiki/Creating-Custom-Studies
Я использовал шаблон из инструкции и просто изменил название своего исследования "abcd"
__customIndicators = [
// *** your indicator object, created from the template ***
{
// Replace the <study name> with your study name
// The name will be used internally by the Charting Library
name: 'abcd',
//name: '<study name>',
metainfo: {
_metainfoVersion: 40,
id: 'abcd@tv-basicstudies-1',
//id: '<study name>@tv-basicstudies-1',
scriptIdPart: '',
name: 'abcd',
//name: '<study name>',
// This description will be displayed in the Indicators window
// It is also used as a "name" argument when calling the createStudy method
description: 'abcd crypto index',
//description: '<study description>',
// This description will be displayed on the chart
shortDescription: 'abcd index',
//shortDescription: '<short study description>',
is_hidden_study: true,
is_price_study: true,
isCustomIndicator: true,
plots: [{ id: 'plot_0', type: 'line' }],
defaults: {
styles: {
plot_0: {
linestyle: 0,
visible: true,
// Plot line width.
linewidth: 2,
// Plot type:
// 1 - Histogram
// 2 - Line
// 3 - Cross
// 4 - Area
// 5 - Columns
// 6 - Circles
// 7 - Line With Breaks
// 8 - Area With Breaks
plottype: 2,
// Show price line?
trackPrice: false,
// Plot transparency, in percent.
transparency: 40,
// Plot color in #RRGGBB format
color: '#0000FF',
},
},
// Precision of the study's output values
// (quantity of digits after the decimal separator).
precision: 2,
inputs: {},
},
styles: {
plot_0: {
// Output name will be displayed in the Style window
title: '-- output name --',
histogramBase: 0,
},
},
inputs: [],
},
constructor: function() {
this.init = function(context, inputCallback) {
this._context = context;
this._input = inputCallback;
// Define the symbol to be plotted.
// Symbol should be a string.
// You can use PineJS.Std.ticker(this._context) to get the selected symbol's ticker.
// For example,
// var symbol = "AAPL";
// var symbol = "#EQUITY";
// var symbol = PineJS.Std.ticker(this._context) + "#TEST";
var symbol = '#abcd';
//var symbol = '<TICKER>';
this._context.new_sym(symbol, PineJS.Std.period(this._context), PineJS.Std.period(this._context));
};
this.main = function(context, inputCallback) {
this._context = context;
this._input = inputCallback;
this._context.select_sym(1);
// You can use following built-in functions in PineJS.Std object:
// open, high, low, close
// hl2, hlc3, ohlc4
var v = PineJS.Std.close(this._context);
return [v];
};
},
},
];
Я использую параметр Indicators_file_name для конструктора Tradingview.
Затем я пытаюсь создать исследование следующим образом:
tvWidget.onChartReady(() => {
tvWidget.chart().createStudy('abcd', false, true);
});
Я использую альтернативу UDF для интеграции со стороной сервера.
При включении режима отладки для виджета tradingview я вижу следующее в
консоль браузера:
1 custom indicator loaded.
Datafeed settings received: {"supports_search":true,"supports_group_request":false,"supports_marks":false,"supports_timescale_marks":false,"supports_time":true,"exchanges":[{"value":"NasdaqNM","name":"NasdaqNM","desc":"NasdaqNM"}],"symbols_types":[{"name":"All types","value":""},{"name":"Stock","value":"stock"},{"name":"Index","value":"index"}],"supported_resolutions":["D"]}
library.4b362457b3a7eceed386.js:698 Symbol resolve requested: `HOLD`
library.4b362457b3a7eceed386.js:698 Symbol resolved: `HOLD`, SymbolInfo in server response {"name":"HOLD","timezone":"America/New_York","minmov":1,"minmov2":0,"pointvalue":1,"session":"24x7","has_intraday":false,"has_no_volume":true,"description":"Portfolio Performance","type":"crypto","supported_resolutions":["D"],"pricescale":1000,"ticker":"HOLD"}
library.4b362457b3a7eceed386.js:698 Symbol info after post-processing: `HOLD`, SymbolInfo {"name":"HOLD","timezone":"America/New_York","minmov":1,"minmov2":0,"pointvalue":1,"session":"24x7","has_intraday":false,"has_no_volume":true,"description":"Portfolio Performance","type":"crypto","supported_resolutions":["1D"],"pricescale":1000,"ticker":"HOLD","base_name":["HOLD"],"legs":["HOLD"],"full_name":"HOLD","pro_name":"HOLD","data_status":"streaming"}
library.4b362457b3a7eceed386.js:339 Event "symbol", arguments: [{"category":"Symbol","label":"HOLD","value":""}]
...
...
...
library.4b362457b3a7eceed386.js:339 Event "onChartReady", arguments: []
library.4b362457b3a7eceed386.js:339 Event "chart_style", arguments: [{"category":"Chart","value":"AREA"}]
index.js:2178 Error: unexpected study id:abcd
at Function.o.findStudyMetaInfoByDescription (library.4b362457b3a7eceed386.js:29)
at y.createStudy (library.4b362457b3a7eceed386.js:718)
at t.<anonymous> (index.jsx:178)
at charting_library.min.js:1
at e.fire (library.4b362457b3a7eceed386.js:16)
at a (library.4b362457b3a7eceed386.js:22)
at Object.l [as emitOnce] (library.4b362457b3a7eceed386.js:22)
at ft (library.4b362457b3a7eceed386.js:441)
at t (library.4b362457b3a7eceed386.js:442)
at e.fire (library.4b362457b3a7eceed386.js:16)
Итак, из этого видно, что виджет tradingview загружает файл моего индикатора, но все равно говорит «неожиданный идентификатор исследования: abcd». Кто-нибудь, кто может увидеть проблему? Любая помощь с благодарностью