<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>待機注文 アーカイブ - 自動売買を作ろう！</title>
	<atom:link href="https://mql-programing.com/archives/tag/%E5%BE%85%E6%A9%9F%E6%B3%A8%E6%96%87/feed/" rel="self" type="application/rss+xml" />
	<link>https://mql-programing.com/archives/tag/待機注文/</link>
	<description>MQLプログラミング学習サイト</description>
	<lastBuildDate>Wed, 01 Apr 2026 04:53:26 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://mql-programing.com/main29/wp-content/uploads/2021/02/cropped-ブログアイコン-32x32.jpg</url>
	<title>待機注文 アーカイブ - 自動売買を作ろう！</title>
	<link>https://mql-programing.com/archives/tag/待機注文/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【MQL4】注文タイプ定数を完全解説！OP_BUY・OP_SELL・指値/逆指値の全6種類を一覧で理解しよう</title>
		<link>https://mql-programing.com/archives/13077/%e3%80%90mql4%e3%80%91%e6%b3%a8%e6%96%87%e3%82%bf%e3%82%a4%e3%83%97%e5%ae%9a%e6%95%b0%e3%82%92%e5%ae%8c%e5%85%a8%e8%a7%a3%e8%aa%ac%ef%bc%81op_buy%e3%83%bbop_sell%e3%83%bb%e6%8c%87%e5%80%a4-%e9%80%86/</link>
		
		<dc:creator><![CDATA[朝日奈りさ]]></dc:creator>
		<pubDate>Mon, 27 Apr 2026 01:00:00 +0000</pubDate>
				<category><![CDATA[【辞書】MQLリファレンス]]></category>
		<category><![CDATA[定数]]></category>
		<category><![CDATA[OP_BUY]]></category>
		<category><![CDATA[MQL4]]></category>
		<category><![CDATA[注文タイプ定数]]></category>
		<category><![CDATA[OrderSend]]></category>
		<category><![CDATA[待機注文]]></category>
		<guid isPermaLink="false">https://mql-programing.com/?p=13077</guid>

					<description><![CDATA[<p>MQL4で注文を出すとき、必ず使うのがOrderSend()関数です。この関数の第2引数には「注文タイプ」を指定する必要があります。 「OP_BUYは分かるけど、OP_BUYLIMITとOP_BUYSTOPの違いって何？ [&#8230;]</p>
<p>投稿 <a href="https://mql-programing.com/archives/13077/%e3%80%90mql4%e3%80%91%e6%b3%a8%e6%96%87%e3%82%bf%e3%82%a4%e3%83%97%e5%ae%9a%e6%95%b0%e3%82%92%e5%ae%8c%e5%85%a8%e8%a7%a3%e8%aa%ac%ef%bc%81op_buy%e3%83%bbop_sell%e3%83%bb%e6%8c%87%e5%80%a4-%e9%80%86/">【MQL4】注文タイプ定数を完全解説！OP_BUY・OP_SELL・指値/逆指値の全6種類を一覧で理解しよう</a> は <a href="https://mql-programing.com">自動売買を作ろう！</a> に最初に表示されました。</p>
]]></description>
										<content:encoded><![CDATA[<p>MQL4で注文を出すとき、必ず使うのが<strong>OrderSend()</strong>関数です。この関数の第2引数には「注文タイプ」を指定する必要があります。</p>
<p>「OP_BUYは分かるけど、OP_BUYLIMITとOP_BUYSTOPの違いって何？」「指値と逆指値がごっちゃになる…」という方も多いのではないでしょうか。</p>
<p>この記事では、MQL4の<strong>注文タイプ定数 全6種類</strong>を一覧表で整理し、それぞれのコードサンプル付きで徹底解説します。これを読めば、すべての注文タイプを自信を持って使い分けられるようになります。</p>
<h2><span id="toc1">注文タイプ定数の一覧（全6種類）</span></h2>
<p>まずは全体像を把握しましょう。MQL4で使える注文タイプ定数は以下の6つです。</p>
<table border="1" cellpadding="8" cellspacing="0" style="border-collapse: collapse; width: 100%;">
<thead>
<tr style="background-color: #f0f0f0;">
<th>定数名</th>
<th>数値</th>
<th>種類</th>
<th>説明</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>OP_BUY</strong></td>
<td>0</td>
<td>成行注文</td>
<td>現在価格で買い（ロング）</td>
</tr>
<tr>
<td><strong>OP_SELL</strong></td>
<td>1</td>
<td>成行注文</td>
<td>現在価格で売り（ショート）</td>
</tr>
<tr>
<td><strong>OP_BUYLIMIT</strong></td>
<td>2</td>
<td>指値注文</td>
<td>現在価格より<strong>下</strong>で買い予約</td>
</tr>
<tr>
<td><strong>OP_SELLLIMIT</strong></td>
<td>3</td>
<td>指値注文</td>
<td>現在価格より<strong>上</strong>で売り予約</td>
</tr>
<tr>
<td><strong>OP_BUYSTOP</strong></td>
<td>4</td>
<td>逆指値注文</td>
<td>現在価格より<strong>上</strong>で買い予約</td>
</tr>
<tr>
<td><strong>OP_SELLSTOP</strong></td>
<td>5</td>
<td>逆指値注文</td>
<td>現在価格より<strong>下</strong>で売り予約</td>
</tr>
</tbody>
</table>
<p>数値の0〜5を直接書いても動作しますが、<strong>定数名を使うことで可読性が格段に上がります</strong>。必ず定数名を使いましょう。</p>
<h2><span id="toc2">成行注文：OP_BUY と OP_SELL</span></h2>
<p>成行注文は「今すぐ約定させたい」ときに使う、最も基本的な注文タイプです。</p>
<h3><span id="toc3">OP_BUY（買い成行注文）</span></h3>
<p>買い注文は<strong>Ask（売値）</strong>で約定します。買うときはスプレッド分だけ高い価格で約定する点に注意してください。</p>
<pre><code class="language-mql4">// 買い成行注文の例
int ticket = OrderSend(
    Symbol(),       // 現在の通貨ペア
    OP_BUY,         // 買い注文
    0.1,            // 0.1ロット
    Ask,            // 買いはAsk価格を指定
    3,              // スリッページ許容（ポイント）
    0,              // ストップロス（0 = なし）
    0,              // テイクプロフィット（0 = なし）
    "Buy Order",    // コメント
    12345,          // マジックナンバー
    0,              // 有効期限（成行では無関係）
    clrBlue         // チャート上の矢印色
);

if(ticket < 0)
{
    Print("買い注文エラー: ", GetLastError());
}
else
{
    Print("買い注文成功！ チケット番号: ", ticket);
}</code></pre>
<h3><span id="toc4">OP_SELL（売り成行注文）</span></h3>
<p>売り注文は<strong>Bid（買値）</strong>で約定します。OP_BUYとの違いは、指定する価格がBidになる点です。</p>
<pre><code class="language-mql4">// 売り成行注文の例
int ticket = OrderSend(
    Symbol(),       // 現在の通貨ペア
    OP_SELL,        // 売り注文
    0.1,            // 0.1ロット
    Bid,            // 売りはBid価格を指定
    3,              // スリッページ許容
    0,              // ストップロス
    0,              // テイクプロフィット
    "Sell Order",   // コメント
    12345,          // マジックナンバー
    0,              // 有効期限
    clrRed          // チャート上の矢印色
);

if(ticket < 0)
{
    Print("売り注文エラー: ", GetLastError());
}</code></pre>
<p><strong>重要ポイント：</strong>買いは<strong>Ask</strong>、売りは<strong>Bid</strong>。これを逆にすると<code>ERR_INVALID_PRICE（エラーコード129）</code>が発生します。初心者がつまずきやすいポイントなので、しっかり覚えておきましょう。</p>
<h2><span id="toc5">指値注文：OP_BUYLIMIT と OP_SELLLIMIT</span></h2>
<p>指値注文は「今より有利な価格になったら約定させたい」ときに使います。<strong>逆張りエントリー</strong>に向いている注文タイプです。</p>
<h3><span id="toc6">OP_BUYLIMIT（買い指値注文）</span></h3>
<p>現在のAsk価格より<strong>下</strong>の価格を指定して、「そこまで下がったら買いたい」という注文です。押し目買いのイメージです。</p>
<pre><code class="language-mql4">// 買い指値注文：現在価格より50pips下で買い予約
double entryPrice = Ask - 50 * Point * 10;  // 50pips下（5桁ブローカーの場合）

int ticket = OrderSend(
    Symbol(),
    OP_BUYLIMIT,     // 買い指値注文
    0.1,
    entryPrice,       // 現在のAskより下の価格
    3,
    entryPrice - 30 * Point * 10,  // SL：エントリーから30pips下
    entryPrice + 60 * Point * 10,  // TP：エントリーから60pips上
    "BuyLimit Order",
    12345,
    0,                // 有効期限（0 = 無期限）
    clrBlue
);

if(ticket < 0)
    Print("買い指値注文エラー: ", GetLastError());</code></pre>
<h3><span id="toc7">OP_SELLLIMIT（売り指値注文）</span></h3>
<p>現在のBid価格より<strong>上</strong>の価格を指定して、「そこまで上がったら売りたい」という注文です。戻り売りのイメージです。</p>
<pre><code class="language-mql4">// 売り指値注文：現在価格より50pips上で売り予約
double entryPrice = Bid + 50 * Point * 10;

int ticket = OrderSend(
    Symbol(),
    OP_SELLLIMIT,     // 売り指値注文
    0.1,
    entryPrice,        // 現在のBidより上の価格
    3,
    entryPrice + 30 * Point * 10,  // SL：エントリーから30pips上
    entryPrice - 60 * Point * 10,  // TP：エントリーから60pips下
    "SellLimit Order",
    12345,
    0,
    clrRed
);

if(ticket < 0)
    Print("売り指値注文エラー: ", GetLastError());</code></pre>
<h2><span id="toc8">逆指値注文：OP_BUYSTOP と OP_SELLSTOP</span></h2>
<p>逆指値注文は「今より不利な価格になったら約定させたい」ときに使います。一見すると不利に思えますが、<strong>ブレイクアウト狙いの順張り</strong>には非常に有効です。</p>
<h3><span id="toc9">OP_BUYSTOP（買い逆指値注文）</span></h3>
<p>現在のAsk価格より<strong>上</strong>の価格を指定します。「レジスタンスを上抜けたら買いたい」というブレイクアウト戦略で使います。</p>
<pre><code class="language-mql4">// 買い逆指値注文：現在価格より50pips上で買い予約（上抜けブレイク狙い）
double entryPrice = Ask + 50 * Point * 10;

int ticket = OrderSend(
    Symbol(),
    OP_BUYSTOP,       // 買い逆指値注文
    0.1,
    entryPrice,        // 現在のAskより上の価格
    3,
    entryPrice - 30 * Point * 10,  // SL
    entryPrice + 60 * Point * 10,  // TP
    "BuyStop Order",
    12345,
    0,
    clrBlue
);

if(ticket < 0)
    Print("買い逆指値注文エラー: ", GetLastError());</code></pre>
<h3><span id="toc10">OP_SELLSTOP（売り逆指値注文）</span></h3>
<p>現在のBid価格より<strong>下</strong>の価格を指定します。「サポートを下抜けたら売りたい」というブレイクアウト戦略で使います。</p>
<pre><code class="language-mql4">// 売り逆指値注文：現在価格より50pips下で売り予約（下抜けブレイク狙い）
double entryPrice = Bid - 50 * Point * 10;

int ticket = OrderSend(
    Symbol(),
    OP_SELLSTOP,      // 売り逆指値注文
    0.1,
    entryPrice,        // 現在のBidより下の価格
    3,
    entryPrice + 30 * Point * 10,  // SL
    entryPrice - 60 * Point * 10,  // TP
    "SellStop Order",
    12345,
    0,
    clrRed
);

if(ticket < 0)
    Print("売り逆指値注文エラー: ", GetLastError());</code></pre>
<h2><span id="toc11">注文タイプの分類整理</span></h2>
<p>6つの注文タイプを改めて分類すると、大きく<strong>2つのグループ</strong>に分けられます。</p>
<h3><span id="toc12">成行注文（即時約定）</span></h3>
<ul>
<li><strong>OP_BUY（0）</strong>：今すぐ買う</li>
<li><strong>OP_SELL（1）</strong>：今すぐ売る</li>
</ul>
<h3><span id="toc13">待機注文（予約注文）</span></h3>
<ul>
<li><strong>OP_BUYLIMIT（2）</strong>：今より下で買い予約（逆張り）</li>
<li><strong>OP_SELLLIMIT（3）</strong>：今より上で売り予約（逆張り）</li>
<li><strong>OP_BUYSTOP（4）</strong>：今より上で買い予約（順張り）</li>
<li><strong>OP_SELLSTOP（5）</strong>：今より下で売り予約（順張り）</li>
</ul>
<p>EAのプログラムでは、成行注文だけで十分なケースも多いですが、ブレイクアウトEAや押し目買いEAを作るなら待機注文の理解は必須です。</p>
<h2><span id="toc14">OrderType()で注文タイプを判定する</span></h2>
<p>注文タイプ定数は、注文を出すときだけでなく<strong>ポジション管理</strong>でも重要です。<code>OrderType()</code>関数を使えば、選択中の注文がどのタイプかを判定できます。</p>
<pre><code class="language-mql4">// 自分のEAが持つ買いポジションだけを決済する例
for(int i = OrdersTotal() - 1; i >= 0; i--)
{
    if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
        continue;

    // マジックナンバーと通貨ペアで自分の注文か判定
    if(OrderMagicNumber() != 12345)
        continue;
    if(OrderSymbol() != Symbol())
        continue;

    // 注文タイプで分岐
    if(OrderType() == OP_BUY)
    {
        // 買いポジションを決済
        bool result = OrderClose(OrderTicket(), OrderLots(), Bid, 3, clrBlue);
        if(!result)
            Print("決済エラー: ", GetLastError());
    }
    else if(OrderType() == OP_SELL)
    {
        // 売りポジションを決済
        bool result = OrderClose(OrderTicket(), OrderLots(), Ask, 3, clrRed);
        if(!result)
            Print("決済エラー: ", GetLastError());
    }
}</code></pre>
<p>ここでも<strong>買いの決済はBid、売りの決済はAsk</strong>を使う点に注意してください。注文時と決済時で使う価格が逆になります。</p>
<h2><span id="toc15">よくある間違いと注意点</span></h2>
<h3><span id="toc16">1. 価格の指定ミス（AskとBidの混同）</span></h3>
<p>最も多いエラーが<code>ERR_INVALID_PRICE（129）</code>です。以下のルールを覚えましょう。</p>
<table border="1" cellpadding="8" cellspacing="0" style="border-collapse: collapse; width: 100%;">
<thead>
<tr style="background-color: #f0f0f0;">
<th>操作</th>
<th>使う価格</th>
</tr>
</thead>
<tbody>
<tr>
<td>買い注文を出す / 売りポジションを決済する</td>
<td><strong>Ask</strong></td>
</tr>
<tr>
<td>売り注文を出す / 買いポジションを決済する</td>
<td><strong>Bid</strong></td>
</tr>
</tbody>
</table>
<h3><span id="toc17">2. ストップレベルの違反</span></h3>
<p>待機注文の価格が現在価格に近すぎると<code>ERR_INVALID_STOPS（130）</code>が発生します。ブローカーごとに「最低限離さなければならない値幅（ストップレベル）」が設定されています。</p>
<pre><code class="language-mql4">// ストップレベルを取得して安全な価格を計算する
int stopLevel = (int)MarketInfo(Symbol(), MODE_STOPLEVEL);
double minDistance = stopLevel * Point;

// 例：OP_BUYLIMITの場合、Ask - minDistance より下の価格を指定する
double safePrice = Ask - minDistance - 10 * Point;  // 余裕を持たせる</code></pre>
<h3><span id="toc18">3. 待機注文の削除はOrderDelete()を使う</span></h3>
<p>初心者がよく間違えるのが、待機注文の削除に<code>OrderClose()</code>を使ってしまうケースです。</p>
<ul>
<li><strong>OrderClose()</strong>：成行注文（OP_BUY / OP_SELL）の決済に使う</li>
<li><strong>OrderDelete()</strong>：待機注文（LIMIT / STOP系）のキャンセルに使う</li>
</ul>
<pre><code class="language-mql4">// 待機注文を削除する正しい方法
if(OrderType() == OP_BUYLIMIT || OrderType() == OP_SELLLIMIT ||
   OrderType() == OP_BUYSTOP  || OrderType() == OP_SELLSTOP)
{
    bool result = OrderDelete(OrderTicket());
    if(!result)
        Print("待機注文の削除エラー: ", GetLastError());
}</code></pre>
<p>待機注文に対して<code>OrderClose()</code>を使うと<code>ERR_INVALID_FUNCTION_PARAMVALUE（4051）</code>などのエラーになるので注意しましょう。</p>
<h2><span id="toc19">まとめ</span></h2>
<p>MQL4の注文タイプ定数は全部で<strong>6種類</strong>あり、大きく3つのカテゴリに分類できます。</p>
<ul>
<li><strong>成行注文</strong>：OP_BUY（0）/ OP_SELL（1）→ 今すぐ約定</li>
<li><strong>指値注文</strong>：OP_BUYLIMIT（2）/ OP_SELLLIMIT（3）→ 有利な価格で予約（逆張り向き）</li>
<li><strong>逆指値注文</strong>：OP_BUYSTOP（4）/ OP_SELLSTOP（5）→ 不利な方向で予約（ブレイクアウト向き）</li>
</ul>
<p>覚えるべきポイントは以下の3つです。</p>
<ul>
<li><strong>買いはAsk、売りはBid</strong>を必ず守る</li>
<li>待機注文はストップレベルを考慮した価格を設定する</li>
<li>成行注文の決済は<strong>OrderClose()</strong>、待機注文のキャンセルは<strong>OrderDelete()</strong>を使う</li>
</ul>
<p>まずはOP_BUYとOP_SELLの成行注文から始めて、慣れてきたら指値・逆指値注文にも挑戦してみてください。注文タイプを使い分けられれば、EAの戦略の幅が大きく広がります。</p>
<p>投稿 <a href="https://mql-programing.com/archives/13077/%e3%80%90mql4%e3%80%91%e6%b3%a8%e6%96%87%e3%82%bf%e3%82%a4%e3%83%97%e5%ae%9a%e6%95%b0%e3%82%92%e5%ae%8c%e5%85%a8%e8%a7%a3%e8%aa%ac%ef%bc%81op_buy%e3%83%bbop_sell%e3%83%bb%e6%8c%87%e5%80%a4-%e9%80%86/">【MQL4】注文タイプ定数を完全解説！OP_BUY・OP_SELL・指値/逆指値の全6種類を一覧で理解しよう</a> は <a href="https://mql-programing.com">自動売買を作ろう！</a> に最初に表示されました。</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
