{"id":2336,"date":"2026-11-19T01:01:57","date_gmt":"2026-11-19T07:01:57","guid":{"rendered":"https:\/\/www.patternsmart.com\/cn\/?p=2336"},"modified":"2026-11-19T07:02:31","modified_gmt":"2026-11-19T07:02:31","slug":"mt4-atr%e6%b3%a2%e5%8a%a8%e7%aa%81%e7%a0%b4%e6%8c%87%e6%a0%87%ef%bc%9a%e6%94%b6%e7%9b%98%e7%a1%ae%e8%ae%a4%e4%bf%a1%e5%8f%b7%e4%b8%8e%e5%ae%8c%e6%95%b4mql4%e6%ba%90%e7%a0%81","status":"publish","type":"post","link":"https:\/\/www.patternsmart.com\/cn\/mt4-atr%e6%b3%a2%e5%8a%a8%e7%aa%81%e7%a0%b4%e6%8c%87%e6%a0%87%ef%bc%9a%e6%94%b6%e7%9b%98%e7%a1%ae%e8%ae%a4%e4%bf%a1%e5%8f%b7%e4%b8%8e%e5%ae%8c%e6%95%b4mql4%e6%ba%90%e7%a0%81\/","title":{"rendered":"MT4 ATR\u6ce2\u52a8\u7a81\u7834\u6307\u6807\uff1a\u6536\u76d8\u786e\u8ba4\u4fe1\u53f7\u4e0e\u5b8c\u6574MQL4\u6e90\u7801"},"content":{"rendered":"<div class=\"postie-post\">\n<div>\n<h1>MT4 ATR\u6ce2\u52a8\u7a81\u7834\u6307\u6807\uff1a\u6536\u76d8\u786e\u8ba4\u4fe1\u53f7\u4e0e\u5b8c\u6574MQL4\u6e90\u7801<\/h1>\n<p>ATR\uff08\u5e73\u5747\u771f\u5b9e\u6ce2\u5e45\uff09\u8861\u91cf\u4ef7\u683c\u6ce2\u52a8\u5e45\u5ea6\uff0c\u5e76\u4e0d\u9884\u6d4b\u6da8\u8dcc\u65b9\u5411\u3002\u8fd9\u4e2a\u539f\u521bMT4\u6307\u6807\u4ee5\u4e0a\u4e00\u6839\u5df2\u6536\u76d8K\u7ebf\u4e3a\u57fa\u51c6\u7ed8\u5236\u6ce2\u52a8\u4e0a\u4e0b\u8f68\uff0c\u53ea\u6709\u540e\u4e00\u6839K\u7ebf\u771f\u6b63\u6536\u76d8\u7a81\u7834\u5bf9\u5e94\u9608\u503c\u65f6\u624d\u6807\u51fa\u7bad\u5934\u3002\u5b83\u7528\u4e8e\u5b66\u4e60\u6ce2\u52a8\u6269\u5f20\u4fe1\u53f7\uff0c\u5e76\u975e\u81ea\u52a8\u4ea4\u6613\u7cfb\u7edf\u3002<\/p>\n<h2>\u7cbe\u786e\u8ba1\u7b97\u89c4\u5219<\/h2>\n<p>\u5bf9\u4e8eK\u7ebfi\uff0c\u4e0a\u8f68\uff1dClose[i+1]\uff0b1.6\u00d7ATR(14)[i+1]\uff1b\u4e0b\u8f68\uff1dClose[i+1]\uff0d1.6\u00d7ATR(14)[i+1]\u3002\u771f\u5b9e\u6ce2\u5e45TR\u53d6\u6700\u9ad8\u4ef7\u51cf\u6700\u4f4e\u4ef7\u3001\u6700\u9ad8\u4ef7\u4e0e\u524d\u6536\u76d8\u4ef7\u5dee\u7684\u7edd\u5bf9\u503c\u3001\u6700\u4f4e\u4ef7\u4e0e\u524d\u6536\u76d8\u4ef7\u5dee\u7684\u7edd\u5bf9\u503c\u4e09\u8005\u4e2d\u7684\u6700\u5927\u503c\uff0cATR\u901a\u8fc7\u5e73\u53f0\u5185\u7f6eiATR\u5e73\u6ed1\u8ba1\u7b97\u3002\u82e5Close[i]\u9ad8\u4e8e\u4e0a\u8f68\uff0c\u51fa\u73b0\u770b\u6da8\u7bad\u5934\uff1b\u82e5\u4f4e\u4e8e\u4e0b\u8f68\uff0c\u51fa\u73b0\u770b\u8dcc\u7bad\u5934\u3002\u53ef\u9009\u7684\u5b9e\u4f53\u786e\u8ba4\u8981\u6c42\u76f8\u5e94\u7684\u9633\u7ebf\u6216\u9634\u7ebf\u3002\u57fa\u51c6\u6536\u76d8\u4ef7\u4e0eATR\u5747\u6765\u81ea\u524d\u4e00\u6839\u5df2\u7ecf\u5b8c\u6210\u7684K\u7ebf\uff0c\u56e0\u6b64\u65e0\u9700\u672a\u6765\u6570\u636e\u3002<\/p>\n<h2>\u6ce2\u52a8\u901a\u9053\u793a\u610f\u56fe<\/h2>\n<figure><img decoding=\"async\" alt=\"\u539f\u521b\u6559\u5b66\u56fe\uff1a\u6536\u76d8\u4ef7\u4e0eATR\u4e0a\u4e0b\u6ce2\u52a8\u9608\u503c\" src=\"https:\/\/www.patternsmart.com\/cn\/wp-content\/uploads\/2026\/11\/\u539f\u521b\u6559\u5b66\u56fe\uff1a\u6536\u76d8\u4ef7\u4e0eATR\u4e0a\u4e0b\u6ce2\u52a8\u9608\u503c.png\" style=\"width:100%;max-width:600px;height:auto\"><figcaption>\u793a\u610f\u56fe\uff1a\u6df1\u84dd\u7ebf\u4e3a\u6536\u76d8\u4ef7\uff0c\u7eff\u7ebf\u4e3aATR\u4e0a\u8f68\uff0c\u6a59\u7ebf\u4e3aATR\u4e0b\u8f68\uff1b\u4e0d\u4ee3\u8868\u771f\u5b9e\u5e02\u573a\u884c\u60c5\u3002<\/figcaption><\/figure>\n<h2>\u6570\u503c\u793a\u4f8b<\/h2>\n<p>\u5047\u8bbe\u4e0a\u4e00\u6839\u5df2\u6536\u76d8K\u7ebf\u6536\u4e8e1.1000\uff0cATR(14)\u4e3a0.0020\uff0c\u500d\u6570\u4e3a1.6\uff0c\u5219\u4e0a\u8f68\u4e3a1.1032\uff0c\u4e0b\u8f68\u4e3a1.0968\u3002\u4e0b\u4e00\u6839\u9633\u7ebf\u82e5\u6536\u4e8e1.1036\uff0c\u6536\u76d8\u540e\u624d\u51fa\u73b0\u7eff\u8272\u7bad\u5934\u3002\u5982\u679c\u76d8\u4e2d\u4e0a\u51b2\u81f31.1032\u4ee5\u4e0a\u3001\u6700\u7ec8\u6536\u4e8e1.1029\uff0c\u5219\u4e0d\u7b97\u7a81\u7834\u3002\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u628a\u76d8\u4e2d\u7684\u77ed\u6682\u51b2\u9ad8\u8bef\u5224\u4e3a\u5df2\u786e\u8ba4\u4fe1\u53f7\u3002<\/p>\n<h2>\u5b8c\u6574MT4\u81ea\u5b9a\u4e49\u6307\u6807\u6e90\u7801<\/h2>\n<p>\u5c06\u4ee3\u7801\u4fdd\u5b58\u4e3a<code>MT4_ATR_Band_Breakout.mq4<\/code>\uff0c\u653e\u5165<code>MQL4\/Indicators<\/code>\u3002\u56db\u4e2a\u7f13\u51b2\u533a\u5206\u522b\u4fdd\u5b58\u4e0a\u8f68\u3001\u4e0b\u8f68\u3001\u770b\u6da8\u7bad\u5934\u548c\u770b\u8dcc\u7bad\u5934\uff1b\u7bad\u5934\u4e0d\u662fEA\u4ea4\u6613\u6307\u4ee4\u3002<\/p>\n<pre style=\"white-space:pre-wrap;background:#f1f5f9;padding:16px\"><code>#property strict&#013; #property indicator_chart_window&#013; #property indicator_buffers 4&#013; #property indicator_color1 clrDodgerBlue&#013; #property indicator_color2 clrOrange&#013; #property indicator_color3 clrLimeGreen&#013; #property indicator_color4 clrTomato&#013; &#013; input int ATRPeriod = 14;&#013; input double ATRMultiplier = 1.6;&#013; input int MaxBarsToCalculate = 1500; \/\/ 0 = all eligible history&#013; input bool RequireBodyConfirmation = true;&#013; &#013; double UpperBand[], LowerBand[], BuyArrow[], SellArrow[];&#013; &#013; int OnInit()&#013; {&#013;    if(ATRPeriod &lt; 1 || ATRMultiplier &lt;= 0 || MaxBarsToCalculate &lt; 0)&#013;       return(INIT_PARAMETERS_INCORRECT);&#013;    SetIndexBuffer(0, UpperBand);&#013;    SetIndexBuffer(1, LowerBand);&#013;    SetIndexBuffer(2, BuyArrow);&#013;    SetIndexBuffer(3, SellArrow);&#013;    ArraySetAsSeries(UpperBand, true);&#013;    ArraySetAsSeries(LowerBand, true);&#013;    ArraySetAsSeries(BuyArrow, true);&#013;    ArraySetAsSeries(SellArrow, true);&#013;    SetIndexStyle(0, DRAW_LINE, STYLE_DASH, 1, clrDodgerBlue);&#013;    SetIndexStyle(1, DRAW_LINE, STYLE_DASH, 1, clrOrange);&#013;    SetIndexStyle(2, DRAW_ARROW, STYLE_SOLID, 1, clrLimeGreen);&#013;    SetIndexStyle(3, DRAW_ARROW, STYLE_SOLID, 1, clrTomato);&#013;    SetIndexArrow(2, 233);&#013;    SetIndexArrow(3, 234);&#013;    for(int j=0; j&lt;4; j++) SetIndexEmptyValue(j, EMPTY_VALUE);&#013;    SetIndexLabel(0, \"Previous close + ATR multiple\");&#013;    SetIndexLabel(1, \"Previous close - ATR multiple\");&#013;    SetIndexLabel(2, \"Confirmed bullish breakout\");&#013;    SetIndexLabel(3, \"Confirmed bearish breakout\");&#013;    IndicatorShortName(\"Confirmed ATR Breakout\");&#013;    return(INIT_SUCCEEDED);&#013; }&#013; &#013; int OnCalculate(const int rates_total, const int prev_calculated,&#013;                 const datetime &amp;time[], const double &amp;open[],&#013;                 const double &amp;high[], const double &amp;low[],&#013;                 const double &amp;close[], const long &amp;tick_volume[],&#013;                 const long &amp;volume[], const int &amp;spread[])&#013; {&#013;    if(rates_total &lt; ATRPeriod + 4) return(0);&#013;    ArraySetAsSeries(open, true);&#013;    ArraySetAsSeries(high, true);&#013;    ArraySetAsSeries(low, true);&#013;    ArraySetAsSeries(close, true);&#013;    \/\/ Never plot on the unfinished candle.&#013;    UpperBand[0] = LowerBand[0] = EMPTY_VALUE;&#013;    BuyArrow[0] = SellArrow[0] = EMPTY_VALUE;&#013;    int oldest = rates_total - ATRPeriod - 2;&#013;    if(MaxBarsToCalculate &gt; 0) oldest = MathMin(oldest, MaxBarsToCalculate);&#013;    for(int i=oldest; i&gt;=1; i--)&#013;    {&#013;       UpperBand[i] = LowerBand[i] = EMPTY_VALUE;&#013;       BuyArrow[i] = SellArrow[i] = EMPTY_VALUE;&#013;       \/\/ The threshold uses ONLY the previous closed candle.&#013;       double a = iATR(NULL, 0, ATRPeriod, i+1);&#013;       if(a &lt;= 0) continue;&#013;       double top = close[i+1] + ATRMultiplier*a;&#013;       double bottom = close[i+1] - ATRMultiplier*a;&#013;       UpperBand[i] = top;&#013;       LowerBand[i] = bottom;&#013;       bool bullish = close[i] &gt; top &amp;&amp;&#013;             (!RequireBodyConfirmation || close[i] &gt; open[i]);&#013;       bool bearish = close[i] &lt; bottom &amp;&amp;&#013;             (!RequireBodyConfirmation || close[i] &lt; open[i]);&#013;       if(bullish) BuyArrow[i] = low[i] - 0.2*a;&#013;       if(bearish) SellArrow[i] = high[i] + 0.2*a;&#013;    }&#013;    return(rates_total);&#013; }<\/code><\/pre>\n<h2>\u53c2\u6570\u4e0e\u8c03\u8282<\/h2>\n<table border=\"1\" cellpadding=\"6\">\n<tr>\n<th>\u53c2\u6570<\/th>\n<th>\u9ed8\u8ba4\u503c<\/th>\n<th>\u542b\u4e49<\/th>\n<\/tr>\n<tr>\n<td>ATRPeriod<\/td>\n<td>14<\/td>\n<td>ATR\u8ba1\u7b97\u5468\u671f<\/td>\n<\/tr>\n<tr>\n<td>ATRMultiplier<\/td>\n<td>1.6<\/td>\n<td>\u8ddd\u79bb\u524d\u6536\u76d8\u4ef7\u7684ATR\u500d\u6570<\/td>\n<\/tr>\n<tr>\n<td>MaxBarsToCalculate<\/td>\n<td>1500<\/td>\n<td>\u5386\u53f2\u8ba1\u7b97\u4e0a\u9650\uff1b0\u8868\u793a\u6240\u6709\u7b26\u5408\u6761\u4ef6\u7684K\u7ebf<\/td>\n<\/tr>\n<tr>\n<td>RequireBodyConfirmation<\/td>\n<td>true<\/td>\n<td>\u8981\u6c42K\u7ebf\u5b9e\u4f53\u65b9\u5411\u4e0e\u7a81\u7834\u65b9\u5411\u4e00\u81f4<\/td>\n<\/tr>\n<\/table>\n<p>\u500d\u6570\u8d8a\u5c0f\u901a\u5e38\u4fe1\u53f7\u8d8a\u591a\uff0c\u4f46\u566a\u58f0\u4e5f\u53ef\u80fd\u589e\u52a0\uff1bATR\u5468\u671f\u8d8a\u957f\uff0c\u6ce2\u52a8\u4f30\u8ba1\u8d8a\u5e73\u6ed1\uff0c\u4f46\u53cd\u5e94\u66f4\u6162\u3002\u9ed8\u8ba4\u503c\u4ec5\u7528\u4e8e\u6559\u5b66\uff0c\u5e76\u975e\u4f18\u5316\u7ed3\u679c\u3002<\/p>\n<h2>\u5b89\u88c5\u4e0e\u9a8c\u8bc1\u6b65\u9aa4<\/h2>\n<ol>\n<li>\u5728MT4\u9009\u62e9File \u2192 Open Data Folder \u2192 MQL4 \u2192 Indicators\u3002<\/li>\n<li>\u4fdd\u5b58\u6e90\u7801\uff0c\u7528MetaEditor\u7f16\u8bd1\u5e76\u68c0\u67e5\u8b66\u544a\u3002<\/li>\n<li>\u5237\u65b0Navigator\uff0c\u52a0\u8f7d\u5230\u5386\u53f2\u6570\u636e\u5145\u8db3\u7684\u56fe\u8868\uff0c\u5e76\u68c0\u67e5\u53c2\u6570\u3002<\/li>\n<li>\u786e\u8ba4\u6b63\u5728\u5f62\u6210\u7684\u7d22\u5f150 K\u7ebf\u4e0d\u7ed8\u5236\u7bad\u5934\u6216\u4e0a\u4e0b\u8f68\uff1b\u6307\u6807\u53ea\u663e\u793a\u5df2\u6536\u76d8K\u7ebf\u3002<\/li>\n<li>\u5728\u4e0d\u540c\u54c1\u79cd\u3001\u5468\u671f\u3001\u5386\u53f2\u7f3a\u53e3\u548c\u7ecf\u7eaa\u5546\u6570\u636e\u4e0a\u6d4b\u8bd5\uff0c\u7ed3\u5408\u524d\u5411\u8bb0\u5f55\u6838\u5bf9\u5386\u53f2\u4fe1\u53f7\u3002<\/li>\n<\/ol>\n<h2>\u5c40\u9650\u4e0e\u98ce\u9669<\/h2>\n<p>\u6ce2\u52a8\u7a81\u7834\u4e0d\u4ee3\u8868\u8d8b\u52bf\u4e00\u5b9a\u5ef6\u7eed\uff0c\u66f4\u4e0d\u4fdd\u8bc1\u4ea4\u6613\u76c8\u5229\u3002\u9707\u8361\u884c\u60c5\u3001\u6d88\u606f\u51b2\u51fb\u4e0e\u8df3\u7a7a\u90fd\u53ef\u80fd\u4ea7\u751f\u5047\u4fe1\u53f7\u3002\u6307\u6807\u4e0d\u4e0b\u5355\u3001\u4e0d\u8bbe\u7f6e\u6b62\u635f\u3001\u4e0d\u8ba1\u7b97\u4ed3\u4f4d\uff0c\u4e5f\u672a\u8ba1\u5165\u70b9\u5dee\u3001\u624b\u7eed\u8d39\u548c\u6ed1\u70b9\u3002\u7ecf\u7eaa\u5546\u4fee\u6b63\u5386\u53f2\u6570\u636e\u540e\uff0c\u5386\u53f2\u56fe\u5f62\u53ef\u80fd\u6539\u53d8\uff0c\u4f46\u4ee3\u7801\u5e76\u672a\u4e3b\u52a8\u5f15\u7528\u672a\u6765K\u7ebf\u3002\u8003\u8651\u4ea4\u6613\u524d\u4ecd\u5e94\u68c0\u67e5\u652f\u6491\u963b\u529b\u53ca\u771f\u5b9e\u76c8\u4e8f\u6bd4\u3002<\/p>\n<p>\u5982\u9700EA\u96c6\u6210\u3001\u6b63\u5f0f\u73af\u5883\u63d0\u9192\u6216\u81ea\u5b9a\u4e49\u6307\u6807\u7f13\u51b2\u533a\uff0c\u53ef\u4e86\u89e3<a href=\"https:\/\/www.patternsmart.com\/cn\/custom\/\">\u4ea4\u6613\u8f6f\u4ef6\u5b9a\u5236\u5f00\u53d1\u670d\u52a1<\/a>\u3002<\/p>\n<p><strong>\u98ce\u9669\u58f0\u660e\uff1a<\/strong>\u672c\u6587\u4ec5\u4f9b\u6280\u672f\u6559\u80b2\uff0c\u4e0d\u6784\u6210\u6295\u8d44\u5efa\u8bae\u6216\u6536\u76ca\u627f\u8bfa\u3002\u4ee3\u7801\u7ed3\u6784\u5df2\u53c2\u7167\u5b98\u65b9MQL4\u6587\u6863\u6838\u5bf9\uff0c\u4f46\u5c1a\u672a\u5728\u5b9e\u9645\u7ec8\u7aef\u4e2d\u7f16\u8bd1\u6216\u56de\u6d4b\u3002<\/p>\n<\/p><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>MT4 ATR\u6ce2\u52a8\u7a81\u7834\u6307\u6807\uff1a\u6536\u76d8\u786e\u8ba4\u4fe1\u53f7\u4e0e\u5b8c\u6574MQL4\u6e90\u7801 ATR\uff08\u5e73\u5747\u771f\u5b9e\u6ce2\u5e45\uff09\u8861\u91cf\u4ef7\u683c\u6ce2\u52a8\u5e45\u5ea6\uff0c\u5e76\u4e0d\u9884\u6d4b\u6da8 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2337,"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":[167,233,217],"tags":[102,426,425,427],"class_list":["post-2336","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mt4","category-233","category-217","tag-atr","tag-mql4","tag-mt4","tag-427"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/www.patternsmart.com\/cn\/wp-content\/uploads\/2026\/11\/\u539f\u521b\u6559\u5b66\u56fe\uff1a\u6536\u76d8\u4ef7\u4e0eATR\u4e0a\u4e0b\u6ce2\u52a8\u9608\u503c.png","_links":{"self":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/posts\/2336","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=2336"}],"version-history":[{"count":0,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/posts\/2336\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/media\/2337"}],"wp:attachment":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/media?parent=2336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/categories?post=2336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/tags?post=2336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}