
MQL5 インジケーター作成
PlotIndexSetInteger()
- できること
- 描画する線の種類・色・太さ・矢印などを設定する
- 対応
- MQL5
PlotIndexSetInteger() とは
MQL5 のカスタムインジケーターで、描画(プロット)ごとの整数の設定(描画の種類、矢印の記号、色、線の太さ、描き始める位置など)を変更する関数です。
PlotIndexSetInteger() の書式と引数
引数の組み合わせが違う 2 通りの書き方があります。
bool PlotIndexSetInteger(
int plot_index,
ENUM_PLOT_PROPERTY_INTEGER prop_id,
int prop_value
)
bool PlotIndexSetInteger(
int plot_index,
ENUM_PLOT_PROPERTY_INTEGER prop_id,
int prop_modifier,
int prop_value
)| 引数 | 型 | 省略時 | 説明 |
|---|---|---|---|
plot_index | int | 必須 | 描画の番号(0 から)。バッファの番号ではなく、#property indicator_plots で数えた番号です。 |
prop_id | ENUM_PLOT_PROPERTY_INTEGER | 必須 | 設定する項目。PLOT_DRAW_TYPE、PLOT_ARROW(矢印の Wingdings コード)、PLOT_LINE_COLOR、PLOT_LINE_WIDTH、PLOT_LINE_STYLE、PLOT_DRAW_BEGIN など。 |
prop_value | int | 必須 | 設定する値。 |
prop_modifier | int | 必須 | 色が複数ある描画の、色の番号。 |
戻り値
設定できたら true を返します。
PlotIndexSetInteger() の使い方(コード例)
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots 1
double ArrowBuf[];
int OnInit()
{
SetIndexBuffer(0, ArrowBuf, INDICATOR_DATA);
PlotIndexSetInteger(0, PLOT_DRAW_TYPE, DRAW_ARROW);
PlotIndexSetInteger(0, PLOT_ARROW, 233); // 上向き矢印
PlotIndexSetInteger(0, PLOT_LINE_COLOR, clrRed);
PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, EMPTY_VALUE);
return INIT_SUCCEEDED;
}
// 陽線の下に矢印を出す
int OnCalculate(const int rates_total, const int prev_calculated,
const datetime &time[], const double &open[], const double &high[],
const double &low[], const double &close[], const long &tick_volume[],
const long &volume[], const int &spread[])
{
int start = (prev_calculated > 0) ? prev_calculated - 1 : 0;
for(int i = start; i < rates_total; i++)
ArrowBuf[i] = (close[i] > open[i]) ? low[i] - 10 * _Point : EMPTY_VALUE;
return rates_total;
}MetaEditor でコンパイルできることを確認済みです。
MQL4 と MQL5 の違い
MQL4 の SetIndexStyle()・SetIndexArrow()・SetIndexDrawBegin() にあたります。












