
MT4・MT5 コンパイルエラー・警告 エラー(コンパイルできない)
wrong parameters count
- エラー番号
error 199- 意味
- 関数に渡した引数の数が合わない
「wrong parameters count」とは
関数を呼び出すときの引数の数が、関数の定義と合わないときのコンパイルエラーです。MQL4 のコードを MQL5 でコンパイルしたときに特によく出ます(iMA・iRSI・OrderSend などは MQL4 と MQL5 で引数が違うため)。
MetaEditor での表示例
| MT4 | error 199: 'f' - wrong parameters count |
|---|---|
| MT5 | error 199: wrong parameters count, 2 passed, but 1 requires |
実際のログでは先頭に「ファイル名(行,列) :」が付きます。ログの行をダブルクリックすると、エラーの場所にカーソルが移動します。表示は 2026年9月の MetaEditor で確認したもので、ビルドによって細部が変わることがあります。
「wrong parameters count」の主な原因
- 自作関数の引数の数と、呼び出し側の引数の数が違う
- MQL4 の iMA(…, shift) のような書き方を MQL5 で使っている(MQL5 の iMA はハンドルを返し、shift 引数がない)
- MQL4 の OrderSend()(引数7個以上)を MQL5 で使っている(MQL5 の OrderSend は構造体2つ)
- 省略できない引数を省略した
「wrong parameters count」の対処法
- MT5 のログには「2 passed, but 1 requires」のように渡した数と必要な数が出るので、それに合わせる
- MQL5 のインジケーター関数は、OnInit() でハンドルを作り CopyBuffer() で値を取り出す形に書き換える
- MQL4 → MQL5 の書き換えには変換ツールを使うと早い
コード例(MQL5)
// MQL4 の iMA(…, shift) を MQL5 に直す例(wrong parameters count 対策)
// NG(MQL4 の書き方。MQL5 の iMA は shift を取らず、ハンドルを返す)
// double ma = iMA(NULL, 0, 20, 0, MODE_SMA, PRICE_CLOSE, 1);
// OK
int hMA = INVALID_HANDLE;
int OnInit()
{
hMA = iMA(_Symbol, _Period, 20, 0, MODE_SMA, PRICE_CLOSE);
return (hMA == INVALID_HANDLE) ? INIT_FAILED : INIT_SUCCEEDED;
}
double MA(int shift)
{
double buf[];
if(CopyBuffer(hMA, 0, shift, 1, buf) != 1) return EMPTY_VALUE;
return buf[0];
}MetaEditor(MT5)でコンパイルできることを確認済みです。自分のEAに組み込むときは、変数名や設定値を合わせてください。
関連するエラー
コンパイルエラー・警告の解説一覧
- undeclared identifier
- semicolon expected
- unexpected token
- unexpected token, probably type is missing?
- some operator expected
- unexpected end of program
- unbalanced parentheses
- closing quote '"' expected
- wrong parameters count
- function already defined and has body
- variable already defined
- function must have a body
- function not defined
- not all control paths return a value
- function must return a value
- expression of 'void' type is illegal
- event handling function not found
- function declared with wrong type or/and parameters
- possible loss of data due to type conversion
- truncation of constant value
- implicit conversion from 'number' to 'string'
- return value of 'OrderSend' should be checked
- declaration hides global variable
- l-value required
- constant cannot be modified
- constant expression required
- invalid index value
- array required
- arrays are passed by reference only
- parameter conversion not allowed
- illegal operation use
- illegal 'else' without matching 'if'
- 'break' must be used within some loop or switch statement
- case value already used
- ambiguous call to overloaded function
- can't open include file
- unknown property
- identifier already used
- struct member undefined
- struct or class type expected
- private member access error
- cannot instantiate abstract class
- structures or classes containing objects are not allowed
- function declarations are allowed on global, namespace or class scope only
- name expected
- division by zero in the constant expression
- expression has no effect
- expression not boolean
- sign mismatch
- possible use of uninitialized variable
- empty controlled statement found
- macro redefinition
- call resolves to … due to new rules of method hiding
- cannot be used for static allocated array












