趋势线(Trend Line)

Since price has tested and respected the trendline for at least three “touches”, we know that our trendline is valid.

javascript 将趋势线添加到现有图表 Chart.js

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43214785/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

Adding trendlines to existing chart Chart.js

提问 by Blue Agency

from hours I've been looking for a solution to add trendlines to an existing chart built with Chart.js

从几个小时开始,我一直在寻找一种解决方案,将趋势线添加到使用 Chart.js 构建的现有图表中

I think we can only add logarithmic trendline on Chart.js ?

我认为我们只能在 Chart.js 上添加对数趋势线?

I don't want to draw a trendline from scratch, but add 趋势线(Trend Line) 2 trendlines based on existing data of these 2 lines ; please see this fiddle example :

A big thank you in advance for all your help.

回答 by jordanwillis

Currently, chart.js does not have a trendline capability at all (not even logarithmic). Perhaps you were getting confused with the custom tick format example 趋势线(Trend Line) at the end of the Common Scale Configurationsection?

You could however use the chartjs-plugin-annotationplugin to draw a trendline on your chart, but keep in mind that you would have to implement your own logic to calculate the correct location of the line (and then just use the annotation plugin to actually draw it).

但是,您可以使用chartjs-plugin-annotation插件在图表上绘制趋势线,但请记住,您必须实现自己的逻辑来计算线的正确位置(然后只需使用 annotation 插件来实际画出来)。

