{"id":6260,"date":"2025-05-30T14:10:25","date_gmt":"2025-06-04T07:00:25","guid":{"rendered":"https:\/\/badgameshow.com\/steven\/?p=6260"},"modified":"2025-06-04T14:10:25","modified_gmt":"2025-06-04T07:00:25","slug":"%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8%e8%b6%a8%e5%8b%a2%e6%8c%87%e6%a8%99%e5%b8%b6trendindicatorbands%e4%ba%a4%e6%98%93%e6%8c%87%e6%a8%99","status":"publish","type":"post","link":"https:\/\/badgameshow.com\/steven\/python\/%e5%ad%b8%e7%bf%92%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8%e8%b6%a8%e5%8b%a2%e6%8c%87%e6%a8%99%e5%b8%b6trendindicatorbands%e4%ba%a4%e6%98%93%e6%8c%87%e6%a8%99\/","title":{"rendered":"2025\u5e74\u6700\u65b0Python\u7a0b\u5f0f\u6559\u5b78\uff1a\u4f7f\u7528\u8da8\u52e2\u6307\u6a19\u5e36(Trend Indicator Bands)\u9032\u884c\u4ea4\u6613\u5206\u6790"},"content":{"rendered":"<p><meta name=\"keywords\" content=\"Python, \u8da8\u52bf\u6307\u6a19\u5e36, \u4ea4\u6613\u6307\u6a19, \u4f7f\u7528\u6642\u6a5f, \u6280\u8853\u5206\u6790\"><\/p>\n<h1>2025\u5e74\u6700\u65b0Python\u7a0b\u5f0f\u6559\u5b78\uff1a\u4f7f\u7528\u8da8\u52e2\u6307\u6a19\u5e36(Trend Indicator Bands)\u9032\u884c\u4ea4\u6613\u5206\u6790<\/h1>\n<p>\u8da8\u52e2\u6307\u6a19\u5e36(Trend Indicator Bands)\u662f\u4e00\u7a2e\u5ee3\u6cdb\u61c9\u7528\u65bc\u6280\u8853\u5206\u6790\u7684\u6307\u6a19\uff0c\u80fd\u5920\u5e6b\u52a9\u6295\u8cc7\u8005\u5224\u65b7\u80a1\u7968\u50f9\u683c\u7684\u8da8\u52e2\uff0c\u4e26\u63d0\u4f9b\u9069\u7576\u7684\u8cb7\u8ce3\u6642\u6a5f\u3002\u6b64\u6307\u6a19\u7531\u4e09\u689d\u7dda\u7d44\u6210\uff1a\u4e2d\u9593\u7dda\u3001\u4e0a\u9650\u7dda\u548c\u4e0b\u9650\u7dda\u3002\u4e2d\u9593\u7dda\u70ba\u79fb\u52d5\u5e73\u5747\u7dda\uff0c\u80fd\u5920\u6709\u6548\u986f\u793a\u50f9\u683c\u8da8\u52e2\uff0c\u800c\u4e0a\u9650\u7dda\u548c\u4e0b\u9650\u7dda\u5247\u662f\u57fa\u65bc\u4e2d\u9593\u7dda\u7684\u79fb\u52d5\u5e73\u5747\u503c\uff0c\u900f\u904e\u52a0\u4e0a\u6216\u6e1b\u53bb\u4e00\u5b9a\u7684\u6a19\u6e96\u5dee\u4f86\u8a08\u7b97\u5f97\u51fa\u3002<\/p>\n<p>\u5728\u9019\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5011\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528Python\u4f86\u5be6\u4f5c\u8da8\u52e2\u6307\u6a19\u5e36\uff0c\u4e26\u63d0\u4f9b\u5b8c\u6574\u7684\u7bc4\u4f8b\u4ee3\u78bc\u3001\u932f\u8aa4\u6392\u9664\u6280\u5de7\u4ee5\u53ca\u5ef6\u4f38\u61c9\u7528\u7684\u5efa\u8b70\u3002<\/p>\n<h2>\u8da8\u52e2\u6307\u6a19\u5e36\u7684\u4f7f\u7528\u6642\u6a5f<\/h2>\n<p>\u8da8\u52e2\u6307\u6a19\u5e36\u7684\u6838\u5fc3\u7528\u9014\u5728\u65bc\u5224\u65b7\u80a1\u7968\u50f9\u683c\u7684\u8da8\u52e2\u3002\u7576\u50f9\u683c\u8d85\u904e\u4e0a\u9650\u7dda\u6642\uff0c\u53ef\u80fd\u9810\u793a\u8457\u5e02\u5834\u904e\u71b1\uff0c\u4e26\u6709\u8f49\u5411\u56de\u843d\u7684\u98a8\u96aa\uff1b\u76f8\u53cd\u5730\uff0c\u7576\u50f9\u683c\u8dcc\u7834\u4e0b\u9650\u7dda\u6642\uff0c\u5247\u53ef\u80fd\u8868\u793a\u5e02\u5834\u904e\u51b7\uff0c\u5b58\u5728\u53cd\u5f48\u7684\u6a5f\u6703\u3002\u56e0\u6b64\uff0c\u6295\u8cc7\u8005\u53ef\u4ee5\u6839\u64da\u9019\u4e9b\u4fe1\u865f\u4f86\u8abf\u6574\u4ed6\u5011\u7684\u4ea4\u6613\u7b56\u7565\u3002<\/p>\n<h2>Python\u7bc4\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u4f7f\u7528Python\u7e6a\u88fd\u8da8\u52e2\u6307\u6a19\u5e36\u7684\u5b8c\u6574\u7bc4\u4f8b\uff1a<\/p>\n<p>&#8220;`python<br \/>\nimport matplotlib.pyplot as plt<br \/>\nimport numpy as np<\/p>\n<p># \u6a21\u64ec\u6578\u64da\uff1a\u96a8\u6a5f\u751f\u6210\u7684\u80a1\u7968\u50f9\u683c<br \/>\nnp.random.seed(0)<br \/>\ndata = np.random.normal(0, 1, 100).cumsum() + 100  # \u96a8\u6a5f\u751f\u6210\u6578\u64da<\/p>\n<p># \u8a2d\u5b9a\u53c3\u6578<br \/>\nperiod = 20  # \u79fb\u52d5\u5e73\u5747\u7dda\u7684\u8a08\u7b97\u5468\u671f<br \/>\nstd_multiplier = 2  # \u6a19\u6e96\u5dee\u7684\u500d\u6578<\/p>\n<p># \u8a08\u7b97\u79fb\u52d5\u5e73\u5747\u7dda<br \/>\nma = np.convolve(data, np.ones(period)\/period, mode=&#8217;valid&#8217;)<\/p>\n<p># \u8a08\u7b97\u4e0a\u9650\u7dda\u548c\u4e0b\u9650\u7dda<br \/>\nupper = ma + std_multiplier * np.std(data[:period])<br \/>\nlower = ma &#8211; std_multiplier * np.std(data[:period])<\/p>\n<p># \u7e6a\u88fd\u5716\u8868<br \/>\nplt.figure(figsize=(10, 6))<br \/>\nplt.plot(data, label=&#8217;\u80a1\u7968\u50f9\u683c&#8217;, color=&#8217;blue&#8217;)<br \/>\nplt.plot(range(period &#8211; 1, len(ma) + period &#8211; 1), ma, label=&#8217;\u79fb\u52d5\u5e73\u5747\u7dda(MA)&#8217;, color=&#8217;orange&#8217;)<br \/>\nplt.plot(range(period &#8211; 1, len(upper) + period &#8211; 1), upper, label=&#8217;\u4e0a\u9650\u7dda&#8217;, color=&#8217;red&#8217;, linestyle=&#8217;&#8211;&#8216;)<br \/>\nplt.plot(range(period &#8211; 1, len(lower) + period &#8211; 1), lower, label=&#8217;\u4e0b\u9650\u7dda&#8217;, color=&#8217;green&#8217;, linestyle=&#8217;&#8211;&#8216;)<br \/>\nplt.title(&#8216;\u8da8\u52e2\u6307\u6a19\u5e36\u793a\u610f\u5716&#8217;)<br \/>\nplt.xlabel(&#8216;\u6642\u9593&#8217;)<br \/>\nplt.ylabel(&#8216;\u50f9\u683c&#8217;)<br \/>\nplt.legend()<br \/>\nplt.grid()<br \/>\nplt.show()<br \/>\n&#8220;`<\/p>\n<p>\u5728\u9019\u500b\u7bc4\u4f8b\u4e2d\uff0c\u6211\u5011\u4f7f\u7528 `matplotlib` \u548c `numpy` \u4f86\u7e6a\u88fd\u8da8\u52e2\u6307\u6a19\u5e36\u3002\u9996\u5148\uff0c\u6211\u5011\u6a21\u64ec\u4e00\u7d44\u96a8\u6a5f\u751f\u6210\u7684\u80a1\u7968\u50f9\u683c\u6578\u64da\uff0c\u7136\u5f8c\u8a2d\u5b9a\u79fb\u52d5\u5e73\u5747\u7dda\u7684\u8a08\u7b97\u5468\u671f\u548c\u6a19\u6e96\u5dee\u7684\u500d\u6578\u3002\u63a5\u8457\uff0c\u8a08\u7b97\u79fb\u52d5\u5e73\u5747\u7dda\u3001\u4e0a\u9650\u7dda\u548c\u4e0b\u9650\u7dda\uff0c\u4e26\u4f7f\u7528 `matplotlib` \u7e6a\u88fd\u5716\u8868\uff0c\u5c07\u8da8\u52e2\u6307\u6a19\u5e36\u53ef\u8996\u5316\u5448\u73fe\u3002<\/p>\n<h2>\u932f\u8aa4\u6392\u9664\u6280\u5de7<\/h2>\n<p>\u5728\u5be6\u4f5c\u904e\u7a0b\u4e2d\uff0c\u53ef\u80fd\u6703\u9047\u5230\u4e00\u4e9b\u5e38\u898b\u932f\u8aa4\uff0c\u4f8b\u5982\uff1a<br \/>\n&#8211; **\u6578\u64da\u9577\u5ea6\u4e0d\u8db3**\uff1a\u5728\u8a08\u7b97\u79fb\u52d5\u5e73\u5747\u7dda\u6642\uff0c\u78ba\u4fdd\u6578\u64da\u9577\u5ea6\u5927\u65bc\u8a2d\u7f6e\u7684\u5468\u671f\u3002<br \/>\n&#8211; **\u7d22\u5f15\u932f\u8aa4**\uff1a\u5728\u8a08\u7b97\u4e0a\u9650\u7dda\u548c\u4e0b\u9650\u7dda\u6642\uff0c\u6aa2\u67e5\u7d22\u5f15\u662f\u5426\u6b63\u78ba\uff0c\u9632\u6b62\u8d85\u51fa\u6578\u7d44\u7bc4\u570d\u3002<\/p>\n<h2>\u5ef6\u4f38\u61c9\u7528<\/h2>\n<p>\u9664\u4e86\u80a1\u7968\u5e02\u5834\uff0c\u8da8\u52e2\u6307\u6a19\u5e36\u9084\u53ef\u4ee5\u61c9\u7528\u65bc\u5176\u4ed6\u91d1\u878d\u5e02\u5834\uff0c\u4f8b\u5982\u5916\u532f\u548c\u5546\u54c1\u5e02\u5834\u3002\u6295\u8cc7\u8005\u4e5f\u53ef\u4ee5\u5c07\u5176\u8207\u5176\u4ed6\u6280\u8853\u6307\u6a19\u7d50\u5408\u4f7f\u7528\uff0c\u4f8b\u5982\u76f8\u5c0d\u5f37\u5f31\u6307\u6a19(RSI)\u6216\u79fb\u52d5\u5e73\u5747\u6536\u6582\u767c\u6563\u6307\u6a19(MACD)\uff0c\u4ee5\u63d0\u9ad8\u4ea4\u6613\u6c7a\u7b56\u7684\u7cbe\u78ba\u5ea6\u3002<\/p>\n<p>\u5728\u5b78\u7fd2Python\u6280\u8853\u5206\u6790\u7684\u904e\u7a0b\u4e2d\uff0c\u60a8\u53ef\u4ee5\u53c3\u8003\u66f4\u591a\u8cc7\u6e90\uff0c\u4f8b\u5982 [vocus.cc\u7684Python\u6559\u5b78](https:\/\/vocus.cc) \u6216 [miner.tw\u7684\u6578\u64da\u5206\u6790\u6307\u5357](https:\/\/miner.tw)\u3002<\/p>\n<h2>\u5e38\u898b\u554f\u984c\u89e3\u7b54 (Q&#038;A)<\/h2>\n<p>**Q1: \u70ba\u4ec0\u9ebc\u8da8\u52e2\u6307\u6a19\u5e36\u7684\u4e0a\u9650\u548c\u4e0b\u9650\u6703\u96a8\u6642\u9593\u8b8a\u5316\uff1f**<br \/>\nA1: \u8da8\u52e2\u6307\u6a19\u5e36\u7684\u4e0a\u9650\u548c\u4e0b\u9650\u662f\u57fa\u65bc\u79fb\u52d5\u5e73\u5747\u7dda\u53ca\u5176\u6a19\u6e96\u5dee\u8a08\u7b97\u5f97\u51fa\uff0c\u56e0\u6b64\u96a8\u8457\u65b0\u7684\u50f9\u683c\u6578\u64da\u9032\u5165\uff0c\u9019\u4e9b\u6307\u6a19\u6703\u91cd\u65b0\u8a08\u7b97\uff0c\u5f9e\u800c\u53cd\u6620\u51fa\u6700\u65b0\u7684\u5e02\u5834\u8da8\u52e2\u3002<\/p>\n<p>**Q2: \u5982\u4f55\u9078\u64c7\u5408\u9069\u7684\u8a08\u7b97\u5468\u671f\uff1f**<br \/>\nA2: \u8a08\u7b97\u5468\u671f\u7684\u9078\u64c7\u901a\u5e38\u53d6\u6c7a\u65bc\u60a8\u7684\u4ea4\u6613\u7b56\u7565\u3002\u5982\u679c\u60a8\u662f\u77ed\u7dda\u4ea4\u6613\u8005\uff0c\u53ef\u4ee5\u9078\u64c7\u8f03\u77ed\u7684\u5468\u671f\uff0c\u4f8b\u598210-20\u5929\uff1b\u5982\u679c\u662f\u9577\u7dda\u6295\u8cc7\u8005\uff0c\u53ef\u4ee5\u9078\u64c7\u8f03\u9577\u7684\u5468\u671f\uff0c\u4f8b\u598250-100\u5929\u3002<\/p>\n<p>**Q3: \u9664\u4e86\u8da8\u52e2\u6307\u6a19\u5e36\uff0c\u9084\u6709\u54ea\u4e9b\u6709\u6548\u7684\u6280\u8853\u5206\u6790\u5de5\u5177\uff1f**<br \/>\nA3: \u9664\u4e86\u8da8\u52e2\u6307\u6a19\u5e36\uff0c\u5e38\u898b\u7684\u6280\u8853\u5206\u6790\u5de5\u5177\u9084\u5305\u62ec\u79fb\u52d5\u5e73\u5747\u7dda(MA)\u3001\u76f8\u5c0d\u5f37\u5f31\u6307\u6a19(RSI)\u3001\u5e03\u6797\u5e36(Bollinger Bands)\u548cMACD\u7b49\uff0c\u9019\u4e9b\u5de5\u5177\u53ef\u4ee5\u5e6b\u52a9\u6295\u8cc7\u8005\u66f4\u597d\u5730\u5206\u6790\u5e02\u5834\u52d5\u5411\u3002<\/p>\n<p>&#8212;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6458\u8981\uff1a\u8da8\u52e2\u6307\u6a19\u5e36(TrendIndicatorBands)\u662f\u4e00\u7a2e\u5e38\u7528\u7684\u4ea4\u6613\u6307\u6a19\uff0c\u53ef\u4ee5\u5e6b\u52a9\u6295\u8cc7\u8005\u66f4\u597d\u5730\u5224\u65b7\u80a1\u7968\u50f9\u683c\u7684\u8da8\u52e2\uff0c\u4e26\u63d0\u4f9b\u6295\u8cc7\u8005\u66f4\u591a\u7684\u4ea4\u6613\u6a5f\u6703\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528Python\u4f86\u69cb\u5efa\u8da8\u52e2\u6307\u6a19\u5e36\uff0c\u4ee5\u53ca\u5982\u4f55\u5229\u7528\u8da8\u52e2\u6307\u6a19\u5e36\u4f86\u9032\u884c\u4ea4\u6613\u3002<\/p>\n","protected":false},"author":1,"featured_media":2518,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18,189],"tags":[15,188],"class_list":["post-6260","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","category-189","tag-python","tag-188"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/badgameshow.com\/steven\/wp-content\/uploads\/2022\/12\/DALL\u00b7E-2022-12-28-14.25.55-\u62f7\u8c9d2.png","jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pcFK27-1CY","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/comments?post=6260"}],"version-history":[{"count":1,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6260\/revisions"}],"predecessor-version":[{"id":6261,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/posts\/6260\/revisions\/6261"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media\/2518"}],"wp:attachment":[{"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/media?parent=6260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/categories?post=6260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/badgameshow.com\/steven\/wp-json\/wp\/v2\/tags?post=6260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}