{"id":3049,"date":"2026-12-02T17:59:49","date_gmt":"2026-12-02T23:59:49","guid":{"rendered":"https:\/\/www.patternsmart.com\/cn\/?p=3049"},"modified":"2026-12-03T00:07:10","modified_gmt":"2026-12-03T00:07:10","slug":"%e5%9f%ba%e4%ba%8e%e5%89%8d%e5%80%bcatr%e6%8c%af%e5%b9%85%e8%bf%87%e6%bb%a4%e7%9a%84%e9%80%9a%e9%81%93%e7%aa%81%e7%a0%b4%e7%ad%96%e7%95%a5","status":"publish","type":"post","link":"https:\/\/www.patternsmart.com\/cn\/%e5%9f%ba%e4%ba%8e%e5%89%8d%e5%80%bcatr%e6%8c%af%e5%b9%85%e8%bf%87%e6%bb%a4%e7%9a%84%e9%80%9a%e9%81%93%e7%aa%81%e7%a0%b4%e7%ad%96%e7%95%a5\/","title":{"rendered":"\u57fa\u4e8e\u524d\u503cATR\u632f\u5e45\u8fc7\u6ee4\u7684\u901a\u9053\u7a81\u7834\u7b56\u7565"},"content":{"rendered":"<div class=\"postie-post\">\n<h2>\u4f7f\u7528Pine Script\u8fc7\u6ee4\u632f\u5e45\u5f02\u5e38\u7684\u7a81\u7834K\u7ebf<\/h2>\n<p>\u7a81\u7834K\u7ebf\u53ef\u80fd\u53cd\u6620\u52a8\u91cf\uff0c\u4e5f\u53ef\u80fd\u610f\u5473\u7740\u5165\u573a\u524d\u4ef7\u683c\u5df2\u7ecf\u5927\u5e45\u6ce2\u52a8\u3002\u672cTradingView\u6559\u80b2\u7b56\u7565\u7528\u4e8e\u68c0\u9a8c\u62d2\u7edd\u632f\u5e45\u8fc7\u5927\u7684\u4fe1\u53f7K\u7ebf\u80fd\u5426\u6539\u5584\u901a\u9053\u7a81\u7834\u7cfb\u7edf\u7684\u7a33\u5b9a\u6027\u3002\u91c7\u7528\u4e0a\u4e00\u6839K\u7ebf\u7684ATR\u4f5c\u4e3a\u57fa\u51c6\uff0c\u907f\u514d\u4fe1\u53f7K\u7ebf\u81ea\u8eab\u62ac\u9ad8\u8fc7\u6ee4\u9608\u503c\u3002<\/p>\n<h2>\u4ea4\u6613\u89c4\u5219\u4e0e\u6570\u503c\u793a\u4f8b<\/h2>\n<p>\u8ba1\u7b97\u6b64\u524d20\u6839\u5df2\u6536\u76d8K\u7ebf\u7684\u6700\u9ad8\u4ef7\u3002\u5f53\u6536\u76d8\u4ef7\u4e0a\u7a7f\u8be5\u6eda\u52a8\u5e8f\u5217\u65f6\u4ea7\u751f\u505a\u591a\u4fe1\u53f7\u3002\u8981\u6c42\u4fe1\u53f7K\u7ebf\u6700\u9ad8\u4ef7\u51cf\u6700\u4f4e\u4ef7\u4e0d\u8d85\u8fc7\u4e0a\u4e00\u6839K\u7ebf14\u5468\u671fATR\u76841.5\u500d\u3002\u8fd9\u91cc\u4f7f\u7528K\u7ebf\u632f\u5e45\u800c\u975e\u771f\u5b9e\u6ce2\u5e45\uff0c\u56e0\u6b64\u8fc7\u6ee4\u5668\u4e0d\u4f1a\u76f4\u63a5\u8861\u91cf\u9694\u591c\u8df3\u7a7a\u3002\u5047\u8bbe\u4e0a\u4e00\u6839ATR\u4e3a2.0\uff0c\u5141\u8bb8\u7684\u6700\u5927\u632f\u5e45\u4e3a3.0\u3002\u963b\u529b\u4f4d102\uff0c\u4e24\u6839\u5019\u9009K\u7ebf\u5747\u6536\u4e8e103.5\uff1a\u6700\u9ad8104\u3001\u6700\u4f4e101.5\u7684\u632f\u5e45\u4e3a2.5\uff0c\u901a\u8fc7\u8fc7\u6ee4\uff1b\u6700\u9ad8106\u3001\u6700\u4f4e100\u7684\u632f\u5e45\u4e3a6.0\uff0c\u62d2\u7edd\u5165\u573a\u3002\u5047\u8bbe\u6b64\u524d\u6536\u76d8\u4ef7\u4e0d\u9ad8\u4e8e\u5176\u5bf9\u5e94\u7684\u901a\u9053\u53c2\u8003\u4f4d\u3002<\/p>\n<p> <img decoding=\"async\" alt=\"atr-range-filter.png\" src=\"https:\/\/www.patternsmart.com\/cn\/wp-content\/uploads\/2026\/12\/atr-range-filter.png\" width=\"720\"><\/p>\n<p><em>\u4e24\u6839\u5047\u8bbe\u7a81\u7834K\u7ebf\u6536\u76d8\u4ef7\u76f8\u540c\u4f46\u632f\u5e45\u4e0d\u540c\u3002\u7eff\u8272\u8868\u793a\u901a\u8fc7\uff0c\u7ea2\u8272\u8868\u793a\u62d2\u7edd\uff0c\u5e76\u975eK\u7ebf\u6da8\u8dcc\u65b9\u5411\u3002<\/em><\/p>\n<h2>Pine Script v6\u793a\u4f8b<\/h2>\n<pre style=\"white-space:pre;font-family:Consolas,Monaco,monospace\"><code><a href=\"mailto:\/\/@version=6\">\/\/@version=6<\/a><br>strategy(&quot;ATR Range Guard&quot;, overlay=true, pyramiding=0,<br>\u00a0\u00a0\u00a0\u00a0default_qty_type=strategy.fixed, default_qty_value=1)<br>length = <a href=\"http:\/\/input.int\">input.int<\/a>(20, &quot;Channel length&quot;, minval=2)<br>cap = input.float(1.5, &quot;Maximum range \/ ATR&quot;, minval=0.1)<br>priorATR = ta.atr(14)[1]<br>upper = ta.highest(high, length)[1]<br>lower = ta.lowest(low, 10)[1]<br>breakout = ta.crossover(close, upper)<br>rangeOK = not na(priorATR) and priorATR &gt; 0 and<br>\u00a0\u00a0\u00a0\u00a0high - low &lt;= cap * priorATR<br>if barstate.isconfirmed and strategy.position_size == 0 and breakout and rangeOK<br>\u00a0\u00a0\u00a0\u00a0riskTicks = math.max(1, int(math.round(2 * priorATR \/ syminfo.mintick)))<br>\u00a0\u00a0\u00a0\u00a0strategy.entry(&quot;L&quot;, strategy.long)<br>\u00a0\u00a0\u00a0\u00a0strategy.exit(&quot;Protect&quot;, &quot;L&quot;, loss=riskTicks, profit=2 * riskTicks)<br>if barstate.isconfirmed and strategy.position_size &gt; 0 and close &lt; lower<br>\u00a0\u00a0\u00a0\u00a0strategy.close(&quot;L&quot;)<br>plot(upper, &quot;Prior channel&quot;, color=color.blue)<br>plot(lower, &quot;Exit channel&quot;, color=color.orange)<\/code><\/pre>\n<p>\u793a\u4f8b\u91c7\u7528\u56fa\u5b9a\u4e00\u4e2a\u4ea4\u6613\u5355\u4f4d\u3002\u63d0\u4ea4\u5165\u573a\u6307\u4ee4\u65f6\u540c\u65f6\u8bbe\u7f6e\u4fdd\u62a4\u6027\u62ec\u53f7\u8ba2\u5355\uff0c\u6b62\u635f\u8ddd\u79bb\u4e3a\u6b64\u524dATR\u7684\u4e24\u500d\u5e76\u6362\u7b97\u4e3a\u6700\u5c0f\u4ef7\u683c\u53d8\u52a8\u5355\u4f4d\uff0c\u6b62\u76c8\u8ddd\u79bb\u4e3a\u53d6\u6574\u540e\u6b62\u635f\u8ddd\u79bb\u7684\u4e24\u500d\u3002\u4f8b\u5982ATR\u4e3a2.0\u3001tick size\u4e3a0.25\u65f6\uff0c\u6b62\u635f16 ticks\uff0c\u6b62\u76c832 ticks\u3002\u76f8\u5bf9\u8ddd\u79bb\u4ee5\u6a21\u62df\u6210\u4ea4\u4ef7\u4e3a\u57fa\u51c6\uff0c\u800c\u975e\u4fe1\u53f7\u6536\u76d8\u4ef7\u3002\u6536\u76d8\u8dcc\u7834\u6b64\u524d10\u6839K\u7ebf\u6700\u4f4e\u4ef7\u65f6\u4e5f\u4f1a\u8bf7\u6c42\u5e02\u4ef7\u9000\u51fa\u3002\u88ab\u62d2\u7edd\u7684\u7a81\u7834\u4e0d\u4f1a\u5728\u540e\u7eedK\u7ebf\u8ffd\u5355\uff0c\u9664\u975e\u51fa\u73b0\u65b0\u7684\u4e0a\u7a7f\u4fe1\u53f7\u3002\u6eda\u52a8\u901a\u9053\u672c\u8eab\u4e5f\u4f1a\u53d8\u5316\uff0c\u56e0\u6b64\u4e0a\u7a7f\u903b\u8f91\u4e0d\u540c\u4e8e\u7a81\u7834\u56fa\u5b9a\u6c34\u5e73\u7ebf\u3002<\/p>\n<h2>\u6d4b\u8bd5\u65b9\u6cd5\u4e0e\u6267\u884c\u5c40\u9650<\/h2>\n<p>\u4fdd\u6301\u4ed3\u4f4d\u3001\u6b62\u635f\u3001\u6210\u672c\u548c\u6570\u636e\u4e00\u81f4\uff0c\u5bf9\u6bd4\u65e0\u8fc7\u6ee4\u57fa\u51c6\u53ca1.0\u30011.5\u30012.0\u500d\u632f\u5e45\u9650\u5236\u3002\u7edf\u8ba1\u62d2\u7edd\u7387\u3001\u51c0\u6536\u76ca\u3001\u56de\u64a4\u548c\u9519\u8fc7\u7684\u76c8\u5229\u4ea4\u6613\u3002\u4f7f\u7528\u6807\u51c6K\u7ebf\u3001\u5408\u7406\u4f63\u91d1\u548c\u6ed1\u70b9\u3001\u6837\u672c\u5916\u6570\u636e\uff0c\u5e76\u5728\u53ef\u7528\u65f6\u91c7\u7528Bar Magnifier\u5206\u6790\u76d8\u4e2d\u6b62\u635f\u6b62\u76c8\u6210\u4ea4\u987a\u5e8f\u4e0d\u660e\u786e\u7684\u60c5\u5f62\u3002\u9ed8\u8ba4\u7b56\u7565\u5e02\u4ef7\u5355\u901a\u5e38\u5728\u4e0b\u4e00\u53ef\u7528tick\u6210\u4ea4\uff0c\u5386\u53f2\u56de\u6d4b\u4e2d\u4e00\u822c\u4e3a\u4e0b\u4e00\u6839K\u7ebf\u5f00\u76d8\u3002TradingView\u7ecf\u7eaa\u5546\u6a21\u62df\u5668\u6210\u4ea4\u4e0e\u5b9e\u76d8\u6267\u884c\u4e0d\u540c\uff0c\u8b66\u62a5\u6216\u7ecf\u7eaa\u5546\u96c6\u6210\u9700\u8981\u72ec\u7acb\u7684\u8ba2\u5355\u6838\u5bf9\u548c\u4fdd\u62a4\u673a\u5236\u3002\u793a\u4f8b\u672a\u7ecf\u5b9e\u9645\u7f16\u8bd1\u6216\u56de\u6d4b\u3002\u4ea4\u6613\u5b58\u5728\u4e8f\u635f\u98ce\u9669\uff0c\u8df3\u7a7a\u53ef\u80fd\u5bfc\u81f4\u4e8f\u635f\u8d85\u8fc7\u6b62\u635f\u9884\u671f\u3002<\/p>\n<p>\u5982\u9700\u5b9a\u5236\u54c1\u79cd\u8fc7\u6ee4\u6761\u4ef6\u4e0e\u8ba2\u5355\u6267\u884c\u96c6\u6210\uff0c\u8bf7\u4e86\u89e3<a href=\"https:\/\/www.patternsmart.com\/cn\/custom\/\">TradingView\u4ea4\u6613\u7b56\u7565\u5b9a\u5236\u5f00\u53d1\u670d\u52a1<\/a>\u3002<\/p>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528Pine Script\u8fc7\u6ee4\u632f\u5e45\u5f02\u5e38\u7684\u7a81\u7834K\u7ebf \u7a81\u7834K\u7ebf\u53ef\u80fd\u53cd\u6620\u52a8\u91cf\uff0c\u4e5f\u53ef\u80fd\u610f\u5473\u7740\u5165\u573a\u524d\u4ef7\u683c\u5df2\u7ecf\u5927\u5e45\u6ce2\u52a8\u3002\u672c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3050,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_seo_schema_type":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"fifu_image_url":"","fifu_image_alt":"","_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[142,520,233],"tags":[102,434,141,693,665,604],"class_list":["post-3049","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tradingview","category-520","category-233","tag-atr","tag-pine-script","tag-tradingview","tag-693","tag-665","tag-604"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/www.patternsmart.com\/cn\/wp-content\/uploads\/2026\/12\/atr-range-filter.png","_links":{"self":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/posts\/3049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/comments?post=3049"}],"version-history":[{"count":0,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/posts\/3049\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/media\/3050"}],"wp:attachment":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/media?parent=3049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/categories?post=3049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/tags?post=3049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}