支撑阻力指标

Note from Towards Data Science’s editors: While we allow independent authors to publish articles in accordance with our rules and guidelines, we do not endorse each author’s contribution. You should not rely on an author’s works without seeking professional advice. See our Reader Terms for details.

Towards Data Science编辑的注意事项: 尽管我们允许独立作者按照我们的 规则和指南 发表文章 ,但我们不认可每位作者的贡献。 您不应在未征求专业意见的情况下依赖作者的作品。 有关 详细信息, 请参见我们的 阅读器条款

Support and resistance are some of the most talked-about concepts when it comes to technical analysis. Support and resistance are used as price barriers, in which the price “bounces” off of. In this article, I will use the K-means clustering algorithm to find these different support and resistance channels, and trade with these insights.

在技​​术分析中,支撑和阻力是最受关注的概念。 支撑和阻力被用作价格壁垒,价格从中反弹。 在本文中,我将使用K-means聚类算法找到这些不同的支撑和阻力通道,并利用这些见解进行交易。

支撑和阻力: (Support and Resistance:)

To understand how best to implement something, we should first understand the thing that we want to implement.

要了解如何最好地实现某件事,我们应该首先了解我们想要实现的那件事。

Self-drawn support and resistance levels. Image By Author
自绘支撑和阻力位。 图片作者

Support and Resistance, are two lines that are drawn on a graph, to form a channel, in which the price exists within.

支撑线和阻力线是在图形上绘制的两条线,形成价格存在于其中的通道。

Support and resistance are resultant of a security not being able to decrease or increase anymore, due to pressure from sellers or buyers. A good rule of thumb is that the more times a price is deflected against a support or resistance line, the less likely it will work again.

支持和阻力是由于卖方或买方的压力导致证券不再能够减少或增加的结果。 一条好的经验法则是,价格相对于支撑线或阻力线偏转的次数越多,其再次发挥作用的可能性就越小。

Support and resistance give good insight into entry points and selling points, as the support and resistance lines are theoretically the lowest and highest points for that limited time period.

支撑位和阻力位可以很好地了解切入点和卖出点,因为理论上,支撑位和阻力位是该有限时间段内的最低和最高点。

Downsides of the support and resistance strategy is that it works for an unknown period of time, and the lines are subjective and are therefore subject to human error.

支持和抵抗策略的缺点是,它在未知的时间段内都可以正常工作,并且线路是主观的,因此容易遭受人为错误的影响。

程序概念: (Program Concept:)

The K-means clustering algorithm, finds different sections of the time series data, and groups them into a defined number of groups. This number (K) can be optimized. The highest and lowest value of each group is then defined as the support and resistance values for the cluster.

K-均值聚类算法,查找时间序列数据的不同部分,并将其分组为定义的组数。 此数字(K)可以优化。 然后将每个组的最高和最低值定义为群集的支撑和阻力值。

Now that we know how the program is intended, let’s try to recreate it in Python!

现在我们知道了程序的意图,让我们尝试在Python中重新创建它!

代码: (The Code:)

import yfinancedf = yfinance.download('AAPL','2013-1-1','2020-1-1')X = np.array(df['Close'])

This script is to access data for the Apple stock price. For this example, we are implementing the support and resistance only on the closing price.

该脚本用于访问Apple股票价格的数据。 对于此示例,我们仅对收盘价实施支撑和阻力。

from sklearn.cluster import KMeansimport numpy as npfrom kneed import DataGenerator, KneeLocatorsum_of_squared_distances = []K = range(1,15)for k in K:    km = KMeans(n_clusters=k)    km = km.fit(X.reshape(-1,1))    sum_of_squared_distances.append(km.inertia_)kn = KneeLocator(K, sum_of_squared_distances,S=1.0, curve="convex", direction="decreasing")kn.plot_knee()# plt.plot(sum_of_squared_distances)

This script is to test the different values of K to find the best value:

该脚本用于测试K的不同值以找到最佳值:

The K-value of 2 creates support and resistance lines that will never be reached for a long time.

K值2会创建支撑线和阻力线,这些支撑线和阻力线将永远不会达到。

A K-value of 9 creates support and resistance that are far too common and make it difficult to make predictions.

K值为9时会产生太常见的支撑和阻力,因此很难进行预测。

Therefore, we have to find the best value of K, calculated by the elbow point when comparing variance between K values. The elbow point is the biggest improvement, given a certain movement.

因此,当比较K值之间的方差时,我们必须找到由弯头计算出的K的最佳值。 给定一定的移动量,肘点是最大的改善。

Based on the kneed library, the elbow point is at 4. This means that the optimum K value is 4.

根据膝盖库,肘点为4。这意味着最佳K值为4。

