
Ничего себе конструкция получилась с периодами



PutLabel("TimeLabel","Время до закрытия свечи: "+(string)(int)((Time[0]+Period()*60-TimeCurrent())/60)+":"+(string)MathMod(Time[0]+Period()*60-TimeCurrent(),60),350,20,Red);
//+------------------------------------------------------------------+
//| CloseCandle.mq4 |
//| Copyright 2016, AM2 |
//| http://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, AM2"
#property link "http://www.forexsystems.biz"
#property version "1.00"
#property strict
#property indicator_chart_window
input int SecondsSound=20;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
EventSetTimer(1);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
Comment("");
ObjectsDeleteAll(0,OBJ_LABEL);
EventKillTimer();
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void PutLabel(string name,string text,int x,int y,color clr)
{
ObjectDelete(name);
//--- создадим текстовую метку
ObjectCreate(0,name,OBJ_LABEL,0,0,0);
//--- установим координаты метки
ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
//--- установим угол графика, относительно которого будут определяться координаты точки
ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
//--- установим текст
ObjectSetString(0,name,OBJPROP_TEXT,text);
//--- установим шрифт текста
ObjectSetString(0,name,OBJPROP_FONT,"Arial");
//--- установим размер шрифта
ObjectSetInteger(0,name,OBJPROP_FONTSIZE,12);
//--- установим цвет
ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
}
//+------------------------------------------------------------------+
//| 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[])
{
//---
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
void OnTimer()
{
int delta=(int)(Time[0]+Period()*60-TimeCurrent());
if(Period()<60 || delta<3600)
{
PutLabel("TimeLabel","Время до закрытия свечи: "+(string)(int)((Time[0]+Period()*60-TimeCurrent())/60)+":"+(string)MathMod(Time[0]+Period()*60-TimeCurrent(),60),350,20,Red);
}
else
{
PutLabel("TimeLabel","Время до закрытия свечи: "+TimeToString(Time[0]+Period()*60-TimeCurrent(),TIME_SECONDS),350,20,Red);
}
PutLabel("TimeLabel2","Время закрытия свечи: "+TimeToString(Time[0]+Period()*60,TIME_SECONDS),320,45,Yellow);
PutLabel("TimeLabel3","Текущее Время: "+TimeToString(TimeCurrent(),TIME_SECONDS),260,70,Lime);
if(delta<=SecondsSound)
{
PlaySound("News.wav");
SendNotification((string)"Меньше "+(string)SecondsSound+" осталось до закрытия!");
}
}
//+------------------------------------------------------------------+
AM2