//+------------------------------------------------------------------+ //| Price_Label2.mq4 | //| Rondo | //| http://fx-dollaryen.seesaa.net/ | //+------------------------------------------------------------------+ #property copyright "Rondo" #property link "http://fx-dollaryen.seesaa.net/" #property version "1.2" #property strict #property indicator_chart_window input ENUM_BASE_CORNER InpCorner = CORNER_RIGHT_UPPER; //コーナー input int InpX = 10; // X軸 input int InpY = 10; // Y軸 input color PairColor = clrGray; //通貨ペアの色 input color UpColor = clrLightSkyBlue; //上昇色(陽線) input color UpColor1 = clrDodgerBlue; //上昇色(前高値を越える陽線) input color DownColor = clrLightPink; //下降色(陰線) input color DownColor1 = clrDeepPink; //下降色(前安値を超える陰線) //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { //--- ObjectDelete(0, "Symbol_Label"); ObjectDelete(0, "Price_Label"); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ 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[]) { Label("Symbol_Label", InpCorner, InpX, InpY, Symbol(), "Arial Bold", 12, PairColor); int DigitsChange; if(Digits()==2 || Digits()==3) DigitsChange = 2; else if(Digits()==4 || Digits()==5) DigitsChange = 4; else DigitsChange = 0; color clrPrice; if(open[0] <= close[0]){ if(high[1] <= close[0]) clrPrice = UpColor1; else clrPrice = UpColor; } else{ if(low[1] >= close[0]) clrPrice = DownColor1; else clrPrice = DownColor; } Label("Price_Label", InpCorner, InpX, InpY+15, DoubleToString(close[0], DigitsChange), "Arial", 20, clrPrice); //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ void Label(string LabelName, int LabelCorner, int LabelPosX, int LabelPosY, string LabelText, string Font, int FontSize, color LabelColor){ if (ObjectFind(0, LabelName) != 0) { double chart_max_price = ChartGetDouble(0,CHART_PRICE_MAX,0); ObjectCreate(0, LabelName, OBJ_LABEL, 0, TimeCurrent(), chart_max_price); ObjectSetInteger(0, LabelName, OBJPROP_COLOR, LabelColor); //ObjectSetInteger(0, LabelName, OBJPROP_BGCOLOR, clrNONE); ObjectSetString(0, LabelName, OBJPROP_TEXT, LabelText); ObjectSetString(0, LabelName, OBJPROP_FONT, Font); ObjectSetInteger(0, LabelName, OBJPROP_FONTSIZE, FontSize); ObjectSetInteger(0, LabelName, OBJPROP_CORNER, LabelCorner); ObjectSetInteger(0, LabelName, OBJPROP_XDISTANCE, LabelPosX); ObjectSetInteger(0, LabelName, OBJPROP_YDISTANCE, LabelPosY); ObjectSetInteger(0, LabelName, OBJPROP_ANCHOR, ANCHOR_RIGHT_UPPER); } else{ ObjectSetInteger(0, LabelName, OBJPROP_COLOR, LabelColor); ObjectSetString(0, LabelName, OBJPROP_TEXT, LabelText); } WindowRedraw(); }