Here is an example demonstrating how to use the plugin (趋势线(Trend Line) the plugin provides a set of annotation properties that you can add to your charts options . You would then just need to create a function that calculates the trendline and use the result to set the annotation value and 趋势线(Trend Line) endValue properties.

这是一个演示如何使用该插件的示例(该插件提供了一组 annotation 您可以添加到图表中的属性 options 。然后您只需要创建一个计算趋势线的函数并使用结果来设置注释 value 和 endValue 属性。

You can see 趋势线(Trend Line) it in action at this codepen.

回答 by Savage

The chartjs-plugin-trendline provides a straight-line 趋势线(Trend Line) trendline that plugs into Chart.js.

在 chartjs-plugin-trendline 提供了直线趋势线插入到chart.js之。

Usage is pretty straightforward - just add the following to your dataset:

回答 by Krishna Gupta

Perhaps think of using Google Charts, instead of Chart.js. Google Charts includes Trendlines - including Linear, Exponential, and Polynomial.

趋势线 – 您在Olymp Trade开立长期交易的最佳线和指标

如何在Olymp Trade创建趋势线

Olymp Trade appeared on the market in 2014. Since then we have continuously created the new and improved the old, so that your trading on the platform is seamless and lucrative. And 趋势线(Trend Line) that’s just the beginning. We don’t just give traders a chance to earn, but we also teach them how. Our team has world-class analysts. They 趋势线(Trend Line) develop original trading strategies and teach traders how to use them intelligently in open webinars, and they consult one-on-one with traders. Education is conducted in all the languages that our traders speak.
Unofficial website of the Olymp Trade

General Risk Notification: trading on the Olymp Trade platform involves high-risk investment. Do not 趋势线(Trend Line) invest funds that you are not prepared to lose. Before you start, we 趋势线(Trend Line) advise that you become familiar with the rules and conditions of trading outlined on our site. Any examples, tips, strategies and instructions on the site do not constitute trading recommendations and are not legally binding. Olymp Trade is a trading platform which operates online. Traders make their decisions independently and this company does not assume responsibility for them. The service contract is concluded in the 趋势线(Trend Line) territory of the sovereign state of Saint Vincent and the Grenadines. The services 趋势线(Trend Line) of the company are provided in the territory of the sovereign state of 趋势线(Trend Line) Saint Vincent and the Grenadines.


By looking at the historical 4 hour chart 趋势线(Trend Line) 趋势线(Trend Line) of the GBPUSD below, there are several reasons we know that we want to go long (购买) 这一对. Price action is above the 200 Simple Moving Average and is pulling away from it. The pair has been making higher 趋势线(Trend Line) highs (green lines) and higher lows which indicates an uptrend. 还, 在此图表的时间, the 趋势线(Trend Line) GBP was strongest currency and the USD was one of the weaker 趋势线(Trend Line) currencies.

All these point to a buying opportunity.

但, the question remains, when do we enter the trade?

Here’s where we bring in the trendline…

Screen Shot 2013-06-24 在 2.58.57 PM

趋势线 1

Let’s 趋势线(Trend Line) take a look at the historical 4 hour chart of the GBPUSD pair below…

We can see that price action has come in contact with trendline support at several points – note the blue boxes.

Since price has tested and respected the trendline for at least three “touches”, we know that our 趋势线(Trend Line) trendline is valid.

Our entry strategy to buy this pair using trendline support 趋势线(Trend Line) will be to wait for price to trade down to the trendline and 趋势线(Trend Line) into the “Buy Zone”. If price trades into the Buy Zone and stalls and a candle does not close below trendline support, just as in our 趋势线(Trend Line) 趋势线(Trend Line) 趋势线(Trend Line) blue box examples, we can take a long position on the pair with our stop just below the trendline or just below the lowest wick that penetrates the trendline.

The trader could exit the trade if price reaches resistance, 趋势线(Trend Line) the previous high, or by employing a simple 1:2 Risk Reward Ratio.

Now let’s take a look at a historical 4 hour chart of the USDCHF for an example of selling against Trendline Resistance in a downtrend…

趋势线 2

This trading scenario will be virtually the opposite of what we did in the previous buy example.

We want to sell the pair a it has been making lower lows (red lines) and lower highs. Price action is below the 200 SMA and pulling away from it. 还, 在此图表的时间, the USD was weak and the CHF was strong.

再次, price action has tested our resistance line at several points (the blue boxes) so we know the trendline to be valid. In this example we would wait for price to trade up to trendline 趋势线(Trend Line) resistance in the “Sell Zone”. As long as a candle does not close above the trendline, we would sell the pair with a stop just above the trendline or just above the highest wick to penetrate the trendline.

The trade could be closed should price reach the previous low or we could use a 1:2 Risk Reward Ratio to exit the trade.


XAUUSD 1W with Gold/Silver Ratio

Looking for Share Trading? Sign up here

Recent Posts

苹果进入BNPL领域,发布Apple 趋势线(Trend Line) Pay Later



Black Bull Group Limited(交易名称:BlackBull Markets)是一家在新西兰注册的公司(NZBN 9429041417799),公司地址位于奥克兰Albert Street 120 号22楼。BlackBull Group Limited是注册金融服务提供商(FSP403326)并持有金融市场管理局颁发FMA(衍生品发行许可)牌照。

Black 趋势线(Trend Line) 趋势线(Trend Line) Bull 英国责任有限公司注册于英国(公司编号-9556804).清算服务由Black Bull 英国责任有限公司提供(公司编号-9556804, 公司地址-483 Green Lanes, London, Greater London, United Kingdom, 趋势线(Trend Line) N13 485

Blackbull Markets is the trade name of BBG Limited, a company registered in Seychelles with registration no. 857010-1 and registered office at CT House, Office 趋势线(Trend Line) 9A, Providence, Mahe, Seychelles. BBG Limited is authorized and regulated as a Securities Dealer by the Financial Services Authority of Seychelles with license number SD045.

风险警示:交易外汇风险较高,可能不适合所有投资者。 高杠杆率在交易中有利有弊。 在决定交易外汇之前,您应仔细考虑您的投资目标,经验水平和风险偏好。 在交易中存在有持续亏损或全部初始投资亏损的可能性。因此,您不应该投入您无法承受损失的金额。您应该意识到与外汇交易相关的所有风险,如果您对交易损失会怎样影响到您的生活方式上有任何疑问或疑虑,那么您需要征求财务顾问的意见。

To provide the best experiences, we use technologies like cookies to 趋势线(Trend Line) store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not 趋势线(Trend Line) consenting or withdrawing consent, may adversely affect certain features and functions.

The technical 趋势线(Trend Line) storage or access is strictly necessary for the legitimate purpose of enabling the 趋势线(Trend Line) use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.

The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.

The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without 趋势线(Tren趋势线(Trend Line) d Line) a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.

The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.