You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Ping should also be halved - you don't need to go back and forth, but only back.
What if MQs only count here?
Added by
Corrected
Added
For the EA to work more confidently
In Market Watch you should add current highly liquid
futures such as RTS, Si, BR
We still need to add synchronisation to the evening clearing.
Added
Made into clearing as well
There was a correction to the clearing (real)
But the result didn't please me at all,
was 49 seconds behind :(
Will check the premarket tomorrow....
Mykalas, you are my idol! :-)
Here's the problem.
" Sync sec = ", loc_time.wSecond, " Sync mcs = ", loc_time.wMilliseconds);
2017.01.18 20:05:01.869 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = Si-3.17 Sync min = 5 Sync sec = 1 Sync mcs = 475
2017.01.18 20:05:01.890 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = BR-2.17 Sync min = 5 Sync sec = 2 Sync mcs = 61
2017.01.18 20:05:01.918 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = BR-2.17 Sync min = 5 Sync sec = 2 Sync mcs = 61
2017.01.18 20:05:01.942 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = RTS-3.17 Sync min = 5 Sync sec = 1 Sync mcs = 428
2017.01.18 20:05:01.942 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = Si-3.17 Sync min = 5 Sync sec = 1 Sync mcs = 475
2017.01.18 20:05:01.983 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = RTS-3.17 Sync min = 5 Sync sec = 2 Sync mcs = 156
2017.01.18 20:05:02.055 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = BR-2.17 Sync min = 5 Sync sec = 2 Sync mcs = 61
2017.01.18 20:05:02.081 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = RTS-3.17 Sync min = 5 Sync sec = 2 Sync mcs = 156
2017.01.18 20:05:02.081 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = Si-3.17 Sync min = 5 Sync sec = 1 Sync mcs = 475
2017.01.18 20:05:02.121 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = RTS-3.17 Sync min = 5 Sync sec = 2 Sync mcs = 156
2017.01.18 20:05:02.216 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = BR-2.17 Sync min = 5 Sync sec = 2 Sync mcs = 385
2017.01.18 20:05:02.242 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = BR-2.17 Sync min = 5 Sync sec = 2 Sync mcs = 385
2017.01.18 20:05:02.255 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = RTS-3.17 Sync min = 5 Sync sec = 2 Sync mcs = 156
2017.01.18 20:05:02.255 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = Si-3.17 Sync min = 5 Sync sec = 1 Sync mcs = 475
2017.01.18 20:05:02.314 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = Si-3.17 Sync min = 5 Sync sec = 1 Sync mcs = 475
2017.01.18 20:05:02.405 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = Si-3.17 Sync min = 5 Sync sec = 1 Sync mcs = 475
2017.01.18 20:05:02.432 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = RTS-3.17 Sync min = 5 Sync sec = 2 Sync mcs = 156
2017.01.18 20:05:02.432 Time_sync_forts (RTS-3.17,M1) Local time sync is done. Symbol = Si-3.17 Sync min = 5 Sync sec = 2 Sync mcs = 614
The previous crutch was much sleeker (by design), but,
I'll try this one.
//| Time_sync_forts.mq5 |
//| Copyright 2017 prostotrader |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017 prostotrader"
#property link "https://www.mql5.com"
#property version "1.00"
//---
struct _SYSTEMTIME
{
ushort wYear;
ushort wMonth;
ushort wDayOfWeek;
ushort wDay;
ushort wHour;
ushort wMinute;
ushort wSecond;
ushort wMilliseconds;
};
_SYSTEMTIME loc_time;
#import "kernel32.dll"
void GetLocalTime(_SYSTEMTIME &sys_time);
bool SetLocalTime(_SYSTEMTIME &sys_time);
#import
//---
bool is_sync;
string symb_rts;
string symb_si;
string symb_gold;
string symb_br;
string symb_gazr;
string symb_sbrf;
datetime last_time;
//
input string BrInstr="BR-2.17"; //Brent
//+------------------------------------------------------------------+
//| Expert set second symbol function |
//+------------------------------------------------------------------+
string SetSecSymbol(const string a_symbol,const string prefix)
{
int str_tire=0;
ushort let_symbol;
int str_size=StringLen(a_symbol);
for(int i=0; i<str_size; i++)
{
let_symbol=StringGetCharacter(a_symbol,i);
if(let_symbol=='-')
{
str_tire=i;
break;
}
}
if(str_tire>0)
{
return(prefix + StringSubstr(a_symbol, str_tire, str_size - str_tire));
}
return("");
}
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
last_time=TimeCurrent();
is_sync=false;
MarketBookAdd(Symbol());
//---
symb_rts=SetSecSymbol(Symbol(),"RTS");
if(!SymbolSelect(symb_rts,true))
{
MessageBox(symb_rts+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
return(INIT_FAILED);
}
else MarketBookAdd(symb_rts);
//---
symb_si=SetSecSymbol(Symbol(),"Si");
if(!SymbolSelect(symb_si,true))
{
MessageBox(symb_si+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
return(INIT_FAILED);
}
else MarketBookAdd(symb_si);
//---
symb_gold=SetSecSymbol(Symbol(),"GOLD");
if(!SymbolSelect(symb_gold,true))
{
MessageBox(symb_gold+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
return(INIT_FAILED);
}
else MarketBookAdd(symb_gold);
//---
symb_gazr=SetSecSymbol(Symbol(),"GAZR");
if(!SymbolSelect(symb_gazr,true))
{
MessageBox(symb_gazr+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
return(INIT_FAILED);
}
else MarketBookAdd(symb_gazr);
//---
symb_sbrf=SetSecSymbol(Symbol(),"SBRF");
if(!SymbolSelect(symb_sbrf,true))
{
MessageBox(symb_sbrf+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
return(INIT_FAILED);
}
else MarketBookAdd(symb_sbrf);
//---
symb_br=BrInstr;
if(!SymbolSelect(symb_br,true))
{
MessageBox(symb_br+" not found in the Market watch!","Error",MB_OK|MB_ICONERROR);
return(INIT_FAILED);
}
else MarketBookAdd(symb_br);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
MarketBookRelease(Symbol());
MarketBookRelease(symb_rts);
MarketBookRelease(symb_br);
MarketBookRelease(symb_si);
MarketBookRelease(symb_gold);
MarketBookRelease(symb_gazr);
MarketBookRelease(symb_sbrf);
}
//+------------------------------------------------------------------+
//| Expert On book event function |
//+------------------------------------------------------------------+
void OnBookEvent(const string &symbol)
{
loc_time.wYear=0;
GetLocalTime(loc_time);
if(loc_time.wYear>0)
{
if(((loc_time.wHour==9) && (loc_time.wMinute>=50) && (loc_time.wMinute<=59)) ||
((loc_time.wHour==14) && (loc_time.wMinute>=0) && (loc_time.wMinute<=4)) ||
((loc_time.wHour==18) && (loc_time.wMinute>=45) && (loc_time.wMinute<=59)))
{
MqlDateTime sv_time;
datetime cur_time=TimeCurrent(sv_time);
if(ulong(cur_time) == ulong(last_time)) return;
if((loc_time.wDayOfWeek==ushort(sv_time.day_of_week)) &&
(loc_time.wHour==ushort(sv_time.hour)))
{
if(!is_sync)
{
loc_time.wMinute = ushort(sv_time.min);
loc_time.wSecond = ushort(sv_time.sec);
loc_time.wMilliseconds=0;
if(SetLocalTime(loc_time))
{
is_sync=true;
Print("Local time sync is done. Symbol = ",symbol," Sync min = ",loc_time.wMinute,
" Sync sec = ",loc_time.wSecond);
}
}
}
}
else
{
is_sync=false;
last_time=TimeCurrent();
}
}
}
//+------------------------------------------------------------------+
The previous crutch was much sleeker (by design), but,
I'll try this one.
This won't work withOnBookEvent, you need to sync it to OnTick.
you get to use the tick time and take the data at the time of the change of the glass,
timeOnBookEvent!=OnTick
TheOnBookEvent will not work, you have to synchronise it with OnTick.
You can use the tick time and get the data at the time of changing the glass,
timeOnBookEvent!=OnTick
No, Sergei!
Your OnTick for the selected symbol might not even come, while OnBookEvent() will be triggered at any change of
glasses of all selected symbols.
No, Serge!
OnTick on the selected symbol may not come, but OnBookEvent() will be triggered at any change of
glasses of all the selected symbols.
OnBookEvent() will be triggered, but the time of the cup change is not fixed anywhere.
Only tick arrival time is fixed, i.e. change of bid, last, ask.
Thus, the market rate has changed, but the time of the last tick arriving is the same as before.