{"id":2680,"date":"2026-11-25T11:21:45","date_gmt":"2026-11-25T17:21:45","guid":{"rendered":"https:\/\/www.patternsmart.com\/cn\/?p=2680"},"modified":"2026-11-25T17:47:13","modified_gmt":"2026-11-25T17:47:13","slug":"ninjascript-%e5%a6%82%e4%bd%95%e5%9c%a8%e6%8f%90%e4%ba%a4-stopmarket-%e5%85%a5%e5%9c%ba%e8%ae%a2%e5%8d%95%e5%89%8d%e6%a3%80%e6%9f%a5%e8%a7%a6%e5%8f%91%e4%bb%b7%e6%a0%bc","status":"publish","type":"post","link":"https:\/\/www.patternsmart.com\/cn\/ninjascript-%e5%a6%82%e4%bd%95%e5%9c%a8%e6%8f%90%e4%ba%a4-stopmarket-%e5%85%a5%e5%9c%ba%e8%ae%a2%e5%8d%95%e5%89%8d%e6%a3%80%e6%9f%a5%e8%a7%a6%e5%8f%91%e4%bb%b7%e6%a0%bc\/","title":{"rendered":"NinjaScript \u5982\u4f55\u5728\u63d0\u4ea4 StopMarket \u5165\u573a\u8ba2\u5355\u524d\u68c0\u67e5\u89e6\u53d1\u4ef7\u683c"},"content":{"rendered":"<div class=\"postie-post\">\n<article style=\"font-family:Arial,sans-serif;color:#182c48;line-height:1.65\">\n<p>\u7a81\u7834\u7b56\u7565\u5728 K \u7ebf\u6536\u76d8\u65f6\u8ba1\u7b97\u51fa\u7684\u6b62\u635f\u5e02\u4ef7\u5165\u573a\u4ef7\u4f4d\u53ef\u80fd\u5b8c\u5168\u5408\u7406\uff0c\u4f46\u771f\u6b63\u63d0\u4ea4\u8ba2\u5355\u4e4b\u524d\uff0c\u884c\u60c5\u5df2\u7ecf\u8d8a\u8fc7\u8be5\u4ef7\u4f4d\u3002\u5728 NinjaTrader 8 \u4e2d\uff0cStopMarket \u5165\u573a\u8ba2\u5355\u5e76\u4e0d\u662f\u53ef\u4ee5\u5728\u4efb\u610f\u4ef7\u683c\u63d0\u4ea4\u7684\u5e02\u4ef7\u5355\uff0c\u5176\u6b62\u635f\u89e6\u53d1\u4ef7\u5fc5\u987b\u7b26\u5408\u4ea4\u6613\u8fde\u63a5\u6216\u4ea4\u6613\u573a\u6240\u7684\u63d0\u4ea4\u53ca\u4fee\u6539\u89c4\u5219\u3002\u4e0b\u5355\u524d\u589e\u52a0\u4ef7\u683c\u6709\u6548\u6027\u68c0\u67e5\uff0c\u53ef\u4ee5\u51cf\u5c11\u90e8\u5206\u53ef\u907f\u514d\u7684\u62d2\u5355\uff0c\u540c\u65f6\u4e0d\u968f\u610f\u6539\u53d8\u7b56\u7565\u7684\u5165\u573a\u903b\u8f91\u3002<\/p>\n<h2>\u5c06\u4ea4\u6613\u4fe1\u53f7\u4e0e\u4e0b\u5355\u6709\u6548\u6027\u5206\u5f00<\/h2>\n<p>\u5148\u4fdd\u5b58\u7a81\u7834\u4fe1\u53f7\u5bf9\u5e94\u7684\u89e6\u53d1\u4ef7\uff0c\u5e76\u6309\u54c1\u79cd\u6700\u5c0f\u53d8\u52a8\u5355\u4f4d\u53d6\u6574\uff0c\u518d\u5728\u5b9e\u9645\u63d0\u4ea4\u65b0\u8ba2\u5355\u4e4b\u524d\u8bfb\u53d6\u5f53\u524d\u62a5\u4ef7\u3002\u5bf9\u4e8e\u4fdd\u5b88\u7684\u4e70\u5165\u6b62\u635f\u5355\u68c0\u67e5\u89c4\u5219\uff0c\u53ef\u8981\u6c42\u89e6\u53d1\u4ef7\u81f3\u5c11\u9ad8\u4e8e Ask \u4e00\u4e2a tick\uff1b\u5356\u51fa\u6b62\u635f\u5165\u573a\u5219\u81f3\u5c11\u4f4e\u4e8e Bid \u4e00\u4e2a tick\u3002\u8fd9\u91cc\u662f\u7b56\u7565\u81ea\u8eab\u7684\u4fdd\u62a4\u6761\u4ef6\uff0c\u800c\u975e\u6240\u6709\u4ea4\u6613\u6240\u7684\u7edf\u4e00\u89c4\u5219\u3002\u4ea4\u6613\u573a\u6240\u53ef\u80fd\u4f7f\u7528\u5176\u4ed6\u89e6\u53d1\u53c2\u8003\u4ef7\u3001\u4ef7\u683c\u9650\u5236\u6216\u6700\u5c0f\u8ddd\u79bb\uff0c\u800c\u4e14\u8ba2\u5355\u4f20\u8f93\u671f\u95f4\u62a5\u4ef7\u4ecd\u53ef\u80fd\u53d8\u5316\u3002<\/p>\n<figure><img decoding=\"async\" src=\"https:\/\/www.patternsmart.com\/cn\/wp-content\/uploads\/2026\/11\/PS_NT8_StopPreflight_CN_Fig1.png\" alt=\"PS_NT8_StopPreflight_CN_Fig1.png\" title=\"\u56fe1\uff1a\u5047\u8bbe\u671f\u8d27\u62a5\u4ef7\u4e0b\uff0c\u540c\u4e00\u4e2a\u4e70\u5165\u6b62\u635f\u4ef7\u5728\u4e0d\u540c\u65f6\u95f4\u53ef\u80fd\u901a\u8fc7\u672c\u5730\u68c0\u67e5\uff0c\u4e5f\u53ef\u80fd\u56e0\u884c\u60c5\u8d8a\u8fc7\u800c\u5931\u6548\u3002\" style=\"width:100%;height:auto;max-width:1080px\"><figcaption>\u56fe1\uff1a\u5047\u8bbe\u671f\u8d27\u62a5\u4ef7\u4e0b\uff0c\u540c\u4e00\u4e2a\u4e70\u5165\u6b62\u635f\u4ef7\u5728\u4e0d\u540c\u65f6\u95f4\u53ef\u80fd\u901a\u8fc7\u672c\u5730\u68c0\u67e5\uff0c\u4e5f\u53ef\u80fd\u56e0\u884c\u60c5\u8d8a\u8fc7\u800c\u5931\u6548\u3002<\/figcaption><\/figure>\n<h2>\u8ba1\u7b97\u793a\u4f8b\uff1a\u7a81\u7834\u5df2\u7ecf\u53d1\u751f<\/h2>\n<p>\u5047\u8bbe\u6700\u5c0f\u53d8\u52a8\u5355\u4f4d\u4e3a 0.25\uff0c\u8ba1\u5212\u4e70\u5165\u6b62\u635f\u4ef7\u4e3a 6000.25\u3002\u5f53 Bid \u4e3a 5999.75\u3001Ask \u4e3a 6000.00 \u65f6\uff0c\u89e6\u53d1\u4ef7\u6bd4 Ask \u9ad8\u4e00\u4e2a tick\uff0c\u672c\u5730\u68c0\u67e5\u5141\u8bb8\u63d0\u4ea4\u3002\u5982\u679c\u4e0b\u5355\u524d Bid \u4e0a\u5347\u81f3 6000.25\u3001Ask \u4e0a\u5347\u81f3 6000.50\uff0c\u539f\u89e6\u53d1\u4ef7\u5df2\u4f4e\u4e8e Ask\uff0c\u6b64\u89c4\u5219\u5e94\u8df3\u8fc7\u5931\u6548\u5165\u573a\u4fe1\u53f7\u3002\u81ea\u52a8\u5c06\u89e6\u53d1\u4ef7\u4e0a\u79fb\u81f3 6000.75\uff0c\u6216\u8005\u6539\u4e3a\u5e02\u4ef7\u5165\u573a\uff0c\u90fd\u6539\u53d8\u4e86\u539f\u7b56\u7565\uff0c\u9700\u8981\u5355\u72ec\u8bc4\u4f30\u3002<\/p>\n<h2>NinjaScript \u4e0b\u5355\u524d\u68c0\u67e5\u793a\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u4e3a\u8bf4\u660e\u6027\u4ee3\u7801\u7247\u6bb5\uff0c\u5e76\u975e\u5b8c\u6574\u53ef\u6267\u884c\u7b56\u7565\u3002\u5e94\u653e\u5728\u4e3b\u6570\u636e\u5e8f\u5217 OnBarUpdate() \u7684\u5165\u573a\u5206\u652f\u4e2d\uff0c\u5e76\u5148\u5224\u65ad\u4fe1\u53f7\u65f6\u6548\u3001\u884c\u60c5\u6570\u636e\u662f\u5426\u5c31\u7eea\u3001\u6301\u4ed3\u53ca\u5de5\u4f5c\u8ba2\u5355\u72b6\u6001\u3002\u56fa\u5b9a\u4ef7\u683c\u4ec5\u7528\u4e8e\u4e0a\u8ff0\u793a\u4f8b\uff0c\u5b9e\u9645\u7b56\u7565\u5e94\u4f20\u5165\u8ba1\u7b97\u51fa\u7684\u89e6\u53d1\u4ef7\u3002\u6b64\u5904\u672a\u8fdb\u884c\u7f16\u8bd1\u6216\u5b9e\u76d8\u6d4b\u8bd5\u3002\u4ee3\u7801\u660e\u786e\u9650\u5b9a\u5b9e\u65f6\u5206\u652f\uff0c\u56e0\u4e3a\u5386\u53f2\u62a5\u4ef7\u51fd\u6570\u53ef\u80fd\u8fd4\u56de\u66ff\u4ee3\u7684 K \u7ebf\u4ef7\u683c\uff0c\u4e0d\u80fd\u5c06\u5176\u5f53\u6210\u771f\u5b9e\u5386\u53f2\u4e70\u5356\u62a5\u4ef7\u3002<\/p>\n<pre style=\"background:#f5f7fa;padding:16px;white-space:pre;font-family:Consolas,Monaco,monospace\"><code>\/\/ Illustrative excerpt inside OnBarUpdate(), primary series.<br>\/\/ Call only for a fresh signal with no working entry order.<br>if (State != State.Realtime || BarsInProgress != 0)<br>\u00a0\u00a0\u00a0\u00a0return;<br><br>double stop = Instrument.MasterInstrument.RoundToTickSize(6000.25);<br>double ask = GetCurrentAsk();<br>double bid = GetCurrentBid();<br><br>if (ask &lt;= 0 || bid &lt;= 0 || ask &lt; bid)<br>\u00a0\u00a0\u00a0\u00a0return;<br><br>if (stop &gt;= ask + TickSize)<br>\u00a0\u00a0\u00a0\u00a0EnterLongStopMarket(1, stop, \"BreakoutLong\");<br>else<br>\u00a0\u00a0\u00a0\u00a0Print(\"Skipped stale buy stop: \" + stop + \" ask: \" + ask);<\/code><\/pre>\n<p>\u7a7a\u5934\u5165\u573a\u9700\u8981\u91c7\u7528\u955c\u50cf\u6bd4\u8f83\u6761\u4ef6\u548c EnterShortStopMarket\u3002\u5e94\u62d2\u7edd\u65e0\u6548\u6216\u8fc7\u671f\u62a5\u4ef7\uff0c\u5728\u6570\u636e\u5141\u8bb8\u65f6\u68c0\u67e5\u62a5\u4ef7\u65f6\u6548\uff1b\u591a\u6570\u636e\u5e8f\u5217\u7b56\u7565\u8fd8\u9700\u786e\u4fdd\u4f7f\u7528\u6b63\u786e\u54c1\u79cd\u3002\u8be5\u7247\u6bb5\u4e0d\u662f\u5b8c\u6574\u8ba2\u5355\u751f\u547d\u5468\u671f\u7ba1\u7406\u5668\uff1a\u63d0\u4ea4\u6210\u529f\u540e\u4ecd\u9700\u8981\u8ffd\u8e2a\u8ba2\u5355\uff0c\u907f\u514d\u6bcf\u6839 K \u7ebf\u53cd\u590d\u63d0\u4ea4\u3002<\/p>\n<h2>\u4e0b\u5355\u4e4b\u540e\u5982\u4f55\u5904\u7406\u62d2\u5355<\/h2>\n<p>\u6309\u4fe1\u53f7\u6807\u8bc6\u8ffd\u8e2a\u8ba2\u5355\u66f4\u65b0\uff0c\u8bb0\u5f55\u63d0\u4ea4\u4ef7\u3001\u62a5\u4ef7\u5feb\u7167\u3001\u65f6\u95f4\u3001\u8ba2\u5355\u72b6\u6001\u3001\u9519\u8bef\u7801\u53ca\u539f\u751f\u9519\u8bef\u4fe1\u606f\u3002OnOrderUpdate() \u53ef\u62a5\u544a\u62d2\u5355\u7b49\u72b6\u6001\u53d8\u5316\uff1b\u9700\u8981\u7531\u6210\u4ea4\u9a71\u52a8\u7684\u64cd\u4f5c\u5e94\u4f7f\u7528 OnExecutionUpdate()\u3002\u6536\u5230\u62d2\u5355\u65f6\uff0c\u5148\u6838\u5bf9\u5de5\u4f5c\u8ba2\u5355\u53ca\u6210\u4ea4\uff0c\u518d\u51b3\u5b9a\u80fd\u5426\u91cd\u65b0\u5c1d\u8bd5\u3002\u9664\u975e\u5df2\u8bbe\u8ba1\u5e76\u5145\u5206\u6d4b\u8bd5\u72ec\u7acb\u6062\u590d\u673a\u5236\uff0c\u5426\u5219\u5e94\u4fdd\u7559\u9ed8\u8ba4\u7684 RealtimeErrorHandling \u4fdd\u62a4\u884c\u4e3a\u3002\u4e0d\u8981\u4ec5\u4e3a\u4e86\u9690\u85cf\u62a5\u9519\u5f39\u7a97\u800c\u8bbe\u7f6e IgnoreAllErrors\u3002<\/p>\n<h2>\u6d4b\u8bd5\u4e0e\u4e0a\u7ebf\u6838\u5bf9<\/h2>\n<ul>\n<li>\u5728 Playback \u6216\u6a21\u62df\u73af\u5883\u4e2d\u5206\u522b\u91cd\u653e\u4f4e\u4e8e\u3001\u7b49\u4e8e\u548c\u9ad8\u4e8e\u9884\u5b9a\u89e6\u53d1\u4ef7\u4e00\u4e2a tick \u7684\u62a5\u4ef7\uff0c\u786e\u8ba4\u672c\u5730\u5224\u65ad\u7ed3\u679c\u3002<\/li>\n<li>\u6d4b\u8bd5\u68c0\u67e5\u4e0e\u4e0b\u5355\u4e4b\u95f4\u62a5\u4ef7\u5feb\u901f\u53d8\u5316\u7684\u60c5\u51b5\uff0c\u5305\u62ec\u62d2\u5355\u3002<\/li>\n<li>\u786e\u8ba4\u91cd\u590d\u4fe1\u53f7\u4e0d\u4f1a\u4ea7\u751f\u91cd\u590d\u5de5\u4f5c\u8ba2\u5355\uff0c\u64a4\u5355\u6216\u62d2\u5355\u4e0d\u4f1a\u5f15\u8d77\u5931\u63a7\u91cd\u8bd5\u3002<\/li>\n<li>\u5206\u522b\u6bd4\u8f83\u5386\u53f2\u548c\u5b9e\u65f6\u6a21\u62df\u7ed3\u679c\uff1b\u4ec5\u51ed\u6536\u76d8\u6570\u636e\u65e0\u6cd5\u8fd8\u539f\u5b9e\u65f6\u62a5\u4ef7\u53ca\u7f51\u7edc\u5ef6\u8fdf\u3002<\/li>\n<li>\u4e0a\u7ebf\u524d\u6838\u5b9e\u7ecf\u7eaa\u5546\u5177\u4f53\u6b62\u635f\u8ba2\u5355\u89c4\u5219\u53ca\u5e94\u6025\u6d41\u7a0b\u3002<\/li>\n<\/ul>\n<p>\u6b62\u635f\u5e02\u4ef7\u8ba2\u5355\u5e76\u4e0d\u4fdd\u8bc1\u4ee5\u89e6\u53d1\u4ef7\u6210\u4ea4\u3002\u8df3\u7a7a\u3001\u5ef6\u8fdf\u3001\u70b9\u5dee\u3001\u8d39\u7528\u548c\u6ed1\u70b9\u5747\u53ef\u80fd\u6269\u5927\u635f\u5931\u3002\u672c\u6587\u4ec5\u7528\u4e8e\u7b56\u7565\u5f00\u53d1\u6559\u80b2\uff0c\u4e0d\u4ee3\u8868\u76c8\u5229\u627f\u8bfa\u3002<\/p>\n<p>\u5b98\u65b9 NinjaScript \u6587\u6863\uff1a<a href=\"https:\/\/static.ninjatrader.com\/support\/helpGuides\/nt8\/getcurrentask.htm\">GetCurrentAsk()<\/a> \u00b7 <a href=\"https:\/\/static.ninjatrader.com\/support\/helpGuides\/nt8\/onorderupdate.htm\">OnOrderUpdate()<\/a> \u00b7 <a href=\"https:\/\/static.ninjatrader.com\/support\/helpGuides\/nt8\/realtimeerrorhandling.htm\">RealtimeErrorHandling<\/a>\u3002<\/p>\n<p>\u5982\u679c\u60a8\u9700\u8981\u5b9a\u5236\u5165\u573a\u4ef7\u683c\u68c0\u67e5\u3001\u8ba2\u5355\u751f\u547d\u5468\u671f\u8bca\u65ad\u6216\u9002\u914d\u7279\u5b9a\u7ecf\u7eaa\u5546\u7684\u6062\u590d\u673a\u5236\uff0c\u6b22\u8fce\u4e86\u89e3\u6211\u4eec\u7684<a href=\"https:\/\/www.patternsmart.com\/cn\/custom\/\">\u4ea4\u6613\u8f6f\u4ef6\u5b9a\u5236\u5f00\u53d1\u670d\u52a1<\/a>\u3002<\/p>\n<\/p>\n<\/article>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7a81\u7834\u7b56\u7565\u5728 K \u7ebf\u6536\u76d8\u65f6\u8ba1\u7b97\u51fa\u7684\u6b62\u635f\u5e02\u4ef7\u5165\u573a\u4ef7\u4f4d\u53ef\u80fd\u5b8c\u5168\u5408\u7406\uff0c\u4f46\u771f\u6b63\u63d0\u4ea4\u8ba2\u5355\u4e4b\u524d\uff0c\u884c\u60c5\u5df2\u7ecf\u8d8a\u8fc7\u8be5\u4ef7\u4f4d\u3002\u5728 Ni [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2681,"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":[89,520],"tags":[174,607,609,610,608,342],"class_list":["post-2680","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ninjatrader","category-520","tag-ninjascript","tag-stopmarket","tag-609","tag-610","tag-608","tag-342"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/www.patternsmart.com\/cn\/wp-content\/uploads\/2026\/11\/PS_NT8_StopPreflight_CN_Fig1.png","_links":{"self":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/posts\/2680","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=2680"}],"version-history":[{"count":0,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/posts\/2680\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/media\/2681"}],"wp:attachment":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/media?parent=2680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/categories?post=2680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/tags?post=2680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}