{"id":3139,"date":"2026-12-04T12:52:12","date_gmt":"2026-12-04T18:52:12","guid":{"rendered":"https:\/\/www.patternsmart.com\/cn\/?p=3139"},"modified":"2026-12-04T18:57:14","modified_gmt":"2026-12-04T18:57:14","slug":"mt5%e5%9f%ba%e4%ba%8eatr%e6%b3%a2%e5%8a%a8%e7%8e%87%e6%a0%87%e5%87%86%e5%8c%96%e7%9a%84%e7%aa%81%e7%a0%b4%e7%a1%ae%e8%ae%a4%e7%ad%96%e7%95%a5","status":"publish","type":"post","link":"https:\/\/www.patternsmart.com\/cn\/mt5%e5%9f%ba%e4%ba%8eatr%e6%b3%a2%e5%8a%a8%e7%8e%87%e6%a0%87%e5%87%86%e5%8c%96%e7%9a%84%e7%aa%81%e7%a0%b4%e7%a1%ae%e8%ae%a4%e7%ad%96%e7%95%a5\/","title":{"rendered":"MT5\u57fa\u4e8eATR\u6ce2\u52a8\u7387\u6807\u51c6\u5316\u7684\u7a81\u7834\u786e\u8ba4\u7b56\u7565"},"content":{"rendered":"<div class=\"postie-post\">\n<h2>\u8861\u91cf\u7a81\u7834\u7a7f\u900f\u8ddd\u79bb\uff0c\u800c\u975e\u4ec5\u5224\u65ad\u662f\u5426\u8d8a\u8fc7\u4ef7\u4f4d<\/h2>\n<p>\u6536\u76d8\u4ef7\u4ec5\u9ad8\u4e8e\u963b\u529b\u4e00\u4e2atick\u4e0e\u5927\u5e45\u9ad8\u4e8e\u963b\u529b\uff0c\u5747\u7b26\u5408\u4f20\u7edf\u7a81\u7834\u89c4\u5219\uff0c\u4f46\u76f8\u5bf9\u4e8e\u8fd1\u671f\u6ce2\u52a8\u7387\u7684\u8ddd\u79bb\u53ef\u80fd\u5dee\u5f02\u5f88\u5927\u3002\u672cMQL5\u8bbe\u8ba1\u91c7\u7528\u4fe1\u53f7\u524d\u7684ATR\u8ba1\u7b97\u6807\u51c6\u5316\u7a81\u7834\u5e45\u5ea6\uff0c\u907f\u514d\u4fe1\u53f7K\u7ebf\u81ea\u8eab\u6269\u5927\u7528\u4e8e\u5224\u65ad\u7684\u5206\u6bcd\u3002<\/p>\n<h2>\u4fe1\u53f7\u5b9a\u4e49<\/h2>\n<p>\u65b0K\u7ebf\u9996\u4e2atick\u8bfb\u53d6\u6700\u8fd1\u5df2\u6536\u76d8K\u7ebf\u53ca\u6b64\u524d20\u6839\u5df2\u6536\u76d8K\u7ebf\u3002\u963b\u529b\u4e3a20\u6839\u53c2\u8003K\u7ebf\u6700\u9ad8\u4ef7\u3002\u5c06\u4fe1\u53f7\u6536\u76d8\u4ef7\u51cf\u53bb\u963b\u529b\uff0c\u518d\u9664\u4ee5\u4fe1\u53f7\u524d\u4e00\u6839K\u7ebf\u768414\u5468\u671fATR\uff0c\u8981\u6c42\u5f97\u5206\u81f3\u5c11\u4e3a0.30\u3002\u5047\u8bbe\u963b\u529b100\u3001\u6b64\u524dATR\u4e3a2\uff0c\u6536\u76d8100.2\u5f97\u52300.10\uff0c\u4e0d\u901a\u8fc7\uff1b\u6536\u76d8101\u5f97\u52300.50\uff0c\u901a\u8fc7\u3002\u56fe\u793a\u91c7\u7528\u5047\u8bbe\u4ef7\u683c\u5355\u4f4d\u3002<\/p>\n<p> <img decoding=\"async\" alt=\"atr-breakout-distance.png\" src=\"https:\/\/www.patternsmart.com\/cn\/wp-content\/uploads\/2026\/12\/atr-breakout-distance.png\" width=\"720\"><\/p>\n<p><em>\u6b64\u524dATR\u4e3a2.0\u65f6\uff0c\u6700\u4f4e\u5408\u683c\u7a81\u7834\u8ddd\u79bb\u4e3a0.60\u4e2a\u4ef7\u683c\u5355\u4f4d\u3002<\/em><\/p>\n<h2>MQL5\u4fe1\u53f7\u6a21\u5757<\/h2>\n<pre style=\"white-space:pre;font-family:Consolas,Monaco,monospace\"><code>\/\/ Call on each tick for one strategy-owned pending order.<br>\/\/ savedBar is the opening time of the submission bar.<br>bool CancelExpiredBuyLimit(int ticket, int magic,<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0datetime savedBar)<br>{<br>\u00a0\u00a0\u00a0\u00a0if (!OrderSelect(ticket, SELECT_BY_TICKET))<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return false;<br>\u00a0\u00a0\u00a0\u00a0if (OrderCloseTime() != 0 ||<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0OrderType() != OP_BUYLIMIT ||<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0OrderSymbol() != Symbol() ||<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0OrderMagicNumber() != magic)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return false;<br><br>\u00a0\u00a0\u00a0\u00a0int age = iBarShift(Symbol(), Period(), savedBar, true);<br>\u00a0\u00a0\u00a0\u00a0if (age &lt; 0) return false; \/\/ Recover missing history.<br>\u00a0\u00a0\u00a0\u00a0if (age &lt; 3) return true;  \/\/ Still valid.<br>\u00a0\u00a0\u00a0\u00a0ResetLastError();<br>\u00a0\u00a0\u00a0\u00a0if (!OrderDelete(ticket))<br>\u00a0\u00a0\u00a0\u00a0{<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Print(&quot;Expiry delete failed: &quot;, GetLastError());<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return false;<br>\u00a0\u00a0\u00a0\u00a0}<br>\u00a0\u00a0\u00a0\u00a0return true;<br>}<\/code><\/pre>\n<p>\u4f7f\u7528\u6709\u6548iATR\u53e5\u67c4\u5e76\u786e\u8ba4\u5386\u53f2\u6570\u636e\u5c31\u7eea\u3002CopyRates\u4ece\u504f\u79fb1\u5f00\u59cb\uff0cCopyBuffer\u4ece\u504f\u79fb2\u5f00\u59cb\uff0c\u5bf9\u5e94\u4fe1\u53f7\u4e4b\u524d\u4e00\u6839K\u7ebf\u3002\u51fd\u6570\u8fd4\u56de\u503c\u8868\u793a\u6570\u636e\u8bfb\u53d6\u662f\u5426\u6210\u529f\uff0c\u8f93\u51fasignal\u8868\u793a\u662f\u5426\u6ee1\u8db3\u4ea4\u6613\u6761\u4ef6\u3002\u6570\u636e\u672a\u5c31\u7eea\u65f6\u5e94\u5148\u91cd\u8bd5\uff0c\u518d\u6807\u8bb0\u65b0K\u7ebf\u5df2\u5904\u7406\u3002\u76f8\u5173API\u53c2\u8003\uff1a<a href=\"https:\/\/www.mql5.com\/zh\/docs\/indicators\/iatr\">iATR<\/a>\u4e0e<a href=\"https:\/\/www.mql5.com\/zh\/docs\/series\/copybuffer\">CopyBuffer<\/a>\u3002<\/p>\n<h2>\u8ba2\u5355\u7ba1\u7406\u53ca\u6d4b\u8bd5<\/h2>\n<p>\u786e\u8ba4\u7b56\u7565\u7a7a\u4ed3\u4e14\u6ca1\u6709\u672a\u5b8c\u6210\u5165\u573a\u5355\u540e\u624d\u63d0\u4ea4\u4e70\u5355\u3002\u5728\u4fe1\u53f7\u6700\u4f4e\u4ef7\u4e0b\u65b9\u8bbe\u7f6e\u4fdd\u62a4\u6027\u6b62\u635f\uff0c\u6838\u5bf9\u5f53\u524dAsk\u4e0e\u6b62\u635f\u8ddd\u79bb\uff0c\u901a\u8fc7OrderCalcProfit\u7ed3\u5408\u8d44\u91d1\u98ce\u9669\u9884\u7b97\u8ba1\u7b97\u4ed3\u4f4d\u3002\u53ef\u6d4b\u8bd5\u5b9e\u9645\u521d\u59cb\u98ce\u9669\u4e24\u500d\u7684\u6b62\u76c8\u76ee\u6807\uff0c\u6210\u4ea4\u540e\u6838\u5bf9\u4fdd\u62a4\u8ba2\u5355\u3002\u4fe1\u53f7\u8fc7\u671f\u6216\u4ef7\u683c\u504f\u79bb\u8fc7\u5927\u65f6\u8df3\u8fc7\uff0c\u800c\u975e\u5047\u8bbe\u6309\u4fe1\u53f7\u6536\u76d8\u4ef7\u6210\u4ea4\u3002\u4fdd\u6301\u9000\u51fa\u89c4\u5219\u548c\u6210\u672c\u4e0d\u53d8\uff0c\u6bd4\u8f830.15\u30010.30\u30010.50\u9608\u503c\u4e0e\u666e\u901a\u6536\u76d8\u7a81\u7834\uff0c\u7edf\u8ba1\u9519\u8fc7\u8d8b\u52bf\u3001\u4ea4\u6613\u6b21\u6570\u3001\u56de\u64a4\u53ca\u6837\u672c\u5916\u8868\u73b0\u3002\u5927\u5e45\u7a81\u7834\u4e5f\u53ef\u80fd\u610f\u5473\u7740\u8d8b\u52bf\u8870\u7aed\uff0cATR\u5177\u6709\u6ede\u540e\u6027\u3002\u6a21\u5757\u672a\u7ecf\u7f16\u8bd1\u6216\u56de\u6d4b\uff0c\u4ea4\u6613\u53ef\u80fd\u9020\u6210\u91cd\u5927\u4e8f\u635f\u3002<\/p>\n<p>\u5982\u9700\u5b9a\u5236\u7b56\u7565\u5b9e\u73b0\u4e0e\u6267\u884c\u63a7\u5236\uff0c\u8bf7\u4e86\u89e3<a href=\"https:\/\/www.patternsmart.com\/cn\/custom\/\">MT5\u4ea4\u6613\u7b56\u7565\u5b9a\u5236\u5f00\u53d1\u670d\u52a1<\/a>\u3002<\/p>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u8861\u91cf\u7a81\u7834\u7a7f\u900f\u8ddd\u79bb\uff0c\u800c\u975e\u4ec5\u5224\u65ad\u662f\u5426\u8d8a\u8fc7\u4ef7\u4f4d \u6536\u76d8\u4ef7\u4ec5\u9ad8\u4e8e\u963b\u529b\u4e00\u4e2atick\u4e0e\u5927\u5e45\u9ad8\u4e8e\u963b\u529b\uff0c\u5747\u7b26\u5408\u4f20\u7edf\u7a81\u7834\u89c4\u5219\uff0c\u4f46\u76f8 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3140,"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":[364,520,233],"tags":[102,429,128,517,604,342,639],"class_list":["post-3139","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mt5","category-520","category-233","tag-atr","tag-mql5","tag-mt5","tag-517","tag-604","tag-342","tag-639"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/www.patternsmart.com\/cn\/wp-content\/uploads\/2026\/12\/atr-breakout-distance.png","_links":{"self":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/posts\/3139","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=3139"}],"version-history":[{"count":0,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/posts\/3139\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/media\/3140"}],"wp:attachment":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/media?parent=3139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/categories?post=3139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/tags?post=3139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}