kmeans = KMeans(n_clusters= kn.knee).fit(X.reshape(-1,1))c = kmeans.predict(X.reshape(-1,1))minmax = []for i in range(kn.knee):    minmax.append([-np.inf,np.inf])for i in range(len(X)):    cluster = c[i]    if X[i] > minmax[cluster][0]:        minmax[cluster][0] = X[i]    if X[i] < minmax[cluster][1]:        minmax[cluster][1] = X[i]

This script finds the minimum and maximum value for the points that reside in each cluster. These, when plotted, become the support and resistance lines.

该脚本查找每个群集中的点的最小值和最大值。 当绘制这些线时,它们将成为支撑线和阻力线。

from matplotlib import pyplot as pltfor i in range(len(X)):    colors = ['b','g','r','c','m','y','k','w']    c = kmeans.predict(X[i].reshape(-1,1))[0]    color = colors[c]    plt.scatter(i,X[i],c = color,s = 1)for i in range(len(minmax)):    plt.hlines(minmax[i][0],xmin = 0,xmax = len(X),colors = 'g')    plt.hlines(minmax[i][1],xmin = 0,xmax = len(X),colors = 'r')

This script plots the support and resistance, along with the actual graph of the prices, which are color coded based on the cluster. Unfortunately, I think that the colors are limited, meaning that there is a limited K value in which the data can be color coded.

该脚本绘制了支撑和阻力以及价格的实际图形,这些图形根据集群进行了颜色编码。 不幸的是,我认为颜色是有限的,这意味着可以对数据进行颜色编码的K值有限。

This is the result of the program, a set of support and resistance lines. Keep in mind that the lines are most accurate, when the values fall back into the channel. Additionally, the final resistance line would be the least accurate ,as it takes the last value into account, without considering any other values.

这是程序的结果,是一组支撑线和阻力线。 请记住,当值回落到通道中时,线条最准确。 另外,最终的阻力线将是最不准确的,因为它将最后一个值考虑在内,而不考虑任何其他值。

感谢您阅读我的文章! (Thank you for reading my article!)

翻译自: https://towardsdatascience.com/using-k-means-clustering-to-create-support-and-resistance-b13fdeeba12

支撑阻力指标


http://www.taodudu.cc/news/show-995286.html

相关文章:

  • 均线交易策略的回测 r_使用r创建交易策略并进行回测
  • 初创公司怎么做销售数据分析_初创公司与Faang公司的数据科学
  • 机器学习股票_使用概率机器学习来改善您的股票交易
  • r psm倾向性匹配_南瓜香料指标psm如何规划季节性广告
  • 使用机器学习预测天气_如何使用机器学习预测着陆
  • 数据多重共线性_多重共线性对您的数据科学项目的影响比您所知道的要多
  • 充分利用昂贵的分析
  • 如何识别媒体偏见_描述性语言理解,以识别文本中的潜在偏见
  • 数据不平衡处理_如何处理多类不平衡数据说不可以
  • 糖药病数据集分类_使用optuna和mlflow进行心脏病分类器调整
  • mongdb 群集_群集文档的文本摘要
  • gdal进行遥感影像读写_如何使用遥感影像进行矿物勘探
  • 推荐算法的先验算法的连接_数据挖掘专注于先验算法
  • 时间序列模式识别_空气质量传感器数据的时间序列模式识别
  • 数据科学学习心得_学习数据科学
  • 数据科学生命周期_数据科学项目生命周期第1部分
  • 条件概率分布_条件概率
  • 成为一名真正的数据科学家有多困难
  • 数据驱动开发_开发数据驱动的股票市场投资方法
  • 算法偏见是什么_算法可能会使任何人(包括您)有偏见
  • 线性回归非线性回归_了解线性回归
  • 数据图表可视化_数据可视化如何选择正确的图表第1部分
  • 使用python和javascript进行数据可视化
  • github gists 101使代码共享漂亮
  • 大熊猫卸妆后_您不应错过的6大熊猫行动
  • jdk重启后步行_向后介绍步行以一种新颖的方式来预测未来
  • scrapy模拟模拟点击_模拟大流行
  • plsql中导入csvs_在命令行中使用sql分析csvs
  • 交替最小二乘矩阵分解_使用交替最小二乘矩阵分解与pyspark建立推荐系统
  • 火种 ctf_分析我的火种数据

