TradingView 为 k 线柱添加标记
2021-11-30 10:44:25
more 
1363

看别人翻译的开发文档

开发文档地址https://zlq4863947.gitbooks.io/tradingview/

getMarks(symbolInfo, startDate, endDate, onDataCallback, resolution)

  1. symbolInfo:SymbolInfo 商品信息对象
  2. startDate: unix 时间戳, 最左边请求的K线时间
  3. endDate: unix 时间戳, 最右边请求的K线时间
  4. onDataCallback: function(标记数字marks)
  5. resolution: string

方法介绍图表库调用这个函数来获得可见的K线范围的标记。 图表预期每调用一次getMarks就会调用一次onDataCallback。

mark为具有以下属性的对象:

  • id: 唯一标识id 。当用户点击标记时将传递给相应的回调:respective callback
  • time: unix time, UTC
  • color:red|green|blue|yellow|{ border: '#ff0000', background: '#00ff00' }
  • text: 标记弹出式文字。 支持HTML
  • label: 印在标记上的文字。单字符
  • labelFontColor: label的文字颜色
  • minSize: 标记的最小尺寸 (diameter, pixels)

每个K线允许几个标记现在最多为10个。目前我测试的可以多于 10 个。不允许标记脱离K线。

Remark: 只有当您声明您的后端是支持标记时才会调用这个函数。supporting marks.

使用时注意

  回调函数中的参数是一个列表marks列表中的每个元素是一个 字典mark

我的代码栗子

     

 1 Datafeeds.Container.prototype.getMarks &#61; function (symbolInfo, startDate, endDate, onDataCallback, resolution) { 2     console.log('endDate: ',endDate); 3     var marks &#61; that.getMarks(); 4     setTimeout(function () { 5         onDataCallback(marks); 6     }, 0); 7 } 8  9 getMarks(){10     var that &#61; this;11     var id &#61; 1;12     var time &#61; Date.parse(new Date())/1000;13     var color &#61; { border: '#103bff', background: '#ff00e9' };14     var text &#61; '这是标记: ';15     var label &#61; 'S';16     var labelFontColor &#61; '#ff8e53';17     var minSize &#61; 5;18     var marks &#61; [];19     for(var i&#61;0;i<15;i&#43;&#43;){20         var mark &#61; {};21         mark.id &#61; id&#43;&#43;;22         mark.time &#61; time;23         time -&#61; 28800;24         mark.color &#61; color;25         mark.text &#61; text &#43; (id-1);26         mark.label &#61; label;27         mark.labelFontColor &#61; labelFontColor;28         mark.minSize &#61; minSize;29         marks.push(mark);30     }31     return marks;32 }

   K 线标记  

 

转载于:https://www.cnblogs.com/xsmile/p/10619620.html

Statement:
The content of this article does not represent the views of fxgecko website. The content is for reference only and does not constitute investment suggestions. Investment is risky, so you should be careful in your choice! If it involves content, copyright and other issues, please contact us and we will make adjustments at the first time!

Related News

您正在访问的是FxGecko网站。 FxGecko互联网及其移动端产品是中国香港特别行政区成立的Hitorank Co.,LIMITED旗下运营和管理的一款面向全球发行的企业资讯査询工具。

您的IP为 中国大陆地区,抱歉的通知您,不能为您提供查询服务,还请谅解。请遵守当地地法律。