Galim_V: Can you tell me how to get the bottom indicators from a timeframe other than the one the owl is hovering on?
1. Why did you hang the bird up? Isn't it a pity?
2. Have you ever opened the help? To receive indicator data in the Expert Advisor from any timeframe is not a problem at all because the first two parameters of functions of receiving indicator data are used to specify the symbol and period of the chart from which you want to receive values.
Indeed, even when you type the code in the editor, the list of formal variables of the function is opened, and a tooltip there shows the symbol and timeframe. Strange that you didn't pay attention to them.
Do you need time? You can get the time of last tick: TimeCurrent(), or the last local time: Time Local().
If you get the time of the last tick at weekend, the timer will not help - the time will be the last tick on Friday, or the last tick of the last working day. And TimeLocal() will not give you server time - you need to recalculate it with an offset.
However, I don't know exactly what you want to get in the end.
2. Have you ever opened the help? To receive indicator data in the Expert Advisor from any timeframe is not a problem at all because the first two parameters of functions of receiving indicator data are used to specify the symbol and period of the chart from which you want to receive values.
Indeed, even when you type the code in the editor, the list of formal variables of the function is opened, and a tooltip there shows the symbol and timeframe. Strange that you didn't pay attention to them.
2018.07.04 22:17:38.398 2016.11.10 13:00:00 Arap01 EURUSD,H1: Rounding 44.53781512605145 45.0 This is stochastic data in "normal" mode. ie:
So I need an alert two seconds before the bar closes without a tick.
It is not easy to do, you need to run more accurate timer (at least 500 ms) and previously do synchronization of local time and server time. I've already told you about this:
At the moment of tick arrival, count the difference TimeCurrent()-TimeLocal() (this is done once to synchronize local and server time) - This is the offset relative to the broker, if this offset changes later, the time should be recalculated; - at the Expert Advisor start (orat appearance of barD1) we recalculate all the necessary times again, in the local time, taking into account the offset; - We wait for what we "counted" in the timer, checking for desynchronization, loss of connection with the broker, translation of the local hands.
It's not easy to do, you have to run a more accurate timer (at least 500ms) and pre-synchronize the local time with the server time. I've already told you about it:
You can catch +/- 1 second
Thank you. How to make the time in seconds, before the M5 bar closes. Right now it's displaying H1.
#property strict#property indicator_chart_window//--- input parameters#define MILLISEC_TIMER_INTERVAL 500int timeOffset;
datetime ServerLocalOffset;
datetime prevTime,myTime,localtime;
bool newBar = false;
//+------------------------------------------------------------------+//| 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 sec;
datetime localtime;
localtime = TimeLocal()+(TimeGMTOffset()+(60*60));
sec=Time[0]-localtime-timeOffset;
if(sec<=2){Alert("время откр. бара ",Time[0]);}
Comment(TimeToStr(sec,TIME_SECONDS ));
}
//+------------------------------------------------------------------+
Didn't come up with it myself"Just make sure you update the data in OnTimer() to make your code work. "
How should I do it?
Do you have an offline schedule?
Can you tell me how to get the bottom indicators from a timeframe other than the one the owl is hovering on?
1. Why did you hang the bird up? Isn't it a pity?
2. Have you ever opened the help? To receive indicator data in the Expert Advisor from any timeframe is not a problem at all because the first two parameters of functions of receiving indicator data are used to specify the symbol and period of the chart from which you want to receive values.
Indeed, even when you type the code in the editor, the list of formal variables of the function is opened, and a tooltip there shows the symbol and timeframe. Strange that you didn't pay attention to them.
Do you have an offline schedule?
No.
No.
Then why the constant refresh without need?
Do you need time? You can get the time of last tick: TimeCurrent(), or the last local time: Time Local().
If you get the time of the last tick at weekend, the timer will not help - the time will be the last tick on Friday, or the last tick of the last working day. And TimeLocal() will not give you server time - you need to recalculate it with an offset.
However, I don't know exactly what you want to get in the end.
1. Why did you hang the bird up? Isn't it a pity?
2. Have you ever opened the help? To receive indicator data in the Expert Advisor from any timeframe is not a problem at all because the first two parameters of functions of receiving indicator data are used to specify the symbol and period of the chart from which you want to receive values.
Indeed, even when you type the code in the editor, the list of formal variables of the function is opened, and a tooltip there shows the symbol and timeframe. Strange that you didn't pay attention to them.
2018.07.04 22:17:38.398 2016.11.10 13:00:00 Arap01 EURUSD,H1: Rounding 44.53781512605145 45.0 This is stochastic data in "normal" mode. ie:
2=iStochastic(NULL,0,K,D,slowing,Average_method,price_field,MODE_MAIN,2);
here I ask M5 2=iStochastic(NULL,5,K,D,slowing,Average_method,price_field,MODE_MAIN,2);
I get 2018.07.04 22:23:05.680 2016.11.10 13:00:00 Arap01 EURUSD,H1: Rounding 0.0 0.0
However, I don't know exactly what you want to end up with.
Alert, I want, two seconds before the bar closes. I won't be working over the weekend.
So I need an alert two seconds before the bar closes without a tick.
It is not easy to do, you need to run more accurate timer (at least 500 ms) and previously do synchronization of local time and server time.
I've already told you about this:
At the moment of tick arrival, count the difference TimeCurrent()-TimeLocal()
(this is done once to synchronize local and server time)
- This is the offset relative to the broker, if this offset changes later, the time should be recalculated;
- at the Expert Advisor start (orat appearance of barD1) we recalculate all the necessary times again, in the local time, taking into account the offset;
- We wait for what we "counted" in the timer, checking for desynchronization, loss of connection with the broker, translation of the local hands.
It's not easy to do, you have to run a more accurate timer (at least 500ms) and pre-synchronize the local time with the server time.
You can catch +/- 1 secondI've already told you about it:
Thank you. How to make the time in seconds, before the M5 bar closes. Right now it's displaying H1.