このMT4インジケーターは任意の為替価格を与えられると
そこから任意のパーセントまで水平線を引きます。
上下のパーセントに5組まで引けます。
為替の値打ちは何%上がったか下がったかでありながら
このようなパーセント表示を描くインジケーターがないので作りました。
なおこのインジケーターはオフライン上の作られたちゃーと上でも動作します。
よって、通貨のドルや日本円がが何%に到達したとかが一目で見ることが出来ます。
下記にコードを書き込んでいますのでコピーした後に
新規Mq4ファイルに移植すれば動作します。
///////////////////////////////////
#property indicator_chart_window
#property strict
extern double BasePrice = 150.00;
extern int NumLevels = 3; // 使用するラインの数(1~5)
extern double Percent1 = 1.0;
extern color Color1 = Red;
extern int Style1 = STYLE_SOLID;
extern double Percent2 = 2.0;
extern color Color2 = Blue;
extern int Style2 = STYLE_DASH;
extern double Percent3 = 3.0;
extern color Color3 = Green;
extern int Style3 = STYLE_DOT;
extern double Percent4 = 4.0;
extern color Color4 = Purple;
extern int Style4 = STYLE_DASHDOT;
extern double Percent5 = 5.0;
extern color Color5 = Orange;
extern int Style5 = STYLE_DASHDOTDOT;
int start()
{
DrawPercentLine(1, Percent1, Color1, Style1);
if (NumLevels >= 2) DrawPercentLine(2, Percent2, Color2, Style2);
if (NumLevels >= 3) DrawPercentLine(3, Percent3, Color3, Style3);
if (NumLevels >= 4) DrawPercentLine(4, Percent4, Color4, Style4);
if (NumLevels >= 5) DrawPercentLine(5, Percent5, Color5, Style5);
return(0);
}
void DrawPercentLine(int index, double percent, color clr, int style)
{
string upName = "UpLine_" + IntegerToString(index);
string downName = "DownLine_" + IntegerToString(index);
double upLevel = BasePrice * (1 + percent / 100.0);
double downLevel = BasePrice * (1 - percent / 100.0);
ObjectDelete(upName);
ObjectDelete(downName);
ObjectCreate(upName, OBJ_HLINE, 0, 0, upLevel);
ObjectSet(upName, OBJPROP_COLOR, clr);
ObjectSet(upName, OBJPROP_STYLE, style);
ObjectSet(upName, OBJPROP_WIDTH, 1);
ObjectCreate(downName, OBJ_HLINE, 0, 0, downLevel);
ObjectSet(downName, OBJPROP_COLOR, clr);
ObjectSet(downName, OBJPROP_STYLE, style);
ObjectSet(downName, OBJPROP_WIDTH, 1);
}
//////////////////////////////////////////////////////////////////





