gpt4 book ai didi

tradingview-api - Tradingview 定制研究

转载 作者:行者123 更新时间:2023-12-04 01:46:21 28 4
gpt4 key购买 nike

尝试在 Tradingview 中创建自定义研究,但在加载 tradeview 小部件时出现以下错误:

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];
};
},
},
];

我将指标文件名参数用于 Tradingview 构造函数。

然后我试图像这样创建研究:
tvWidget.onChartReady(() => {
tvWidget.chart().createStudy('abcd', false, true);
});

我正在使用 UDF 替代方案与服务器端集成。

为交易 View 小部件启用 Debug模式时,我可以在
浏览器控制台:
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)

因此,从这里看来,tradeview 小部件正在加载我的指标文件,但仍显示“意外的研究 ID:abcd”。谁能看到问题?非常感谢任何帮助

最佳答案

  • 除了“描述:”必须与“名称:”完全相同
    让它工作, createStudy() 按描述搜索,所以请确保正确调用它。
    // referring to your description: 'abcd crypto index'
    widget.chart().createStudy("abcd crypto index", false, true);
  • 确保将包含 __customIndicators 的文件放入 public\charting_library\static\your-file-that-contains-__customIndicators.js
  • 如果您使用的是 TradeView v1.14,您可能应该使用 indicators_file_name 参数,而不是 custom_indicators_getter (就像文档推荐的那个,对我来说不起作用)。
  • 关于tradingview-api - Tradingview 定制研究,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55111957/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com