サブウィンドウに表示されるカスタム指標の場合、サブウィンドウの左上に、現在のバーにおける指標値がラベルと一緒に表示されます。このラベル名は通常プログラム名となっています。

これを別のラベル名(指標短縮名)に変えるために、以下のようにOnInit()関数にコードを追加します。

//初期化関数
int OnInit()
{
   //配列を指標バッファに関連付ける
   SetIndexBuffer(0, Buf);
   SetIndexBuffer(1, BufSmooth);
   //時系列配列に設定
   ArraySetAsSeries(Buf, true);
   ArraySetAsSeries(BufSmooth, true);
   //プロット開始位置の設定
   PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, MomPeriod);
   PlotIndexSetInteger(1, PLOT_DRAW_BEGIN, MomPeriod+Smooth);
   //指標短縮名の設定
   IndicatorShortName("SMmom("+IntegerToString(MomPeriod)+","+IntegerToString(Smooth)+")");
   return(INIT_SUCCEEDED);
}

[IndicatorShortName()](<https://docs.mql4.com/customind/indicatorshortname>)の引数に表示させたいラベル名を設定します。

ここでは、パラメータの値も表示させるために、""で囲んだ文字列と、各パラメータの値を[IntegerToString()](<https://www.mql5.com/ja/docs/convert/integertostring>)で文字列に変換したデータを+で連結しておきます。

このコードを追加することで、以下のようにサブウインドウに指標短縮名が表示されます。

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/02883fc5-5a60-4d74-9df3-30019f92f50e/chart3.png