{"id":13436,"date":"2024-08-19T01:58:50","date_gmt":"2024-08-18T16:58:50","guid":{"rendered":"https:\/\/jyakusyadansei.com\/?p=13436"},"modified":"2024-08-19T01:59:16","modified_gmt":"2024-08-18T16:59:16","slug":"%e3%80%90fx%e3%80%91%e3%83%ac%e3%82%a4%e3%83%a4%e3%83%bc%e3%83%88%e3%83%ac%e3%83%bc%e3%83%89ea%e3%81%ae%e5%9f%ba%e6%9c%ac%e3%81%ae%e3%81%a8%e3%81%93%e3%82%8d","status":"publish","type":"post","link":"https:\/\/jyakusyadansei.com\/?p=13436","title":{"rendered":"\u3010FX\u3011\u30ec\u30a4\u30e4\u30fc\u30c8\u30ec\u30fc\u30c9EA\u306e\u57fa\u672c\u306e\u3068\u3053\u308d"},"content":{"rendered":"<p>\u30ec\u30a4\u30e4\u30fc\u30c8\u30ec\u30fc\u30c9\u306e\u8a2d\u5b9a\u753b\u9762\u306f\u3053\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n<p><a href=\"https:\/\/jyakusyadansei.com\/wp-content\/uploads\/2024\/08\/image-12.png\"><img fetchpriority=\"high\" decoding=\"async\" class=\"wp-image-13437 size-full aligncenter\" src=\"https:\/\/jyakusyadansei.com\/wp-content\/uploads\/2024\/08\/image-12.png\" alt=\"\" width=\"852\" height=\"217\" srcset=\"https:\/\/jyakusyadansei.com\/wp-content\/uploads\/2024\/08\/image-12.png 852w, https:\/\/jyakusyadansei.com\/wp-content\/uploads\/2024\/08\/image-12-300x76.png 300w, https:\/\/jyakusyadansei.com\/wp-content\/uploads\/2024\/08\/image-12-150x38.png 150w, https:\/\/jyakusyadansei.com\/wp-content\/uploads\/2024\/08\/image-12-768x196.png 768w\" sizes=\"(max-width: 852px) 100vw, 852px\" \/><\/a><\/p>\n<p>TradeInterval\u306f5\u79d2\u3001TradeCount\u306f10\u3001SL\u306f50\u3001TP\u306f60\u3001\u30ed\u30c3\u30c8\u30b5\u30a4\u30ba\u306f0.01\u3067\u3084\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<br \/>\n\u91d1\u306e\u5834\u5408\u3001SL\u306f5\u30c9\u30eb\u3001TP\u306f6\u30c9\u30eb\u3068\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002\uff08SL\u306f\u3042\u308b\u7a0b\u5ea6\u306e\u30d0\u30c3\u30d5\u30a1\u30fc\u3092\u30a4\u30e1\u30fc\u30b8\u3057\u3066\u3044\u307e\u3059<\/p>\n<p>\u30b7\u30b0\u30ca\u30eb\u306f\u5927\u6587\u5b57\u5c0f\u6587\u5b57\u306b\u95a2\u308f\u3089\u305a\u3001buy, sell, close, secure \u3067\u53cd\u5fdc\u3059\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u30d7\u30ed\u30b0\u30e9\u30e0<\/h2>\n<blockquote><p>\/\/+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\n\/\/| Expert initialization function |<br \/>\n\/\/+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\ninput int TradeInterval = 5; \/\/ \u79d2\u6570\uff08\u9593\u9694\uff09<br \/>\ninput int TradeCount = 10; \/\/ \u30c8\u30ec\u30fc\u30c9\u56de\u6570<br \/>\ninput double SL = 50.0; \/\/ \u30b9\u30c8\u30c3\u30d7\u30ed\u30b9\uff08\u30d4\u30c3\u30d7\u30b9\uff09<br \/>\ninput double TP = 60.0; \/\/ \u30c6\u30a4\u30af\u30d7\u30ed\u30d5\u30a3\u30c3\u30c8\uff08\u30d4\u30c3\u30d7\u30b9\uff09<br \/>\ninput double LotSize = 0.01; \/\/ \u30ed\u30c3\u30c8\u30b5\u30a4\u30ba<br \/>\ninput string SignalFileName = &#8220;signal.txt&#8221;; \/\/ \u30b7\u30b0\u30ca\u30eb\u30d5\u30a1\u30a4\u30eb\u540d<br \/>\ninput int MAGIC_NUMBER = 123456; \/\/ MAGIC_NUMBER\u3092\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u3057\u3066\u8a2d\u5b9a<\/p>\n<p>int startTime;<br \/>\nbool isTrading = false;<br \/>\nint currentTrade = 0;<\/p>\n<p>\/\/+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\n\/\/| Expert initialization function |<br \/>\n\/\/+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\nint OnInit()<br \/>\n{<br \/>\nstartTime = TimeCurrent();<br \/>\nPrint(&#8220;EA Initialized.&#8221;);<br \/>\nreturn(INIT_SUCCEEDED);<br \/>\n}<\/p>\n<p>\/\/+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\n\/\/| Expert tick function |<br \/>\n\/\/+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\nvoid OnTick()<br \/>\n{<br \/>\n\/\/ \u30d5\u30a1\u30a4\u30eb\u304b\u3089\u30b7\u30b0\u30ca\u30eb\u3092\u8aad\u307f\u8fbc\u307f<br \/>\nstring signal = ReadSignalFromFile();<\/p>\n<p>Print(&#8220;Signal read: &#8220;, signal);<\/p>\n<p>\/\/ &#8220;CLOSE ALL&#8221;, &#8220;ALLCLOSE&#8221;, &#8220;close all&#8221;, &#8220;allclose&#8221; \u3067\u5168\u3066\u306e\u30c8\u30ec\u30fc\u30c9\u3092\u30af\u30ed\u30fc\u30ba<br \/>\nif(signal == &#8220;CLOSE ALL&#8221; || signal == &#8220;ALLCLOSE&#8221; || signal == &#8220;close all&#8221; || signal == &#8220;allclose&#8221;)<br \/>\n{<br \/>\nCloseAllTrades();<br \/>\nClearSignalFile(); \/\/ \u30b7\u30b0\u30ca\u30eb\u30d5\u30a1\u30a4\u30eb\u3092\u30af\u30ea\u30a2<br \/>\nPrint(&#8220;All trades closed and signal file cleared.&#8221;);<br \/>\nreturn;<br \/>\n}<\/p>\n<p>\/\/ \u30c8\u30ec\u30fc\u30c9\u304c\u5b9f\u884c\u4e2d\u3067\u306a\u3044\u5834\u5408\u3001\u30b7\u30b0\u30ca\u30eb\u306b\u57fa\u3065\u3044\u3066\u30c8\u30ec\u30fc\u30c9\u3092\u958b\u59cb<br \/>\nif(!isTrading &amp;&amp; (signal == &#8220;BUY&#8221; || signal == &#8220;SELL&#8221; || signal == &#8220;buy&#8221; || signal == &#8220;sell&#8221;))<br \/>\n{<br \/>\nisTrading = true;<br \/>\ncurrentTrade = 0;<br \/>\nstartTime = TimeCurrent();<br \/>\nPrint(&#8220;Trading started: &#8220;, signal);<br \/>\n}<\/p>\n<p>\/\/ \u30c8\u30ec\u30fc\u30c9\u3092\u958b\u59cb\u3057\u3066\u3044\u308b\u5834\u5408\u3001\u6307\u5b9a\u3057\u305f\u79d2\u6570\u9593\u9694\u3067\u30c8\u30ec\u30fc\u30c9\u3092\u5b9f\u884c<br \/>\nif(isTrading &amp;&amp; currentTrade &lt; TradeCount)<br \/>\n{<br \/>\nif(TimeCurrent() &#8211; startTime &gt;= TradeInterval)<br \/>\n{<br \/>\nif(signal == &#8220;BUY&#8221; || signal == &#8220;buy&#8221;)<br \/>\n{<br \/>\nOpenBuy();<br \/>\n}<br \/>\nelse if(signal == &#8220;SELL&#8221; || signal == &#8220;sell&#8221;)<br \/>\n{<br \/>\nOpenSell();<br \/>\n}<br \/>\ncurrentTrade++;<br \/>\nstartTime = TimeCurrent(); \/\/ \u6b21\u306e\u30c8\u30ec\u30fc\u30c9\u306e\u305f\u3081\u306b\u6642\u9593\u3092\u30ea\u30bb\u30c3\u30c8<br \/>\n}<br \/>\n}<\/p>\n<p>\/\/ \u6307\u5b9a\u56de\u6570\u306e\u30c8\u30ec\u30fc\u30c9\u304c\u5b8c\u4e86\u3057\u305f\u5834\u5408\u3001\u30c8\u30ec\u30fc\u30c9\u30d5\u30e9\u30b0\u3092\u30ea\u30bb\u30c3\u30c8\u3057\u30d5\u30a1\u30a4\u30eb\u3092\u30af\u30ea\u30a2<br \/>\nif(currentTrade &gt;= TradeCount)<br \/>\n{<br \/>\nisTrading = false;<br \/>\nClearSignalFile(); \/\/ \u30d5\u30a1\u30a4\u30eb\u3092\u30af\u30ea\u30a2<br \/>\nPrint(&#8220;Trading completed. Signal file cleared.&#8221;);<br \/>\n}<br \/>\n}<\/p>\n<p>\/\/+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\n\/\/| \u30b7\u30b0\u30ca\u30eb\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u30b7\u30b0\u30ca\u30eb\u3092\u8aad\u307f\u8fbc\u3080 |<br \/>\n\/\/+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\nstring ReadSignalFromFile()<br \/>\n{<br \/>\nint fileHandle = FileOpen(SignalFileName, FILE_READ|FILE_TXT);<br \/>\nstring signal = &#8220;&#8221;;<br \/>\nif(fileHandle &gt; 0)<br \/>\n{<br \/>\nsignal = FileReadString(fileHandle);<br \/>\nFileClose(fileHandle);<\/p>\n<p>\/\/ \u4f59\u5206\u306a\u30b9\u30da\u30fc\u30b9\u3084\u6539\u884c\u3092\u524a\u9664<br \/>\nsignal = StringTrimLeft(signal);<br \/>\nsignal = StringTrimRight(signal);<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nPrint(&#8220;Failed to open signal file.&#8221;);<br \/>\n}<br \/>\nreturn signal;<br \/>\n}<\/p>\n<p>\/\/+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\n\/\/| Buy\u30dd\u30b8\u30b7\u30e7\u30f3\u3092\u958b\u304f |<br \/>\n\/\/+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\nvoid OpenBuy()<br \/>\n{<br \/>\ndouble sl = Bid &#8211; SL * MarketInfo(Symbol(), MODE_POINT) * 10;<br \/>\ndouble tp = Bid + TP * MarketInfo(Symbol(), MODE_POINT) * 10;<br \/>\nint ticket = OrderSend(Symbol(), OP_BUY, LotSize, Ask, 3, sl, tp, &#8220;Layer Buy&#8221;, MAGIC_NUMBER, 0, Green);<\/p>\n<p>if(ticket &lt; 0)<br \/>\n{<br \/>\nPrint(&#8220;Buy OrderSend failed with error #&#8221;, GetLastError());<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nPrint(&#8220;Buy Order sent: Ticket#&#8221;, ticket);<br \/>\n}<br \/>\n}<\/p>\n<p>\/\/+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\n\/\/| Sell\u30dd\u30b8\u30b7\u30e7\u30f3\u3092\u958b\u304f |<br \/>\n\/\/+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\nvoid OpenSell()<br \/>\n{<br \/>\ndouble sl = Bid + SL * MarketInfo(Symbol(), MODE_POINT) * 10;<br \/>\ndouble tp = Bid &#8211; TP * MarketInfo(Symbol(), MODE_POINT) * 10;<br \/>\nint ticket = OrderSend(Symbol(), OP_SELL, LotSize, Bid, 3, sl, tp, &#8220;Layer Sell&#8221;, MAGIC_NUMBER, 0, Red);<\/p>\n<p>if(ticket &lt; 0)<br \/>\n{<br \/>\nPrint(&#8220;Sell OrderSend failed with error #&#8221;, GetLastError());<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nPrint(&#8220;Sell Order sent: Ticket#&#8221;, ticket);<br \/>\n}<br \/>\n}<\/p>\n<p>\/\/+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\n\/\/| \u30b7\u30b0\u30ca\u30eb\u30d5\u30a1\u30a4\u30eb\u3092\u30af\u30ea\u30a2\u3059\u308b |<br \/>\n\/\/+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\nvoid ClearSignalFile()<br \/>\n{<br \/>\nint fileHandle = FileOpen(SignalFileName, FILE_WRITE|FILE_TXT);<br \/>\nif(fileHandle &gt; 0)<br \/>\n{<br \/>\nFileWrite(fileHandle, &#8220;&#8221;); \/\/ \u30d5\u30a1\u30a4\u30eb\u3092\u30af\u30ea\u30a2<br \/>\nFileClose(fileHandle);<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nPrint(&#8220;Failed to open signal file for clearing.&#8221;);<br \/>\n}<br \/>\n}<\/p>\n<p>\/\/+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\n\/\/| \u5168\u3066\u306e\u30dd\u30b8\u30b7\u30e7\u30f3\u3092\u30af\u30ed\u30fc\u30ba\u3059\u308b |<br \/>\n\/\/+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<br \/>\nvoid CloseAllTrades()<br \/>\n{<br \/>\nfor(int i = OrdersTotal() &#8211; 1; i &gt;= 0; i&#8211;)<br \/>\n{<br \/>\nif(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))<br \/>\n{<br \/>\nint orderType = OrderType();<br \/>\ndouble closePrice;<br \/>\nif(orderType == OP_BUY)<br \/>\n{<br \/>\nclosePrice = Bid;<br \/>\n}<br \/>\nelse if(orderType == OP_SELL)<br \/>\n{<br \/>\nclosePrice = Ask;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\ncontinue; \/\/ \u4ed6\u306e\u6ce8\u6587\u30bf\u30a4\u30d7\u306f\u30b9\u30ad\u30c3\u30d7<br \/>\n}<\/p>\n<p>bool result = OrderClose(OrderTicket(), OrderLots(), closePrice, 3, clrNONE);<br \/>\nif(result)<br \/>\n{<br \/>\nPrint(&#8220;Order closed: Ticket#&#8221;, OrderTicket());<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nPrint(&#8220;Failed to close order: Ticket#&#8221;, OrderTicket(), &#8221; Error #&#8221;, GetLastError());<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n\/\/+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u30ec\u30a4\u30e4\u30fc\u30c8\u30ec\u30fc\u30c9\u306e\u8a2d\u5b9a\u753b\u9762\u306f\u3053\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u3059\u3002 TradeInterval\u306f5\u79d2\u3001TradeCount\u306f10\u3001SL\u306f50\u3001TP\u306f60\u3001\u30ed\u30c3\u30c8\u30b5\u30a4\u30ba\u306f0.01\u3067\u3084\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002 \u91d1\u306e\u5834\u5408\u3001SL\u306f5\u30c9\u30eb\u3001TP\u306f6\u30c9\u30eb\u3068 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":13412,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-13436","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-fx"],"acf":[],"_links":{"self":[{"href":"https:\/\/jyakusyadansei.com\/index.php?rest_route=\/wp\/v2\/posts\/13436","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jyakusyadansei.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jyakusyadansei.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jyakusyadansei.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jyakusyadansei.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13436"}],"version-history":[{"count":1,"href":"https:\/\/jyakusyadansei.com\/index.php?rest_route=\/wp\/v2\/posts\/13436\/revisions"}],"predecessor-version":[{"id":13438,"href":"https:\/\/jyakusyadansei.com\/index.php?rest_route=\/wp\/v2\/posts\/13436\/revisions\/13438"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jyakusyadansei.com\/index.php?rest_route=\/wp\/v2\/media\/13412"}],"wp:attachment":[{"href":"https:\/\/jyakusyadansei.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jyakusyadansei.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jyakusyadansei.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}