{"id":2843,"date":"2026-11-28T21:23:40","date_gmt":"2026-11-29T03:23:40","guid":{"rendered":"https:\/\/www.patternsmart.com\/cn\/?p=2843"},"modified":"2026-11-29T03:37:11","modified_gmt":"2026-11-29T03:37:11","slug":"atr%e5%bd%92%e4%b8%80%e5%8c%96%e5%bc%80%e7%9b%98%e8%b7%b3%e7%a9%ba%e6%8c%87%e6%a0%87","status":"publish","type":"post","link":"https:\/\/www.patternsmart.com\/cn\/atr%e5%bd%92%e4%b8%80%e5%8c%96%e5%bc%80%e7%9b%98%e8%b7%b3%e7%a9%ba%e6%8c%87%e6%a0%87\/","title":{"rendered":"ATR\u5f52\u4e00\u5316\u5f00\u76d8\u8df3\u7a7a\u6307\u6807"},"content":{"rendered":"<div class=\"postie-post\">\n<h2>\u9ad8\u7ea7\u4ea4\u6613\u6559\u7a0b\u2014\u2014ATR\u5f52\u4e00\u5316\u5f00\u76d8\u8df3\u7a7a\u6307\u6807<\/h2>\n<p>\u540c\u6837\u662f\u4e24\u4e2a\u4ef7\u683c\u5355\u4f4d\u7684\u5f00\u76d8\u8df3\u7a7a\uff0c\u5728\u4f4e\u6ce2\u52a8\u5e02\u573a\u53ef\u80fd\u975e\u5e38\u663e\u8457\uff0c\u5728\u9ad8\u6ce2\u52a8\u5e02\u573a\u5374\u53ef\u80fd\u5341\u5206\u666e\u901a\u3002\u672c\u6559\u7a0b\u901a\u8fc7MT5\u7684\u5e73\u5747\u771f\u5b9e\u6ce2\u5e45\uff08ATR\uff09\u5bf9\u5f00\u76d8\u4ef7\u4e0e\u524d\u4e00\u6839K\u7ebf\u6536\u76d8\u4ef7\u4e4b\u95f4\u7684\u5dee\u503c\u8fdb\u884c\u5f52\u4e00\u5316\u3002\u76ee\u7684\u5728\u4e8e\u4f7f\u7528\u8df3\u7a7a\u53d1\u751f\u524d\u5df2\u7ecf\u83b7\u5f97\u7684\u6ce2\u52a8\u7387\u4fe1\u606f\u8861\u91cf\u4ef7\u683c\u4e0d\u8fde\u7eed\u7a0b\u5ea6\uff0c\u800c\u4e0d\u662f\u9884\u6d4b\u7f3a\u53e3\u662f\u5426\u56de\u8865\u3002<\/p>\n<h2>\u8ba1\u7b97\u903b\u8f91<\/h2>\n<p>\u91c7\u7528\u65f6\u95f4\u5e8f\u5217\u7d22\u5f15\uff0c\u5bf9\u5df2\u6536\u76d8K\u7ebfi\u8ba1\u7b97\uff08Open[i]\uff0dClose[i+1]\uff09\u00f7ATR[i+1]\u3002\u5206\u6bcd\u7279\u610f\u91c7\u7528\u524d\u4e00\u6839K\u7ebf\u7684ATR\uff0c\u907f\u514d\u672c\u6b21\u8df3\u7a7a\u672c\u8eab\u6269\u5927\u6ce2\u52a8\u7387\u5206\u6bcd\uff0c\u4ece\u800c\u63a9\u76d6\u8df3\u7a7a\u7684\u76f8\u5bf9\u663e\u8457\u6027\u3002ATR\u8861\u91cf\u771f\u5b9e\u6ce2\u5e45\uff0c\u5305\u62ec\u4ef7\u683c\u4e0d\u8fde\u7eed\u9020\u6210\u7684\u6ce2\u52a8\uff0c\u4f46\u4e0d\u53cd\u6620\u65b9\u5411\u3002\u5e26\u7b26\u53f7\u7684\u5f52\u4e00\u5316\u7ed3\u679c\u65e2\u4fdd\u7559\u8df3\u7a7a\u65b9\u5411\uff0c\u53c8\u6d88\u9664\u4ef7\u683c\u5355\u4f4d\u5dee\u5f02\u3002<\/p>\n<figure><img decoding=\"async\" alt=\"atr-gap.png\" style=\"max-width:100%;height:auto\" src=\"https:\/\/www.patternsmart.com\/cn\/wp-content\/uploads\/2026\/11\/atr-gap.png\"><figcaption>\u5047\u8bbe\u8df3\u7a7a\u7684\u5f52\u4e00\u5316\u7ed3\u679c\u4f9d\u6b21\u4e3a+0.5\u3001\u22121.0\u3001+1.5\u548c\u22120.5\u4e2aATR\u5355\u4f4d\u3002<\/figcaption><\/figure>\n<p>\u5047\u8bbe\u524d\u4e00\u6839K\u7ebf\u6536\u76d8\u4ef7\u4e3a100\uff0cATR\u4e3a2\u3002\u5f00\u76d8101\u65f6\u7ed3\u679c\u4e3a+0.5\uff1b\u5f00\u76d898\u65f6\u4e3a\u22121.0\uff1b\u5f00\u76d8103\u65f6\u4e3a+1.5\uff1b\u5f00\u76d899\u65f6\u4e3a\u22120.5\u3002\u56db\u4e2a\u4f8b\u5b50\u5206\u522b\u72ec\u7acb\u4f7f\u7528\u76f8\u540c\u7684\u5047\u8bbe\u53c2\u8003\u6536\u76d8\u4ef7\u4e0eATR\u3002+1.5\u610f\u5473\u7740\u5f00\u76d8\u4f4d\u79fb\u76f8\u5f53\u4e8e\u6b64\u524dATR\u76841.5\u500d\uff0c\u5e76\u4e0d\u610f\u5473\u7740\u540e\u7eed\u4ef7\u683c\u8fd8\u4f1a\u7ee7\u7eed\u4e0a\u6da8\u540c\u6837\u7684\u5e45\u5ea6\u3002<\/p>\n<h2>\u5b8c\u6574MQL5\u6307\u6807\u6e90\u7801<\/h2>\n<p>\u4e0eMQL4\u76f4\u63a5\u8bfb\u53d6\u6307\u6807\u6570\u503c\u7684\u65b9\u5f0f\u4e0d\u540c\uff0cMQL5\u4f7f\u7528\u6307\u6807\u53e5\u67c4\u4e0eCopyBuffer\u3002\u521d\u59cb\u5316\u65f6\u521b\u5efa\u4e00\u6b21ATR\u53e5\u67c4\uff0c\u5378\u8f7d\u6307\u6807\u65f6\u91ca\u653e\u3002\u901a\u8fc7BarsCalculated\u53caCopyBuffer\u8fd4\u56de\u503c\u5224\u65ad\u6570\u636e\u662f\u5426\u51c6\u5907\u5b8c\u6574\u3002\u660e\u786e\u8bbe\u7f6e\u8f93\u5165\u4e0e\u8f93\u51fa\u6570\u7ec4\u7684\u65f6\u95f4\u5e8f\u5217\u65b9\u5411\uff0c\u5e76\u5c06\u5f53\u524d\u672a\u6536\u76d8K\u7ebf\u8bbe\u7f6e\u4e3aEMPTY_VALUE\uff0c\u53ea\u5c55\u793a\u5df2\u7ecf\u786e\u8ba4\u7684\u5386\u53f2\u7ed3\u679c\u3002<\/p>\n<pre style=\"white-space:pre;font-family:Consolas,Monaco,monospace\"><code>#property indicator_separate_window<br>#property indicator_buffers 1<br>#property indicator_plots 1<br>#property indicator_type1 DRAW_HISTOGRAM<br>#property indicator_color1 clrDodgerBlue<br>#property indicator_width1 3<br>#property indicator_label1 &quot;ATR Gap&quot;<br>#property indicator_level1 0<br>input int ATRPeriod=14;<br>double Gap[];<br>int handle=INVALID_HANDLE;<br>int OnInit()<br>{<br>\u00a0\u00a0\u00a0if(ATRPeriod&lt;1) return INIT_PARAMETERS_INCORRECT;<br>\u00a0\u00a0\u00a0SetIndexBuffer(0,Gap,INDICATOR_DATA);<br>\u00a0\u00a0\u00a0ArraySetAsSeries(Gap,true);<br>\u00a0\u00a0\u00a0PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);<br>\u00a0\u00a0\u00a0handle=iATR(_Symbol,_Period,ATRPeriod);<br>\u00a0\u00a0\u00a0if(handle==INVALID_HANDLE) return INIT_FAILED;<br>\u00a0\u00a0\u00a0return INIT_SUCCEEDED;<br>}<br>void OnDeinit(const int reason)<br>{<br>\u00a0\u00a0\u00a0if(handle!=INVALID_HANDLE) IndicatorRelease(handle);<br>}<br>int OnCalculate(const int rates_total,const int prev_calculated,<br>\u00a0const datetime &amp;time[],const double &amp;open[],const double &amp;high[],<br>\u00a0const double &amp;low[],const double &amp;close[],const long &amp;tick_volume[],<br>\u00a0const long &amp;volume[],const int &amp;spread[])<br>{<br>\u00a0\u00a0\u00a0ArraySetAsSeries(open,true);<br>\u00a0\u00a0\u00a0ArraySetAsSeries(close,true);<br>\u00a0\u00a0\u00a0Gap[0]=EMPTY_VALUE;<br>\u00a0\u00a0\u00a0if(prev_calculated==0) ArrayInitialize(Gap,EMPTY_VALUE);<br>\u00a0\u00a0\u00a0if(rates_total&lt;ATRPeriod+3) return 0;<br>\u00a0\u00a0\u00a0if(BarsCalculated(handle)&lt;rates_total) return 0;<br>\u00a0\u00a0\u00a0int limit=rates_total-ATRPeriod-2;<br>\u00a0\u00a0\u00a0if(prev_calculated&gt;0 &amp;&amp; prev_calculated&lt;=rates_total)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0limit=MathMin(limit,rates_total-prev_calculated+1);<br>\u00a0\u00a0\u00a0double atr[];<br>\u00a0\u00a0\u00a0ArraySetAsSeries(atr,true);<br>\u00a0\u00a0\u00a0\/\/ Include the ATR of the bar preceding each measured bar.<br>\u00a0\u00a0\u00a0if(CopyBuffer(handle,0,0,limit+2,atr)!=limit+2) return 0;<br>\u00a0\u00a0\u00a0for(int i=limit;i&gt;=1;i--)<br>\u00a0\u00a0\u00a0{<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0double v=atr[i+1];<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Gap[i]=(v&gt;0 &amp;&amp; v!=EMPTY_VALUE)?<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0(open[i]-close[i+1])\/v:EMPTY_VALUE;<br>\u00a0\u00a0\u00a0}<br>\u00a0\u00a0\u00a0return rates_total;<br>}<\/code><\/pre>\n<h2>\u8ba1\u7b97\u751f\u547d\u5468\u671f<\/h2>\n<p>\u9996\u6b21\u8fd0\u884c\u65f6\u5904\u7406\u53ef\u7528\u5386\u53f2\u6570\u636e\uff0c\u5e76\u4fdd\u7559\u8f83\u4e3a\u4fdd\u5b88\u7684ATR\u9884\u70ed\u533a\u95f4\u3002\u540e\u7eed\u4ec5\u8ba1\u7b97\u65b0\u589eK\u7ebf\u53ca\u4e00\u6839\u91cd\u53e0K\u7ebf\u3002\u7ec8\u7aef\u8981\u6c42\u5b8c\u6574\u91cd\u7b97\u65f6\uff0c\u91cd\u65b0\u521d\u59cb\u5316\u7f13\u51b2\u533a\u3002CopyBuffer\u8bfb\u53d6\u8303\u56f4\u989d\u5916\u5305\u542b\u6700\u65e9\u5f85\u8ba1\u7b97K\u7ebf\u7684\u524d\u4e00\u6839ATR\u3002\u82e5\u5206\u6bcd\u7f3a\u5931\u6216\u4e3a\u96f6\uff0c\u5219\u8f93\u51fa\u7a7a\u503c\u800c\u975e\u5f02\u5e38\u6781\u7aef\u503c\u3002ATR\u5c1a\u672a\u51c6\u5907\u597d\u65f6\u8fd4\u56de\u96f6\uff0c\u4fbf\u4e8e\u540e\u7eed\u91cd\u65b0\u8ba1\u7b97\u3002<\/p>\n<h2>\u5b89\u88c5\u4e0e\u7814\u7a76\u65b9\u6cd5<\/h2>\n<p>\u4eceMT5\u6253\u5f00MetaEditor\uff0c\u65b0\u5efa\u540d\u4e3aATRNormalizedGap\u7684\u81ea\u5b9a\u4e49\u6307\u6807\uff0c\u66ff\u6362\u6a21\u677f\u5e76\u7f16\u8bd1\uff0c\u518d\u901a\u8fc7\u5bfc\u822a\u5668\u52a0\u8f7d\u5230\u56fe\u8868\u3002\u521d\u59cb\u53c2\u6570\u53ef\u8bbe\u4e3a14\u3002\u80a1\u7968\u65e5\u7ebf\u9002\u5408\u89c2\u5bdf\u9694\u591c\u8df3\u7a7a\uff0c\u65e5\u5185\u56fe\u8868\u5219\u53ef\u80fd\u53cd\u6620\u4ea4\u6613\u65f6\u6bb5\u5207\u6362\u6216\u6570\u636e\u4e0d\u8fde\u7eed\u3002\u672c\u7a0b\u5e8f\u8861\u91cf\u6240\u6709\u76f8\u90bbK\u7ebf\u4e4b\u95f4\u7684\u5f00\u76d8\u5dee\u503c\uff0c\u4e0d\u4f1a\u81ea\u52a8\u8bc6\u522b\u4ea4\u6613\u6240\u5f00\u76d8\u65f6\u95f4\u3002\u82e5\u4ec5\u7814\u7a76\u4ea4\u6613\u65f6\u6bb5\u5f00\u76d8\u7f3a\u53e3\uff0c\u9700\u8981\u53e6\u5916\u52a0\u5165\u4ea4\u6613\u65e5\u5386\u4e0e\u65f6\u6bb5\u5224\u65ad\u903b\u8f91\u3002<\/p>\n<h2>\u6d4b\u8bd5\u4e0e\u5c40\u9650\u6027<\/h2>\n<p>\u4f7f\u7528\u5185\u7f6eATR\u53ca\u6570\u636e\u7a97\u53e3\u624b\u5de5\u6838\u5bf9\u5386\u53f2\u6570\u503c\u3002\u5206\u522b\u68c0\u67e5\u6b63\u8d1f\u8df3\u7a7a\u3001\u5f00\u76d8\u7b49\u4e8e\u524d\u6536\u76d8\u3001\u5386\u53f2\u4e0d\u8db3\u3001\u5207\u6362\u5468\u671f\u53ca\u5237\u65b0\u5386\u53f2\u7b49\u60c5\u51b5\u3002\u6700\u8fd1\u5df2\u6536\u76d8\u7ed3\u679c\u5e94\u5728\u4e0b\u4e00\u6839K\u7ebf\u88ab\u8bc6\u522b\u540e\u51fa\u73b0\u3002\u7a0b\u5e8f\u4e0d\u5f15\u7528\u672a\u6765\u4ef7\u683c\uff0c\u4e0d\u4f1a\u4e3b\u52a8\u91cd\u7ed8\u5df2\u6536\u76d8\u7ed3\u679c\uff0c\u4f46\u5386\u53f2\u6570\u636e\u4fee\u8ba2\u4ecd\u53ef\u80fd\u6539\u53d8\u6570\u503c\u3002\u6536\u76d8\u786e\u8ba4\u673a\u5236\u76f8\u8f83\u4e8e\u5f00\u76d8\u5373\u65f6\u6d4b\u91cf\u5b58\u5728\u5ef6\u8fdf\u3002\u8fde\u7eed\u671f\u8d27\u6362\u6708\u8c03\u6574\u3001\u516c\u53f8\u884c\u4e3a\u53ca\u7ecf\u7eaa\u5546\u65f6\u6bb5\u5dee\u5f02\u53ef\u80fd\u4ea7\u751f\u4e0e\u666e\u901a\u4ea4\u6613\u65e0\u5173\u7684\u8868\u9762\u8df3\u7a7a\u3002ATR\u4e5f\u53ef\u80fd\u6ede\u540e\u4e8e\u7a81\u7136\u53d8\u5316\u7684\u6ce2\u52a8\u73af\u5883\u3002\u5f52\u4e00\u5316\u8df3\u7a7a\u4e0d\u80fd\u72ec\u7acb\u4f5c\u4e3a\u8fdb\u51fa\u573a\u4fe1\u53f7\u3002\u672c\u6e90\u7801\u5c1a\u672a\u5728MT5\u5b9e\u9645\u7f16\u8bd1\u6216\u8fd0\u884c\u6d4b\u8bd5\u3002<\/p>\n<p>\u5982\u9700\u4ea4\u6613\u65f6\u6bb5\u8fc7\u6ee4\u3001\u63d0\u9192\u529f\u80fd\u6216EA\u96c6\u6210\uff0c\u8bf7\u8054\u7cfb\u6211\u4eec\u7684<a href=\"https:\/\/www.patternsmart.com\/cn\/custom\/\">MT5\u6307\u6807\u5b9a\u5236\u5f00\u53d1\u670d\u52a1<\/a>\u3002<\/p>\n<p>\u98ce\u9669\u63d0\u793a\uff1a\u4ec5\u4f9b\u5b66\u4e60\u4ea4\u6d41\u3002\u4ea4\u6613\u5b58\u5728\u4e8f\u635f\u98ce\u9669\uff0c\u5047\u8bbe\u793a\u4f8b\u4e0d\u80fd\u8bc1\u660e\u76c8\u5229\u80fd\u529b\u3002<\/p>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u9ad8\u7ea7\u4ea4\u6613\u6559\u7a0b\u2014\u2014ATR\u5f52\u4e00\u5316\u5f00\u76d8\u8df3\u7a7a\u6307\u6807 \u540c\u6837\u662f\u4e24\u4e2a\u4ef7\u683c\u5355\u4f4d\u7684\u5f00\u76d8\u8df3\u7a7a\uff0c\u5728\u4f4e\u6ce2\u52a8\u5e02\u573a\u53ef\u80fd\u975e\u5e38\u663e\u8457\uff0c\u5728\u9ad8\u6ce2\u52a8\u5e02\u573a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2844,"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,233,217],"tags":[102,428,464],"class_list":["post-2843","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mt5","category-233","category-217","tag-atr","tag-mt5","tag-464"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/www.patternsmart.com\/cn\/wp-content\/uploads\/2026\/11\/atr-gap.png","_links":{"self":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/posts\/2843","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=2843"}],"version-history":[{"count":0,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/posts\/2843\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/media\/2844"}],"wp:attachment":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/media?parent=2843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/categories?post=2843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/tags?post=2843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}