目次
MQL4とMQL5の違い
MQL5では、ObjectSet()は廃止され、ObjectSetInteger()、ObjectSetDouble()、ObjectSetString()を使わなければならなくなりました。
MQL4のコードをMQL5でそのまま使うための関数
bool ObjectSet(string name, int index, double value) {
switch(index) {
case 0:
ObjectSetInteger(0, name, OBJPROP_TIME, (int)value);
return(true);
case 1:
ObjectSetDouble(0, name, OBJPROP_PRICE, value);
return(true);
case 2:
ObjectSetInteger(0, name, OBJPROP_TIME, 1, (int)value);
return(true);
case 3:
ObjectSetDouble(0, name, OBJPROP_PRICE, 1, value);
return(true);
case 4:
ObjectSetInteger(0, name, OBJPROP_TIME, 2, (int)value);
return(true);
case 5:
ObjectSetDouble(0, name, OBJPROP_PRICE, 2, value);
return(true);
case 6:
ObjectSetInteger(0, name, OBJPROP_COLOR, (int)value);
return(true);
case 7:
ObjectSetInteger(0, name, OBJPROP_STYLE, (int)value);
return(true);
case 8:
ObjectSetInteger(0, name, OBJPROP_WIDTH, (int)value);
return(true);
case 9:
ObjectSetInteger(0, name, OBJPROP_BACK, (int)value);
return(true);
case 10:
ObjectSetInteger(0, name, OBJPROP_RAY_RIGHT, (int)value);
return(true);
case 11:
ObjectSetInteger(0, name, OBJPROP_ELLIPSE, (int)value);
return(true);
case 12:
ObjectSetDouble(0, name, OBJPROP_SCALE, value);
return(true);
case 13:
ObjectSetDouble(0, name, OBJPROP_ANGLE, value);
return(true);
case 14:
ObjectSetInteger(0, name, OBJPROP_ARROWCODE, (int)value);
return(true);
case 15:
ObjectSetInteger(0, name, OBJPROP_TIMEFRAMES, (int)value);
return(true);
case 16:
ObjectSetDouble(0, name, OBJPROP_DEVIATION, value);
return(true);
case 100:
ObjectSetInteger(0, name, OBJPROP_FONTSIZE, (int)value);
return(true);
case 101:
ObjectSetInteger(0, name, OBJPROP_CORNER, (int)value);
return(true);
case 102:
ObjectSetInteger(0, name, OBJPROP_XDISTANCE, (int)value);
return(true);
case 103:
ObjectSetInteger(0, name, OBJPROP_YDISTANCE, (int)value);
return(true);
case 200:
ObjectSetInteger(0, name, OBJPROP_LEVELS, (int)value);
return(true);
case 201:
ObjectSetInteger(0, name, OBJPROP_LEVELCOLOR, (int)value);
return(true);
case 202:
ObjectSetInteger(0, name, OBJPROP_LEVELSTYLE, (int)value);
return(true);
case 203:
ObjectSetInteger(0, name, OBJPROP_LEVELWIDTH, (int)value);
return(true);
default:
return(false);
}
return(false);
}