Yes, but the code above, in the comment, counts down smoothly every second and the function is jerky. On M1, out of 60 bars, 3 or 4 times there is no alert.
Yes, but the above code, in the comment, counts down smoothly every second, while the function is jerky. On M1, out of 60 bars 3 or 4 times there is no alert.
That's because the function uses TimeCurrent() - arrival time of the last quote. You need to replace this time with a local TimeLocal() with a calculated offset (you have already been told about it).
You need to replace this time with local TimeLocal() with calculated offset (you were already told about this)
I don't know how to do it correctly, so I found a code that counts down time to close H1 without ticks, and I'm trying to use it, I replacedTimeCurrent() in your function, but it doesn't want to show me seconds to close.
#property strict#property indicator_chart_window//--- input parameters#define MILLISEC_TIMER_INTERVAL 500int timeOffset;
datetime ServerLocalOffset;
datetime prevTime,myTime,localtime;
bool newBar = false;
datetime sec;
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+intOnInit()
{
//--- indicator buffers mappingEventSetMillisecondTimer(MILLISEC_TIMER_INTERVAL);
datetime srvtime,tmpOffset;
RefreshRates();
srvtime = TimeCurrent();
// Modified
localtime = TimeLocal()+TimeGMTOffset();
if(TimeHour(srvtime)>TimeHour(localtime)){
// Server Time is still ahead of usint newOffset = TimeHour(srvtime)-TimeHour(localtime);
ServerLocalOffset = (newOffset*60*60);
}elseif(TimeHour(srvtime)<TimeHour(localtime)){
// Server Time is Behind usint newOffset = TimeHour(localtime)-TimeHour(srvtime);
ServerLocalOffset = (newOffset*60*60);
}else{
// No modification required
ServerLocalOffset = srvtime;
}
localtime = TimeLocal()-ServerLocalOffset;
tmpOffset = TimeSeconds(srvtime) - TimeSeconds(localtime);
if(tmpOffset < 30 && tmpOffset >= 0){
timeOffset = TimeSeconds(srvtime) - TimeSeconds(localtime);
}
return(INIT_SUCCEEDED);
}
voidOnDeinit(constint reason)
{
EventKillTimer();
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime &time[],
constdouble &open[],
constdouble &high[],
constdouble &low[],
constdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[])
{
//---//--- return value of prev_calculated for next callreturn(rates_total);
}
//+------------------------------------------------------------------+//| Timer function |//+------------------------------------------------------------------+voidOnTimer()
{
//---datetime localtime;
localtime = TimeLocal()+(TimeGMTOffset()+(60*60));
sec=Time[0]+Period()*60-localtime-timeOffset;//if(SecondsToCandleClose(Symbol(),0)<=2){Alert("время откр. бара ",Time[0]);}
Comment(" Time 1: ",TimeToStr(sec,TIME_SECONDS )," Time 2: ",TimeToStr(SecondsToCandleClose(Symbol(),0),TIME_SECONDS ));
}
//+------------------------------------------------------------------+//+------------------------------------------------------------------+long SecondsToCandleClose(conststring symbol_name,constENUM_TIMEFRAMES timeframe)
{
datetime array[];
return(CopyTime(symbol_name,timeframe,0,1,array)==1 ? PeriodSeconds(timeframe)+array[0]-sec : 0);
}
////
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Still haven't figured out how to count the seconds until the bar closes on the current period. I need your help.
I gave you the function.
I gave you the function.
Yes, but the code above, in the comment, counts down smoothly every second and the function is jerky. On M1, out of 60 bars, 3 or 4 times there is no alert.
Yes, but the above code, in the comment, counts down smoothly every second, while the function is jerky. On M1, out of 60 bars 3 or 4 times there is no alert.
That's because the function uses TimeCurrent() - arrival time of the last quote. You need to replace this time with a local TimeLocal() with a calculated offset (you have already been told about it).
You need to replace this time with local TimeLocal() with calculated offset (you were already told about this)
I don't know how to do it correctly, so I found a code that counts down time to close H1 without ticks, and I'm trying to use it, I replacedTimeCurrent() in your function, but it doesn't want to show me seconds to close.
Please tell me how to implement the idea in the code:
If (OrdersTotal ==0) {Alert ;}
Guys!
There are a lot of objects on the graph.
But when you access it.
It says there's only three.
Why isn't it counting arrows?
Please tell me how to implement the idea in the code:
Do it like this. The code is almost correct. Only one word is missing there:
Guys!
There are a lot of objects on the graph.
But when you access it.
It says there's only three.
Why isn't it counting arrows?