支撑阻力指标_使用k表示聚类以创建支撑和阻力相关推荐

  1. python k线图和指标_期货k线图基础知识_一眼看清股市状况之用Python绘制K线图

    本文介绍关于一眼看清股市状况之用Python绘制K线图与cdp指标与期货大盘的分析周期选用有关吗?应该选用日线,还是60分钟.30分钟等时分线最为精确.与股票指标ovl是什么意思与股票均线怎么看与我想 ...

  2. k均值聚类图像分割matlab代码_用K均值聚类法为人类拍摄的首张黑洞照片进行分割...

    众所周知,人类最近拍摄了首张黑洞照片.网友们纷纷表示,这明明就是一个甜甜圈嘛!以前以为黑洞是这个世界上最最高冷的存在,而此刻突然现出真身,形象却是如此的人畜无害!不但如此,还勾起了网友的食欲!简直是罪 ...

  3. python图像分割_基于K均值聚类算法的Python图像分割

    1个K均值算法 实际上,K-means算法是一种非常简单的算法,与算法思想或特定实现无关. 通过以一定方式测量样本之间的相似度,并迭代更新聚类中心,它属于无监督分类. 当聚类中心不再移动或移动差异小于 ...

  4. r型聚类典型指标_常用的聚类算法及聚类算法评价指标

    1. 典型聚类算法 1.1 基于划分的方法 代表:kmeans算法 ·指定k个聚类中心 ·(计算数据点与初始聚类中心的距离) ·(对于数据点,找到最近的{i}ci(聚类中心),将分配到{i}ci中) ...

  5. java 在底图上绘制线条_使用底图和geonamescache绘制k表示聚类

    java 在底图上绘制线条 This is the third of four stories that aim to address the issue of identifying disease ...

  6. kmeans及模型评估指标_如何评估聚类模型?兰德指数、轮廓系数、Calinski Harabaz指数...

    我们可以通过对一系列曲目进行聚类来创建歌曲的自动播放列表,我们可以展示如何自动创建相似歌曲的子组.通过我们现有的歌曲知识,我们能够验证该聚类练习的结果. 但是,如果我们对数据没有这种先验知识怎么办?如 ...

  7. kmeans及模型评估指标_基于K-MEANS聚类模型和RFM价值分类模型的订单交易用户价值分析...

    用户数据化运营是互联网运营工作必备工作之一,且产品的生存必须有用户.而会员价价值度是用来评估用户的价值情况,是区分会员价值的重要性模型和参考依据,也是衡量不同营销效果的关键指标之一,我们可以通过复购率 ...

  8. r型聚类典型指标_应用统计学与R语言实现学习笔记(十)——聚类分析

    Chapter 10 Cluster Analysis 本篇是第十章,内容是聚类分析.由于之后的几章是典型的分析方法.而且在14章的案例里面可能不会体现,所以内容里会渗透较多的R语言操作.由于简书不支 ...

  9. k中心点聚类算法伪代码_聚类算法之——K-Means、Canopy、Mini Batch K-Means

    K-Means||算法 K-Means||算法是为了解决K-Means++算法缺点而产生的一种算法: 主要思路是改变每次遍历时候的取样规则,并非按照K-Means++算法每次遍历只获取一个样本,而是每 ...

最新文章

  1. Rocksdb 利用recycle_log_file_num 重用wal-log文件
  2. 乐刷科技-Java工程师社招面试
  3. html5网页仿写,纯CSS代码模仿绘制蚂蚁庄园页面
  4. TensorFlow入门:第一个机器学习Demo
  5. 建造者模式源码解析(jdk-guava+mybatis)
  6. Ubuntu18.04的vim和ifconfig的安装
  7. 【实习】同方威视南京研发中心招聘图像算法工程师
  8. RMAN 系列(四) ---- RMAN 备份
  9. Cobbler部署指南之配置管理篇[上文]
  10. $stateParams 详解
  11. Java毕业设计-疫情防控系统
  12. 广告公司测试软件题目,信息流广告测试题,看看你广告优化能力
  13. Ansible自动运维工具
  14. 异构图注意力网络(Heterogeneous Graph Attention Network)
  15. 安装RAC小记(Oracle11gR2)
  16. CTF学习记录 i春秋 《从0到1:CTFer成长之路》文件上传
  17. JavaWeb进阶之路:MyBatis初体验
  18. js将base64图片处理成背景透明png
  19. 论文查重时图片会不会被检测?
  20. 项管行知05--可交付成果

热门文章

  1. wpa_supplicant与wpa_cli之间通信过程
  2. java开发工作找不到要放弃吗,年薪50W
  3. MMKV集成与原理,详细学习指南
  4. php 方法参数传递,在PHP中将实例方法作为参数传递
  5. vue实现可编辑的文字_苹果还自带文字转语音,只要一键按下便可实现,今天分享给大家...
  6. 移动端Rem之讲解总结
  7. Java开发环境之RabbitMQ
  8. org.dom4j.DocumentException: null Nested exception: null解决方法
  9. 搭建Maven私服那点事
  10. DBCP连接池配置常用参数说明