int _AppliedTo

_AppliedTo変数を使用すると、指標計算に使用されるデータの型を見つけることができます。

データ型

意味

指標計算に使用されるデータの説明

0

この指標ではOnCalculate()2番目の呼び出し形式を使用し、計算のためのデータはデータ配列のバッファでは指定されません。

Close

1

終値

Open

2

始値

High

3

高値

Low

4

安値

Median Price (HL/2)

5

Median price = (高値+安値)/2

Typical Price (HLC/3)

6

Typical price = (高値+安値+終値)/3

Weighted Price (HLCC/4)

7

Weighted price = (始値+高値+安値+終値)/4

1つ前の指標データ

8

チャートでこの指標の前に起動された指標のデータ

1番目の指標データ

9

チャートで1番目に起動された指標のデータ

指標ハンドル

10+

指標ハンドルを通してiCustom()関数に渡された指標のデータ_AppliedTo値は指標ハンドルを含みます。

 

例:

//+------------------------------------------------------------------+
//| カスタム指標初期化関数                                                |
//+------------------------------------------------------------------+
int OnInit()
 {
//--- 指標バッファマッピング
  SetIndexBuffer(0,Label1Buffer,INDICATOR_DATA);
// 指標計算に使用されるデータの取得
  Print("_AppliedTo=",_AppliedTo);
  Print(getIndicatorDataDescription(_AppliedTo));
//---
  return(INIT_SUCCEEDED);
 }
//+------------------------------------------------------------------+
//| 指標計算に使用されるデータの説明                                         |
//+------------------------------------------------------------------+
string getIndicatorDataDescription(int data_id)
 {
  string descr="";
  switch(data_id)
    {
    case(0):descr="It's first type of OnCalculate() - no data buffer";
        break;
    case(1):descr="Indicator calculates on Close price";
        break;
    case(2):descr="Indicator calculates on Open price";
        break;
    case(3):descr="Indicator calculates on High price";
        break;
    case(4):descr="Indicator calculates on Low price";
        break;
    case(5):descr="Indicator calculates on Median Price (HL/2)";
        break;
    case(6):descr="Indicator calculates on Typical Price (HLC/3)";
        break;
    case(7):descr="Indicator calculates on Weighted Price (HLCC/4)";
        break;
    case(8):descr="Indicator calculates Previous Indicator's data";
        break;
    case(9):descr="Indicator calculates on First Indicator's data";
        break;
    default: descr="Indicator calculates on data of indicator with handle="+string(data_id);
        break;
    }
//---
  return descr;
 }

参照

ENUM_APPLIED_PRICE