// SpreadInfo.mq4 — live spread in the corner of the chart #property indicator_chart_window input int CornerX = 10; input int CornerY = 18; input color NormalColor = clrGray; input color WideColor = clrOrangeRed; input double WideThresholdPips = 2.0; string tag = "spreadinfo_label"; int OnInit() { ObjectCreate(0, tag, OBJ_LABEL, 0, 0, 0); ObjectSetInteger(0, tag, OBJPROP_CORNER, CORNER_LEFT_UPPER); ObjectSetInteger(0, tag, OBJPROP_XDISTANCE, CornerX); ObjectSetInteger(0, tag, OBJPROP_YDISTANCE, CornerY); return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { ObjectDelete(0, tag); } 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[]) { double pts = (Ask - Bid) / Point; double pips = (Digits == 3 || Digits == 5) ? pts / 10.0 : pts; ObjectSetString(0, tag, OBJPROP_TEXT, 0, StringFormat("spread %.1f pips (%.0f pts)", pips, pts)); ObjectSetInteger(0, tag, OBJPROP_COLOR, pips >= WideThresholdPips ? WideColor : NormalColor); return(rates_total); }