{"id":2801,"date":"2026-11-27T16:44:18","date_gmt":"2026-11-27T22:44:18","guid":{"rendered":"https:\/\/www.patternsmart.com\/cn\/?p=2801"},"modified":"2026-11-27T22:47:08","modified_gmt":"2026-11-27T22:47:08","slug":"thinkscript-%e5%a6%82%e4%bd%95%e5%9c%a8%e7%ad%96%e7%95%a5%e6%a8%a1%e6%8b%9f%e4%b8%ad%e8%ae%be%e7%bd%ae%e6%ad%a2%e6%8d%9f%e5%90%8e%e5%86%8d%e5%85%a5%e5%9c%ba%e5%86%b7%e5%8d%b4%e6%9c%9f","status":"publish","type":"post","link":"https:\/\/www.patternsmart.com\/cn\/thinkscript-%e5%a6%82%e4%bd%95%e5%9c%a8%e7%ad%96%e7%95%a5%e6%a8%a1%e6%8b%9f%e4%b8%ad%e8%ae%be%e7%bd%ae%e6%ad%a2%e6%8d%9f%e5%90%8e%e5%86%8d%e5%85%a5%e5%9c%ba%e5%86%b7%e5%8d%b4%e6%9c%9f\/","title":{"rendered":"thinkScript \u5982\u4f55\u5728\u7b56\u7565\u6a21\u62df\u4e2d\u8bbe\u7f6e\u6b62\u635f\u540e\u518d\u5165\u573a\u51b7\u5374\u671f"},"content":{"rendered":"<div class=\"postie-post\">\n<p>\u9707\u8361\u5e02\u573a\u4e2d\uff0c\u6b62\u635f\u9000\u51fa\u4e0e\u65b0\u5165\u573a\u4fe1\u53f7\u53ef\u80fd\u4ec5\u76f8\u9694\u51e0\u6839K\u7ebf\u3002\u6b62\u635f\u540e\u51b7\u5374\u671f\u662f\u4e00\u79cd\u53ef\u6d4b\u8bd5\u7684\u673a\u5236\uff0c\u53ef\u9650\u5236\u7acb\u5373\u91cd\u65b0\u5165\u573a\uff0c\u800c\u65e0\u9700\u6539\u53d8\u539f\u6709\u4fe1\u53f7\u6216\u4fdd\u62a4\u6027\u9000\u51fa\u3002thinkorswim\u7b56\u7565\u5fc5\u987b\u660e\u786e\u533a\u5206\u4f5c\u51fa\u51b3\u7b56\u7684K\u7ebf\u4e0eAddOrder\u8bb0\u5f55\u5047\u8bbe\u8ba2\u5355\u7684\u4e0b\u4e00\u6839K\u7ebf\u3002\u53ea\u6709\u5148\u5b9a\u4e49\u51b7\u5374\u671f\u8d77\u70b9\uff0c\u624d\u80fd\u6b63\u786e\u8bc4\u4ef7\u6548\u679c\u3002<\/p>\n<h2>\u660e\u786e\u8ba1\u65f6\u89c4\u5219\uff1a\u4fe1\u53f7K\u7ebf\uff0c\u800c\u975e\u6210\u4ea4\u786e\u8ba4<\/h2>\n<p>\u672c\u4f8b\u7981\u6b62\u6b62\u635f\u51b3\u7b56K\u7ebf\u53ca\u5176\u540e\u8fde\u7eed\u4e09\u6839K\u7ebf\u4ea7\u751f\u65b0\u5165\u573a\u51b3\u7b56\u3002\u5047\u8bbe\u591a\u5934\u6301\u4ed3\u5728\u7b2c20\u6839K\u7ebf\u4ea7\u751f\u7b26\u5408\u6301\u4ed3\u6761\u4ef6\u7684\u6b62\u635f\u9000\u51fa\u51b3\u7b56\uff0c\u6a21\u62df\u9000\u51fa\u6309\u4e0b\u4e00\u6839\u5f00\u76d8\u4ef7\u8bb0\u5f55\u4e8e\u7b2c21\u6839\u3002\u7b2c21\u300122\u300123\u6839\u7684\u65b0\u5165\u573a\u51b3\u7b56\u5747\u88ab\u7981\u6b62\u3002\u7b2c24\u6839\u82e5\u6ee1\u8db3\u7a7a\u4ed3\u53ca\u5165\u573a\u6761\u4ef6\u5373\u53ef\u53d1\u51fa\u4fe1\u53f7\uff0c\u5047\u8bbe\u65b0\u8ba2\u5355\u8bb0\u5f55\u4e8e\u7b2c25\u6839\u3002\u8ba1\u6570\u5355\u4f4d\u4e3a\u56fe\u8868K\u7ebf\uff0c\u800c\u975e\u5206\u949f\u6216\u7ecf\u7eaa\u5546\u5b9e\u76d8\u6210\u4ea4\u786e\u8ba4\u3002<\/p>\n<figure><img decoding=\"async\" src=\"https:\/\/www.patternsmart.com\/cn\/wp-content\/uploads\/2026\/11\/PS_TOS_Cooldown_CN.png\" alt=\"PS_TOS_Cooldown_CN.png\" title=\"\u7b2c20\u6839\u6b62\u635f\u51b3\u7b56\u540e\u7981\u6b62\u7b2c21\u81f323\u6839\u5165\u573a\uff0c\u7b2c24\u6839\u6062\u590d\u8d44\u683c\uff0c\u82e5\u4fe1\u53f7\u6210\u7acb\u5219\u7b2c25\u6839\u6a21\u62df\u5165\u573a\u3002\" width=\"960\" height=\"420\" style=\"max-width:100%;height:auto\"><figcaption>\u7b2c20\u6839\u6b62\u635f\u51b3\u7b56\u540e\u7981\u6b62\u7b2c21\u81f323\u6839\u5165\u573a\uff0c\u7b2c24\u6839\u6062\u590d\u8d44\u683c\uff0c\u82e5\u4fe1\u53f7\u6210\u7acb\u5219\u7b2c25\u6839\u6a21\u62df\u5165\u573a\u3002<\/figcaption><\/figure>\n<table border=\"1\" cellpadding=\"8\" style=\"border-collapse:collapse;width:100%\">\n<tr>\n<th>K\u7ebf\u5e8f\u53f7<\/th>\n<th>\u8ba1\u6570\u5668<\/th>\n<th>\u5165\u573a\u51b3\u7b56<\/th>\n<\/tr>\n<tr>\n<td>20<\/td>\n<td>4<\/td>\n<td>\u7981\u6b62\uff1b\u6b62\u635f\u51b3\u7b56<\/td>\n<\/tr>\n<tr>\n<td>21<\/td>\n<td>3<\/td>\n<td>\u7981\u6b62\uff1b\u6a21\u62df\u9000\u51fa<\/td>\n<\/tr>\n<tr>\n<td>22<\/td>\n<td>2<\/td>\n<td>\u7981\u6b62<\/td>\n<\/tr>\n<tr>\n<td>23<\/td>\n<td>1<\/td>\n<td>\u7981\u6b62<\/td>\n<\/tr>\n<tr>\n<td>24<\/td>\n<td>0<\/td>\n<td>\u6709\u6709\u6548\u4fe1\u53f7\u65f6\u5141\u8bb8<\/td>\n<\/tr>\n<tr>\n<td>25<\/td>\n<td>0<\/td>\n<td>\u53ef\u80fd\u6267\u884c\u7b2c24\u6839\u7684\u6a21\u62df\u5165\u573a<\/td>\n<\/tr>\n<\/table>\n<h2>\u6574\u5408\u9012\u5f52\u5165\u573a\u9650\u5236<\/h2>\n<p>CompoundValue\u7528\u4e8e\u521d\u59cb\u5316\u9012\u5f52\u5e8f\u5217\u3002\u6b62\u635f\u51b3\u7b56\u53d1\u751f\u65f6\uff0c\u5c06\u8ba1\u6570\u5668\u8bbe\u4e3a\u6307\u5b9a\u7b49\u5f85K\u7ebf\u6570\u91cf\u52a0\u4e00\uff0c\u4e4b\u540e\u6bcf\u6839\u9012\u51cf\u4e00\u4e14\u4e0d\u4f4e\u4e8e\u96f6\u3002\u989d\u5916\u7684\u4e00\u4fdd\u8bc1\u6b62\u635f\u51b3\u7b56\u672c\u8eab\u4e5f\u7eb3\u5165\u7981\u6b62\u8303\u56f4\u3002\u9996\u6839K\u7ebf\u521d\u59cb\u5316\u4e3a\u96f6\uff1b\u539f\u6709\u7b56\u7565\u5e94\u5728\u751f\u6210\u51b3\u7b56\u524d\u4fdd\u7559\u8db3\u591f\u9884\u70ed\u5386\u53f2\u3002<\/p>\n<p>\u4ee5\u4e0b\u4e3a\u6574\u5408\u7247\u6bb5\uff0c\u5e76\u975e\u72ec\u7acb\u5b8c\u6574\u7b56\u7565\u3002stopExitSignal\u3001rawEntry\u53caflatForEntry\u9700\u7531\u539f\u6709\u7b56\u7565\u6a21\u578b\u63d0\u4f9b\u3002\u6b62\u635f\u4e8b\u4ef6\u5fc5\u987b\u662f\u4e00\u6b21\u6027\u7684\u3001\u7b26\u5408\u6301\u4ed3\u6761\u4ef6\u7684\u51b3\u7b56\uff0c\u800c\u4e0d\u662f\u7a7a\u4ed3\u65f6\u4ecd\u6301\u7eed\u4e3a\u771f\u7684\u539f\u59cb\u4ef7\u683c\u6761\u4ef6\u3002\u5165\u573a\u8d44\u683c\u72b6\u6001\u9700\u8003\u8651\u6a21\u62df\u5165\u573a\u53ca\u9000\u51fa\u51b3\u7b56\u7684\u7b49\u5f85\u72b6\u6001\uff0c\u4e0d\u80fd\u76f4\u63a5\u5047\u8bbe\u4e3a\u8d26\u6237\u5b9e\u65f6\u6301\u4ed3\u3002\u7b56\u7565\u72b6\u6001\u4f9d\u8d56\u5173\u7cfb\u5e94\u907f\u514d\u540c\u4e00\u6839K\u7ebf\u5faa\u73af\u5f15\u7528\u3002\u4fdd\u7559\u539f\u6709\u9000\u51fa\u6307\u4ee4\uff0c\u5e76\u66ff\u6362\u539f\u6709\u5165\u573aAddOrder\uff0c\u907f\u514d\u91cd\u590d\u4e0b\u5355\u8bb0\u5f55\u3002<\/p>\n<pre style=\"white-space:pre;font-family:Consolas,Monaco,monospace\"><code># Integration excerpt: use existing strategy definitions<br># stopExitSignal: one-shot, position-qualified stop decision<br># rawEntry: original entry signal<br># flatForEntry: strategy state permits a new long entry<br>input cooldownBars = 3;<br><br>def waitCount = CompoundValue(1,<br>\u00a0\u00a0\u00a0\u00a0if stopExitSignal then Max(0, cooldownBars) + 1<br>\u00a0\u00a0\u00a0\u00a0else Max(0, waitCount[1] - 1), 0);<br><br>def allowEntry = !stopExitSignal and waitCount == 0;<br>def enterLong = rawEntry and flatForEntry and allowEntry;<br><br># Replace the original entry AddOrder, do not duplicate it.<br>AddOrder(OrderType.BUY_TO_OPEN, enterLong,<br>\u00a0\u00a0\u00a0\u00a0open[-1], 1, Color.GREEN, Color.GREEN, &quot;Cooldown entry&quot;);<br><br># Keep the existing exit AddOrder independent of allowEntry.<\/code><\/pre>\n<h2>\u5904\u7406\u53ef\u80fd\u6539\u53d8\u7ed3\u679c\u7684\u8fb9\u754c\u60c5\u51b5<\/h2>\n<ul>\n<li>\u672c\u7248\u672c\u76f4\u63a5\u4e22\u5f03\u6682\u505c\u671f\u95f4\u51fa\u73b0\u7684\u4ea4\u53c9\u4fe1\u53f7\u3002\u6682\u505c\u7ed3\u675f\u65f6\uff0c\u80fd\u5426\u5165\u573a\u7531\u539f\u59cb\u4fe1\u53f7\u5b9a\u4e49\u51b3\u5b9a\u3002\u4fdd\u5b58\u65e7\u4ea4\u53c9\u4fe1\u53f7\u5e76\u5ef6\u8fdf\u91ca\u653e\u5c5e\u4e8e\u53e6\u4e00\u79cd\u7b56\u7565\u3002<\/li>\n<li>\u7b49\u5f85\u671f\u8bbe\u4e3a\u96f6\u65f6\u4ecd\u7981\u6b62\u6b62\u635f\u51b3\u7b56\u5f53\u6839K\u7ebf\u91cd\u65b0\u5165\u573a\uff1b\u4e0b\u4e00\u6839\u662f\u5426\u5141\u8bb8\u53d6\u51b3\u4e8e\u6301\u4ed3\u72b6\u6001\u89c4\u5219\u3002<\/li>\n<li>\u7b49\u5f85\u671f\u8de8\u4ea4\u6613\u65f6\u6bb5\u6309K\u7ebf\u8ba1\u6570\uff0c\u4e94\u5206\u949f\u56fe\u4e0e\u65e5\u7ebf\u5bf9\u5e94\u7684\u5b9e\u9645\u65f6\u95f4\u4e0d\u540c\u3002\u6309\u4ea4\u6613\u65f6\u6bb5\u6682\u505c\u9700\u8981\u72ec\u7acb\u903b\u8f91\u3002<\/li>\n<li>\u6b62\u635f\u6761\u4ef6\u548c\u9000\u51fa\u4ef7\u683c\u5fc5\u987b\u5206\u5f00\u3002\u6536\u76d8\u4ef7\u89e6\u53d1\u6b62\u635f\u4fe1\u53f7\u5e76\u4e8e\u4e0b\u4e00\u6839\u5f00\u76d8\u6a21\u62df\u9000\u51fa\uff0c\u53ef\u80fd\u4ea7\u751f\u4e0e\u76d8\u4e2d\u6b62\u635f\u8ba2\u5355\u660e\u663e\u4e0d\u540c\u7684\u4e8f\u635f\u3002\u4e0d\u80fd\u5047\u5b9a\u6b62\u635f\u6210\u4ea4\u4ef7\u5f97\u5230\u4fdd\u8bc1\u3002<\/li>\n<\/ul>\n<h2>\u9a8c\u8bc1\u89c4\u5219\uff0c\u800c\u975e\u4ec5\u6bd4\u8f83\u51c0\u5229\u6da6<\/h2>\n<ol>\n<li>\u4f7f\u7528\u76f8\u540c\u5386\u53f2\u3001\u8ba2\u5355\u6570\u91cf\u53ca\u6210\u672c\u5047\u8bbe\uff0c\u5bf9\u6bd4\u51b7\u5374\u671f0\u30011\u30013\u30015\u3002<\/li>\n<li>\u68c0\u67e5\u7b56\u7565\u62a5\u544a\u65f6\u95f4\u6233\uff0c\u9a8c\u8bc1\u4e0a\u8ff0\u516d\u6839K\u7ebf\u793a\u4f8b\uff0c\u5e76\u6d4b\u8bd5\u6bcf\u6839\u7981\u6b62K\u7ebf\u5747\u51fa\u73b0\u65b0\u4ea4\u53c9\u4fe1\u53f7\u7684\u60c5\u51b5\u3002<\/li>\n<li>\u6bd4\u8f83\u4ea4\u6613\u6b21\u6570\u3001\u5e73\u5747\u51c0\u6536\u76ca\u3001\u56de\u64a4\u53ca\u9519\u8fc7\u7684\u76c8\u5229\u518d\u5165\u573a\u3002\u7eb3\u5165\u5408\u7406\u624b\u7eed\u8d39\u3001\u6ed1\u70b9\u53ca\u8df3\u7a7a\u60c5\u666f\u3002<\/li>\n<li>\u4f7f\u7528\u6837\u672c\u5916\u533a\u95f4\u53ca\u4e0d\u540c\u5e02\u573a\u72b6\u6001\u8bc4\u4ef7\uff0c\u4e0d\u8981\u4ec5\u4e3a\u6700\u5927\u5316\u5386\u53f2\u5229\u6da6\u800c\u4f18\u5316\u5355\u4e00\u51b7\u5374\u53c2\u6570\u3002<\/li>\n<\/ol>\n<p>thinkScript AddOrder\u7528\u4e8e\u56fe\u8868\u5206\u6790\u4e2d\u7684\u5047\u8bbe\u7b56\u7565\u8ba2\u5355\uff0c\u4e0d\u63d0\u4f9b\u65e0\u4eba\u503c\u5b88\u5b9e\u76d8\u6267\u884c\u6216\u7ecf\u7eaa\u5546\u786e\u8ba4\u6210\u4ea4\u56de\u8c03\u3002\u5b9e\u76d8\u7cfb\u7edf\u9700\u8981\u81ea\u5df1\u7684\u5b9e\u9645\u6210\u4ea4\u8d26\u672c\u3001\u98ce\u9669\u63a7\u5236\u53ca\u660e\u786e\u7684\u91cd\u542f\u89c4\u5219\u3002\u51b7\u5374\u671f\u4e0d\u80fd\u4fdd\u8bc1\u6539\u5584\u7b56\u7565\u8868\u73b0\u3002<\/p>\n<p>\u5b98\u65b9\u53c2\u8003\uff1a<a href=\"https:\/\/toslc.thinkorswim.com\/center\/reference\/thinkScript\/Functions\/Others\/AddOrder\">AddOrder<\/a>\uff1b<a href=\"https:\/\/toslc.thinkorswim.com\/center\/reference\/thinkScript\/Functions\/Others\/CompoundValue\">CompoundValue<\/a>\u3002<\/p>\n<p>\u793a\u4f8b\u672a\u5b9e\u9645\u7f16\u8bd1\u6216\u56de\u6d4b\uff0c\u4ec5\u7528\u4e8e\u6559\u5b66\u3002\u4ea4\u6613\u5b58\u5728\u4e8f\u635f\u98ce\u9669\uff0c\u6a21\u62df\u7ed3\u679c\u4e0d\u4ee3\u8868\u672a\u6765\u8868\u73b0\u3002<\/p>\n<p>\u5982\u9700\u5c06\u6b64\u514d\u8d39\u7b56\u7565\u601d\u8def\u6269\u5c55\u4e3a\u9002\u5408\u81ea\u8eab\u4ea4\u6613\u89c4\u5219\u7684\u7a0b\u5e8f\uff0c\u6b22\u8fce\u8054\u7cfb\u6211\u4eec\u4e86\u89e3<a href=\"https:\/\/www.patternsmart.com\/cn\/custom\/\">Thinkorswim\u4ea4\u6613\u7b56\u7565\u5b9a\u5236\u5f00\u53d1\u670d\u52a1<\/a>\u3002<\/p>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u9707\u8361\u5e02\u573a\u4e2d\uff0c\u6b62\u635f\u9000\u51fa\u4e0e\u65b0\u5165\u573a\u4fe1\u53f7\u53ef\u80fd\u4ec5\u76f8\u9694\u51e0\u6839K\u7ebf\u3002\u6b62\u635f\u540e\u51b7\u5374\u671f\u662f\u4e00\u79cd\u53ef\u6d4b\u8bd5\u7684\u673a\u5236\uff0c\u53ef\u9650\u5236\u7acb\u5373\u91cd\u65b0\u5165\u573a\uff0c\u800c\u65e0\u9700 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2802,"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":[71,520],"tags":[152,177,340,653,342,639],"class_list":["post-2801","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thinkorswim","category-520","tag-thinkorswim","tag-thinkscript","tag-340","tag-653","tag-342","tag-639"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/www.patternsmart.com\/cn\/wp-content\/uploads\/2026\/11\/PS_TOS_Cooldown_CN.png","_links":{"self":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/posts\/2801","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=2801"}],"version-history":[{"count":0,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/posts\/2801\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/media\/2802"}],"wp:attachment":[{"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/media?parent=2801"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/categories?post=2801"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.patternsmart.com\/cn\/wp-json\/wp\/v2\/tags?post=2801"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}