datetime t=0;
.....
if(t!=Time[0])
{
// открываем позу по сигналу
t=Time[0];
}
Андрей, а котировки за 15 лет вы вручную подгружали в МТ? Или у Вас брокер их дает? Или, как вариант, MQL5 Cloud Network?
//+------------------------------------------------------------------+
//| 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;
input bool AlertOn=true;
bool one=true;
//+------------------------------------------------------------------+
//| 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,White);
if(delta>SecondsSound) one=true;
if(delta<=SecondsSound && one && AlertOn)
{
PlaySound("News.wav");
SendNotification("Меньше "+(string)SecondsSound+" секунд осталось до закрытия!");
SendMail("Сигнал индикатора","Меньше "+(string)SecondsSound+" секунд осталось до закрытия!");
one=false;
}
}
//+------------------------------------------------------------------+
ObjectDelete("BLine");
ObjectDelete("SLine");
ObjectDelete("ALine");
AM2